Class: Zool::Configuration
- Inherits:
-
Object
- Object
- Zool::Configuration
- Defined in:
- lib/zool/configuration.rb
Defined Under Namespace
Classes: ParseError
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(raw_config) ⇒ Configuration
constructor
A new instance of Configuration.
- #keys ⇒ Object
- #upload_keys ⇒ Object
Constructor Details
#initialize(raw_config) ⇒ Configuration
Returns a new instance of Configuration.
27 28 29 30 |
# File 'lib/zool/configuration.rb', line 27 def initialize(raw_config) @raw_config = raw_config parse end |
Instance Attribute Details
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
4 5 6 |
# File 'lib/zool/configuration.rb', line 4 def groups @groups end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
4 5 6 |
# File 'lib/zool/configuration.rb', line 4 def roles @roles end |
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
4 5 6 |
# File 'lib/zool/configuration.rb', line 4 def servers @servers end |
Class Method Details
.build(pool) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zool/configuration.rb', line 15 def self.build(pool) conf = "" pool.servers.each do |server| next if server.keys == [] conf << "\n" unless conf == "" conf << "[server #{server.hostname}]\n" keynames = server.keys.map {|key| KeyfileWriter.keyname_for_key(key)} conf << " keys = #{keynames.join(', ')}\n" end conf end |
.parse(configuration) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/zool/configuration.rb', line 6 def self.parse(configuration) parser = PyConfigParser.new if raw_config = parser.parse(configuration) self.new(raw_config.build) else raise ParseError.new(parser.failure_reason) end end |
Instance Method Details
#keys ⇒ Object
32 33 34 |
# File 'lib/zool/configuration.rb', line 32 def keys @keys ||= read_keys end |
#upload_keys ⇒ Object
36 37 38 |
# File 'lib/zool/configuration.rb', line 36 def upload_keys @servers.each { |servername, server| server.upload_keys } end |