README.rdoc in easy_diff-0.0.3 vs README.rdoc in easy_diff-0.0.4
- old
+ new
@@ -5,11 +5,11 @@
is included with diff and merge to more easily allow versioning of arbitrary data.
== Install
gem install easy_diff
-
+
== Examples
=== Hash#easy_diff
Takes another hash and recursively determines the differences between the two. This method returns two hashes.
@@ -21,39 +21,39 @@
:some_str => "bla",
:some_int => 1,
:some_bool => false,
:extra_removed => "bye"
}
-
+
modified = {
:tags => ['b', 'c', 'd'],
:pos => {:x => '3', :y => '2'},
:some_str => "bla",
:some_int => 2,
:some_bool => true,
:extra_added => "hi"
}
-
+
removed, added = original.easy_diff modified
-
+
# The removed and added hashes should contain the following:
# removed = {
# :tags => ['a'],
# :pos => {:x => '1'},
# :some_int => 1,
# :some_bool => false,
# :extra_removed => "bye"
# }
- #
+ #
# added = {
# :tags => ['d'],
# :pos => {:x => '3'},
# :some_int => 2,
# :some_bool => true,
# :extra_added => "hi"
# }
-
+
=== Hash#easy_merge
Takes a hash and recursively merges it with self. Arrays are merged by the union operation and then sorted.
Using Hash#easy_merge! will modify self instead of returning a new hash.
@@ -63,19 +63,19 @@
:some_str => "bla",
:some_int => 1,
:some_bool => false,
:extra_removed => "bye"
}
-
+
extra = {
:tags => ['d'],
:pos => {:x => '3'},
:some_int => 2,
:some_bool => true,
:extra_added => "hi"
}
-
+
merged = original.easy_merge extra
# The merged hash should look like this:
# merged = {
# :tags => ['a', 'b', 'c', 'd'],
@@ -84,11 +84,11 @@
# :some_int => 2,
# :some_bool => true,
# :extra_removed => "bye",
# :extra_added => "hi"
# }
-
+
=== Hash#easy_unmerge
Takes a hash and recursively unmerges it with self. By unmerging, I mean it will remove all matching values from
the hash. All matching elements will be removed in arrays as well and then the arrays will be sorted.
Using Hash#easy_unmerge! will modify self instead of returning a new hash.
@@ -99,49 +99,49 @@
:some_str => "bla",
:some_int => 2,
:some_bool => true,
:extra_added => "hi"
}
-
+
extra = {
:tags => ['d'],
:pos => {:x => '3'},
:some_int => 2,
:some_bool => true,
:extra_added => "hi"
}
-
+
unmerged = original.easy_unmerge extra
# The unmerged hash should look like this:
# unmerged = {
# :tags => ['b', 'c'],
# :pos => {:y => '2'},
# :some_str => "bla"
# }
-
+
=== Hash#easy_clone
Performs a deep clone on a hash
original = {
:tags => ['b', 'c', 'd'],
:pos => {:x => '3', :y => '2'}
}
-
+
new = original.easy_clone
-
+
new[:tags] << 'e'
new[:pos][:y] = '1'
-
+
# The original hash will still look like this:
# original = {
# :tags => ['b', 'c', 'd'],
# :pos => {:x => '3', :y => '2'}
# }
== Contributing to easy_diff
-
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
* Fork the project
* Start a feature/bugfix branch
* Commit and push until you are happy with your contribution