Class: GithubIssueSync::IssueExporter
- Inherits:
-
Object
- Object
- GithubIssueSync::IssueExporter
- Defined in:
- lib/github_issue_sync/issue_exporter.rb
Overview
Fetches GitHub issues matching the given filters and writes them to a CSV that QA engineers can open in Google Sheets.
Usage:
exporter = GithubIssueSync::IssueExporter.new(
repo: "owner/repo",
token: ENV["GITHUB_TOKEN"],
labels: ["qa-feedback"],
state: "open"
)
exporter.call(output_path: "tmp/gh-issues-export.csv")
exporter.call(output_path: "tmp/gh-issues-export.csv", dry_run: true, io: $stdout)
Constant Summary collapse
- PER_PAGE =
100
Instance Method Summary collapse
- #call(output_path: nil, dry_run: false, io: $stdout) ⇒ Object
-
#initialize(repo:, token:, labels: [ "qa-feedback" ], state: "open") ⇒ IssueExporter
constructor
A new instance of IssueExporter.
Constructor Details
#initialize(repo:, token:, labels: [ "qa-feedback" ], state: "open") ⇒ IssueExporter
Returns a new instance of IssueExporter.
23 24 25 26 27 28 |
# File 'lib/github_issue_sync/issue_exporter.rb', line 23 def initialize(repo:, token:, labels: [ "qa-feedback" ], state: "open") @repo = repo @token = token @labels = labels @state = state end |
Instance Method Details
#call(output_path: nil, dry_run: false, io: $stdout) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/github_issue_sync/issue_exporter.rb', line 33 def call(output_path: nil, dry_run: false, io: $stdout) issues = fetch_all_issues rows = issues.map { |i| IssueRow.from_github(i) } if dry_run print_preview(rows, io) elsif output_path write_csv(rows, output_path) io.puts "Exported #{rows.size} issue(s) to #{output_path}" if io.respond_to?(:puts) else io.print generate_csv(rows) end end |