Sha256: 9ada1c95c4739514dd57b439118a7e92b9e74aa4442ab0142fe7ec9e5312493c

Contents?: true

Size: 1.13 KB

Versions: 39

Compression:

Stored size: 1.13 KB

Contents

module Octopolo
  module GitHub
    class Commit
      attr_accessor :commit_data

      # Public: Instantiate a new Commit wrapper object
      #
      # commit_data - The GitHub API data about the commit
      def initialize commit_data
        self.commit_data = commit_data
      end

      # Public: Find commits for a given pull request
      #
      # pull_request - A PullRequest or other object responding to #repo_name
      #   and #number
      #
      # Returns an Array of Commit objects
      def self.for_pull_request pull_request
        GitHub.pull_request_commits(pull_request.repo_name, pull_request.number).map do |c|
          Commit.new c
        end
      end

      # Public: GitHub User that is the author of the commit
      #
      # Returns a Hashie::Mash object of the GitHub User
      def author
        GitHub::User.new(commit_data.author.login)
      rescue NoMethodError
        GitHub::User.new(GitHub::UNKNOWN_USER)
      end

      # Public: The name of the author of the commit
      #
      # Returns a String containing the author's name
      def author_name
        author.author_name
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
octopolo-1.1.0 lib/octopolo/github/commit.rb
octopolo-1.0.2 lib/octopolo/github/commit.rb
octopolo-1.0.1 lib/octopolo/github/commit.rb
octopolo-1.0.0 lib/octopolo/github/commit.rb
octopolo-0.4.1 lib/octopolo/github/commit.rb
octopolo-0.4.0 lib/octopolo/github/commit.rb
octopolo-0.3.6 lib/octopolo/github/commit.rb
octopolo-0.3.5 lib/octopolo/github/commit.rb
octopolo-0.3.4 lib/octopolo/github/commit.rb
octopolo-0.3.3 lib/octopolo/github/commit.rb
octopolo-0.3.2 lib/octopolo/github/commit.rb
octopolo-0.3.1 lib/octopolo/github/commit.rb
octopolo-0.3.0 lib/octopolo/github/commit.rb
octopolo-0.2.1 lib/octopolo/github/commit.rb
octopolo-0.1.4 lib/octopolo/github/commit.rb
octopolo-0.2.0 lib/octopolo/github/commit.rb
octopolo-0.1.3 lib/octopolo/github/commit.rb
octopolo-0.1.2 lib/octopolo/github/commit.rb
octopolo-0.1.1 lib/octopolo/github/commit.rb