class Datapimp::Clients::Github
Public Class Methods
client(options={})
click to toggle source
# File lib/datapimp/clients/github.rb, line 14 def self.client(options={}) require 'octokit' unless defined?(::Oktokit) @client ||= begin instance.with_options(options) end end
method_missing(meth, *args, &block)
click to toggle source
Calls superclass method
# File lib/datapimp/clients/github.rb, line 6 def self.method_missing(meth, *args, &block) if client.respond_to?(meth) return client.send(meth, *args, &block) end super end
Public Instance Methods
api()
click to toggle source
# File lib/datapimp/clients/github.rb, line 31 def api @api ||= begin Octokit::Client.new(access_token: Datapimp.config.github_access_token, auto_paginate: true) end end
options()
click to toggle source
# File lib/datapimp/clients/github.rb, line 22 def options @options ||= {} end
setup(options={})
click to toggle source
# File lib/datapimp/clients/github.rb, line 37 def setup(options={}) access_token = options[:github_access_token] || Datapimp.config.github_access_token unless access_token.to_s.length == 40 puts "You should generate an access token to use with the Github client." puts "Access tokens allow you to revoke and/or limit access if needed." puts "To learn more about access tokens, and how to generate them, visit: https://help.github.com/articles/creating-an-access-token-for-command-line-use/" if respond_to?(:ask) access_token = ask("Enter a 40 character access token when you have one", String) end end unless access_token.to_s.length == 40 puts "Can not proceed without a valid access token: error code #{ access_token.length }" return end Datapimp.config.set(:github_access_token, access_token) end
with_options(opts={})
click to toggle source
# File lib/datapimp/clients/github.rb, line 26 def with_options(opts={}) options.merge!(opts) self end