Class: Gigest::GithubConnection
- Inherits:
-
Object
- Object
- Gigest::GithubConnection
- Defined in:
- lib/gigest/github/github_connection.rb
Instance Method Summary collapse
- #details_for(account = nil) ⇒ Object
- #gemfile_for(repository_name) ⇒ Object
-
#initialize(auth_params) ⇒ GithubConnection
constructor
A new instance of GithubConnection.
- #repositories_for(account = nil) ⇒ Object
Constructor Details
#initialize(auth_params) ⇒ GithubConnection
Returns a new instance of GithubConnection.
3 4 5 |
# File 'lib/gigest/github/github_connection.rb', line 3 def initialize(auth_params) @connection = Octokit::Client.new(auth_params) end |
Instance Method Details
#details_for(account = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gigest/github/github_connection.rb', line 7 def details_for(account=nil) details = @connection.user(account) { name: details[:name], type: details[:type], avatar_url: details._rels[:avatar].href, company: details[:company], location: details[:location], html_url: details._rels[:html].href } end |
#gemfile_for(repository_name) ⇒ Object
34 35 36 37 38 |
# File 'lib/gigest/github/github_connection.rb', line 34 def gemfile_for(repository_name) decode(file_blob(repository_name, "Gemfile")) rescue Octokit::NotFound nil end |
#repositories_for(account = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gigest/github/github_connection.rb', line 20 def repositories_for(account=nil) all_repositories = [] page = 0 loop do repositories = @connection.repositories(account, page: page+=1) break if repositories.empty? all_repositories += repositories.map { |repository| GithubRepo.new(repository, gemfile_for(repository.full_name)) } end all_repositories end |