Hello community,
here is the log from the commit of package rubygem-hashdiff for
openSUSE:Factory checked in at 2020-05-11 13:41:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-hashdiff (Old)
and /work/SRC/openSUSE:Factory/.rubygem-hashdiff.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-hashdiff"
Mon May 11 13:41:13 2020 rev:10 rq:802338 version:1.0.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-hashdiff/rubygem-hashdiff.changes
2019-08-06 15:09:43.579795868 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-hashdiff.new.2738/rubygem-hashdiff.changes
2020-05-11 13:41:18.137112920 +0200
@@ -1,0 +2,10 @@
+Thu May 7 20:54:26 UTC 2020 - Stephan Kulow <[email protected]>
+
+- updated to version 1.0.1
+ see installed changelog.md
+
+ ## v1.0.1 2020-02-25
+
+ * Add indifferent option
+
+-------------------------------------------------------------------
Old:
----
hashdiff-1.0.0.gem
New:
----
hashdiff-1.0.1.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-hashdiff.spec ++++++
--- /var/tmp/diff_new_pack.AAhrJe/_old 2020-05-11 13:41:18.981114711 +0200
+++ /var/tmp/diff_new_pack.AAhrJe/_new 2020-05-11 13:41:18.981114711 +0200
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-hashdiff
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
#
Name: rubygem-hashdiff
-Version: 1.0.0
+Version: 1.0.1
Release: 0
%define mod_name hashdiff
%define mod_full_name %{mod_name}-%{version}
@@ -32,7 +32,7 @@
BuildRequires: %{ruby >= 2.0.0}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: ruby-macros >= 5
-Url: https://github.com/liufengyun/hashdiff
+URL: https://github.com/liufengyun/hashdiff
Source: https://rubygems.org/gems/%{mod_full_name}.gem
Source1: gem2rpm.yml
Summary: Hashdiff is a diff lib to compute the smallest difference
between
++++++ hashdiff-1.0.0.gem -> hashdiff-1.0.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/.rubocop.yml new/.rubocop.yml
--- old/.rubocop.yml 2019-07-15 07:51:54.000000000 +0200
+++ new/.rubocop.yml 2020-02-27 20:39:09.000000000 +0100
@@ -1,4 +1,6 @@
require: rubocop-rspec
+AllCops:
+ TargetRubyVersion: 2.0 # always the lowest version we support
Metrics/PerceivedComplexity:
Enabled: false
Metrics/CyclomaticComplexity:
@@ -26,3 +28,5 @@
Enabled: false
RSpec/ExampleLength:
Enabled: false
+RSpec/DescribeClass:
+ Enabled: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2019-07-15 07:51:54.000000000 +0200
+++ new/README.md 2020-02-27 20:39:09.000000000 +0100
@@ -32,7 +32,7 @@
To use the gem, add the following to your Gemfile:
-```ruby
+```Ruby
gem 'hashdiff'
```
@@ -95,8 +95,8 @@
### Options
There are eight options available: `:delimiter`, `:similarity`,
-`:strict`, `:numeric_tolerance`, `:strip`, `:case_insensitive`, `:array_path`
-and `:use_lcs`
+`:strict`, `:indifferent`, `:numeric_tolerance`, `:strip`, `:case_insensitive`,
+`:array_path` and `:use_lcs`
#### `:delimiter`
@@ -106,7 +106,7 @@
a = {a:{x:2, y:3, z:4}, b:{x:3, z:45}}
b = {a:{y:3}, b:{y:3, z:30}}
-diff = Hashdiff.diff(a, b, :delimiter => '\t')
+diff = Hashdiff.diff(a, b, delimiter: '\t')
diff.should == [['-', 'a\tx', 2], ['-', 'a\tz', 4], ['-', 'b\tx', 3], ['~',
'b\tz', 45, 30], ['+', 'b\ty', 3]]
```
@@ -118,6 +118,10 @@
The `:strict` option, which defaults to `true`, specifies whether numeric
types are compared on type as well as value. By default, an Integer will never
be equal to a Float (e.g. 4 != 4.0). Setting `:strict` to false makes the
comparison looser (e.g. 4 == 4.0).
+#### `:indifferent`
+
+The `:indifferent` option, which defaults to `false`, specifies whether to
treat hash keys indifferently. Setting `:indifferent` to true has the effect
of ignoring differences between symbol keys (ie. {a: 1} ~= {'a' => 1})
+
#### `:numeric_tolerance`
The :numeric_tolerance option allows for a small numeric tolerance.
@@ -126,7 +130,7 @@
a = {x:5, y:3.75, z:7}
b = {x:6, y:3.76, z:7}
-diff = Hashdiff.diff(a, b, :numeric_tolerance => 0.1)
+diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1)
diff.should == [["~", "x", 5, 6]]
```
@@ -138,7 +142,7 @@
a = {x:5, s:'foo '}
b = {x:6, s:'foo'}
-diff = Hashdiff.diff(a, b, :comparison => { :numeric_tolerance => 0.1, :strip
=> true })
+diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1, strip: true)
diff.should == [["~", "x", 5, 6]]
```
@@ -150,7 +154,7 @@
a = {x:5, s:'FooBar'}
b = {x:6, s:'foobar'}
-diff = Hashdiff.diff(a, b, :comparison => { :numeric_tolerance => 0.1,
:case_insensitive => true })
+diff = Hashdiff.diff(a, b, numeric_tolerance: 0.1, case_insensitive: true)
diff.should == [["~", "x", 5, 6]]
```
@@ -164,7 +168,7 @@
a = {x:5}
b = {'x'=>6}
-diff = Hashdiff.diff(a, b, :array_path => true)
+diff = Hashdiff.diff(a, b, array_path: true)
diff.should == [['-', [:x], 5], ['+', ['x'], 6]]
```
@@ -173,7 +177,7 @@
a = {x:[0,1]}
b = {x:[0,2]}
-diff = Hashdiff.diff(a, b, :array_path => true)
+diff = Hashdiff.diff(a, b, array_path: true)
diff.should == [["-", [:x, 1], 1], ["+", [:x, 1], 2]]
```
@@ -183,7 +187,7 @@
a = {x:{0=>1}}
b = {x:[1]}
-diff = Hashdiff.diff(a, b, :array_path => true)
+diff = Hashdiff.diff(a, b, array_path: true)
diff.should == [["~", [:x], {0=>1}, [1]]]
```
@@ -205,7 +209,7 @@
a = {x: [0, 1, 2]}
b = {x: [0, 2, 2, 3]}
-diff = Hashdiff.diff(a, b, :use_lcs => false)
+diff = Hashdiff.diff(a, b, use_lcs: false)
diff.should == [["~", "x[1]", 1, 2], ["+", "x[3]", 3]]
```
@@ -255,11 +259,11 @@
a = {a:'car', b:['boat', 'plane'] }
b = {a:'car', b:['plane', 'boat'] }
-Hashdiff.diff(a, b) => [["+", "b[0]", "plane"], ["-", "b[2]", "plane"]]
+Hashdiff.diff(a, b).should == [["+", "b[0]", "plane"], ["-", "b[2]", "plane"]]
b[:b].sort!
-Hashdiff.diff(a, b) => []
+Hashdiff.diff(a, b).should == []
```
## Maintainers
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/changelog.md new/changelog.md
--- old/changelog.md 2019-07-15 07:51:54.000000000 +0200
+++ new/changelog.md 2020-02-27 20:39:09.000000000 +0100
@@ -1,5 +1,9 @@
# Change Log
+## v1.0.1 2020-02-25
+
+* Add indifferent option
+
## v1.0.0 2019-06-06
* Fix typo in readme (#72 @koic)
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/hashdiff.gemspec new/hashdiff.gemspec
--- old/hashdiff.gemspec 2019-07-15 07:51:54.000000000 +0200
+++ new/hashdiff.gemspec 2020-02-27 20:39:09.000000000 +0100
@@ -23,7 +23,7 @@
s.add_development_dependency('bluecloth')
s.add_development_dependency('rspec', '~> 2.0')
- s.add_development_dependency('rubocop')
+ s.add_development_dependency('rubocop', '~> 0.49.1') # last version that
works with ruby 2.0
s.add_development_dependency('rubocop-rspec')
s.add_development_dependency('yard')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/hashdiff/compare_hashes.rb
new/lib/hashdiff/compare_hashes.rb
--- old/lib/hashdiff/compare_hashes.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/lib/hashdiff/compare_hashes.rb 2020-02-27 20:39:09.000000000 +0100
@@ -10,6 +10,15 @@
obj1_keys = obj1.keys
obj2_keys = obj2.keys
+ obj1_lookup = {}
+ obj2_lookup = {}
+
+ if opts[:indifferent]
+ obj1_lookup = obj1_keys.each_with_object({}) { |k, h| h[k.to_s] = k }
+ obj2_lookup = obj2_keys.each_with_object({}) { |k, h| h[k.to_s] = k }
+ obj1_keys = obj1_keys.map { |k| k.is_a?(Symbol) ? k.to_s : k }
+ obj2_keys = obj2_keys.map { |k| k.is_a?(Symbol) ? k.to_s : k }
+ end
added_keys = (obj2_keys - obj1_keys).sort_by(&:to_s)
common_keys = (obj1_keys & obj2_keys).sort_by(&:to_s)
@@ -19,6 +28,7 @@
# add deleted properties
deleted_keys.each do |k|
+ k = opts[:indifferent] ? obj1_lookup[k] : k
change_key = Hashdiff.prefix_append_key(opts[:prefix], k, opts)
custom_result = Hashdiff.custom_compare(opts[:comparison],
change_key, obj1[k], nil)
@@ -33,13 +43,16 @@
common_keys.each do |k|
prefix = Hashdiff.prefix_append_key(opts[:prefix], k, opts)
- result.concat(Hashdiff.diff(obj1[k], obj2[k], opts.merge(prefix:
prefix)))
+ k1 = opts[:indifferent] ? obj1_lookup[k] : k
+ k2 = opts[:indifferent] ? obj2_lookup[k] : k
+ result.concat(Hashdiff.diff(obj1[k1], obj2[k2], opts.merge(prefix:
prefix)))
end
# added properties
added_keys.each do |k|
change_key = Hashdiff.prefix_append_key(opts[:prefix], k, opts)
+ k = opts[:indifferent] ? obj2_lookup[k] : k
custom_result = Hashdiff.custom_compare(opts[:comparison],
change_key, nil, obj2[k])
if custom_result
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/hashdiff/diff.rb new/lib/hashdiff/diff.rb
--- old/lib/hashdiff/diff.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/lib/hashdiff/diff.rb 2020-02-27 20:39:09.000000000 +0100
@@ -9,6 +9,7 @@
# @param [Array, Hash] obj2
# @param [Hash] options the options to use when comparing
# * :strict (Boolean) [true] whether numeric values will be compared on
type as well as value. Set to false to allow comparing Integer, Float,
BigDecimal to each other
+ # * :indifferent (Boolean) [false] whether to treat hash keys
indifferently. Set to true to ignore differences between symbol keys (ie. {a:
1} ~= {'a' => 1})
# * :delimiter (String) ['.'] the delimiter used when returning nested key
references
# * :numeric_tolerance (Numeric) [0] should be a positive numeric value.
Value by which numeric differences must be greater than. By default, numeric
values are compared exactly; with the :tolerance option, the difference between
numeric values must be greater than the given value.
# * :strip (Boolean) [false] whether or not to call #strip on strings
before comparing
@@ -52,6 +53,7 @@
# @param [Array, Hash] obj2
# @param [Hash] options the options to use when comparing
# * :strict (Boolean) [true] whether numeric values will be compared on
type as well as value. Set to false to allow comparing Integer, Float,
BigDecimal to each other
+ # * :indifferent (Boolean) [false] whether to treat hash keys
indifferently. Set to true to ignore differences between symbol keys (ie. {a:
1} ~= {'a' => 1})
# * :similarity (Numeric) [0.8] should be between (0, 1]. Meaningful if
there are similar hashes in arrays. See {best_diff}.
# * :delimiter (String) ['.'] the delimiter used when returning nested key
references
# * :numeric_tolerance (Numeric) [0] should be a positive numeric value.
Value by which numeric differences must be greater than. By default, numeric
values are compared exactly; with the :tolerance option, the difference between
numeric values must be greater than the given value.
@@ -79,6 +81,7 @@
similarity: 0.8,
delimiter: '.',
strict: true,
+ indifferent: false,
strip: false,
numeric_tolerance: 0,
array_path: false,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/hashdiff/util.rb new/lib/hashdiff/util.rb
--- old/lib/hashdiff/util.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/lib/hashdiff/util.rb 2020-02-27 20:39:09.000000000 +0100
@@ -16,7 +16,7 @@
diffs = count_diff diff(obja, objb, opts)
- (1 - diffs.to_f / (count_a + count_b).to_f) >= opts[:similarity]
+ (1 - diffs / (count_a + count_b).to_f) >= opts[:similarity]
end
# @private
@@ -107,6 +107,7 @@
# check if objects are comparable
def self.comparable?(obj1, obj2, strict = true)
return true if (obj1.is_a?(Array) || obj1.is_a?(Hash)) &&
obj2.is_a?(obj1.class)
+ return true if (obj2.is_a?(Array) || obj2.is_a?(Hash)) &&
obj1.is_a?(obj2.class)
return true if !strict && obj1.is_a?(Numeric) && obj2.is_a?(Numeric)
obj1.is_a?(obj2.class) && obj2.is_a?(obj1.class)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/hashdiff/version.rb new/lib/hashdiff/version.rb
--- old/lib/hashdiff/version.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/lib/hashdiff/version.rb 2020-02-27 20:39:09.000000000 +0100
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module Hashdiff
- VERSION = '1.0.0'.freeze
+ VERSION = '1.0.1'.freeze
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2019-07-15 07:51:54.000000000 +0200
+++ new/metadata 2020-02-27 20:39:09.000000000 +0100
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: hashdiff
version: !ruby/object:Gem::Version
- version: 1.0.0
+ version: 1.0.1
platform: ruby
authors:
- Liu Fengyun
autorequire:
bindir: bin
cert_chain: []
-date: 2019-07-15 00:00:00.000000000 Z
+date: 2020-02-27 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: bluecloth
@@ -42,16 +42,16 @@
name: rubocop
requirement: !ruby/object:Gem::Requirement
requirements:
- - - ">="
+ - - "~>"
- !ruby/object:Gem::Version
- version: '0'
+ version: 0.49.1
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - - ">="
+ - - "~>"
- !ruby/object:Gem::Version
- version: '0'
+ version: 0.49.1
- !ruby/object:Gem::Dependency
name: rubocop-rspec
requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,7 @@
- spec/hashdiff/lcs_spec.rb
- spec/hashdiff/linear_compare_array_spec.rb
- spec/hashdiff/patch_spec.rb
+- spec/hashdiff/readme_spec.rb
- spec/hashdiff/util_spec.rb
- spec/spec_helper.rb
homepage: https://github.com/liufengyun/hashdiff
@@ -140,8 +141,7 @@
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubyforge_project:
-rubygems_version: 2.5.2.3
+rubygems_version: 3.0.6
signing_key:
specification_version: 4
summary: Hashdiff is a diff lib to compute the smallest difference between two
hashes.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/hashdiff/diff_spec.rb
new/spec/hashdiff/diff_spec.rb
--- old/spec/hashdiff/diff_spec.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/spec/hashdiff/diff_spec.rb 2020-02-27 20:39:09.000000000 +0100
@@ -49,6 +49,11 @@
diff.should == []
end
+ it 'ignores string vs symbol differences, when indifferent is true' do
+ diff = described_class.diff({ 'a' => 2, :b => 2 }, { :a => 2, 'b' => 2, :c
=> 3 }, indifferent: true)
+ diff.should == [['+', 'c', 3]]
+ end
+
it 'is able to diff changes in hash value' do
diff = described_class.diff({ 'a' => 2, 'b' => 3, 'c' => ' hello' }, 'a'
=> 2, 'b' => 4, 'c' => 'hello')
diff.should == [['~', 'b', 3, 4], ['~', 'c', ' hello', 'hello']]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/hashdiff/readme_spec.rb
new/spec/hashdiff/readme_spec.rb
--- old/spec/hashdiff/readme_spec.rb 1970-01-01 01:00:00.000000000 +0100
+++ new/spec/hashdiff/readme_spec.rb 2020-02-27 20:39:09.000000000 +0100
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'README.md' do
+ it 'has correct examples' do
+ File.read('README.md').scan(/```ruby(.*?)```/m).flatten(1).each do |block|
+ begin
+ eval block # rubocop:disable Security/Eval
+ rescue Exception => e # rubocop:disable Lint/RescueException
+ raise "README.md code block:\n#{block}\n\nhas error:\n#{e}"
+ end
+ end
+ end
+end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/spec/hashdiff/util_spec.rb
new/spec/hashdiff/util_spec.rb
--- old/spec/hashdiff/util_spec.rb 2019-07-15 07:51:54.000000000 +0200
+++ new/spec/hashdiff/util_spec.rb 2020-02-27 20:39:09.000000000 +0100
@@ -68,6 +68,7 @@
it 'compares different objects without tolerance' do
expect(described_class.compare_values('hats', 'ninjas')).to be false
end
+
it 'compares other objects with tolerance' do
expect(described_class.compare_values('hats', 'ninjas',
numeric_tolerance: 0.01)).to be false
end
@@ -92,4 +93,24 @@
expect(described_class.compare_values('horse', 'Horse',
case_insensitive: true)).to be true
end
end
+
+ describe '.comparable?' do
+ it 'identifies hashes as comparable' do
+ expect(described_class.comparable?({}, {})).to be true
+ end
+
+ it 'identifies a subclass of Hash to be comparable with a Hash' do
+ other = Class.new(Hash)
+ expect(described_class.comparable?(other.new, {})).to be true
+ end
+
+ it 'identifies a Hash to be comparable with a subclass of Hash' do
+ other = Class.new(Hash)
+ expect(described_class.comparable?({}, other.new)).to be true
+ end
+
+ it 'does not identify a Numeric as comparable with a Hash' do
+ expect(described_class.comparable?(1, {})).to be false
+ end
+ end
end