class Travis::Tools::TokenFinder
This is used when running ‘travis login –auto`
def self.find(options = {})
def self.find(options = {}) new(options).find end
def find
def find find_netrc || find_hub end
def find_hub
def find_hub return unless File.readable? hub data = YAML.load_file(File.expand_path(hub)) data &&= Array(data[github]) data.first['oauth_token'] if data.size == 1 rescue => e raise e if explode end
def find_netrc
def find_netrc return unless File.readable? netrc data = Netrc.read(netrc)[github] data.detect { |e| e.size == 40 } if data rescue => e raise e if explode end
def hub=(file)
def hub=(file) @hub = File.expand_path(file) end
def initialize(options = {})
def initialize(options = {}) self.netrc = options[:netrc] || Netrc.default_path self.hub = options[:hub] || ENV['HUB_CONFIG'] || '~/.config/hub' self.github = options[:github] self.github = 'github.com' if github.nil? or github == 'api.github.com' self.explode = options[:explode] end
def netrc=(file)
def netrc=(file) @netrc = File.expand_path(file) end