hash_diff 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTE5YWFkZDliYzM3NGNkZTk4ZDk1Y2E3YzI0OGI3MGNmMmFmM2U4OA==
4
+ NmI4YmU1N2U2YWY3MjI1YTA5M2NiMDExZjViNDk3YjE5ZTE1YTVmYg==
5
5
  data.tar.gz: !binary |-
6
- MDdhMjNjMGIxMTI5ODdlYjQ0NDliY2I3NGViZGNkY2Q2ZDEyODQ2NQ==
6
+ ZmIxMzIyODkzMzBjOTg5ODRkMmQ0MTRhMTNhMzAwMDAzMGM1MmIxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODFlOWRmOGM4Zjc1YWYzZjgxZWM4MTRmZTMzZjY2YmRjNjJkZjI5NmNmMjVl
10
- ZGE4Y2ZjYWRmNjM4YWJkNDIzY2Y2NjUxMGYyOGQ0M2Y0MzAyN2RjYTU0YmNh
11
- YjY4YzQ1MDczNGNlOWQ0NmZkZjJkZjJkMDQ1ODFiOTY1NTYxMDU=
9
+ M2UxM2M2NmYzOTVhYTAwNzg2NWJlY2RmMDQyNjc0YzgzNDA1NDA1M2YyZGYz
10
+ ZmMzNTAzY2UxMGU0MDI3MWFiYWI4NTBjNDQ4OTAxNjgxYTZlZGUzMjE4YmM3
11
+ ZjA0OTc3ZGVjZjk2ZTJlZDBkYzU1ZDYzNDY4OThlZmZhN2MxYTU=
12
12
  data.tar.gz: !binary |-
13
- ZWMyZGY4ZTQ4ZDFmZDNkOGM3Y2FmMzYzODBhNjhiY2E5MGY0ZDY5NTdlY2E0
14
- NGUyZmExMWQzZDkxMWQwNjNiODBhNTFkZjhkNGQxZWI5ZTVmM2ZiZmJhYTMw
15
- M2Q5OWRhMjkxN2M5NzA3YTlhMGNmMDZkYjU3YjA3YzIyZGQwYzI=
13
+ NjI4OTQ3MzViNjZiYzE0MjNlYzQwNjM4YTBmNjM0NTRjMDI4YWU5YzU0MTky
14
+ MjBiMzA5M2NmOTRhYjU5ZDg2ZGE5ZGEyNWQyOWQ1MWM2NTdlYjJhYWMyZDBk
15
+ MTVlZWQ3YzJjNDAyZmE2MmRiZDBjOWQxMDVmMWNmYmJlNTZmODk=
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in hash_diff.gemspec
4
- gemspec
5
-
6
- gem 'debugger'
4
+ gemspec
data/README.md CHANGED
@@ -66,6 +66,29 @@ Comparison#right_diff returns only the right side differences
66
66
  hash_diff.right_diff # => { foo: "bar", bar: "foo", nested: { foo: "bar", bar: { one: "foo1", two: nil } }, num: 1, word: nil }
67
67
  ```
68
68
 
69
+ You can also use these shorthand methods
70
+
71
+ ```ruby
72
+ HashDiff.diff(left, right)
73
+ HashDiff.left_diff(left, right)
74
+ HashDiff.right_diff(left, right)
75
+ ```
76
+
77
+ Hash#diff is not provided by default, and monkey patching is frowned upon by some, but to provide a one way shorthand, use the following code snippet.
78
+
79
+ ```ruby
80
+ class Hash
81
+ def diff(right)
82
+ HashDiff.right_diff(self, right)
83
+ end
84
+ end
85
+
86
+ left = { foo: 'bar', num: 1 }
87
+ right = { foo: 'baz', num: 1 }
88
+
89
+ left.diff(right) # => { foo: 'baz' }
90
+ ```
91
+
69
92
  ## Contributing
70
93
 
71
94
  1. Fork it
data/hash_diff.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Coding Zeal", "Adam Cuppy"]
10
10
  spec.email = ["info@codingzeal.com"]
11
11
  spec.description = %q{Diff tool for deep Ruby hash comparison}
12
- spec.summary = %q{Deep Hash comparison}
12
+ spec.summary = %q{Deep Ruby Hash comparison}
13
13
  spec.homepage = "https://github.com/CodingZeal/hash_diff"
14
14
  spec.license = "MIT"
15
15
 
data/lib/hash_diff.rb CHANGED
@@ -1,2 +1,18 @@
1
1
  require "hash_diff/version"
2
- require "hash_diff/comparison"
2
+ require "hash_diff/comparison"
3
+
4
+ module HashDiff
5
+ class << self
6
+ def diff(*args)
7
+ Comparison.new(*args).diff
8
+ end
9
+
10
+ def left_diff(*args)
11
+ Comparison.new(*args).left_diff
12
+ end
13
+
14
+ def right_diff(*args)
15
+ Comparison.new(*args).right_diff
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module HashDiff
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -0,0 +1,39 @@
1
+ require "spec_helper"
2
+
3
+ describe HashDiff do
4
+ describe ".diff" do
5
+ let(:comparison) { double("comparison") }
6
+ let(:left) { double("left") }
7
+ let(:right) { double("right") }
8
+
9
+ it "delegates to Comparison#diff" do
10
+ HashDiff::Comparison.should_receive(:new).with(left, right).and_return(comparison)
11
+ comparison.should_receive(:diff)
12
+ HashDiff.diff(left, right)
13
+ end
14
+ end
15
+
16
+ describe ".left_diff" do
17
+ let(:comparison) { double("comparison") }
18
+ let(:left) { double("left") }
19
+ let(:right) { double("right") }
20
+
21
+ it "delegates to Comparison#left_diff" do
22
+ HashDiff::Comparison.should_receive(:new).with(left, right).and_return(comparison)
23
+ comparison.should_receive(:left_diff)
24
+ HashDiff.left_diff(left, right)
25
+ end
26
+ end
27
+
28
+ describe ".right_diff" do
29
+ let(:comparison) { double("comparison") }
30
+ let(:left) { double("left") }
31
+ let(:right) { double("right") }
32
+
33
+ it "delegates to Comparison#right_diff" do
34
+ HashDiff::Comparison.should_receive(:new).with(left, right).and_return(comparison)
35
+ comparison.should_receive(:right_diff)
36
+ HashDiff.right_diff(left, right)
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Coding Zeal
@@ -70,6 +70,7 @@ files:
70
70
  - lib/hash_diff/comparison.rb
71
71
  - lib/hash_diff/version.rb
72
72
  - spec/hash_diff/comparison_spec.rb
73
+ - spec/hash_diff_spec.rb
73
74
  - spec/spec_helper.rb
74
75
  homepage: https://github.com/CodingZeal/hash_diff
75
76
  licenses:
@@ -94,7 +95,8 @@ rubyforge_project:
94
95
  rubygems_version: 2.1.11
95
96
  signing_key:
96
97
  specification_version: 4
97
- summary: Deep Hash comparison
98
+ summary: Deep Ruby Hash comparison
98
99
  test_files:
99
100
  - spec/hash_diff/comparison_spec.rb
101
+ - spec/hash_diff_spec.rb
100
102
  - spec/spec_helper.rb