Class: AbideDevUtils::Ppt::Hiera::Config
- Inherits:
 - 
      Object
      
        
- Object
 - AbideDevUtils::Ppt::Hiera::Config
 
 
- Defined in:
 - lib/abide_dev_utils/ppt/hiera.rb
 
Overview
Represents a Hiera configuration file
Instance Method Summary collapse
- #default_data_hash ⇒ Object
 - #default_datadir ⇒ Object
 - #defaults ⇒ Object
 - #hierarchy ⇒ Object
 - 
  
    
      #initialize(path = DEFAULT_CONFIG_FILE, facter_version: DEFAULT_FACTER_VERSION)  ⇒ Config 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Config.
 - #local_hiera_files(hierarchy_name: nil) ⇒ Object
 - #local_hiera_files_with_fact(fact_str, value = nil, hierarchy_name: nil) ⇒ Object
 - #local_hiera_files_with_facts(*fact_arrays, hierarchy_name: nil) ⇒ Object
 - #version ⇒ Object
 
Constructor Details
#initialize(path = DEFAULT_CONFIG_FILE, facter_version: DEFAULT_FACTER_VERSION) ⇒ Config
Returns a new instance of Config.
      37 38 39 40 41 42 43 44 45 46 47 48  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 37 def initialize(path = DEFAULT_CONFIG_FILE, facter_version: DEFAULT_FACTER_VERSION) @path = File.(path) raise "Hiera config file at path #{@path} not found!" unless File.file?(@path) @root_dir = File.dirname(@path) @conf = YAML.load_file(File.(path)) @by_name_path_store = {} #AbideDevUtils::Ppt::Hiera.facter_version = facter_version if @conf['defaults'].key?('datadir') AbideDevUtils::Ppt::Hiera.default_datadir = File.join(@root_dir, @conf['defaults']['datadir']) end end  | 
  
Instance Method Details
#default_data_hash ⇒ Object
      66 67 68  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 66 def default_data_hash @default_data_hash ||= defaults['data_hash'] end  | 
  
#default_datadir ⇒ Object
      62 63 64  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 62 def default_datadir AbideDevUtils::Ppt::Hiera.default_datadir end  | 
  
#defaults ⇒ Object
      58 59 60  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 58 def defaults @defaults ||= @conf['defaults'] end  | 
  
#hierarchy ⇒ Object
      50 51 52  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 50 def hierarchy @hierarchy ||= Hierarchy.new(@conf['hierarchy'], AbideDevUtils::Ppt::Hiera.default_datadir) end  | 
  
#local_hiera_files(hierarchy_name: nil) ⇒ Object
      70 71 72 73 74 75 76  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 70 def local_hiera_files(hierarchy_name: nil) if hierarchy_name hierarchy.entry_by_name(hierarchy_name).local_files else hierarchy.entries.map(&:local_files).flatten end end  | 
  
#local_hiera_files_with_fact(fact_str, value = nil, hierarchy_name: nil) ⇒ Object
      78 79 80 81 82 83 84  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 78 def local_hiera_files_with_fact(fact_str, value = nil, hierarchy_name: nil) if hierarchy_name hierarchy.entry_by_name(hierarchy_name).local_files_with_fact(fact_str, value) else hierarchy.entries.map { |e| e.local_files_with_fact(fact_str, value) }.flatten end end  | 
  
#local_hiera_files_with_facts(*fact_arrays, hierarchy_name: nil) ⇒ Object
      86 87 88 89 90 91 92  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 86 def local_hiera_files_with_facts(*fact_arrays, hierarchy_name: nil) if hierarchy_name hierarchy.entry_by_name(hierarchy_name).local_files_with_facts(*fact_arrays) else hierarchy.entries.map { |e| e.local_files_with_fact(*fact_arrays) }.flatten end end  | 
  
#version ⇒ Object
      54 55 56  | 
    
      # File 'lib/abide_dev_utils/ppt/hiera.rb', line 54 def version @version ||= @conf['version'] end  |