dry-equalizer 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +24 -20
- data/CHANGELOG.md +8 -0
- data/CONTRIBUTING.md +29 -11
- data/Gemfile +9 -5
- data/README.md +12 -13
- data/dry-equalizer.gemspec +1 -3
- data/lib/dry/equalizer.rb +4 -6
- data/lib/dry/equalizer/version.rb +1 -3
- data/spec/spec_helper.rb +13 -12
- data/spec/support/config_alias.rb +0 -2
- data/spec/unit/equalizer/included_spec.rb +1 -3
- data/spec/unit/equalizer/methods/eql_predicate_spec.rb +1 -3
- data/spec/unit/equalizer/methods/equality_operator_spec.rb +1 -3
- data/spec/unit/equalizer/universal_spec.rb +41 -6
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3a819572ea7edadec962667cf45602118b745509ee33a86bbf440153340500f6
|
4
|
+
data.tar.gz: 725faa38c3a44a8ccb1a79e33e194f3aed15d2d08778167a90d144950d85718a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b7145d6579f21bbd00dee972501f4251c60dea36f7e4c22eb4ea20ec640fe4e115b1ffc5da597354be807f2d844030a6ffa64a8712a660a543cb470f5801ddb
|
7
|
+
data.tar.gz: 3d2bc74a8e66dee5e2873391a2a37a8768c063d5e36e17fca6dd5986129483ee7e2ba361335d4de65cd2c2b03070a8987e16eb6bae196dc89f9d5280f814c6ee
|
data/.travis.yml
CHANGED
@@ -1,23 +1,27 @@
|
|
1
1
|
language: ruby
|
2
|
-
bundler_args: --without yard guard benchmarks
|
3
|
-
script: "bundle exec rake spec"
|
4
2
|
cache: bundler
|
5
|
-
|
3
|
+
bundler_args: --without benchmarks tools
|
4
|
+
script:
|
5
|
+
- bundle exec rake
|
6
|
+
before_install:
|
7
|
+
- gem update --system
|
8
|
+
after_success:
|
9
|
+
- '[ -d coverage ] && bundle exec codeclimate-test-reporter'
|
6
10
|
rvm:
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
- 2.2.9
|
12
|
+
- 2.3.6
|
13
|
+
- 2.4.3
|
14
|
+
- 2.5.0
|
15
|
+
- jruby-9.1.15.0
|
16
|
+
env:
|
17
|
+
global:
|
18
|
+
- COVERAGE=true
|
19
|
+
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
20
|
+
notifications:
|
21
|
+
email: false
|
22
|
+
webhooks:
|
23
|
+
urls:
|
24
|
+
- https://webhooks.gitter.im/e/19098b4253a72c9796db
|
25
|
+
on_success: change # options: [always|never|change] default: always
|
26
|
+
on_failure: always # options: [always|never|change] default: always
|
27
|
+
on_start: false # default: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v0.2.1 2018-04-26
|
2
|
+
|
3
|
+
### Fixed
|
4
|
+
|
5
|
+
* Including equalizer module with same keys multiple times won't cause duped keys in `inspect` output (radar)
|
6
|
+
|
7
|
+
[Compare v0.2.0...v0.2.1](https://github.com/dry-rb/dry-equalizer/compare/v0.2.0...v0.2.1)
|
8
|
+
|
1
9
|
# v0.2.0 2015-11-13
|
2
10
|
|
3
11
|
Really make it work with MRI 2.0 again (it's Friday 13th OK?!)
|
data/CONTRIBUTING.md
CHANGED
@@ -1,11 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
# Issue Guidelines
|
2
|
+
|
3
|
+
## Reporting bugs
|
4
|
+
|
5
|
+
If you found a bug, report an issue and describe what's the expected behavior versus what actually happens. If the bug causes a crash, attach a full backtrace. If possible, a reproduction script showing the problem is highly appreciated.
|
6
|
+
|
7
|
+
## Reporting feature requests
|
8
|
+
|
9
|
+
Report a feature request **only after discussing it first on [discuss.dry-rb.org](https://discuss.dry-rb.org)** where it was accepted. Please provide a concise description of the feature, don't link to a discussion thread, and instead summarize what was discussed.
|
10
|
+
|
11
|
+
## Reporting questions, support requests, ideas, concerns etc.
|
12
|
+
|
13
|
+
**PLEASE DON'T** - use [discuss.dry-rb.org](http://discuss.dry-rb.org) instead.
|
14
|
+
|
15
|
+
# Pull Request Guidelines
|
16
|
+
|
17
|
+
A Pull Request will only be accepted if it addresses a specific issue that was reported previously, or fixes typos, mistakes in documentation etc.
|
18
|
+
|
19
|
+
Other requirements:
|
20
|
+
|
21
|
+
1) Do not open a pull request if you can't provide tests along with it. If you have problems writing tests, ask for help in the related issue.
|
22
|
+
2) Follow the style conventions of the surrounding code. In most cases, this is standard ruby style.
|
23
|
+
3) Add API documentation if it's a new feature
|
24
|
+
4) Update API documentation if it changes an existing feature
|
25
|
+
5) Bonus points for sending a PR to [github.com/dry-rb/dry-rb.org](github.com/dry-rb/dry-rb.org) which updates user documentation and guides
|
26
|
+
|
27
|
+
# Asking for help
|
28
|
+
|
29
|
+
If these guidelines aren't helpful, and you're stuck, please post a message on [discuss.dry-rb.org](https://discuss.dry-rb.org).
|
data/Gemfile
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
source 'https://rubygems.org'
|
4
2
|
|
3
|
+
gemspec
|
4
|
+
|
5
5
|
group :development, :test do
|
6
6
|
gem 'rake'
|
7
|
-
gem '
|
8
|
-
gem 'rspec', '~> 3.4'
|
7
|
+
gem 'rspec', '~> 3.5'
|
9
8
|
end
|
10
9
|
|
11
|
-
|
10
|
+
group :test do
|
11
|
+
platform :mri do
|
12
|
+
gem "codeclimate-test-reporter", require: false
|
13
|
+
gem 'simplecov', require: false
|
14
|
+
end
|
15
|
+
end
|
data/README.md
CHANGED
@@ -1,24 +1,23 @@
|
|
1
|
-
dry-equalizer
|
2
|
-
=========
|
1
|
+
# dry-equalizer <a href="https://gitter.im/dry-rb/chat" target="_blank">![Join the chat at https://gitter.im/dry-rb/chat](https://badges.gitter.im/Join%20Chat.svg)</a>
|
3
2
|
|
4
3
|
Module to define equality, equivalence and inspection methods
|
5
4
|
|
6
|
-
[![Gem Version](http://img.shields.io/gem/v/equalizer.svg)][gem]
|
7
|
-
[![Build Status](http://img.shields.io/travis/
|
8
|
-
[![
|
9
|
-
[![
|
5
|
+
[![Gem Version](http://img.shields.io/gem/v/dry-equalizer.svg)][gem]
|
6
|
+
[![Build Status](http://img.shields.io/travis/dry-rb/dry-equalizer.svg)][travis]
|
7
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/5a9a139af1d4a80a28c4/maintainability)](https://codeclimate.com/github/dry-rb/dry-equalizer/maintainability)
|
8
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/5a9a139af1d4a80a28c4/test_coverage)](https://codeclimate.com/github/dry-rb/dry-equalizer/test_coverage)
|
10
9
|
|
11
|
-
[gem]: https://rubygems.org/gems/equalizer
|
12
|
-
[travis]: https://travis-ci.org/
|
13
|
-
[gemnasium]: https://gemnasium.com/
|
14
|
-
[codeclimate]: https://codeclimate.com/github/
|
10
|
+
[gem]: https://rubygems.org/gems/dry-equalizer
|
11
|
+
[travis]: https://travis-ci.org/dry-rb/dry-equalizer
|
12
|
+
[gemnasium]: https://gemnasium.com/dry-rb/dry-equalizer
|
13
|
+
[codeclimate]: https://codeclimate.com/github/dry-rb/dry-equalizer
|
15
14
|
|
16
15
|
Examples
|
17
16
|
--------
|
18
17
|
|
19
18
|
``` ruby
|
20
19
|
class GeoLocation
|
21
|
-
include Equalizer
|
20
|
+
include Dry::Equalizer(:latitude, :longitude)
|
22
21
|
|
23
22
|
attr_reader :latitude, :longitude
|
24
23
|
|
@@ -50,8 +49,8 @@ Supported Ruby Versions
|
|
50
49
|
This library aims to support and is [tested against][travis] the following Ruby
|
51
50
|
implementations:
|
52
51
|
|
53
|
-
*
|
54
|
-
*
|
52
|
+
* MRI 2.2+
|
53
|
+
* JRuby 9.x
|
55
54
|
|
56
55
|
If something doesn't work on one of these versions, it's a bug.
|
57
56
|
|
data/dry-equalizer.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require File.expand_path('../lib/dry/equalizer/version', __FILE__)
|
4
2
|
|
5
3
|
Gem::Specification.new do |gem|
|
@@ -9,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
9
7
|
gem.email = %w[dan.kubb@gmail.com mbj@schirp-dso.com]
|
10
8
|
gem.description = 'Module to define equality, equivalence and inspection methods'
|
11
9
|
gem.summary = gem.description
|
12
|
-
gem.homepage = 'https://github.com/
|
10
|
+
gem.homepage = 'https://github.com/dryrb/dry-equalizer'
|
13
11
|
gem.licenses = 'MIT'
|
14
12
|
|
15
13
|
gem.require_paths = %w[lib]
|
data/lib/dry/equalizer.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
module Dry
|
4
2
|
# Build an equalizer module for the inclusion in other class
|
5
3
|
#
|
@@ -21,7 +19,7 @@ module Dry
|
|
21
19
|
#
|
22
20
|
# @api private
|
23
21
|
def initialize(*keys)
|
24
|
-
@keys = keys
|
22
|
+
@keys = keys.uniq
|
25
23
|
define_methods
|
26
24
|
freeze
|
27
25
|
end
|
@@ -88,8 +86,8 @@ module Dry
|
|
88
86
|
keys = @keys
|
89
87
|
define_method(:inspect) do | |
|
90
88
|
klass = self.class
|
91
|
-
|
92
|
-
|
89
|
+
name = klass.name || klass.inspect
|
90
|
+
"#<#{name}#{keys.map { |key| " #{key}=#{__send__(key).inspect}" }.join}>"
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
@@ -122,7 +120,7 @@ module Dry
|
|
122
120
|
#
|
123
121
|
# @api public
|
124
122
|
def ==(other)
|
125
|
-
other.
|
123
|
+
other.is_a?(self.class) && cmp?(__method__, other)
|
126
124
|
end
|
127
125
|
end # module Methods
|
128
126
|
end # class Equalizer
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
|
1
|
+
if RUBY_ENGINE == 'ruby' && ENV['COVERAGE'] == 'true'
|
2
|
+
require 'yaml'
|
3
|
+
rubies = YAML.load(File.read(File.join(__dir__, '..', '.travis.yml')))['rvm']
|
4
|
+
latest_mri = rubies.select { |v| v =~ /\A\d+\.\d+.\d+\z/ }.max
|
2
5
|
|
3
|
-
if
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
add_filter 'config'
|
10
|
-
add_filter 'spec'
|
11
|
-
add_filter 'vendor'
|
12
|
-
|
13
|
-
minimum_coverage 100
|
6
|
+
if RUBY_VERSION == latest_mri
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter '/spec/'
|
10
|
+
end
|
14
11
|
end
|
15
12
|
end
|
16
13
|
|
@@ -19,7 +16,11 @@ require 'dry-equalizer'
|
|
19
16
|
RSpec.configure do |config|
|
20
17
|
config.raise_errors_for_deprecations!
|
21
18
|
|
19
|
+
config.disable_monkey_patching!
|
20
|
+
|
22
21
|
config.expect_with :rspec do |expect_with|
|
23
22
|
expect_with.syntax = :expect
|
24
23
|
end
|
24
|
+
|
25
|
+
config.warnings = true
|
25
26
|
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'spec_helper'
|
4
2
|
|
5
|
-
describe Dry::Equalizer do
|
6
|
-
let(:object) { described_class }
|
3
|
+
RSpec.describe Dry::Equalizer do
|
7
4
|
let(:name) { 'User' }
|
8
5
|
let(:klass) { ::Class.new }
|
9
6
|
|
@@ -18,7 +15,7 @@ describe Dry::Equalizer do
|
|
18
15
|
|
19
16
|
let(:instance) { klass.new }
|
20
17
|
|
21
|
-
it { should be_instance_of(
|
18
|
+
it { should be_instance_of(described_class) }
|
22
19
|
|
23
20
|
it { should be_frozen }
|
24
21
|
|
@@ -98,7 +95,7 @@ describe Dry::Equalizer do
|
|
98
95
|
klass.send(:include, subject)
|
99
96
|
end
|
100
97
|
|
101
|
-
it { should be_instance_of(
|
98
|
+
it { should be_instance_of(described_class) }
|
102
99
|
|
103
100
|
it { should be_frozen }
|
104
101
|
|
@@ -155,4 +152,42 @@ describe Dry::Equalizer do
|
|
155
152
|
end
|
156
153
|
end
|
157
154
|
end
|
155
|
+
|
156
|
+
context 'with duplicate keys' do
|
157
|
+
subject { Dry::Equalizer(*keys) }
|
158
|
+
|
159
|
+
let(:keys) { %i[firstname firstname lastname].freeze }
|
160
|
+
let(:firstname) { 'John' }
|
161
|
+
let(:lastname) { 'Doe' }
|
162
|
+
let(:instance) { klass.new(firstname, lastname) }
|
163
|
+
|
164
|
+
let(:klass) do
|
165
|
+
::Class.new do
|
166
|
+
attr_reader :firstname, :lastname
|
167
|
+
private :firstname, :lastname
|
168
|
+
|
169
|
+
def initialize(firstname, lastname)
|
170
|
+
@firstname = firstname
|
171
|
+
@lastname = lastname
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
before do
|
177
|
+
# specify the class #inspect method
|
178
|
+
allow(klass).to receive_messages(name: nil, inspect: name)
|
179
|
+
klass.send(:include, subject)
|
180
|
+
end
|
181
|
+
|
182
|
+
it { should be_instance_of(described_class) }
|
183
|
+
|
184
|
+
it { should be_frozen }
|
185
|
+
|
186
|
+
describe '#inspect' do
|
187
|
+
it 'returns the expected string' do
|
188
|
+
expect(instance.inspect)
|
189
|
+
.to eql('#<User firstname="John" lastname="Doe">')
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
158
193
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-equalizer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -63,7 +63,7 @@ files:
|
|
63
63
|
- spec/unit/equalizer/methods/eql_predicate_spec.rb
|
64
64
|
- spec/unit/equalizer/methods/equality_operator_spec.rb
|
65
65
|
- spec/unit/equalizer/universal_spec.rb
|
66
|
-
homepage: https://github.com/
|
66
|
+
homepage: https://github.com/dryrb/dry-equalizer
|
67
67
|
licenses:
|
68
68
|
- MIT
|
69
69
|
metadata: {}
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.4
|
86
|
+
rubygems_version: 2.7.4
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Module to define equality, equivalence and inspection methods
|
@@ -92,4 +92,3 @@ test_files:
|
|
92
92
|
- spec/unit/equalizer/methods/eql_predicate_spec.rb
|
93
93
|
- spec/unit/equalizer/methods/equality_operator_spec.rb
|
94
94
|
- spec/unit/equalizer/universal_spec.rb
|
95
|
-
has_rdoc:
|