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.
27 28 29 |
# File 'lib/docker-sync/config/global_config.rb', line 27 def initialize load_global_config end |
Class Method Details
.load ⇒ Object
25 |
# File 'lib/docker-sync/config/global_config.rb', line 25 def self.load; instance end |
Instance Method Details
#first_run? ⇒ Boolean
43 44 45 |
# File 'lib/docker-sync/config/global_config.rb', line 43 def first_run? @first_run end |
#load_global_config ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/docker-sync/config/global_config.rb', line 31 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
49 50 51 52 53 |
# File 'lib/docker-sync/config/global_config.rb', line 49 def update!(updates) @config.merge!(updates) File.open(@config_path, 'w') {|f| f.write @config.to_yaml } end |