Class: Gerd::GHClient
- Inherits:
-
Object
- Object
- Gerd::GHClient
- Defined in:
- lib/gerd/github_client.rb
Class Method Summary collapse
Class Method Details
.create(explicit_token) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/gerd/github_client.rb', line 8 def self.create(explicit_token) Octokit.auto_paginate = true token = explicit_token token = ENV['GERD_TOKEN'] unless token token = from_local unless token token = from_global unless token client = token ? Octokit::Client.new(:access_token => token) : client = Octokit::Client.new client end |
.from_global ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/gerd/github_client.rb', line 26 def self.from_global() file = File.join(ENV['HOME'], ".gerd") return unless File.exist?(file) global_file = File.read(file) grim_conf = JSON.parse(global_file) grim_conf['token'] end |
.from_local ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/gerd/github_client.rb', line 18 def self.from_local() file = File.join(Dir.pwd, ".gerd") return unless File.exist?(file) local_file = File.read(file) grim_conf = JSON.parse(local_file) grim_conf['token'] end |