Class: DataDir
- Inherits:
-
Object
- Object
- DataDir
- Defined in:
- lib/hiera_browser/data.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #datafiles ⇒ Array
- #initialize(args = {}) ⇒ void constructor
- #keys ⇒ Array
- #render_paths(args) ⇒ Array
- #yaml_files ⇒ Array
Constructor Details
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
4 5 6 |
# File 'lib/hiera_browser/data.rb', line 4 def paths @paths end |
Instance Method Details
#datafiles ⇒ Array
34 35 36 37 38 |
# File 'lib/hiera_browser/data.rb', line 34 def datafiles @paths.map{|path| yaml_files.map{|f| DataFile.new(:path => File.join(path,f))} }.flatten end |
#keys ⇒ Array
41 42 43 |
# File 'lib/hiera_browser/data.rb', line 41 def keys datafiles.map{|datafile| datafile.keys}.flatten.uniq.sort end |
#render_paths(args) ⇒ Array
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hiera_browser/data.rb', line 13 def render_paths(args) begin interpolated_variables = args[:path].match(/\%\{([a-z_\:]+)\}/).captures collected_parameters = @node_dir.collected_parameters # collected_parameters is a ParameterCollection # interpolated_variables might look like ['::environment'] interpolated_variables.map{|v| collected_parameters[v].map{|param| args[:path].gsub(/%{#{v}}/, param)} }.flatten rescue NoMethodError [args[:path]] end end |
#yaml_files ⇒ Array
29 30 31 |
# File 'lib/hiera_browser/data.rb', line 29 def yaml_files @paths.map{|p| Dir.chdir(p) { Dir.glob('**/*.yaml') } }.flatten end |