Sha256: a917e3d6469803bc9a64216738edef7e1bfefc55eb0a135def8245662113a3ed

Contents?: true

Size: 925 Bytes

Versions: 10

Compression:

Stored size: 925 Bytes

Contents

module Janky
  module GitHub
    class Payload
      def self.parse(json)
        parsed = PayloadParser.new(json)
        new(parsed.uri, parsed.branch, parsed.head, parsed.pusher,
            parsed.commits,
            parsed.compare)
      end

      def initialize(uri, branch, head, pusher, commits, compare)
        @uri     = uri
        @branch  = branch
        @head    = head
        @pusher  = pusher
        @commits = commits
        @compare = compare
      end

      attr_reader :uri, :branch, :head, :pusher, :commits, :compare

      def head_commit
        @commits.detect do |commit|
          commit.sha1 == @head
        end
      end

      def to_json
        { :after   => @head,
          :ref     => "refs/heads/#{@branch}",
          :pusher  => {:name => @pusher},
          :uri     => @uri,
          :commits => @commits,
          :compare => @compare }.to_json
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
janky-0.13.0.pre1 lib/janky/github/payload.rb
janky-0.12.0 lib/janky/github/payload.rb
janky-0.11.1 lib/janky/github/payload.rb
janky-0.11.0 lib/janky/github/payload.rb
janky-0.10.2 lib/janky/github/payload.rb
janky-0.10.0 lib/janky/github/payload.rb
janky-0.9.15 lib/janky/github/payload.rb
janky-0.9.14 lib/janky/github/payload.rb
janky-0.9.14.rc1 lib/janky/github/payload.rb
janky-0.9.13 lib/janky/github/payload.rb