Class: Abt::DirectoryConfig

Inherits:
Hash
  • Object
show all
Defined in:
lib/abt/directory_config.rb

Constant Summary collapse

FILE_NAME =
".abt.yml"

Instance Method Summary collapse

Constructor Details

#initializeDirectoryConfig

Returns a new instance of DirectoryConfig.



7
8
9
10
# File 'lib/abt/directory_config.rb', line 7

def initialize
  super
  load! if config_file_path && File.exist?(config_file_path)
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/abt/directory_config.rb', line 12

def available?
  !config_file_path.nil?
end

#load!Object



16
17
18
# File 'lib/abt/directory_config.rb', line 16

def load!
  merge!(YAML.load_file(config_file_path))
end

#save!Object



20
21
22
23
24
25
26
# File 'lib/abt/directory_config.rb', line 20

def save!
  raise Abt::Cli::Abort("Configuration files are not available outside of git repositories") unless available?

  config_file = File.open(config_file_path, "w")
  YAML.dump(to_h, config_file)
  config_file.close
end