Class: Github::Commit
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Github::Commit
- Defined in:
- lib/github.rb
Constant Summary collapse
- ATTR_NAMES =
[:commit, :message, :branch, :committed_at, :committer_name, :committer_email, :author_name, :author_email, :compare_url]
Instance Method Summary collapse
- #author ⇒ Object
- #author_email ⇒ Object
- #author_name ⇒ Object
- #branch ⇒ Object
- #commit ⇒ Object
- #committed_at ⇒ Object
- #committer ⇒ Object
- #committer_email ⇒ Object
- #committer_name ⇒ Object
- #compare_url ⇒ Object
-
#initialize(data, repository) ⇒ Commit
constructor
A new instance of Commit.
- #to_hash ⇒ Object
Methods inherited from OpenStruct
Constructor Details
#initialize(data, repository) ⇒ Commit
Returns a new instance of Commit.
98 99 100 101 102 |
# File 'lib/github.rb', line 98 def initialize(data, repository) data['author'] ||= {} data['repository'] = repository super(data) end |
Instance Method Details
#author ⇒ Object
132 133 134 |
# File 'lib/github.rb', line 132 def self['author'] || {} end |
#author_email ⇒ Object
140 141 142 |
# File 'lib/github.rb', line 140 def ['email'] end |
#author_name ⇒ Object
136 137 138 |
# File 'lib/github.rb', line 136 def ['name'] end |
#branch ⇒ Object
112 113 114 |
# File 'lib/github.rb', line 112 def branch (self['ref'] || '').split('/').last end |
#commit ⇒ Object
108 109 110 |
# File 'lib/github.rb', line 108 def commit self['id'] end |
#committed_at ⇒ Object
116 117 118 |
# File 'lib/github.rb', line 116 def committed_at self['timestamp'] end |
#committer ⇒ Object
120 121 122 |
# File 'lib/github.rb', line 120 def committer self['committer'] || {} end |
#committer_email ⇒ Object
128 129 130 |
# File 'lib/github.rb', line 128 def committer_email committer['email'] end |
#committer_name ⇒ Object
124 125 126 |
# File 'lib/github.rb', line 124 def committer_name committer['name'] end |
#compare_url ⇒ Object
144 145 146 |
# File 'lib/github.rb', line 144 def compare_url self['compare_url'] end |
#to_hash ⇒ Object
104 105 106 |
# File 'lib/github.rb', line 104 def to_hash ATTR_NAMES.inject({}) { |result, name| result.merge(name => self.send(name)) } end |