Module: Daigaku::GithubClient
- Defined in:
- lib/daigaku/github_client.rb
Class Method Summary collapse
-
.master_zip_url(user_and_repo) ⇒ Object
Returns the url to the master zip file of the Github repo.
-
.updated?(user_and_repo) ⇒ Boolean
Returns whether the pushed_at time from Github API is newer than the stored one.
-
.updated_at(user_and_repo) ⇒ Object
Returns the timestamp of updated_at for the repo from the Github API.
Class Method Details
.master_zip_url(user_and_repo) ⇒ Object
Returns the url to the master zip file of the Github repo.
9 10 11 |
# File 'lib/daigaku/github_client.rb', line 9 def self.master_zip_url(user_and_repo) "https://github.com/#{user_and_repo}/archive/master.zip" end |
.updated?(user_and_repo) ⇒ Boolean
Returns whether the pushed_at time from Github API is newer than the stored one.
21 22 23 24 25 26 27 28 |
# File 'lib/daigaku/github_client.rb', line 21 def self.updated?(user_and_repo) return false unless user_and_repo course = Course.new(user_and_repo.split('/').last) stored_time = QuickStore.store.get(course.key(:updated_at)) current_time = self.updated_at(user_and_repo) DateTime.parse(stored_time) < DateTime.parse(current_time) end |
.updated_at(user_and_repo) ⇒ Object
Returns the timestamp of updated_at for the repo from the Github API.
14 15 16 17 |
# File 'lib/daigaku/github_client.rb', line 14 def self.updated_at(user_and_repo) url = "https://api.github.com/repos/#{user_and_repo}" JSON.parse(open(url).read)['updated_at'] end |