Class: FirstGithubCommit

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, repo) ⇒ FirstGithubCommit

Returns a new instance of FirstGithubCommit.

Raises:



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

#pageObject (readonly)

Returns the value of attribute page.



11
12
13
# File 'lib/first_github_commit.rb', line 11

def page
  @page
end

#repoObject (readonly)

Returns the value of attribute repo.



11
12
13
# File 'lib/first_github_commit.rb', line 11

def repo
  @repo
end

#requests_madeObject (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

#userObject (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_urlObject



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

#yamlObject



28
29
30
# File 'lib/first_github_commit.rb', line 28

def yaml
  @yaml ||= YAML.load(last_response.body)["commits"].last
end