Class: Papa::Helper::Config

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

Class Method Summary collapse

Class Method Details

.config_exists?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/papa/helper/config.rb', line 17

def self.config_exists?
  File.exists?(config_path)
end

.config_pathObject



13
14
15
# File 'lib/papa/helper/config.rb', line 13

def self.config_path
  "#{Dir.home}/.papa.config.yml"
end

.exit_on_config_not_existsObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/papa/helper/config.rb', line 21

def self.exit_on_config_not_exists
  message = 'Cannot find config file.'
  Helper::Output.failure message
  info = <<-INFO
Make sure you have a valid config file in #{config_path}.
See README.md for more details.
  INFO
  Helper::Output.failure_info info
  exit 1
end

.readObject



7
8
9
10
11
# File 'lib/papa/helper/config.rb', line 7

def self.read
  return @config if defined?(@config)
  exit_on_config_not_exists unless config_exists?
  @config = YAML.load_file(config_path)
end