facter 4.5.2 → 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/bin/facter +1 -1
  3. data/lib/docs/generate.rb +1 -6
  4. data/lib/facter/custom_facts/core/directed_graph.rb +2 -4
  5. data/lib/facter/custom_facts/core/execution/base.rb +1 -1
  6. data/lib/facter/custom_facts/core/execution/posix.rb +6 -2
  7. data/lib/facter/custom_facts/core/execution/windows.rb +4 -1
  8. data/lib/facter/custom_facts/core/execution.rb +1 -1
  9. data/lib/facter/custom_facts/core/file_loader.rb +0 -4
  10. data/lib/facter/custom_facts/core/suitable.rb +1 -1
  11. data/lib/facter/custom_facts/util/collection.rb +2 -4
  12. data/lib/facter/custom_facts/util/confine.rb +4 -1
  13. data/lib/facter/custom_facts/util/fact.rb +1 -1
  14. data/lib/facter/custom_facts/util/loader.rb +2 -2
  15. data/lib/facter/custom_facts/util/resolution.rb +8 -4
  16. data/lib/facter/custom_facts/util/values.rb +1 -1
  17. data/lib/facter/facts/linux/dmi/product/version.rb +19 -0
  18. data/lib/facter/facts/linux/kernelmajversion.rb +1 -1
  19. data/lib/facter/facts/macosx/is_virtual.rb +1 -1
  20. data/lib/facter/facts/macosx/virtual.rb +3 -3
  21. data/lib/facter/facts/mariner/os/release.rb +1 -1
  22. data/lib/facter/facts/photon/os/release.rb +1 -1
  23. data/lib/facter/facts/solaris/kernelmajversion.rb +1 -1
  24. data/lib/facter/facts/solaris/ldom.rb +1 -1
  25. data/lib/facter/facts/windows/hypervisors/kvm.rb +1 -1
  26. data/lib/facter/facts/windows/interfaces.rb +1 -1
  27. data/lib/facter/framework/benchmarking/timer.rb +2 -2
  28. data/lib/facter/framework/cli/cli.rb +6 -8
  29. data/lib/facter/framework/cli/cli_launcher.rb +1 -1
  30. data/lib/facter/framework/config/fact_groups.rb +1 -1
  31. data/lib/facter/framework/core/cache_manager.rb +5 -6
  32. data/lib/facter/framework/core/fact_loaders/fact_loader.rb +1 -3
  33. data/lib/facter/framework/core/fact_manager.rb +4 -4
  34. data/lib/facter/framework/core/file_loader.rb +734 -733
  35. data/lib/facter/framework/core/options/config_file_options.rb +4 -6
  36. data/lib/facter/framework/formatters/hocon_fact_formatter.rb +3 -2
  37. data/lib/facter/framework/formatters/legacy_fact_formatter.rb +4 -4
  38. data/lib/facter/framework/logging/logger.rb +6 -6
  39. data/lib/facter/framework/logging/logger_helper.rb +10 -11
  40. data/lib/facter/resolvers/aix/ffi/ffi_helper.rb +1 -1
  41. data/lib/facter/resolvers/aix/networking.rb +1 -1
  42. data/lib/facter/resolvers/aix/serialnumber.rb +1 -1
  43. data/lib/facter/resolvers/amzn/os_release_rpm.rb +1 -1
  44. data/lib/facter/resolvers/dmi.rb +2 -1
  45. data/lib/facter/resolvers/fips_enabled.rb +1 -1
  46. data/lib/facter/resolvers/freebsd/dmi.rb +1 -1
  47. data/lib/facter/resolvers/freebsd/swap_memory.rb +1 -1
  48. data/lib/facter/resolvers/freebsd/virtual.rb +1 -1
  49. data/lib/facter/resolvers/linux/hostname.rb +1 -1
  50. data/lib/facter/resolvers/macosx/dmi.rb +1 -1
  51. data/lib/facter/resolvers/macosx/filesystems.rb +1 -1
  52. data/lib/facter/resolvers/memory.rb +1 -1
  53. data/lib/facter/resolvers/networking.rb +3 -3
  54. data/lib/facter/resolvers/os_release.rb +1 -1
  55. data/lib/facter/resolvers/partitions.rb +2 -2
  56. data/lib/facter/resolvers/processors_lscpu.rb +2 -2
  57. data/lib/facter/resolvers/solaris/ffi/ffi.rb +2 -2
  58. data/lib/facter/resolvers/solaris/mountpoints.rb +1 -1
  59. data/lib/facter/resolvers/solaris/networking.rb +1 -1
  60. data/lib/facter/resolvers/solaris/os_release.rb +2 -2
  61. data/lib/facter/resolvers/virt_what.rb +2 -1
  62. data/lib/facter/resolvers/windows/memory.rb +3 -2
  63. data/lib/facter/resolvers/windows/product_release.rb +7 -7
  64. data/lib/facter/util/aix/odm_query.rb +1 -1
  65. data/lib/facter/util/api_debugger.rb +2 -2
  66. data/lib/facter/util/facts/posix/virtual_detector.rb +8 -5
  67. data/lib/facter/util/facts/unit_converter.rb +2 -2
  68. data/lib/facter/util/file_helper.rb +1 -2
  69. data/lib/facter/util/macosx/system_profile_executor.rb +3 -3
  70. data/lib/facter/util/resolvers/networking/networking.rb +4 -3
  71. data/lib/facter/util/utils.rb +2 -2
  72. data/lib/facter/version.rb +1 -1
  73. data/lib/facter.rb +7 -0
  74. metadata +10 -9
@@ -60,10 +60,8 @@ module Facter
60
60
  def augment_custom(file_global_conf)
61
61
  return unless file_global_conf
62
62
 
63
- if Options.cli?
64
- unless file_global_conf['no-custom-facts'].nil?
65
- @options[:no_custom_facts] = file_global_conf['no-custom-facts']
66
- end
63
+ if Options.cli? && !file_global_conf['no-custom-facts'].nil?
64
+ @options[:no_custom_facts] = file_global_conf['no-custom-facts']
67
65
  end
68
66
 
69
67
  @options[:custom_dir] = file_global_conf['custom-dir'] unless file_global_conf['custom-dir'].nil?
@@ -73,8 +71,8 @@ module Facter
73
71
  def augment_external(global_conf)
74
72
  return unless global_conf
75
73
 
76
- if Options.cli?
77
- @options[:no_external_facts] = global_conf['no-external-facts'] unless global_conf['no-external-facts'].nil?
74
+ if Options.cli? && !global_conf['no-external-facts'].nil?
75
+ @options[:no_external_facts] = global_conf['no-external-facts']
78
76
  end
79
77
 
80
78
  @options[:external_dir] = [global_conf['external-dir']].flatten unless global_conf['external-dir'].nil?
@@ -14,7 +14,8 @@ module Facter
14
14
 
15
15
  user_query = user_queries.first
16
16
  return format_for_no_query(resolved_facts) if user_query.empty?
17
- return format_for_single_user_query(user_queries.first, resolved_facts) unless user_query.empty?
17
+
18
+ format_for_single_user_query(user_queries.first, resolved_facts) unless user_query.empty?
18
19
  end
19
20
 
20
21
  private
@@ -39,7 +40,7 @@ module Facter
39
40
 
40
41
  return '' unless fact_value
41
42
 
42
- fact_value.class == Hash ? hash_to_hocon(fact_value) : fact_value
43
+ fact_value.instance_of?(Hash) ? hash_to_hocon(fact_value) : fact_value
43
44
  end
44
45
 
45
46
  def hash_to_hocon(fact_collection)
@@ -42,7 +42,7 @@ module Facter
42
42
  pretty_json = handle_newlines(pretty_json)
43
43
 
44
44
  @log.debug('Remove quotes from value if value is a string')
45
- pretty_json.gsub(/^(\S*) => \"(.*)\"/, '\1 => \2')
45
+ pretty_json.gsub(/^(\S*) => "(.*)"/, '\1 => \2')
46
46
  end
47
47
 
48
48
  def format_for_single_user_query(user_query, resolved_facts)
@@ -55,7 +55,7 @@ module Facter
55
55
  pretty_json = fact_value.nil? ? '' : hash_to_facter_format(fact_value)
56
56
 
57
57
  @log.debug('Remove quotes from value if it is a simple string')
58
- pretty_json.gsub(/^"(.*)\"/, '\1')
58
+ pretty_json.gsub(/^"(.*)"/, '\1')
59
59
  end
60
60
 
61
61
  def hash_to_facter_format(facts_hash)
@@ -66,7 +66,7 @@ module Facter
66
66
  pretty_json.gsub!(/":\s/, '" => ')
67
67
 
68
68
  @log.debug('Remove quotes from parent nodes')
69
- pretty_json.gsub!(/\"(.*)\"\ =>/, '\1 =>')
69
+ pretty_json.gsub!(/"(.*)"\ =>/, '\1 =>')
70
70
 
71
71
  @log.debug('Remove double backslashes from paths')
72
72
  pretty_json.gsub(/\\\\/, '\\')
@@ -95,7 +95,7 @@ module Facter
95
95
  # quotation marks that come after \ are not removed
96
96
  @log.debug('Remove unnecessary comma and quotation marks on root facts')
97
97
  output.split("\n")
98
- .map! { |line| /^[\s]+/.match?(line) ? line : line.gsub(/,$|(?<!\\)\"/, '').gsub('\\"', '"') }.join("\n")
98
+ .map! { |line| /^\s+/.match?(line) ? line : line.gsub(/,$|(?<!\\)"/, '').gsub('\\"', '"') }.join("\n")
99
99
  end
100
100
  end
101
101
  end
@@ -107,7 +107,7 @@ module Facter
107
107
  @@message_callback.call(:debug, msg)
108
108
  else
109
109
  msg = colorize(msg, CYAN) if Options[:color]
110
- @@logger.debug(@class_name + ' - ' + msg)
110
+ @@logger.debug("#{@class_name} - #{msg}")
111
111
  end
112
112
  end
113
113
 
@@ -128,7 +128,7 @@ module Facter
128
128
  @@message_callback.call(:info, msg)
129
129
  else
130
130
  msg = colorize(msg, GREEN) if Options[:color]
131
- @@logger.info(@class_name + ' - ' + msg)
131
+ @@logger.info("#{@class_name} - #{msg}")
132
132
  end
133
133
  end
134
134
 
@@ -137,7 +137,7 @@ module Facter
137
137
  @@message_callback.call(:warn, msg)
138
138
  else
139
139
  msg = colorize(msg, YELLOW) if Options[:color]
140
- @@logger.warn(@class_name + ' - ' + msg)
140
+ @@logger.warn("#{@class_name} - #{msg}")
141
141
  end
142
142
  end
143
143
 
@@ -149,20 +149,20 @@ module Facter
149
149
  warn(message_string)
150
150
  end
151
151
 
152
- def error(msg, colorize = false)
152
+ def error(msg, colorize = false) # rubocop:disable Style/OptionalBooleanParameter
153
153
  @@has_errors = true
154
154
 
155
155
  if @@message_callback && Options[:allow_external_loggers]
156
156
  @@message_callback.call(:error, msg)
157
157
  else
158
158
  msg = colorize(msg, RED) if colorize || Options[:color]
159
- @@logger.error(@class_name + ' - ' + msg)
159
+ @@logger.error("#{@class_name} - #{msg}")
160
160
  end
161
161
  end
162
162
 
163
163
  def log_exception(exception)
164
164
  msg = exception.message
165
- msg += "\n" + exception.backtrace.join("\n") if Options[:trace]
165
+ msg += "\n#{exception.backtrace.join("\n")}" if Options[:trace]
166
166
 
167
167
  error(msg, true)
168
168
  end
@@ -3,17 +3,16 @@
3
3
  class LoggerHelper
4
4
  class << self
5
5
  def determine_callers_name(sender_self)
6
- class_name = case sender_self
7
- when String
8
- sender_self
9
- when Class
10
- sender_self.name
11
- when Module
12
- sender_self.name
13
- else # when class is singleton
14
- sender_self.class.name
15
- end
16
- class_name
6
+ case sender_self
7
+ when String
8
+ sender_self
9
+ when Class
10
+ sender_self.name
11
+ when Module
12
+ sender_self.name
13
+ else # when class is singleton
14
+ sender_self.class.name
15
+ end
17
16
  end
18
17
  end
19
18
  end
@@ -77,7 +77,7 @@ module Facter
77
77
 
78
78
  family = FFI::AF_UNSPEC
79
79
 
80
- addresses.each do |_k, addr|
80
+ addresses.each_value do |addr|
81
81
  if family != FFI::AF_UNSPEC &&
82
82
  addr[:sa_family] != FFI::AF_UNSPEC &&
83
83
  family != addr[:sa_family]
@@ -47,7 +47,7 @@ module Facter
47
47
 
48
48
  info = line.split("\s")
49
49
  interface_name = info[0]
50
- mac = info[3][/^([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})$/]
50
+ mac = info[3][/^([0-9a-f]{1,2}[.:-]){5}([0-9a-f]{1,2})$/]
51
51
  if interfaces[interface_name]
52
52
  interfaces[interface_name][:mtu] = info[1].to_i
53
53
  interfaces[interface_name][:mac] = format_mac_address(mac) if mac
@@ -22,7 +22,7 @@ module Facter
22
22
 
23
23
  result.each_line do |line|
24
24
  if line.include?('value')
25
- @fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..-1]
25
+ @fact_list[:serialnumber] = line.split('=')[1].strip.delete('\"')[6..]
26
26
  break
27
27
  end
28
28
  end
@@ -15,7 +15,7 @@ module Facter
15
15
 
16
16
  def rpm_system_call(fact_name)
17
17
  output = Facter::Core::Execution.execute(
18
- 'rpm -q --qf \'%{NAME}\n%{VERSION}\n%{RELEASE}\n%{VENDOR}\' -f /etc/os-release',
18
+ 'rpm -q --qf \'%<NAME>s\n%<VERSION>s\n%<RELEASE>s\n%<VENDOR>s\' -f /etc/os-release',
19
19
  logger: log
20
20
  )
21
21
  build_fact_list(output)
@@ -22,6 +22,7 @@ module Facter
22
22
  # :product_serial
23
23
  # :product_name
24
24
  # :product_uuid
25
+ # :product_version
25
26
 
26
27
  private
27
28
 
@@ -32,7 +33,7 @@ module Facter
32
33
  def read_facts(fact_name)
33
34
  files = %w[bios_date bios_vendor bios_version board_asset_tag board_vendor board_name
34
35
  board_serial chassis_asset_tag chassis_type sys_vendor product_name
35
- product_serial product_uuid]
36
+ product_serial product_uuid product_version]
36
37
  return unless File.directory?('/sys/class/dmi')
37
38
 
38
39
  file_content = Facter::Util::FileHelper.safe_read("/sys/class/dmi/id/#{fact_name}", nil)
@@ -4,7 +4,7 @@ module Facter
4
4
  module Resolvers
5
5
  module Linux
6
6
  class FipsEnabled < BaseResolver
7
- #:fips_enabled
7
+ # :fips_enabled
8
8
 
9
9
  init_resolver
10
10
 
@@ -7,7 +7,7 @@ module Facter
7
7
  init_resolver
8
8
 
9
9
  class << self
10
- #:model
10
+ # :model
11
11
 
12
12
  private
13
13
 
@@ -15,7 +15,7 @@ module Facter
15
15
 
16
16
  def read_swap_memory(fact_name)
17
17
  output = Facter::Core::Execution.execute('swapinfo -k', logger: log)
18
- data = output.split("\n")[1..-1].map { |line| line.split(/\s+/) }
18
+ data = output.split("\n")[1..].map { |line| line.split(/\s+/) }
19
19
 
20
20
  unless data.empty?
21
21
  @fact_list[:total_bytes] = kilobytes_to_bytes(data.map { |line| line[1].to_i }.inject(:+))
@@ -7,7 +7,7 @@ module Facter
7
7
  init_resolver
8
8
 
9
9
  class << self
10
- #:model
10
+ # :model
11
11
 
12
12
  VM_GUEST_SYSCTL_NAMES = {
13
13
  'hv' => 'hyperv',
@@ -50,7 +50,7 @@ module Facter
50
50
  end
51
51
 
52
52
  log.debug("Tried to retrieve hostname and got: #{output}")
53
- return output unless output&.empty?
53
+ output unless output&.empty?
54
54
  end
55
55
 
56
56
  def parse_fqdn(output)
@@ -7,7 +7,7 @@ module Facter
7
7
  init_resolver
8
8
 
9
9
  class << self
10
- #:model
10
+ # :model
11
11
 
12
12
  private
13
13
 
@@ -16,7 +16,7 @@ module Facter
16
16
 
17
17
  def read_filesystems(fact_name)
18
18
  output = Facter::Core::Execution.execute('mount', logger: log)
19
- filesystems = output.scan(/\(([a-z]+)\,*/).flatten
19
+ filesystems = output.scan(/\(([a-z]+),*/).flatten
20
20
  @fact_list[:macosx_filesystems] = filesystems.uniq.sort.join(',')
21
21
  @fact_list[fact_name]
22
22
  end
@@ -57,7 +57,7 @@ module Facter
57
57
  end
58
58
 
59
59
  def compute_capacity(used, total)
60
- format('%<computed_capacity>.2f', computed_capacity: (used / total.to_f * 100)) + '%'
60
+ "#{format('%<computed_capacity>.2f', computed_capacity: (used / total.to_f * 100))}%"
61
61
  end
62
62
 
63
63
  def compute_used(total, free)
@@ -39,12 +39,12 @@ module Facter
39
39
  # convert ip ranges into single ip. eg. 10.16.132.213 --> 10.16.132.213 is converted to 10.16.132.213
40
40
  # convert ip6 ranges into single ip. eg. 2001:db8:cafe::132:213 -->
41
41
  # 2001:db8:cafe::132:213 is converted to 2001:db8:cafe::132:213
42
- response.gsub!(/([\da-fA-F]+([\.:]+[\da-fA-F]+)*)\s+-->\s+[\da-fA-F]+([\.:]+[\da-fA-F]+)*/, '\\1')
42
+ response.gsub!(/([\da-fA-F]+([.:]+[\da-fA-F]+)*)\s+-->\s+[\da-fA-F]+([.:]+[\da-fA-F]+)*/, '\\1')
43
43
  end
44
44
 
45
45
  def parse_interfaces_response(response)
46
46
  parsed_interfaces_data = {}
47
- interfaces_data = Hash[*response.split(/^([A-Za-z0-9_\.]+): /)[1..-1]]
47
+ interfaces_data = Hash[*response.split(/^([A-Za-z0-9_.]+): /)[1..]]
48
48
 
49
49
  interfaces_data.each do |interface_name, raw_data|
50
50
  parsed_interface_data = {}
@@ -66,7 +66,7 @@ module Facter
66
66
 
67
67
  def extract_mac(raw_data, parsed_interface_data)
68
68
  mac = raw_data.match(/(?:ether|lladdr)\s+((?:\w?\w:){5}\w?\w)|(?:infiniband)\s+((?:\w?\w:){19}\w?\w)/)
69
- &.captures&.compact&.first
69
+ &.captures&.compact&.first
70
70
  parsed_interface_data[:mac] = mac unless mac.nil?
71
71
  end
72
72
 
@@ -110,7 +110,7 @@ module Facter
110
110
 
111
111
  def append_linux_to_os_name
112
112
  os_name = @fact_list[:name]
113
- @fact_list[:name] = os_name + 'Linux' if os_name.downcase.start_with?('virtuozzo')
113
+ @fact_list[:name] = "#{os_name}Linux" if os_name.downcase.start_with?('virtuozzo')
114
114
  end
115
115
  end
116
116
  end
@@ -112,9 +112,9 @@ module Facter
112
112
 
113
113
  def execute_and_extract_blkid_info
114
114
  stdout = Facter::Core::Execution.execute('blkid', logger: log)
115
- output_hash = Hash[*stdout.split(/^([^:]+):/)[1..-1]]
115
+ output_hash = Hash[*stdout.split(/^([^:]+):/)[1..]]
116
116
  output_hash.each do |key, value|
117
- output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..-1]]
117
+ output_hash[key] = Hash[*value.delete('"').chomp.rstrip.split(/ ([^= ]+)=/)[1..]]
118
118
  end
119
119
  end
120
120
 
@@ -10,8 +10,8 @@ module Facter
10
10
  cores_per_socket: "-e 'Core(s)'" }.freeze
11
11
 
12
12
  class << self
13
- #:cores_per_socket
14
- #:threads_per_core
13
+ # :cores_per_socket
14
+ # :threads_per_core
15
15
 
16
16
  private
17
17
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'ffi'
4
- require_relative 'structs.rb'
5
- require_relative 'functions.rb'
4
+ require_relative 'structs'
5
+ require_relative 'functions'
6
6
 
7
7
  module Facter
8
8
  module Resolvers
@@ -23,7 +23,7 @@ module Facter
23
23
  end
24
24
  end
25
25
 
26
- def read_mounts(fact_name) # rubocop:disable Metrics/MethodLength
26
+ def read_mounts(fact_name)
27
27
  @mounts = []
28
28
  @auto_home_paths = []
29
29
  begin
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'ffi/ffi.rb'
3
+ require_relative 'ffi/ffi'
4
4
  module Facter
5
5
  module Resolvers
6
6
  module Solaris
@@ -26,7 +26,7 @@ module Facter
26
26
 
27
27
  @fact_list[:major] = major
28
28
  @fact_list[:minor] = minor
29
- @fact_list[:full] = major == '10' ? major + '_u' + minor : major + '.' + minor
29
+ @fact_list[:full] = major == '10' ? "#{major}_u#{minor}" : "#{major}.#{minor}"
30
30
  break
31
31
  end
32
32
  @fact_list[fact_name]
@@ -36,7 +36,7 @@ module Facter
36
36
  result = text.match(regex_pattern)
37
37
  major, minor = result.captures if result
38
38
  minor = regex_pattern == /Solaris (\d+)/ ? '0' : minor
39
- return [major, minor] if major && minor
39
+ [major, minor] if major && minor
40
40
  end
41
41
  end
42
42
  end
@@ -30,7 +30,8 @@ module Facter
30
30
  xen_info = xen_info.to_s
31
31
  return 'xenu' if /xen-domu/.match?(xen_info)
32
32
  return 'xenhvm' if /xen-hvm/.match?(xen_info)
33
- return 'xen0' if /xen-dom0/.match?(xen_info)
33
+
34
+ 'xen0' if /xen-dom0/.match?(xen_info)
34
35
  end
35
36
 
36
37
  def determine_other(output)
@@ -58,8 +58,9 @@ module Facter
58
58
  @fact_list[:total_bytes] = result[:total_bytes]
59
59
  @fact_list[:available_bytes] = result[:available_bytes]
60
60
  @fact_list[:used_bytes] = result[:used_bytes]
61
- @fact_list[:capacity] = format('%<capacity>.2f',
62
- capacity: (result[:used_bytes] / result[:total_bytes].to_f * 100)) + '%'
61
+ @fact_list[:capacity] = format(
62
+ '%<capacity>.2f%%', capacity: (result[:used_bytes] / result[:total_bytes].to_f * 100)
63
+ )
63
64
  end
64
65
  end
65
66
  end
@@ -23,19 +23,19 @@ module Facter
23
23
  end
24
24
 
25
25
  def build_fact_list(reg)
26
- reg.each do |name, _value|
26
+ reg.each do |name, _type, value|
27
27
  case name
28
28
  when 'EditionID'
29
- @fact_list[:edition_id] = reg[name]
29
+ @fact_list[:edition_id] = value
30
30
  when 'InstallationType'
31
- @fact_list[:installation_type] = reg[name]
31
+ @fact_list[:installation_type] = value
32
32
  when 'ProductName'
33
- @fact_list[:product_name] = reg[name]
33
+ @fact_list[:product_name] = value
34
34
  when 'DisplayVersion'
35
- @fact_list[:release_id] = reg[name]
36
- @fact_list[:display_version] = reg[name]
35
+ @fact_list[:release_id] = value
36
+ @fact_list[:display_version] = value
37
37
  when 'ReleaseId'
38
- @fact_list[:release_id] = reg[name] unless @fact_list[:release_id]
38
+ @fact_list[:release_id] = value unless @fact_list[:release_id]
39
39
  end
40
40
  end
41
41
  end
@@ -38,7 +38,7 @@ module Facter
38
38
  end
39
39
 
40
40
  def query
41
- 'odmget -q "' + @conditions.join(' AND ') + '"'
41
+ "odmget -q \"#{@conditions.join(' AND ')}\""
42
42
  end
43
43
  end
44
44
  end
@@ -34,9 +34,9 @@ module Facter
34
34
 
35
35
  options.split(',').each do |option|
36
36
  if option.start_with?('-')
37
- exclude << option[1..-1].to_sym
37
+ exclude << option[1..].to_sym
38
38
  elsif option.start_with?('+')
39
- print_caller << option[1..-1].to_sym
39
+ print_caller << option[1..].to_sym
40
40
  end
41
41
  end
42
42
 
@@ -7,11 +7,10 @@ module Facter
7
7
  module VirtualDetector
8
8
  class << self
9
9
  def platform
10
- @@fact_value ||= check_docker_lxc || check_freebsd || check_gce || retrieve_from_virt_what
11
- @@fact_value ||= check_vmware || check_open_vz || check_vserver || check_xen || check_other_facts
12
- @@fact_value ||= check_lspci || 'physical'
13
-
14
- @@fact_value
10
+ @fact_value ||= # rubocop:disable Naming/MemoizedInstanceVariableName
11
+ check_docker_lxc || check_freebsd || check_gce || check_illumos_lx || \
12
+ retrieve_from_virt_what || check_vmware || check_open_vz || check_vserver || \
13
+ check_xen || check_other_facts || check_lspci || 'physical'
15
14
  end
16
15
 
17
16
  private
@@ -25,6 +24,10 @@ module Facter
25
24
  'gce' if bios_vendor&.include?('Google')
26
25
  end
27
26
 
27
+ def check_illumos_lx
28
+ 'illumos-lx' if Facter::Resolvers::Uname.resolve(:kernelversion) == 'BrandZ virtual linux'
29
+ end
30
+
28
31
  def check_vmware
29
32
  Facter::Resolvers::Vmware.resolve(:vm)
30
33
  end
@@ -19,12 +19,12 @@ module Facter
19
19
 
20
20
  validated_speed, metric_prefix = determine_metric_prefix(speed)
21
21
 
22
- format('%<displayed_speed>.2f', displayed_speed: validated_speed.round(2)).to_s + ' ' + metric_prefix + 'Hz'
22
+ "#{format('%<displayed_speed>.2f', displayed_speed: validated_speed.round(2))} #{metric_prefix}Hz"
23
23
  end
24
24
 
25
25
  def bytes_to_human_readable(bytes)
26
26
  return unless bytes
27
- return bytes.to_s + ' bytes' if bytes < 1024
27
+ return "#{bytes} bytes" if bytes < 1024
28
28
 
29
29
  number, multiple = determine_exponent(bytes)
30
30
 
@@ -27,8 +27,7 @@ module Facter
27
27
  # method, we can't remove it entirely until the next major Facter
28
28
  # release (presumably Facter 5).
29
29
  def dir_children(path)
30
- children = Dir.children(path)
31
- children
30
+ Dir.children(path)
32
31
  end
33
32
 
34
33
  private
@@ -23,12 +23,12 @@ module Facter
23
23
  private
24
24
 
25
25
  def output_to_hash(output)
26
- output.scan(/.*:[ ].*$/).map { |e| e.strip.match(/(.*?): (.*)/).captures }.to_h
26
+ output.scan(/.*: .*$/).map { |e| e.strip.match(/(.*?): (.*)/).captures }.to_h
27
27
  end
28
28
 
29
29
  def normalize_keys(system_profiler_hash)
30
- system_profiler_hash.map do |k, v|
31
- [k.downcase.tr(' ', '_').delete("\(\)").to_sym, v]
30
+ system_profiler_hash.transform_keys do |k|
31
+ k.downcase.tr(' ', '_').delete("\(\)").to_sym
32
32
  end.to_h
33
33
  end
34
34
  end
@@ -54,7 +54,8 @@ module Facter
54
54
  'site'
55
55
  elsif addrinfo.ipv6_loopback?
56
56
  'host'
57
- else 'global'
57
+ else
58
+ 'global'
58
59
  end
59
60
  scope6.join
60
61
  end
@@ -102,7 +103,7 @@ module Facter
102
103
  def expand_interfaces(interfaces)
103
104
  interfaces.each_value do |values|
104
105
  expand_binding(values, values[:bindings]) if values[:bindings]
105
- expand_binding(values, values[:bindings6], false) if values[:bindings6]
106
+ expand_binding(values, values[:bindings6], ipv4_type: false) if values[:bindings6]
106
107
  end
107
108
  end
108
109
 
@@ -112,7 +113,7 @@ module Facter
112
113
  end
113
114
  end
114
115
 
115
- def expand_binding(values, bindings, ipv4_type = true)
116
+ def expand_binding(values, bindings, ipv4_type: true)
116
117
  binding = find_valid_binding(bindings)
117
118
  ip_protocol_type = ipv4_type ? '' : '6'
118
119
 
@@ -3,10 +3,10 @@
3
3
  module Facter
4
4
  module Utils
5
5
  # Sort nested hash.
6
- def self.sort_hash_by_key(hash, recursive = true, &block)
6
+ def self.sort_hash_by_key(hash, recursive: true, &block)
7
7
  hash.keys.sort(&block).each_with_object(hash.class.new) do |key, seed|
8
8
  seed[key] = hash[key]
9
- seed[key] = sort_hash_by_key(seed[key], true, &block) if recursive && seed[key].is_a?(Hash)
9
+ seed[key] = sort_hash_by_key(seed[key], recursive: true, &block) if recursive && seed[key].is_a?(Hash)
10
10
 
11
11
  seed
12
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Facter
4
- VERSION = '4.5.2' unless defined?(VERSION)
4
+ VERSION = '4.6.1' unless defined?(VERSION)
5
5
  end
data/lib/facter.rb CHANGED
@@ -653,6 +653,13 @@ module Facter
653
653
  nil
654
654
  end
655
655
 
656
+ # We don't respond to any missing methods
657
+ #
658
+ # @api private
659
+ def respond_to_missing?(_method, *)
660
+ false
661
+ end
662
+
656
663
  prepend ApiDebugger if ENV['API_DEBUG']
657
664
  end
658
665
  end