Class: Dip::Config
- Inherits:
-
Object
- Object
- Dip::Config
- Defined in:
- lib/dip/config.rb
Defined Under Namespace
Classes: ConfigFinder
Constant Summary collapse
- DEFAULT_PATH =
"dip.yml"- CONFIG_DEFAULTS =
{ environment: {}, compose: {}, kubectl: {}, interaction: {}, provision: [] }.freeze
- ConfigKeyMissingError =
Class.new(ArgumentError)
Class Method Summary collapse
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #file_path ⇒ Object
-
#initialize(work_dir = Dir.pwd) ⇒ Config
constructor
A new instance of Config.
- #to_h ⇒ Object
Constructor Details
#initialize(work_dir = Dir.pwd) ⇒ Config
Returns a new instance of Config.
82 83 84 |
# File 'lib/dip/config.rb', line 82 def initialize(work_dir = Dir.pwd) @work_dir = work_dir end |
Class Method Details
.load_yaml(file_path = path) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dip/config.rb', line 63 def load_yaml(file_path = path) return {} unless File.exist?(file_path) data = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0") YAML.safe_load( ERB.new(File.read(file_path)).result, aliases: true ) else YAML.safe_load( ERB.new(File.read(file_path)).result, [], [], true ) end data&.deep_symbolize_keys! || {} end |
Instance Method Details
#exist? ⇒ Boolean
90 91 92 |
# File 'lib/dip/config.rb', line 90 def exist? finder.exist? end |
#file_path ⇒ Object
86 87 88 |
# File 'lib/dip/config.rb', line 86 def file_path finder.file_path end |
#to_h ⇒ Object
94 95 96 |
# File 'lib/dip/config.rb', line 94 def to_h config end |