Class: GithubIssueSync::IssueRow
- Inherits:
-
Object
- Object
- GithubIssueSync::IssueRow
- Defined in:
- lib/github_issue_sync/issue_row.rb
Overview
Represents one GitHub issue as a flat hash keyed by CSV column name. Knows how to build itself from a Sawyer::Resource (GitHub API response) or from a CSV row hash, and how to emit its values as an ordered array suitable for CSV serialisation.
Constant Summary collapse
- COLUMNS =
[ "GitHub Issue #", "State", "Title", "Type", "Priority", "Section", "Element / Feature", "Description", "Labels", "URL" ].freeze
- TYPE_LABELS =
Type labels recognised by import-qa-issues (lowercase match).
%w[bug enhancement ux copy question security performance].freeze
- PRIORITY_LABEL_MAP =
Priority labels → human-readable names.
{ "critical" => "Critical", "high-priority" => "High", "pre-launch" => "High", # legacy: pre-launch treated as High priority "low-priority" => "Low" }.freeze
- PRIORITY_EMOJI_RE =
Emoji prefixes written by import-qa-issues build_body_v2.
/\A(?:🔴|🟠|🟡|🟢)\s*/
Class Method Summary collapse
-
.from_csv_row(row) ⇒ Object
Build an IssueRow from a CSV::Row or plain Hash keyed by column name.
-
.from_github(issue) ⇒ Object
Build an IssueRow from a Sawyer::Resource returned by Octokit.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(data) ⇒ IssueRow
constructor
—————————————————————— Instance interface ——————————————————————.
- #keys ⇒ Object
- #to_h ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(data) ⇒ IssueRow
Instance interface
73 74 75 |
# File 'lib/github_issue_sync/issue_row.rb', line 73 def initialize(data) @data = data end |
Class Method Details
.from_csv_row(row) ⇒ Object
Build an IssueRow from a CSV::Row or plain Hash keyed by column name.
62 63 64 65 66 67 |
# File 'lib/github_issue_sync/issue_row.rb', line 62 def self.from_csv_row(row) data = COLUMNS.each_with_object({}) do |col, h| h[col] = row[col].to_s end new(data) end |
.from_github(issue) ⇒ Object
Build an IssueRow from a Sawyer::Resource returned by Octokit.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/github_issue_sync/issue_row.rb', line 43 def self.from_github(issue) label_names = Array(issue.labels).map(&:name) body = issue.body.to_s new( "GitHub Issue #" => issue.number.to_s, "State" => issue.state.to_s, "Title" => issue.title.to_s, "Type" => extract_type(body, label_names), "Priority" => extract_priority(body, label_names), "Section" => extract_table_field(body, "Page / Section"), "Element / Feature" => extract_table_field(body, "Element / Feature"), "Description" => body, "Labels" => label_names.join(", "), "URL" => issue.html_url.to_s ) end |
Instance Method Details
#[](key) ⇒ Object
77 |
# File 'lib/github_issue_sync/issue_row.rb', line 77 def [](key) = @data[key] |
#keys ⇒ Object
80 |
# File 'lib/github_issue_sync/issue_row.rb', line 80 def keys = @data.keys |
#to_h ⇒ Object
79 |
# File 'lib/github_issue_sync/issue_row.rb', line 79 def to_h = @data.dup |
#values ⇒ Object
78 |
# File 'lib/github_issue_sync/issue_row.rb', line 78 def values = COLUMNS.map { |c| @data[c] } |