Class: RightConf::Profile
- Inherits:
-
Object
- Object
- RightConf::Profile
- Includes:
- Singleton
- Defined in:
- lib/rconf/profile.rb
Instance Method Summary collapse
-
#configurator_signature(key) ⇒ Object
Retrieve persisted configurator signature.
-
#force_check ⇒ Object
Force re-configuration even if it was already done.
-
#force_check? ⇒ Boolean
Should next configuration force re-configuration?.
-
#force_reconfigure ⇒ Object
Bypass checks and always reconfigure.
-
#force_reconfigure? ⇒ Boolean
Should next configuration bypass checks?.
-
#initialize ⇒ Profile
constructor
Load profile from disk on instantiation.
-
#profile ⇒ Object
Entire profile with all settings.
-
#reset ⇒ Object
Delete profile from disk.
-
#set_configurator_signature(key, signature) ⇒ Object
Set signature for given configurator.
Methods included from Singleton
Constructor Details
#initialize ⇒ Profile
Load profile from disk on instantiation
24 25 26 27 28 29 30 31 |
# File 'lib/rconf/profile.rb', line 24 def initialize if File.exist?(profile_path) @profile = YAML.load(IO.read(profile_path)) rescue {} @profile = {} unless @profile.is_a?(Hash) else @profile = {} end end |
Instance Method Details
#configurator_signature(key) ⇒ Object
Retrieve persisted configurator signature
Return
- signature(String)
-
Persisted configurator signature
37 38 39 40 |
# File 'lib/rconf/profile.rb', line 37 def configurator_signature(key) sigs = @profile[:configurator_signatures] signature = sigs && sigs[key] end |
#force_check ⇒ Object
Force re-configuration even if it was already done
Return
- true
-
Always return true
79 80 81 82 |
# File 'lib/rconf/profile.rb', line 79 def force_check @force_check = true reset end |
#force_check? ⇒ Boolean
Should next configuration force re-configuration?
Return
- true
-
If re-configuration should be forced
- false
-
Otherwise
89 90 91 |
# File 'lib/rconf/profile.rb', line 89 def force_check? res = @force_check || false end |
#force_reconfigure ⇒ Object
Bypass checks and always reconfigure
Return
- true
-
Always return true
97 98 99 100 |
# File 'lib/rconf/profile.rb', line 97 def force_reconfigure @force_reconfigure = true reset end |
#force_reconfigure? ⇒ Boolean
Should next configuration bypass checks?
Return
- true
-
If re-configuration should bypass checks
- false
-
Otherwise
107 108 109 |
# File 'lib/rconf/profile.rb', line 107 def force_reconfigure? res = @force_reconfigure || false end |
#profile ⇒ Object
Entire profile with all settings
Return
- profile(Hash)
-
Profile settings
71 72 73 |
# File 'lib/rconf/profile.rb', line 71 def profile @profile end |
#reset ⇒ Object
Delete profile from disk
Return
- true
-
Always return true
61 62 63 64 65 |
# File 'lib/rconf/profile.rb', line 61 def reset File.delete(profile_path) if File.file?(profile_path) @profile = {} true end |
#set_configurator_signature(key, signature) ⇒ Object
Set signature for given configurator
Parameters
- key(String)
-
Configurator key
- signature(String)
-
Persisted configurator signature
Return
- true
-
Always return true
50 51 52 53 54 55 |
# File 'lib/rconf/profile.rb', line 50 def set_configurator_signature(key, signature) @profile[:configurator_signatures] ||= {} @profile[:configurator_signatures][key] = signature persist true end |