summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornordsieck-oc <theo@opscode.com>2013-08-19 14:04:26 -0700
committernordsieck-oc <theo@opscode.com>2013-08-19 14:04:26 -0700
commit5d74f1a56f866b025fff17f6f19a18d024c83842 (patch)
tree76c09e597dfd84027a55213d0274b71818016f98
parent4b8a8e74f9382a94584f5bcf15c72c7ac6782d7d (diff)
parentf614da5e09e38d281dc0f66c503bea66f6cf8800 (diff)
downloadohai-5d74f1a56f866b025fff17f6f19a18d024c83842.tar.gz
Merge pull request #171 from opscode/tn/cleanup
Assorted bug fixes and tweaks.
-rw-r--r--bin/grab_data.rb6
-rw-r--r--spec/unit/path/ohai_plugin_common.rb10
2 files changed, 9 insertions, 7 deletions
diff --git a/bin/grab_data.rb b/bin/grab_data.rb
index 6776bf4a..10489d02 100644
--- a/bin/grab_data.rb
+++ b/bin/grab_data.rb
@@ -47,7 +47,7 @@ class MyCLI
:long => "--params [P1,P2,...]",
:description => "List of parameters, applied one at a time",
#not sure how to use optparse's array syntax, so this is a hack to reproduce that behavior
- :proc => Proc.new { |s| if s then s.split( "," ) else [""] end }
+ :proc => Proc.new { |s| if s then s.split( "," ) end }
option :platform,
:short => "-f PLATFORM",
@@ -65,7 +65,7 @@ class MyCLI
:short => "-e [E1,E2,...]",
:long => "--environment [E1,E2,...]",
:description => "List of labels that describe the environment",
- :proc => Proc.new { |s| if s then s.split( "," ) else [] end } #same here
+ :proc => Proc.new { |s| if s then s.split( "," ) end } #same here
end
cli = MyCLI.new
@@ -80,6 +80,8 @@ cmd, params, platform, arch, env = cli.config[:command], cli.config[:params], cl
data ||= {}
data[platform] ||= {}
data[platform][arch] ||= []
+params ||= [""]
+env ||= []
# collect output
diff --git a/spec/unit/path/ohai_plugin_common.rb b/spec/unit/path/ohai_plugin_common.rb
index 97aac44f..cb1a9800 100644
--- a/spec/unit/path/ohai_plugin_common.rb
+++ b/spec/unit/path/ohai_plugin_common.rb
@@ -107,14 +107,14 @@ module OhaiPluginCommon
# output a fake executable case in the DSL
def to_fake_exe_format(platform, arch, env, params, stdout, stderr, exit_status)
- p = Yajl::Parser.new
+ e = Yajl::Encoder.new
<<-eos
platform "#{platform}"
arch "#{arch}"
env #{env}
-params #{p.parse( params )}
-stdout #{p.parse( stdout )}
-stderr #{p.parse( stderr )}
+params #{e.encode( params )}
+stdout #{e.encode( stdout )}
+stderr #{e.encode( stderr )}
exit_status #{exit_status}
eos
end
@@ -175,7 +175,7 @@ shared_context "cross platform data" do
data = OhaiPluginCommon.read_output c
data = data[platform][arch].select { |f| f[:env] == env }
- if data.all? { |f| /command not found/ =~ f[:stderr] && f[:exit_status] == 127 }
+ if data.all? { |f| ( /command not found/ =~ f[:stderr] ) && f[:exit_status] == 127 }
cmd_not_found.add c
else
OhaiPluginCommon.create_exe c, path, platform, arch, env