Skip to content

Commit

Permalink
Merge pull request #135 from itamae-kitchen/host-inventory-mash
Browse files Browse the repository at this point in the history
Wrap host inventory value with Hashie::Mash.
  • Loading branch information
ryotarai committed Jun 2, 2015
2 parents 8dd2b07 + ef2a57a commit c768fd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/itamae/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ def respond_to?(method, priv = false)
end

def fetch_inventory_value(key)
@backend.host_inventory[key]
value = @backend.host_inventory[key]
if value.is_a?(Hash)
value = Hashie::Mash.new(value)
end

value
rescue NotImplementedError, NameError
nil
end
Expand Down
10 changes: 10 additions & 0 deletions spec/integration/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,13 @@
end
end
end

###

v1 = node.memory.total
v2 = node[:memory][:total]
v3 = node['memory']['total']

unless v1 == v2 && v2 == v3 && v1 =~ /\A\d+kB\z/
raise "failed to fetch host inventory value (#{v1}, #{v2}, #{v3})"
end

0 comments on commit c768fd3

Please sign in to comment.