Class: IssueExporting::CsvOutputter
- Inherits:
-
BaseOutputter
- Object
- BaseOutputter
- IssueExporting::CsvOutputter
- Defined in:
- lib/issue_exporter/outputter.rb
Instance Method Summary collapse
Methods inherited from BaseOutputter
Constructor Details
This class inherits a constructor from IssueExporting::BaseOutputter
Instance Method Details
#write(response_text) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/issue_exporter/outputter.rb', line 30 def write(response_text) path = @options[:path] || default_path array_of_issues = JSON.parse response_text keys = ["number", "title", "state", "user.login", "created_at", "updated_at", "closed_at", "url"] text = "Issue #,Title,State,Created By,Created At,Last Updated At,Closed At,GitHub URL\n" mapped_values = array_of_issues.map do |issue| values = keys.map do |key| args = key.split '.' issue.dig(*args) end values.to_csv end csv_text = text + mapped_values.join("") write_file path, csv_text end |