-
Notifications
You must be signed in to change notification settings - Fork 42
Hash diff function broken #13
Comments
Can you give more information about your Chef version, etc? Are you using the hook LWRP? Works fine via irb, but I don't use that specific LWRP.
|
Also please pass along the full Chef error in a gist. |
My original comment is the wrong fix. I'm using Vagrant as my chef solo environment, which uses 1.8.7, which in turn doesn't allow this type of syntax. The code as it's written compiles and runs fine with 2.0.0-current and 1.9.3. I'm not sure on the correct syntax to make it work on 1.8.7. |
# Hash extension class
class Hash
# Returns a hash that represents the difference between two hashes.
#
# {1 => 2}.diff(1 => 2) # => {}
# {1 => 2}.diff(1 => 3) # => {1 => 2}
# {}.diff(1 => 2) # => {1 => 2}
# {1 => 2, 3 => 4}.diff(1 => 2) # => {3 => 4}
def diff(other)
d = dup.delete_if { |k, v| other[k] == v }
d.merge!(other.dup.delete_if { |k, v| key?(k) })
end
end |
https://gist.github.com/Prandium/7034389 gist of the bug. |
I'll patch in your fix. Thanks for the detective work. |
Released in 3.0.1 - can you confirm the fix? |
This should've been resolved in 3.0.1+ and hasn't been mentioned in 2+ weeks. Closing the issue. Let me know if its still a problem. |
chef-stash/libraries/helper.rb:107 is currently failing during run because it starts with a period. I think you meant to do 'self.merge!' instead of '.merge!'.
The text was updated successfully, but these errors were encountered: