Class: HornOfPlenty::Adapters::Github::Parsers::Issue
- Inherits:
-
Object
- Object
- HornOfPlenty::Adapters::Github::Parsers::Issue
- Includes:
- Parsers::Hash
- Defined in:
- lib/horn_of_plenty/adapters/github/parsers/issue.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#raw ⇒ Object
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #assignee_ids ⇒ Object
- #author_id ⇒ Object
- #closed_at ⇒ Object
- #closer_id ⇒ Object
- #created_at ⇒ Object
- #description ⇒ Object
- #has_pull_request? ⇒ Boolean
- #id ⇒ Object
-
#initialize(raw:) ⇒ Issue
constructor
A new instance of Issue.
- #labels ⇒ Object
- #repository ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(raw:) ⇒ Issue
Returns a new instance of Issue.
16 17 18 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 16 def initialize(raw:) self.raw = raw end |
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
14 15 16 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 14 def raw @raw end |
Class Method Details
.to_model(raw_item) ⇒ Object
85 86 87 88 89 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 85 def self.to_model(raw_item) return NullObjects::Issue.instance unless raw_item Models::Issue.from_parser(parser: new(raw: raw_item)) end |
Instance Method Details
#assignee_ids ⇒ Object
28 29 30 31 32 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 28 def assignee_ids @assignee_ids ||= begin parse_key(raw, 'assignees').map { |assignee| assignee['login'] } end end |
#author_id ⇒ Object
24 25 26 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 24 def @author_id ||= parse_text(raw, 'user/:/login') end |
#closed_at ⇒ Object
69 70 71 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 69 def closed_at @closed_at ||= parse_time(raw, 'closed_at') end |
#closer_id ⇒ Object
34 35 36 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 34 def closer_id @closer_id ||= parse_text(raw, 'closed_by/:/login') end |
#created_at ⇒ Object
73 74 75 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 73 def created_at @created_at ||= parse_time(raw, 'created_at') end |
#description ⇒ Object
54 55 56 57 58 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 54 def description @description ||= parse_text(raw, 'body') do |description| description.delete("\r") end end |
#has_pull_request? ⇒ Boolean
81 82 83 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 81 def has_pull_request? @has_pull_request ||= parse_existance(raw, 'pull_request') end |
#id ⇒ Object
20 21 22 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 20 def id @id ||= parse_text(raw, 'number') end |
#labels ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 60 def labels @labels ||= begin labels = parse_key(raw, 'labels').map { |label| label['name'] } milestone = Array(parse_key(raw, 'milestone/:/title')) labels + milestone end end |
#repository ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 38 def repository @repository ||= parse_text(raw, 'url') do |url| repo_name = url.match(%r{\A.*/repos/((?:[^/]+/){2}).*\z})[1] repo_name && repo_name[0..-2] end end |
#status ⇒ Object
46 47 48 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 46 def status @status ||= parse_text(raw, 'state') end |
#title ⇒ Object
50 51 52 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 50 def title @title ||= parse_text(raw, 'title') end |
#updated_at ⇒ Object
77 78 79 |
# File 'lib/horn_of_plenty/adapters/github/parsers/issue.rb', line 77 def updated_at @updated_at ||= parse_time(raw, 'updated_at') end |