From f40a4669b9d0854f832fb2d4d7152f9668662115 Mon Sep 17 00:00:00 2001 From: Dmitry Ilyin Date: Wed, 31 Aug 2016 13:30:47 -0500 Subject: [PATCH] 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 --- Gemfile | 1 + lib/noop/task/facts.rb | 5 +++-- lib/noop/task/report.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 74a52b5..316d132 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ group :development, :test do gem 'colorize' gem 'parallel' gem 'openstack' + gem 'activesupport', '< 5.0.0' end if ENV['PUPPET_GEM_VERSION'] diff --git a/lib/noop/task/facts.rb b/lib/noop/task/facts.rb index 7aaf735..858243f 100644 --- a/lib/noop/task/facts.rb +++ b/lib/noop/task/facts.rb @@ -1,4 +1,5 @@ require 'yaml' +require 'active_support/core_ext/hash/indifferent_access' module Noop class Task @@ -70,9 +71,9 @@ module Noop facts_data[:puppetversion] = Puppet.version end - # @return [Hash] + # @return [ActiveSupport::HashWithIndifferentAccess] def facts_data - facts_data = {} + facts_data = ActiveSupport::HashWithIndifferentAccess.new facts_hierarchy.each do |file_path| begin file_data = YAML.load_file file_path diff --git a/lib/noop/task/report.rb b/lib/noop/task/report.rb index e477763..d118529 100644 --- a/lib/noop/task/report.rb +++ b/lib/noop/task/report.rb @@ -35,7 +35,7 @@ Facts hierarchy: gem = gem.to_s return unless Object.const_defined? 'Gem' return unless Gem.loaded_specs.is_a? Hash - return unless Gem.loaded_specs[gem].is_a? Gem::Specification + return unless Gem.loaded_specs[gem].respond_to? :version Gem.loaded_specs[gem].version end