From 2323ec52d207551241425006ca75ee79303ee55d Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 13 May 2016 11:52:05 +0200 Subject: [PATCH] add polyfill for ruby 1.9.3. struct --- lib/inspec/polyfill.rb | 13 +++++++++++++ lib/inspec/profile.rb | 1 + 2 files changed, 14 insertions(+) create mode 100644 lib/inspec/polyfill.rb diff --git a/lib/inspec/polyfill.rb b/lib/inspec/polyfill.rb new file mode 100644 index 000000000..8161c5ec8 --- /dev/null +++ b/lib/inspec/polyfill.rb @@ -0,0 +1,13 @@ +# encoding: utf-8 +# copyright: 2016, Chef Software Inc. +# author: Dominik Richter +# author: Christoph Hartmann +# license: All rights reserved + +class Struct + unless instance_methods.include? :to_h + def to_h + Hash[each_pair.to_a] + end + end +end diff --git a/lib/inspec/profile.rb b/lib/inspec/profile.rb index b9f647527..de2cb9923 100644 --- a/lib/inspec/profile.rb +++ b/lib/inspec/profile.rb @@ -4,6 +4,7 @@ # author: Christoph Hartmann require 'forwardable' +require 'inspec/polyfill' require 'inspec/fetcher' require 'inspec/source_reader' require 'inspec/metadata'