Class: Thanks::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/thanks/registry.rb

Overview

Loaders for the local registry and the online version

Instance Method Summary collapse

Instance Method Details

#fetchObject



7
8
9
10
11
12
# File 'lib/thanks/registry.rb', line 7

def fetch
  @remote_memoized ||= remote
rescue SocketError => err
  STDERR.puts("Unable to contact GitHub: #{err}")
  local
end

#localObject



14
15
16
# File 'lib/thanks/registry.rb', line 14

def local
  @_local ||= YAML.load_file(File.join(__dir__, 'registry.yml'))
end

#remoteObject



18
19
20
21
22
23
24
25
# 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