From 88ed1794cbad55536dc835304d47c0fe68b45963 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Sun, 6 Oct 2019 19:30:37 -0400 Subject: [PATCH] Revert to a small amount of duplicating to_hash in inspec/input.rb Signed-off-by: Clinton Wolfe --- lib/inspec/input.rb | 11 +++++++++++ lib/inspec/input_registry.rb | 2 +- test/unit/inputs/input_test.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/inspec/input.rb b/lib/inspec/input.rb index dd5529f88..6c1987418 100644 --- a/lib/inspec/input.rb +++ b/lib/inspec/input.rb @@ -318,6 +318,17 @@ module Inspec !current_value.is_a? NO_VALUE_SET end + def to_hash + as_hash = { name: name, options: {} } + %i{description title identifier type required value}.each do |field| + val = send(field) + next if val.nil? + + as_hash[:options][field] = val + end + as_hash + end + #--------------------------------------------------------------------------# # Value Type Coercion #--------------------------------------------------------------------------# diff --git a/lib/inspec/input_registry.rb b/lib/inspec/input_registry.rb index 3b38620e7..c0c088c50 100644 --- a/lib/inspec/input_registry.rb +++ b/lib/inspec/input_registry.rb @@ -1,6 +1,6 @@ require "forwardable" require "singleton" -require "inspec/objects/input" +require "inspec/input" require "inspec/secrets" require "inspec/exceptions" require "inspec/plugin/v2" diff --git a/test/unit/inputs/input_test.rb b/test/unit/inputs/input_test.rb index b3df794a0..86e752fb7 100644 --- a/test/unit/inputs/input_test.rb +++ b/test/unit/inputs/input_test.rb @@ -1,5 +1,5 @@ require "helper" -require "inspec/objects/input" +require "inspec/input" describe Inspec::Input do let(:opts) { {} }