class IssueExporting::FileOutputter

Public Instance Methods

write(response_text) click to toggle source
# File lib/issue_exporter/outputter.rb, line 53
def write(response_text)
  path = @options[:path] || default_path
  if @options[:multiple_files]
    write_multi_file path, response_text
  else
    write_file path, response_text
  end
end

Private Instance Methods

write_multi_file(dir, response_text) click to toggle source
# File lib/issue_exporter/outputter.rb, line 63
def write_multi_file(dir, response_text)
  array_of_issues = JSON.parse response_text
  array_of_issues.each do |issue|
    issue_number = issue["number"]
    filename = "#{dir}/issue-#{issue_number}.json"
    File.open(filename, 'w') { |f| f.write issue.to_json }
  end
end