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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1280055a0b7064bb007c07dc9633688d1c5ddb0e
4
- data.tar.gz: 1eb6898c8bf1f15c2783450098ca688902efd9ed
2
+ SHA256:
3
+ metadata.gz: 3a819572ea7edadec962667cf45602118b745509ee33a86bbf440153340500f6
4
+ data.tar.gz: 725faa38c3a44a8ccb1a79e33e194f3aed15d2d08778167a90d144950d85718a
5
5
  SHA512:
6
- metadata.gz: 1996023f8b02db4e528061e1b4041fdd93bfc0248a0e8fd96d4d2239a234ac3359b32c727c81e58ace335eb8fc8797e49079e8041ce814b72cac105a094c5d17
7
- data.tar.gz: a1ca9a8c7d27b5feda84484ef4c98927feb48bd8e4cc6126ee232a62e0c92f1f60aa59a7eb16f9b359faf6c1b6f2d3e161249ce97b46c7a49bd60495e8162715
6
+ metadata.gz: 6b7145d6579f21bbd00dee972501f4251c60dea36f7e4c22eb4ea20ec640fe4e115b1ffc5da597354be807f2d844030a6ffa64a8712a660a543cb470f5801ddb
7
+ data.tar.gz: 3d2bc74a8e66dee5e2873391a2a37a8768c063d5e36e17fca6dd5986129483ee7e2ba361335d4de65cd2c2b03070a8987e16eb6bae196dc89f9d5280f814c6ee
@@ -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
- sudo: false
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.0
8
- - 2.1
9
- - 2.2
10
- - ruby-head
11
- - rbx-2
12
- matrix:
13
- include:
14
- - rvm: jruby-9000
15
- env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0" # for simplecov
16
- - rvm: jruby-head
17
- env: JRUBY_OPTS="$JRUBY_OPTS --debug --2.0" # for simplecov
18
- allow_failures:
19
- - rvm: jruby-9000
20
- - rvm: jruby-head
21
- - rvm: rbx-2
22
- - rvm: ruby-head
23
- fast_finish: true
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
@@ -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?!)
@@ -1,11 +1,29 @@
1
- Contributing
2
- ------------
3
-
4
- * If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it. This library is still in early development, and the direction it is going may not always be clear. Some features may not be appropriate yet, may need to be deferred until later when the foundation for them is laid, or may be more applicable in a plugin.
5
- * Fork the project.
6
- * Make your feature addition or bug fix.
7
- * Follow this [style guide](https://github.com/dkubb/styleguide).
8
- * Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
9
- * Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
10
- * Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
11
- * Send me a pull request. Bonus points for topic branches.
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 'anima', '~> 0.2.0' # for MRI >= 2.0
8
- gem 'rspec', '~> 3.4'
7
+ gem 'rspec', '~> 3.5'
9
8
  end
10
9
 
11
- gemspec
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/dryrb/dry-equalizer.svg)][travis]
8
- [![Dependency Status](http://img.shields.io/gemnasium/dryrb/dry-equalizer.svg)][gemnasium]
9
- [![Code Climate](http://img.shields.io/codeclimate/github/dryrb/dry-equalizer.svg)][codeclimate]
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/dryrb/dry-equalizer
13
- [gemnasium]: https://gemnasium.com/dryrb/dry-equalizer
14
- [codeclimate]: https://codeclimate.com/github/dryrb/dry-equalizer
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.new(:latitude, :longitude)
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
- * Ruby 2.1
54
- * Ruby 2.2
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
 
@@ -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/dkubb/equalizer'
10
+ gem.homepage = 'https://github.com/dryrb/dry-equalizer'
13
11
  gem.licenses = 'MIT'
14
12
 
15
13
  gem.require_paths = %w[lib]
@@ -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
- name = klass.name || klass.inspect
92
- "#<#{name}#{keys.map { |key| " #{key}=#{__send__(key).inspect}" }.join}>"
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.kind_of?(self.class) && cmp?(__method__, other)
123
+ other.is_a?(self.class) && cmp?(__method__, other)
126
124
  end
127
125
  end # module Methods
128
126
  end # class Equalizer
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  module Dry
4
2
  class Equalizer < Module
5
3
  # Gem version
6
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.2.1'.freeze
7
5
  end # class Equalizer
8
6
  end
@@ -1,16 +1,13 @@
1
- # encoding: utf-8
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 ENV['COVERAGE'] == 'true'
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- command_name 'spec:unit'
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,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'rbconfig'
4
2
 
5
3
  ::Config = RbConfig unless defined?(::Config)
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
- describe Dry::Equalizer, '#included' do
3
+ RSpec.describe Dry::Equalizer, '#included' do
6
4
  subject { descendant.instance_exec(object) { |mod| include mod } }
7
5
 
8
6
  let(:object) { described_class.new }
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
- describe Dry::Equalizer::Methods, '#eql?' do
3
+ RSpec.describe Dry::Equalizer::Methods, '#eql?' do
6
4
  subject { object.eql?(other) }
7
5
 
8
6
  let(:object) { described_class.new(true) }
@@ -1,8 +1,6 @@
1
- # encoding: utf-8
2
-
3
1
  require 'spec_helper'
4
2
 
5
- describe Dry::Equalizer::Methods, '#==' do
3
+ RSpec.describe Dry::Equalizer::Methods, '#==' do
6
4
  subject { object == other }
7
5
 
8
6
  let(:object) { described_class.new(true) }
@@ -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(object) }
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(object) }
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.0
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: 2015-11-13 00:00:00.000000000 Z
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/dkubb/equalizer
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.5
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: