Class: Jets::Gems::Config::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/gems/config/token.rb

Instance Method Summary collapse

Instance Method Details

#dataObject



7
8
9
# File 'lib/jets/gems/config/token.rb', line 7

def data
  load_yaml("#{ENV["HOME"]}/.jets/config.yml")
end

#keyObject



3
4
5
# File 'lib/jets/gems/config/token.rb', line 3

def key
  data["key"]
end

#load_yaml(path) ⇒ Object

Ensure a Hash is returned



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jets/gems/config/token.rb', line 12

def load_yaml(path)
  return {} unless File.exist?(path)

  data = YAML.load_file(path)
  if data.is_a?(Hash)
    data
  else
    puts "WARN: #{path} is not in the correct format. Loading an empty hash.".color(:yellow)
    {}
  end
end