easy_diff 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
- gem "rspec", "~> 2.3.0"
9
+ gem "rspec", "~> 2.4.0"
10
10
  gem "yard", "~> 0.6.0"
11
11
  gem "bundler", "~> 1.0.0"
12
12
  gem "jeweler", "~> 1.5.2"
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.2)
4
+ diff-lcs (1.1.3)
5
5
  git (1.2.5)
6
6
  jeweler (1.5.2)
7
7
  bundler (~> 1.0.0)
@@ -9,14 +9,14 @@ GEM
9
9
  rake
10
10
  rake (0.8.7)
11
11
  rcov (0.9.9)
12
- rspec (2.3.0)
13
- rspec-core (~> 2.3.0)
14
- rspec-expectations (~> 2.3.0)
15
- rspec-mocks (~> 2.3.0)
16
- rspec-core (2.3.1)
17
- rspec-expectations (2.3.0)
12
+ rspec (2.4.0)
13
+ rspec-core (~> 2.4.0)
14
+ rspec-expectations (~> 2.4.0)
15
+ rspec-mocks (~> 2.4.0)
16
+ rspec-core (2.4.0)
17
+ rspec-expectations (2.4.0)
18
18
  diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.3.0)
19
+ rspec-mocks (2.4.0)
20
20
  yard (0.6.4)
21
21
 
22
22
  PLATFORMS
@@ -26,5 +26,5 @@ DEPENDENCIES
26
26
  bundler (~> 1.0.0)
27
27
  jeweler (~> 1.5.2)
28
28
  rcov
29
- rspec (~> 2.3.0)
29
+ rspec (~> 2.4.0)
30
30
  yard (~> 0.6.0)
@@ -119,6 +119,26 @@ Using Hash#easy_unmerge! will modify self instead of returning a new hash.
119
119
  # :some_str => "bla"
120
120
  # }
121
121
 
122
+ === Hash#easy_clone
123
+
124
+ Performs a deep clone on a hash
125
+
126
+ original = {
127
+ :tags => ['b', 'c', 'd'],
128
+ :pos => {:x => '3', :y => '2'}
129
+ }
130
+
131
+ new = original.easy_clone
132
+
133
+ new[:tags] << 'e'
134
+ new[:pos][:y] = '1'
135
+
136
+ # The original hash will still look like this:
137
+ # original = {
138
+ # :tags => ['b', 'c', 'd'],
139
+ # :pos => {:x => '3', :y => '2'}
140
+ # }
141
+
122
142
  == Contributing to easy_diff
123
143
 
124
144
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,70 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "easy_diff"
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Abner Qian"]
12
+ s.date = "2012-02-13"
13
+ s.description = "Easy Diff enhances the functionality of Hash, allowing recursive diff, merge, and unmerge of arbitrarily constructed hashes.\n This is perfect for people who need to do diffs on not only plain text files but also data as Hash or JSON objects. Unmerge\n is included with diff and merge to more easily allow versioning of arbitrary data."
14
+ s.email = "LargeBagel@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "easy_diff.gemspec",
29
+ "lib/easy_diff.rb",
30
+ "lib/easy_diff/core.rb",
31
+ "lib/easy_diff/hash_ext.rb",
32
+ "lib/easy_diff/safe_dup.rb",
33
+ "spec/easy_diff_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = "http://github.com/Blargel/easy_diff"
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "1.8.12"
40
+ s.summary = "Recursive diff, merge, and unmerge for hashes and arrays."
41
+ s.test_files = [
42
+ "spec/easy_diff_spec.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_development_dependency(%q<rspec>, ["~> 2.4.0"])
51
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
52
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
54
+ s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<rspec>, ["~> 2.4.0"])
57
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
58
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
60
+ s.add_dependency(%q<rcov>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<rspec>, ["~> 2.4.0"])
64
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ end
69
+ end
70
+
@@ -62,5 +62,9 @@ module EasyDiff
62
62
  end
63
63
  original
64
64
  end
65
+
66
+ def self.easy_clone(original)
67
+ Marshal::load(Marshal.dump(original))
68
+ end
65
69
  end
66
70
  end
@@ -13,11 +13,15 @@ module EasyDiff
13
13
  end
14
14
 
15
15
  def easy_merge(other)
16
- self.dup.easy_merge!(other)
16
+ self.easy_clone.easy_merge!(other)
17
17
  end
18
18
 
19
19
  def easy_unmerge(other)
20
- self.dup.easy_unmerge!(other)
20
+ self.easy_clone.easy_unmerge!(other)
21
+ end
22
+
23
+ def easy_clone
24
+ EasyDiff::Core.easy_clone self
21
25
  end
22
26
  end
23
27
  end
@@ -62,6 +62,14 @@ describe EasyDiff do
62
62
  :extra_removed => "bye",
63
63
  :extra_added => "hi"
64
64
  }
65
+ @original.should == {
66
+ :tags => ['a', 'b', 'c'],
67
+ :pos => {:x => '1', :y => '2'},
68
+ :some_str => "bla",
69
+ :some_int => 1,
70
+ :some_bool => false,
71
+ :extra_removed => "bye"
72
+ }
65
73
  end
66
74
 
67
75
  it "should stay the same" do
@@ -70,4 +78,27 @@ describe EasyDiff do
70
78
  original = unmerged.easy_merge removed
71
79
  original.should == @original
72
80
  end
81
+
82
+ it "should do a deep clone" do
83
+ cloned = @original.easy_clone
84
+ cloned.should == @original
85
+ cloned[:tags] << 'd'
86
+ cloned[:pos][:x] = '2'
87
+ cloned.should == {
88
+ :tags => ['a', 'b', 'c', 'd'],
89
+ :pos => {:x => '2', :y => '2'},
90
+ :some_str => "bla",
91
+ :some_int => 1,
92
+ :some_bool => false,
93
+ :extra_removed => "bye"
94
+ }
95
+ @original.should == {
96
+ :tags => ['a', 'b', 'c'],
97
+ :pos => {:x => '1', :y => '2'},
98
+ :some_str => "bla",
99
+ :some_int => 1,
100
+ :some_bool => false,
101
+ :extra_removed => "bye"
102
+ }
103
+ end
73
104
  end
metadata CHANGED
@@ -1,86 +1,83 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: easy_diff
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Abner Qian
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-03-03 00:00:00 -08:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: rspec
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2151858500 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
23
- version: 2.3.0
20
+ - !ruby/object:Gem::Version
21
+ version: 2.4.0
24
22
  type: :development
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2151858500
25
+ - !ruby/object:Gem::Dependency
28
26
  name: yard
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2151856820 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
29
+ requirements:
32
30
  - - ~>
33
- - !ruby/object:Gem::Version
31
+ - !ruby/object:Gem::Version
34
32
  version: 0.6.0
35
33
  type: :development
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2151856820
36
+ - !ruby/object:Gem::Dependency
39
37
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &2151855560 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
40
+ requirements:
43
41
  - - ~>
44
- - !ruby/object:Gem::Version
42
+ - !ruby/object:Gem::Version
45
43
  version: 1.0.0
46
44
  type: :development
47
45
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2151855560
47
+ - !ruby/object:Gem::Dependency
50
48
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &2151854440 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
51
+ requirements:
54
52
  - - ~>
55
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
56
54
  version: 1.5.2
57
55
  type: :development
58
56
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2151854440
58
+ - !ruby/object:Gem::Dependency
61
59
  name: rcov
62
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &2151853080 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
68
66
  type: :development
69
67
  prerelease: false
70
- version_requirements: *id005
71
- description: |-
72
- Easy Diff enhances the functionality of Hash, allowing recursive diff, merge, and unmerge of arbitrarily constructed hashes.
73
- This is perfect for people who need to do diffs on not only plain text files but also data as Hash or JSON objects. Unmerge
74
- is included with diff and merge to more easily allow versioning of arbitrary data.
68
+ version_requirements: *2151853080
69
+ description: ! "Easy Diff enhances the functionality of Hash, allowing recursive diff,
70
+ merge, and unmerge of arbitrarily constructed hashes.\n This is perfect for people
71
+ who need to do diffs on not only plain text files but also data as Hash or JSON
72
+ objects. Unmerge\n is included with diff and merge to more easily allow versioning
73
+ of arbitrary data."
75
74
  email: LargeBagel@gmail.com
76
75
  executables: []
77
-
78
76
  extensions: []
79
-
80
- extra_rdoc_files:
77
+ extra_rdoc_files:
81
78
  - LICENSE.txt
82
79
  - README.rdoc
83
- files:
80
+ files:
84
81
  - .document
85
82
  - .rspec
86
83
  - Gemfile
@@ -89,43 +86,41 @@ files:
89
86
  - README.rdoc
90
87
  - Rakefile
91
88
  - VERSION
89
+ - easy_diff.gemspec
92
90
  - lib/easy_diff.rb
93
91
  - lib/easy_diff/core.rb
94
92
  - lib/easy_diff/hash_ext.rb
95
93
  - lib/easy_diff/safe_dup.rb
96
94
  - spec/easy_diff_spec.rb
97
95
  - spec/spec_helper.rb
98
- has_rdoc: true
99
96
  homepage: http://github.com/Blargel/easy_diff
100
- licenses:
97
+ licenses:
101
98
  - MIT
102
99
  post_install_message:
103
100
  rdoc_options: []
104
-
105
- require_paths:
101
+ require_paths:
106
102
  - lib
107
- required_ruby_version: !ruby/object:Gem::Requirement
103
+ required_ruby_version: !ruby/object:Gem::Requirement
108
104
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- hash: 744956757776922527
113
- segments:
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ segments:
114
110
  - 0
115
- version: "0"
116
- required_rubygems_version: !ruby/object:Gem::Requirement
111
+ hash: -1601548536444288509
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
113
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
122
118
  requirements: []
123
-
124
119
  rubyforge_project:
125
- rubygems_version: 1.5.2
120
+ rubygems_version: 1.8.12
126
121
  signing_key:
127
122
  specification_version: 3
128
123
  summary: Recursive diff, merge, and unmerge for hashes and arrays.
129
- test_files:
124
+ test_files:
130
125
  - spec/easy_diff_spec.rb
131
126
  - spec/spec_helper.rb