Class: Janky::GitHub::Payload
- Inherits:
-
Object
- Object
- Janky::GitHub::Payload
- Defined in:
- lib/janky/github/payload.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#compare ⇒ Object
readonly
Returns the value of attribute compare.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#pusher ⇒ Object
readonly
Returns the value of attribute pusher.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #head_commit ⇒ Object
-
#initialize(uri, branch, head, pusher, commits, compare) ⇒ Payload
constructor
A new instance of Payload.
- #to_json ⇒ Object
Constructor Details
#initialize(uri, branch, head, pusher, commits, compare) ⇒ Payload
Returns a new instance of Payload.
11 12 13 14 15 16 17 18 |
# File 'lib/janky/github/payload.rb', line 11 def initialize(uri, branch, head, pusher, commits, compare) @uri = uri @branch = branch @head = head @pusher = pusher @commits = commits @compare = compare end |
Instance Attribute Details
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def branch @branch end |
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def commits @commits end |
#compare ⇒ Object (readonly)
Returns the value of attribute compare.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def compare @compare end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def head @head end |
#pusher ⇒ Object (readonly)
Returns the value of attribute pusher.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def pusher @pusher end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
20 21 22 |
# File 'lib/janky/github/payload.rb', line 20 def uri @uri end |
Class Method Details
.parse(json) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/janky/github/payload.rb', line 4 def self.parse(json) parsed = PayloadParser.new(json) new(parsed.uri, parsed.branch, parsed.head, parsed.pusher, parsed.commits, parsed.compare) end |
Instance Method Details
#head_commit ⇒ Object
22 23 24 25 26 |
# File 'lib/janky/github/payload.rb', line 22 def head_commit @commits.detect do |commit| commit.sha1 == @head end end |
#to_json ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/janky/github/payload.rb', line 28 def to_json { :after => @head, :ref => "refs/heads/#{@branch}", :pusher => {:name => @pusher}, :uri => @uri, :commits => @commits, :compare => @compare }.to_json end |