Sha256: 46ed82ea1dff0c121f05537ef8b57463b3628e0fd40ee15bb2225b81fe99eaae

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Lexhub
  # Wrapper for Github API Repo
  class Repo < Base
    # Public: Initialize a new Lexhub::Repo
    #
    # username  - the github username of the repo owner
    # repo_name - the name of the repo
    #
    # Examples
    #
    #   repo = Lexhub::Repo.new('joemsak', 'lexhub')
    #
    def initialize(username, repo_name)
      @username  = username
      @repo_name = repo_name
    end

    # Public: Get the commits of the named repo
    #
    # Examples
    #
    #   repo.commits
    #   # => [#<Hashie::Mash author=...>, #<Hashie::Mash author...>]
    #
    #   # same as if you had done:
    #   #
    #   # github = Github.new(:oauth_token => 'abc123...')
    #   # github.repos.commits.all('joemsak', 'lexhub')
    #
    # Returns Array commits
    def commits
      @commits ||= _collect(:commit, 'repos.commits.all')
    end

    # Public: Collect the words of all commit messages
    #
    # Examples
    #
    #   repo.words
    #   # => ['a', 'bunch', 'of', 'words']
    #
    # Returns Array all commit message words
    def words
      @words ||= commits.collect(&:message).join(' ').split(' ')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lexhub-0.0.1.alpha lib/lexhub/repo.rb