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.12.0 lib/octopolo/github/commit.rb
octopolo-1.11.4 lib/octopolo/github/commit.rb
octopolo-1.11.3 lib/octopolo/github/commit.rb
octopolo-1.11.1 lib/octopolo/github/commit.rb
octopolo-1.11.0 lib/octopolo/github/commit.rb
octopolo-1.9.0 lib/octopolo/github/commit.rb
octopolo-1.8.1 lib/octopolo/github/commit.rb
octopolo-1.8.0 lib/octopolo/github/commit.rb
octopolo-1.7.1 lib/octopolo/github/commit.rb
octopolo-1.7.0 lib/octopolo/github/commit.rb
octopolo-1.6.0 lib/octopolo/github/commit.rb
octopolo-1.5.3 lib/octopolo/github/commit.rb
octopolo-1.5.2 lib/octopolo/github/commit.rb
octopolo-1.5.1 lib/octopolo/github/commit.rb
octopolo-1.5.0 lib/octopolo/github/commit.rb
octopolo-1.4.0 lib/octopolo/github/commit.rb
octopolo-1.3.0 lib/octopolo/github/commit.rb
octopolo-1.2.1 lib/octopolo/github/commit.rb
octopolo-1.2.0 lib/octopolo/github/commit.rb
octopolo-1.1.1 lib/octopolo/github/commit.rb