Class: Clustr::Config::Clusters
- Inherits:
-
Hash
- Object
- Hash
- Clustr::Config::Clusters
- Defined in:
- lib/clustr/config/clusters.rb
Overview
Handles determining the configuration for clusters that are present on the machine. Note that configurations should be defined in “~/.clustr”.
Class Method Summary collapse
-
.configuration ⇒ hash
Returns the configuration for the clusters that have been defined inside the “~/.clustr/” folder.
-
.configured? ⇒ boolean
Determines if there are any configured clusters.
Class Method Details
.configuration ⇒ hash
Returns the configuration for the clusters that have been defined inside the “~/.clustr/” folder. Note that the filename for each configuration, becomes the determined name for that cluster.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/clustr/config/clusters.rb', line 23 def self.configuration clusters ||= self.new config_files.each do |file| cluster = Pathname.new(file).basename.to_s clusters[cluster] = {} File.open(file, 'r') do |fh| fh.each_line do |line| key, val = line.strip.split(%r(\s*=\s*)) clusters[cluster][key] = val if key && val end end end clusters end |
.configured? ⇒ boolean
Determines if there are any configured clusters.
12 13 14 |
# File 'lib/clustr/config/clusters.rb', line 12 def self.configured? !configuration.empty? end |