Class: Mccloud::Provider::Fog::FogConfig
- Inherits:
-
Object
- Object
- Mccloud::Provider::Fog::FogConfig
- Defined in:
- lib/mccloud/provider/fog/fogconfig.rb
Instance Attribute Summary collapse
-
#credential ⇒ Object
readonly
Returns the value of attribute credential.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(credential) ⇒ FogConfig
constructor
A new instance of FogConfig.
- #missing_credentials(keynames) ⇒ Object
- #missing_snippet(keynames) ⇒ Object
Constructor Details
#initialize(credential) ⇒ FogConfig
Returns a new instance of FogConfig.
7 8 9 |
# File 'lib/mccloud/provider/fog/fogconfig.rb', line 7 def initialize(credential) @credential=credential end |
Instance Attribute Details
#credential ⇒ Object (readonly)
Returns the value of attribute credential.
6 7 8 |
# File 'lib/mccloud/provider/fog/fogconfig.rb', line 6 def credential @credential end |
Instance Method Details
#exists? ⇒ Boolean
11 12 13 |
# File 'lib/mccloud/provider/fog/fogconfig.rb', line 11 def exists? return File.exists?(::Fog.credentials_path) end |
#missing_credentials(keynames) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mccloud/provider/fog/fogconfig.rb', line 15 def missing_credentials(keynames) missing_credentials=Array.new ::Fog.credential=@credential keynames.each do |key| unless ::Fog.credentials.has_key?(key) missing_credentials << key end end return missing_credentials end |
#missing_snippet(keynames) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mccloud/provider/fog/fogconfig.rb', line 27 def missing_snippet(keynames) # Reading the existing file if needed path=::Fog.credentials_path keys={} if File.exists?(path) keys=YAML.load(File.read(path)) end missing_credentials(keynames).each do |key| keys[@credential]=Hash.new if keys[@credential].nil? keys[@credential][key]="<your #{key}>" end return keys.to_yaml end |