Class: Carioca::RegistryFile
- Inherits:
-
Object
- Object
- Carioca::RegistryFile
show all
- Includes:
- Constants
- Defined in:
- lib/carioca/registry_file.rb
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
Instance Method Summary
collapse
Constructor Details
#initialize(filename:) ⇒ RegistryFile
Returns a new instance of RegistryFile.
9
10
11
12
13
14
15
|
# File 'lib/carioca/registry_file.rb', line 9
def initialize(filename:)
@filename = filename
@candidates = {}
@validated = {}
@altered = []
open
end
|
Instance Attribute Details
#altered ⇒ Object
Returns the value of attribute altered.
5
6
7
|
# File 'lib/carioca/registry_file.rb', line 5
def altered
@altered
end
|
#validated ⇒ Object
Returns the value of attribute validated.
5
6
7
|
# File 'lib/carioca/registry_file.rb', line 5
def validated
@validated
end
|
Instance Method Details
#add(service:, definition:) ⇒ Object
31
32
33
34
35
|
# File 'lib/carioca/registry_file.rb', line 31
def add(service:, definition:)
checker = Carioca::Services::Validator.new(service:, definition:)
checker.validate!
@validated[service] = checker.definition
end
|
#altered? ⇒ Boolean
17
18
19
|
# File 'lib/carioca/registry_file.rb', line 17
def altered?
!@altered.empty?
end
|
#create!(force: false) ⇒ Object
21
22
23
24
25
|
# File 'lib/carioca/registry_file.rb', line 21
def create!(force: false)
write_ok = true
write_ok = force if File.exist? @filename
File.write(@filename, @validated.to_yaml) if write_ok
end
|
#open ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/carioca/registry_file.rb', line 37
def open
if File.exist?(@filename)
@candidates = YAML.load_file(@filename)
else
create!
end
prepare!
end
|
#save! ⇒ Object
27
28
29
|
# File 'lib/carioca/registry_file.rb', line 27
def save!
create! force: true
end
|