Class: Facter::OsHierarchy

Inherits:
Object
  • Object
show all
Defined in:
lib/facter/framework/detector/os_hierarchy.rb

Instance Method Summary collapse

Constructor Details

#initializeOsHierarchy

Returns a new instance of OsHierarchy.



7
8
9
10
# File 'lib/facter/framework/detector/os_hierarchy.rb', line 7

def initialize
  @log = Log.new(self)
  @os_hierarchy = Facter::Config::OS_HIERARCHY
end

Instance Method Details

#construct_hierarchy(searched_os) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/facter/framework/detector/os_hierarchy.rb', line 12

def construct_hierarchy(searched_os)
  return [] if searched_os.nil?

  searched_os = searched_os.to_s.capitalize
  if @os_hierarchy.nil?
    @log.debug("There is no os_hierarchy, will fall back to: #{searched_os}")
    return [searched_os]
  end

  @searched_path = []
  search(@os_hierarchy, searched_os, [])

  @searched_path.map { |os_name| os_name.to_s.capitalize }
end