Module: Exportify::Config

Defined in:
lib/exportify/config.rb

Constant Summary collapse

CONFIG_PATH =
File.expand_path('~/.exportify')

Class Method Summary collapse

Class Method Details

.loadObject



11
12
13
14
15
16
17
# File 'lib/exportify/config.rb', line 11

def load
  return {} unless File.exist?(CONFIG_PATH)

  JSON.parse(File.read(CONFIG_PATH))
rescue JSON::ParserError
  {}
end

.output_dirObject



24
25
26
# File 'lib/exportify/config.rb', line 24

def output_dir
  load['output_dir'] || CLI::DEFAULT_OUTPUT_DIR
end

.save(data) ⇒ Object



19
20
21
22
# File 'lib/exportify/config.rb', line 19

def save(data)
  File.write(CONFIG_PATH, JSON.pretty_generate(load.merge(data)))
  File.chmod(0o600, CONFIG_PATH)
end