Class: FirstGithubCommit
- Inherits:
-
Object
- Object
- FirstGithubCommit
- Defined in:
- lib/first_github_commit.rb
Defined Under Namespace
Classes: RepoNotFound, TooManyRequests
Constant Summary collapse
- DEBUG =
false- MAX_REQUESTS =
30
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#requests_made ⇒ Object
readonly
Returns the value of attribute requests_made.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #github_url ⇒ Object
-
#initialize(user, repo) ⇒ FirstGithubCommit
constructor
A new instance of FirstGithubCommit.
- #yaml ⇒ Object
Constructor Details
#initialize(user, repo) ⇒ FirstGithubCommit
Returns a new instance of FirstGithubCommit.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/first_github_commit.rb', line 16 def initialize(user, repo) @user, @repo = user, repo @requests_made = 0 @range = (1..130) # Make sure the repo even exists! raise RepoNotFound if RedirectFollower.new(url_for_page(1)).response.kind_of?(Net::HTTPNotFound) find_upper_limit find_page_number end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
11 12 13 |
# File 'lib/first_github_commit.rb', line 11 def page @page end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
11 12 13 |
# File 'lib/first_github_commit.rb', line 11 def repo @repo end |
#requests_made ⇒ Object (readonly)
Returns the value of attribute requests_made.
11 12 13 |
# File 'lib/first_github_commit.rb', line 11 def requests_made @requests_made end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
11 12 13 |
# File 'lib/first_github_commit.rb', line 11 def user @user end |
Class Method Details
.find(user, repo) ⇒ Object
36 37 38 |
# File 'lib/first_github_commit.rb', line 36 def self.find(user, repo) FirstGithubCommit.new(user, repo).yaml end |
Instance Method Details
#github_url ⇒ Object
32 33 34 |
# File 'lib/first_github_commit.rb', line 32 def github_url @github_url ||= "http://github.com/#{user}/#{repo}/commits/master?page=#{page}" end |
#yaml ⇒ Object
28 29 30 |
# File 'lib/first_github_commit.rb', line 28 def yaml @yaml ||= YAML.load(last_response.body)["commits"].last end |