Browse Source

Misc fixes 2

* Symbolize fact names form the facts files
* Fix Gem versions reporter.

Change-Id: I1a5afaf44d6f75c3485720f819477db5281900bb
Dmitry Ilyin 2 years ago
parent
commit
0e7a148f48
3 changed files with 14 additions and 1 deletions
  1. 1
    0
      lib/noop/task/facts.rb
  2. 1
    1
      lib/noop/task/report.rb
  3. 12
    0
      lib/noop/utils.rb

+ 1
- 0
lib/noop/task/facts.rb View File

@@ -77,6 +77,7 @@ module Noop
77 77
         begin
78 78
           file_data = YAML.load_file file_path
79 79
           next unless file_data.is_a? Hash
80
+          file_data = Noop::Utils.symbolize_hash_to_keys file_data
80 81
           facts_data.merge! file_data
81 82
         rescue
82 83
           next

+ 1
- 1
lib/noop/task/report.rb View File

@@ -35,7 +35,7 @@ Facts hierarchy:
35 35
       gem = gem.to_s
36 36
       return unless Object.const_defined? 'Gem'
37 37
       return unless Gem.loaded_specs.is_a? Hash
38
-      return unless Gem.loaded_specs[gem].is_a? Gem::Specification
38
+      return unless Gem.loaded_specs[gem].respond_to? :version
39 39
       Gem.loaded_specs[gem].version
40 40
     end
41 41
 

+ 12
- 0
lib/noop/utils.rb View File

@@ -104,5 +104,17 @@ module Noop
104 104
         '=' * 70
105 105
       end
106 106
     end
107
+
108
+    # Convert the top level keys of the hash to Symbols
109
+    # @param input_hash [Hash]
110
+    # @return [Hash <Symbol => Object>]
111
+    def self.symbolize_hash_to_keys(input_hash)
112
+      symbolized_hash = {}
113
+      input_hash.each do |key, value|
114
+        key = key.to_sym if key.respond_to? :to_sym
115
+        symbolized_hash[key] = value
116
+      end
117
+      symbolized_hash
118
+    end
107 119
   end
108 120
 end

Loading…
Cancel
Save