module Octokit::Client::IssueExport
Public Instance Methods
_dir_for_export()
click to toggle source
# File lib/octokit/client/issue_export.rb, line 86 def _dir_for_export @_dir_for_export end
_dir_for_export=(path)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 81 def _dir_for_export=(path) _mkdir_recursive(path) @_dir_for_export = path end
_dump_resources(resources)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 74 def _dump_resources(resources) return resources unless resources.respond_to?(:attrs) resources.attrs.each_with_object({}) do |(k,v), result| result[k] = v.respond_to?(:attrs) ? v.attrs : v end end
_export_issue(repo, issue)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 45 def _export_issue(repo, issue) data = _dump_resources(issue) comment_data = [] page = 1 loop do paged_comments = issue_comments(repo, issue.number, per_page: 100, page: page) break if paged_comments.empty? paged_comments.each { |comment| comment_data << _dump_resources(comment) } page += 1 end data.merge!(comment_data: comment_data) file = File.join(_dir_for_export, "#{issue.number}.json") _export_json(data, file) end
_export_issues(repo)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 27 def _export_issues(repo) %i(open closed).each { |state| page = 1 loop do paged_issues = issues(repo, per_page: 100, page: page, state: state) break if paged_issues.empty? paged_issues.each { |issue| _output_for_export(issue.number, state, issue.comments, issue.title) _export_issue(repo, issue) } page += 1 end } end
_export_json(data, file)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 97 def _export_json(data, file) File.open(file , 'w') { |f| f.write JSON.pretty_generate(data) } end
_mkdir_recursive(path)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 90 def _mkdir_recursive(path) return if File.directory?(path) parent = File::dirname(path) _mkdir_recursive(parent) Dir::mkdir(path) end
_output_for_export(number, state, comments, title)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 65 def _output_for_export(number, state, comments, title) puts <<-OUTPUT.gsub(/\s{10}/, '').gsub(/\n/, '') - #{"##{number}".rjust(4)}, state: #{state.to_s.rjust(6)}, comments: #{comments.to_s.rjust(3)}, title: "#{title.to_s}" OUTPUT end
export_issues(repo)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 4 def export_issues(repo) puts "[#{repo}]" if repo(repo).has_issues? self._dir_for_export = File.join(%w(.) + repo.split('/')) _export_issues(repo) else puts "- project without issues" end Time.now end
export_organization_issues(organization)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 21 def export_organization_issues(organization) org_repos(organization).each { |resource| export_issues(resource.full_name) } Time.now end
Also aliased as: export_org_issues
export_user_issues(username = nil)
click to toggle source
# File lib/octokit/client/issue_export.rb, line 15 def export_user_issues(username = nil) username = login if username.nil? repos(username).each { |resource| export_issues(resource.full_name) } Time.now end