Browse Source

Misc fixes

* Change facts structure from a Hash to a HashWithIndifferentAccess.
  It will simplyfy adding facts values and working with them.

* Fix Gem versions reporter.

Change-Id: Ie28b2ea6bcd854e96cc8d9833be8adaafd689140
Dmitry Ilyin 2 years ago
parent
commit
f40a4669b9
3 changed files with 5 additions and 3 deletions
  1. 1
    0
      Gemfile
  2. 3
    2
      lib/noop/task/facts.rb
  3. 1
    1
      lib/noop/task/report.rb

+ 1
- 0
Gemfile View File

@@ -11,6 +11,7 @@ group :development, :test do
11 11
   gem 'colorize'
12 12
   gem 'parallel'
13 13
   gem 'openstack'
14
+  gem 'activesupport', '< 5.0.0'
14 15
 end
15 16
 
16 17
 if ENV['PUPPET_GEM_VERSION']

+ 3
- 2
lib/noop/task/facts.rb View File

@@ -1,4 +1,5 @@
1 1
 require 'yaml'
2
+require 'active_support/core_ext/hash/indifferent_access'
2 3
 
3 4
 module Noop
4 5
   class Task
@@ -70,9 +71,9 @@ module Noop
70 71
       facts_data[:puppetversion] = Puppet.version
71 72
     end
72 73
 
73
-    # @return [Hash]
74
+    # @return [ActiveSupport::HashWithIndifferentAccess]
74 75
     def facts_data
75
-      facts_data = {}
76
+      facts_data = ActiveSupport::HashWithIndifferentAccess.new
76 77
       facts_hierarchy.each do |file_path|
77 78
         begin
78 79
           file_data = YAML.load_file file_path

+ 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
 

Loading…
Cancel
Save