class Thanks::Registry
Loaders for the local registry and the online version
Public Instance Methods
fetch()
click to toggle source
# File lib/thanks/registry.rb, line 7 def fetch @remote_memoized ||= remote rescue SocketError => err STDERR.puts("Unable to contact GitHub: #{err}") local end
local()
click to toggle source
# File lib/thanks/registry.rb, line 14 def local @_local ||= YAML.load_file(File.join(__dir__, 'registry.yml')) end
remote()
click to toggle source
# File lib/thanks/registry.rb, line 18 def remote if response.code != '200' STDERR.puts "Bad HTTP request: #{response.body}" false else YAML.safe_load(response.body.to_s) end end
Private Instance Methods
remote_uri()
click to toggle source
# File lib/thanks/registry.rb, line 44 def remote_uri URI('https://raw.githubusercontent.com/dpritchett/thanks-ruby/master/lib/thanks/registry.yml') end
request()
click to toggle source
# File lib/thanks/registry.rb, line 29 def request Net::HTTP::Get.new(remote_uri) end
response()
click to toggle source
# File lib/thanks/registry.rb, line 33 def response Net::HTTP.start( remote_uri.hostname, remote_uri.port, use_ssl: true, timeout: 2 ) do |http| http.request(request) end end