Class: Metahub::GithubService
- Inherits:
-
Object
- Object
- Metahub::GithubService
- Defined in:
- lib/metahub/github.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ GithubService
constructor
A new instance of GithubService.
- #repositories ⇒ Object
Constructor Details
#initialize ⇒ GithubService
Returns a new instance of GithubService.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/metahub/github.rb', line 11 def initialize = { :login => Auth.username, :password => Auth.password, :auto_traversal => true } = { :scopes => ["repo"], :client_id => "099bb3db6bf979a92391", :client_secret => "ad2cbeac50c2d19478b1d9041b72fd7b9a3b0d26", :idempotent => true } simple = Octokit::Client.new() begin token = simple.() @client = Octokit::Client.new(:access_token => token[:token]) rescue Octokit::OneTimePasswordRequired => e token = simple.(.merge(:headers => { "X-GitHub-OTP" => Auth.otp_code })) @client = Octokit::Client.new(:access_token => token[:token]) end # puts @client.ratelimit_remaining end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/metahub/github.rb', line 10 def client @client end |
Class Method Details
.owner ⇒ Object
6 7 8 |
# File 'lib/metahub/github.rb', line 6 def self.owner @owner ||= self.new end |
Instance Method Details
#repositories ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/metahub/github.rb', line 33 def repositories repos = [] client.repositories.each do |hash| repos << hash.full_name end self.organizations(client.login).each do |org_name| client.organization_repositories(org_name).each do |hash| repos << hash.full_name end end # return these, ignoring requested ones repos.compact.uniq end |