equalizer 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f081b71232d8ecf91f28b2dd4710cf36b5cd2936
4
- data.tar.gz: 49a8eb253f2c6168a3ef15a0d96a150abc30cfab
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZGRlOGMwM2JjYmE4MzM0Yzg0YmQxN2MwYzZmM2U3MWIzNjkxNmNkMA==
5
+ data.tar.gz: !binary |-
6
+ ZDVhZGIwM2U5MTdhNWYyNDZjYTlkOTY4ZTM4NzZhNzEyOTQzZGRiZQ==
5
7
  SHA512:
6
- metadata.gz: a96e4b95601585fcb934831c4825bfd8394d8e1d146f1ab5b89290ba3667a32a4d16b732f58c16d728dfbb33fd31d44383b406ed985e01996e30a6a62bd36295
7
- data.tar.gz: 474ae8729aa767e617328fe05be9205f3fc72470f9ab5c79fb88aa2a894c3eea2029fecee7f36dad7a2bee526308690319aa5ce55cf31a471dc9beb6cd6c9457
8
+ metadata.gz: !binary |-
9
+ OGM3NDcwMzhjY2M3MWJjNDBlYWRjZDk4YWY4NjYyNTI1NzdiZDc3MzBiMGEz
10
+ ZjAwYmJhNzgwNTg4YjU5ZmFlOTU1N2NiYjBmMWY4NmU0N2ZhOWZjZTNiNzhi
11
+ ZTdiN2NjODk1YWMyNzE5OWY0ZjY2NmQ3ZjNhYjY5Yzk1NjQ5OTI=
12
+ data.tar.gz: !binary |-
13
+ MGM3YzJhODdkMDZhOTVmOWNkNWIzMTdhMWY1MjY5Njg1OWRmYWU5NDg5MGQw
14
+ M2RmNjVmOTM4OWYzODQ0NTk5Y2I3YTViYjgwMTdmMTI3MmVlMjVlZDZmMjE0
15
+ ZTc1Y2YzZGRhZWYyYTQyMWExNDJiYjY3NTljMDA5ZmIxYWVkZjI=
@@ -1,12 +1,11 @@
1
1
  language: ruby
2
- before_install: gem install bundler
3
2
  bundler_args: --without yard guard benchmarks
4
3
  script: "bundle exec rake ci"
5
4
  rvm:
6
5
  - 1.9.3
7
6
  - 2.0.0
8
7
  - ruby-head
9
- - rbx-19mode
8
+ - rbx
10
9
  matrix:
11
10
  include:
12
11
  - rvm: jruby-19mode
@@ -14,10 +13,7 @@ matrix:
14
13
  - rvm: jruby-head
15
14
  env: JRUBY_OPTS="$JRUBY_OPTS --debug"
16
15
  allow_failures:
17
- - rvm: 1.9.3 # mutant fails
18
- - rvm: 2.0.0 # mutant fails
19
- - rvm: ruby-head # travis broken
20
- - rvm: rbx-19mode # mutant fails
16
+ - rvm: 2.0.0 # travis broken
21
17
  notifications:
22
18
  irc:
23
19
  channels:
@@ -4,10 +4,14 @@ group :development do
4
4
  gem 'rake', '~> 10.1.0'
5
5
  gem 'rspec', '~> 2.14.1'
6
6
  gem 'yard', '~> 0.8.7'
7
+
8
+ platform :rbx do
9
+ gem 'rubysl-singleton', '~> 2.0.0'
10
+ end
7
11
  end
8
12
 
9
13
  group :yard do
10
- gem 'kramdown', '~> 1.1.0'
14
+ gem 'kramdown', '~> 1.2.0'
11
15
  end
12
16
 
13
17
  group :guard do
@@ -15,7 +19,7 @@ group :guard do
15
19
  gem 'guard-bundler', '~> 1.0.0'
16
20
  gem 'guard-rspec', '~> 3.0.2'
17
21
  gem 'guard-rubocop', '~> 0.2.0'
18
- # gem 'guard-mutant', '~> 0.0.1'
22
+ gem 'guard-mutant', '~> 0.0.1'
19
23
 
20
24
  # file system change event handling
21
25
  gem 'listen', '~> 1.3.0'
@@ -30,18 +34,27 @@ group :guard do
30
34
  end
31
35
 
32
36
  group :metrics do
33
- gem 'coveralls', '~> 0.6.7'
37
+ gem 'coveralls', '~> 0.7.0'
34
38
  gem 'flay', '~> 2.4.0'
35
- gem 'flog', '~> 4.1.1'
39
+ gem 'flog', '~> 4.2.0'
36
40
  gem 'reek', '~> 1.3.2'
37
- gem 'rubocop', '~> 0.11.0'
38
- gem 'simplecov', '~> 0.7.1'
41
+ gem 'rubocop', '~> 0.15.0'
42
+ gem 'simplecov', '~> 0.8.2'
39
43
  gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
40
44
 
41
45
  platforms :ruby_19, :ruby_20 do
42
- # gem 'mutant', git: 'https://github.com/mbj/mutant.git'
46
+ gem 'mutant', '~> 0.3.0.rc3', git: 'https://github.com/mbj/mutant.git'
47
+ gem 'unparser', '~> 0.1.5', git: 'https://github.com/mbj/unparser.git'
43
48
  gem 'yard-spellcheck', '~> 0.1.5'
44
49
  end
50
+
51
+ platform :rbx do
52
+ gem 'json', '~> 1.8.1'
53
+ gem 'racc', '~> 1.4.10'
54
+ gem 'rubysl-logger', '~> 2.0.0'
55
+ gem 'rubysl-open-uri', '~> 2.0.0'
56
+ gem 'rubysl-prettyprint', '~> 2.0.2'
57
+ end
45
58
  end
46
59
 
47
60
  group :benchmarks do
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 20.9
2
+ threshold: 18.7
@@ -29,7 +29,7 @@ CollectionMethods:
29
29
  # sections of code and visually separate them. When the keyword is at the same
30
30
  # level I think it sort of blends in with the def keywords and makes it harder
31
31
  # to scan the code and see where the sections are.
32
- AccessControl:
32
+ AccessModifierIndentation:
33
33
  Enabled: false
34
34
 
35
35
  # Disable documentation checking until a class needs to be documented once
@@ -55,3 +55,7 @@ ConstantName:
55
55
  # Not all trivial readers/writers can be defined with attr_* methods
56
56
  TrivialAccessors:
57
57
  Enabled: false
58
+
59
+ # Allow empty lines around body
60
+ EmptyLinesAroundBody:
61
+ Enabled: false
@@ -16,12 +16,24 @@ class Equalizer < Module
16
16
  def initialize(*keys)
17
17
  @keys = keys
18
18
  define_methods
19
- include_comparison_methods
20
19
  freeze
21
20
  end
22
21
 
23
22
  private
24
23
 
24
+ # Hook called when module is included
25
+ #
26
+ # @param [Module] descendant
27
+ # the module or class including Equalizer
28
+ #
29
+ # @return [self]
30
+ #
31
+ # @api private
32
+ def included(descendant)
33
+ super
34
+ descendant.module_eval { include Methods }
35
+ end
36
+
25
37
  # Define the equalizer methods based on #keys
26
38
  #
27
39
  # @return [undefined]
@@ -41,7 +53,7 @@ private
41
53
  def define_cmp_method
42
54
  keys = @keys
43
55
  define_method(:cmp?) do |comparator, other|
44
- keys.all? { |key| send(key).send(comparator, other.send(key)) }
56
+ keys.all? { |key| send(key).public_send(comparator, other.send(key)) }
45
57
  end
46
58
  private :cmp?
47
59
  end
@@ -72,15 +84,6 @@ private
72
84
  end
73
85
  end
74
86
 
75
- # Include the #eql? and #== methods
76
- #
77
- # @return [undefined]
78
- #
79
- # @api private
80
- def include_comparison_methods
81
- module_eval { include Methods }
82
- end
83
-
84
87
  # The comparison methods
85
88
  module Methods
86
89
 
@@ -3,6 +3,6 @@
3
3
  class Equalizer < Module
4
4
 
5
5
  # Gem version
6
- VERSION = '0.0.7'.freeze
6
+ VERSION = '0.0.8'.freeze
7
7
 
8
8
  end # class Equalizer
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Equalizer, '#included' do
6
+ subject { descendant.instance_exec(object) { |mod| include mod } }
7
+
8
+ let(:object) { described_class.new }
9
+ let(:descendant) { Class.new }
10
+ let(:superclass) { described_class.superclass }
11
+
12
+ before do
13
+ # Prevent Module.included from being called through inheritance
14
+ described_class::Methods.stub(:included)
15
+ end
16
+
17
+ around do |example|
18
+ # Restore included method after each example
19
+ superclass.class_eval do
20
+ alias_method :original_included, :included
21
+ example.call
22
+ undef_method :included
23
+ alias_method :included, :original_included
24
+ end
25
+ end
26
+
27
+ it 'delegates to the superclass #included method' do
28
+ # This is the most succinct approach I could think of to test whether the
29
+ # superclass#included method is called. All of the built-in rspec helpers
30
+ # did not seem to work for this.
31
+ included = false
32
+ superclass.class_eval { define_method(:included) { |_| included = true } }
33
+ expect { subject }.to change { included }.from(false).to(true)
34
+ end
35
+
36
+ it 'includes methods into the descendant' do
37
+ subject
38
+ expect(descendant.included_modules).to include(described_class::Methods)
39
+ end
40
+ end
@@ -5,14 +5,20 @@ require 'spec_helper'
5
5
  describe Equalizer::Methods, '#eql?' do
6
6
  subject { object.eql?(other) }
7
7
 
8
- let(:object) { described_class.new }
8
+ let(:object) { described_class.new(true) }
9
9
 
10
10
  let(:described_class) do
11
11
  Class.new do
12
12
  include Equalizer::Methods
13
13
 
14
+ attr_reader :boolean
15
+
16
+ def initialize(boolean)
17
+ @boolean = boolean
18
+ end
19
+
14
20
  def cmp?(comparator, other)
15
- !!(comparator && other)
21
+ boolean.send(comparator, other.boolean)
16
22
  end
17
23
  end
18
24
  end
@@ -38,7 +44,17 @@ describe Equalizer::Methods, '#eql?' do
38
44
  end
39
45
 
40
46
  context 'with an equivalent object of a subclass' do
41
- let(:other) { Class.new(described_class).new }
47
+ let(:other) { Class.new(described_class).new(true) }
48
+
49
+ it { should be(false) }
50
+
51
+ it 'is symmetric' do
52
+ should eql(other.eql?(object))
53
+ end
54
+ end
55
+
56
+ context 'with a different object' do
57
+ let(:other) { described_class.new(false) }
42
58
 
43
59
  it { should be(false) }
44
60
 
@@ -95,4 +95,14 @@ describe Equalizer::Methods, '#==' do
95
95
  should_not eql(other == object)
96
96
  end
97
97
  end
98
+
99
+ context 'with a different object' do
100
+ let(:other) { described_class.new(false) }
101
+
102
+ it { should be(false) }
103
+
104
+ it 'is symmetric' do
105
+ should eql(other == object)
106
+ end
107
+ end
98
108
  end
@@ -84,6 +84,7 @@ describe Equalizer, '.new' do
84
84
  let(:klass) do
85
85
  ::Class.new do
86
86
  attr_reader :firstname, :lastname
87
+ private :firstname, :lastname
87
88
 
88
89
  def initialize(firstname, lastname)
89
90
  @firstname, @lastname = firstname, lastname
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equalizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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: 2013-08-22 00:00:00.000000000 Z
12
+ date: 2013-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -18,7 +18,7 @@ dependencies:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
- - - '>='
21
+ - - ! '>='
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.3.5
24
24
  type: :development
@@ -28,7 +28,7 @@ dependencies:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: '1.3'
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.5
34
34
  description: Module to define equality, equivalence and inspection methods
@@ -68,6 +68,7 @@ files:
68
68
  - lib/equalizer/version.rb
69
69
  - spec/spec_helper.rb
70
70
  - spec/support/config_alias.rb
71
+ - spec/unit/equalizer/included_spec.rb
71
72
  - spec/unit/equalizer/methods/eql_predicate_spec.rb
72
73
  - spec/unit/equalizer/methods/equality_operator_spec.rb
73
74
  - spec/unit/equalizer/universal_spec.rb
@@ -81,21 +82,22 @@ require_paths:
81
82
  - lib
82
83
  required_ruby_version: !ruby/object:Gem::Requirement
83
84
  requirements:
84
- - - '>='
85
+ - - ! '>='
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  requirements:
89
- - - '>='
90
+ - - ! '>='
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.0.2
95
+ rubygems_version: 2.1.11
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Module to define equality, equivalence and inspection methods
98
99
  test_files:
100
+ - spec/unit/equalizer/included_spec.rb
99
101
  - spec/unit/equalizer/methods/eql_predicate_spec.rb
100
102
  - spec/unit/equalizer/methods/equality_operator_spec.rb
101
103
  - spec/unit/equalizer/universal_spec.rb