Class: Dip::Config

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

Constant Summary collapse

DEFAULT_PATH =
"dip.yml"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exist?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dip/config.rb', line 16

def exist?
  File.exist?(path)
end

.load_yaml(file_path = path) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/dip/config.rb', line 28

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

  YAML.safe_load(
    ERB.new(File.read(file_path)).result,
    [], [], true
  ).deep_symbolize_keys!
end

.override_pathObject



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

def override_path
  path.gsub(/\.yml$/, ".override.yml")
end

.pathObject



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

def path
  ENV["DIP_FILE"] || File.join(Dir.pwd, DEFAULT_PATH)
end

Instance Method Details

#to_hObject



44
45
46
# File 'lib/dip/config.rb', line 44

def to_h
  config
end