Class: Janky::GitHub::PayloadParser
- Inherits:
-
Object
- Object
- Janky::GitHub::PayloadParser
- Defined in:
- lib/janky/github/payload_parser.rb
Instance Method Summary collapse
- #branch ⇒ Object
- #commits ⇒ Object
- #compare ⇒ Object
- #head ⇒ Object
-
#initialize(json) ⇒ PayloadParser
constructor
A new instance of PayloadParser.
- #normalize_author(author) ⇒ Object
- #pusher ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(json) ⇒ PayloadParser
Returns a new instance of PayloadParser.
4 5 6 |
# File 'lib/janky/github/payload_parser.rb', line 4 def initialize(json) @payload = Yajl.load(json) end |
Instance Method Details
#branch ⇒ Object
56 57 58 |
# File 'lib/janky/github/payload_parser.rb', line 56 def branch @payload["ref"].split("refs/heads/").last end |
#commits ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/janky/github/payload_parser.rb', line 20 def commits @payload["commits"].map do |commit| GitHub::Commit.new( commit["id"], commit["url"], commit["message"], (commit["author"]), commit["timestamp"] ) end end |
#compare ⇒ Object
16 17 18 |
# File 'lib/janky/github/payload_parser.rb', line 16 def compare @payload["compare"] end |
#head ⇒ Object
12 13 14 |
# File 'lib/janky/github/payload_parser.rb', line 12 def head @payload["after"] end |
#normalize_author(author) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/janky/github/payload_parser.rb', line 32 def () if email = ["email"] "#{author["name"]} <#{email}>" else end end |
#pusher ⇒ Object
8 9 10 |
# File 'lib/janky/github/payload_parser.rb', line 8 def pusher @payload["pusher"]["name"] end |
#uri ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/janky/github/payload_parser.rb', line 40 def uri if uri = @payload["uri"] return uri end repository = @payload["repository"] if repository["private"] "git@#{GitHub.git_host}:#{URI(repository["url"]).path[1..-1]}" else uri = URI(repository["url"]) uri.scheme = "git" uri.to_s end end |