Class: Carioca::Services::Config::ConfigFile
- Inherits:
-
Object
- Object
- Carioca::Services::Config::ConfigFile
- Includes:
- Constants
- Defined in:
- lib/carioca/services/config.rb
Overview
config file manager
Constant Summary
Constants included from Constants
Constants::BUILTINS, Constants::DEFAULT_COLORS_STATUS, Constants::DEFAULT_CONFIG_FILE, Constants::DEFAULT_CONFIG_ROOT, Constants::DEFAULT_DEBUGGER_TRACER, Constants::DEFAULT_EMOJI_STATUS, Constants::DEFAULT_ENVIRONMENT, Constants::DEFAULT_ENVIRONMENTS_LIST, Constants::DEFAULT_LOCALE, Constants::DEFAULT_LOG_LEVEL, Constants::DEFAULT_MASTER_KEY_FILE, Constants::DEFAULT_OUTPUT_MODE, Constants::DEFAULT_OUTPUT_TARGET, Constants::DEFAULT_REGISTRY_FILE, Constants::DEFAULT_SECURE_STORE_FILE, Constants::DEFAULT_USER_CONFIG_PATH, Constants::SERVICES_FULL_LIST_SPECS, Constants::SERVICES_MANDATORY_SPECS, Constants::SERVICES_SPECS_DETAIL
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#filename ⇒ Object
Returns the value of attribute filename.
Instance Method Summary collapse
- #create!(force: false) ⇒ Object
- #error? ⇒ Boolean
-
#initialize(filename:) ⇒ ConfigFile
constructor
A new instance of ConfigFile.
- #open ⇒ Object
Constructor Details
#initialize(filename:) ⇒ ConfigFile
Returns a new instance of ConfigFile.
34 35 36 37 38 39 |
# File 'lib/carioca/services/config.rb', line 34 def initialize(filename:) @filename = filename @data = {} @error = '' open end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
31 32 33 |
# File 'lib/carioca/services/config.rb', line 31 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
32 33 34 |
# File 'lib/carioca/services/config.rb', line 32 def error @error end |
#filename ⇒ Object
Returns the value of attribute filename.
31 32 33 |
# File 'lib/carioca/services/config.rb', line 31 def filename @filename end |
Instance Method Details
#create!(force: false) ⇒ Object
45 46 47 48 49 |
# File 'lib/carioca/services/config.rb', line 45 def create!(force: false) write_ok = true write_ok = force if File.exist? @filename File.write(@filename, @data.to_yaml) if write_ok end |
#error? ⇒ Boolean
41 42 43 |
# File 'lib/carioca/services/config.rb', line 41 def error? !@error.empty? end |
#open ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/carioca/services/config.rb', line 51 def open if File.exist?(@filename) begin @data = YAML.load_file(@filename) rescue StandardError => e @error = e. @data = {} end end prepare! end |