<commit_before>
module Nucleon
module Action
module Cloud
class Hiera < CORL.plugin_class(:nucleon, :cloud_action)
  
  #-----------------------------------------------------------------------------
  # Info
  
  def self.describe
    super(:cloud, :hiera, 925)
  end
 
  #-----------------------------------------------------------------------------
  # Settings
 
  def configure
    super do
      register :properties, :array, []
      config.defaults(CORL.action_config(:node_lookup))  
    end
  end
  
  #---
  
  def ignore
    [ :property ]
  end
   
  def arguments
    [ :properties ]
  end
  
  #-----------------------------------------------------------------------------
  # Operations
   
  def execute
    super do |node, network|
      ensure_node(node) do
        if settings[:properties].empty?
          ui.info("\n" + CORL.render_object(node.hiera_configuration) + "\n\n", { :prefix => false })
        else
          settings.delete(:properties).each do |property|
            value = Util::Data.to_json(node.lookup(property, nil, settings), true)
            
            ui_group(property) do
              if value.match(/\n/)      
                ui.info("\n\n#{value}\n\n")
              else
                ui.info(value)  
              end
            end
          end  
        end        
      end
    end
  end
end
end
end
end<commit_msg>Reworking the hiera cloud action provider to work with updated lookup architecture.<commit_after>
module Nucleon
module Action
module Cloud
class Hiera < CORL.plugin_class(:nucleon, :cloud_action)
  
  #-----------------------------------------------------------------------------
  # Info
  
  def self.describe
    super(:cloud, :hiera, 925)
  end
 
  #-----------------------------------------------------------------------------
  # Settings
 
  def configure
    super do
      register :properties, :array, []
      config.defaults(CORL.action_config(:node_lookup))  
    end
  end
  
  #---
  
  def ignore
    [ :property ]
  end
   
  def arguments
    [ :properties ]
  end
  
  #-----------------------------------------------------------------------------
  # Operations
   
  def execute
    super do |node, network|
      ensure_node(node) do
        if settings[:properties].empty?
          $stderr.puts Util::Data.to_json(node.hiera_configuration(node.facts), true)
        else
          settings.delete(:properties).each do |property|
            ui_group(property) do
              $stderr.puts Util::Data.to_json(node.lookup(property, nil, settings), true)
            end
          end  
        end      
      end
    end
  end
end
end
end
end
{'fraction_non_alphanumeric': 0.2546348846008324, 'fraction_numerical': 0.0022701475595913734, 'mean_word_length': 1.1548492257538712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3083238', 'n_tokens_mistral': 712, 'n_tokens_neox': 681, 'n_words': 162}