Class: DockerSync::GlobalConfig
- Inherits:
-
Object
- Object
- DockerSync::GlobalConfig
- Extended by:
- Forwardable
- Includes:
- Singleton
- Defined in:
- lib/docker-sync/config/global_config.rb
Constant Summary collapse
- DEFAULTS =
noinspection RubyStringKeysInHashInspection
{ 'update_check' => true, 'update_last_check' => DateTime.new(2001, 1, 1).iso8601(9), 'update_enforce' => true, 'upgrade_status' => '', }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #first_run? ⇒ Boolean
-
#initialize ⇒ GlobalConfig
constructor
A new instance of GlobalConfig.
- #load_global_config ⇒ Object
-
#update!(updates) ⇒ Object
Updates and saves the configuration back to the file.
Constructor Details
#initialize ⇒ GlobalConfig
Returns a new instance of GlobalConfig.
28 29 30 |
# File 'lib/docker-sync/config/global_config.rb', line 28 def initialize load_global_config end |
Class Method Details
.load ⇒ Object
26 |
# File 'lib/docker-sync/config/global_config.rb', line 26 def self.load; instance end |
Instance Method Details
#first_run? ⇒ Boolean
44 45 46 |
# File 'lib/docker-sync/config/global_config.rb', line 44 def first_run? @first_run end |
#load_global_config ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/docker-sync/config/global_config.rb', line 32 def load_global_config @config_path = DockerSync::ConfigLocator.current_global_config_path if File.exist?(@config_path) @config = DockerSync::ConfigSerializer.default_deserializer_file(@config_path) end unless @config @config = DEFAULTS.dup @first_run = true end end |
#update!(updates) ⇒ Object
Updates and saves the configuration back to the file
50 51 52 53 54 |
# File 'lib/docker-sync/config/global_config.rb', line 50 def update!(updates) @config.merge!(updates) File.open(@config_path, 'w') {|f| f.write @config.to_yaml } end |