Class: Freighthop::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/freighthop/config.rb

Class Method Summary collapse

Class Method Details

.configObject



10
11
12
# File 'lib/freighthop/config.rb', line 10

def self.config
  @config ||= JSON.parse(file.read)
end

.exist?Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/freighthop/config.rb', line 2

def self.exist?
  file.exist?
end

.fetch(*args) ⇒ Object



14
15
16
# File 'lib/freighthop/config.rb', line 14

def self.fetch(*args)
  config.fetch(*args)
end

.fileObject



6
7
8
# File 'lib/freighthop/config.rb', line 6

def self.file
  Freighthop.host_root.join('.freighthop.json')
end

.write(config_hash) ⇒ Object



18
19
20
# File 'lib/freighthop/config.rb', line 18

def self.write(config_hash)
  file.open('w') { |f| f.puts(JSON.pretty_generate(config_hash)) }
end