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.
-
#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 |
#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 |