Class: Starter::Config
- Inherits:
-
Object
- Object
- Starter::Config
- Defined in:
- lib/starter/config.rb
Class Method Summary collapse
Class Method Details
.config_file ⇒ Object
24 25 26 |
# File 'lib/starter/config.rb', line 24 def config_file File.join(@dest, '.config') end |
.read(dest: Dir.getwd) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/starter/config.rb', line 8 def read(dest: Dir.getwd) @dest = dest return {} unless File.exist?(config_file) YAML.load_file(config_file) end |
.save(dest: Dir.getwd, content: nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/starter/config.rb', line 15 def save(dest: Dir.getwd, content: nil) @dest = dest return if content.nil? || content.empty? || !content.is_a?(Hash) existent = File.exist?(config_file) ? YAML.load_file(config_file) : {} content = existent.merge(content) File.write(config_file, YAML.dump(content)) end |