Class: Facter::FactGroups
- Inherits:
-
Object
- Object
- Facter::FactGroups
- Defined in:
- lib/facter/framework/config/fact_groups.rb
Constant Summary collapse
- STRING_TO_SECONDS =
{ 'seconds' => 1, 'minutes' => 60, 'hours' => 3600, 'days' => 3600 * 24 }.freeze
Instance Attribute Summary collapse
- #block_list ⇒ Object readonly
- #groups ⇒ Object readonly
Instance Method Summary collapse
-
#blocked_facts ⇒ Object
Breakes down blocked groups in blocked facts.
-
#get_fact_group(fact_name) ⇒ Object
Get the group name a fact is part of.
-
#get_group_ttls(group_name) ⇒ Object
Get config ttls for a given group.
-
#initialize(group_list_path = nil) ⇒ FactGroups
constructor
A new instance of FactGroups.
Constructor Details
#initialize(group_list_path = nil) ⇒ FactGroups
Returns a new instance of FactGroups.
11 12 13 14 15 16 17 |
# File 'lib/facter/framework/config/fact_groups.rb', line 11 def initialize(group_list_path = nil) default_path = File.join(File.dirname(__FILE__), '../../fact_groups.conf') @groups_file_path = group_list_path || default_path @groups ||= File.readable?(@groups_file_path) ? Hocon.load(@groups_file_path) : {} load_groups end |
Instance Attribute Details
#block_list ⇒ Object (readonly)
5 6 7 |
# File 'lib/facter/framework/config/fact_groups.rb', line 5 def block_list @block_list end |
#groups ⇒ Object (readonly)
5 6 7 |
# File 'lib/facter/framework/config/fact_groups.rb', line 5 def groups @groups end |
Instance Method Details
#blocked_facts ⇒ Object
Breakes down blocked groups in blocked facts
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/facter/framework/config/fact_groups.rb', line 20 def blocked_facts fact_list = [] @block_list.each do |group_name| facts_for_block = @groups[group_name] fact_list += facts_for_block || [group_name] end fact_list end |
#get_fact_group(fact_name) ⇒ Object
Get the group name a fact is part of
33 34 35 |
# File 'lib/facter/framework/config/fact_groups.rb', line 33 def get_fact_group(fact_name) @groups.detect { |k, v| break k if Array(v).find { |f| fact_name =~ /^#{f}.*/ } } end |
#get_group_ttls(group_name) ⇒ Object
Get config ttls for a given group
38 39 40 41 42 |
# File 'lib/facter/framework/config/fact_groups.rb', line 38 def get_group_ttls(group_name) return unless (ttls = @groups_ttls.find { |g| g[group_name] }) ttls_to_seconds(ttls[group_name]) end |