equalizer 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +5 -0
  3. data/.ruby-gemset +1 -0
  4. data/.travis.yml +20 -13
  5. data/CONTRIBUTING.md +11 -0
  6. data/Gemfile +3 -62
  7. data/Gemfile.devtools +55 -0
  8. data/Guardfile +22 -8
  9. data/LICENSE +1 -1
  10. data/README.md +17 -58
  11. data/Rakefile +2 -9
  12. data/config/devtools.yml +2 -0
  13. data/config/flay.yml +1 -1
  14. data/config/flog.yml +1 -1
  15. data/config/mutant.yml +3 -0
  16. data/config/{site.reek → reek.yml} +63 -48
  17. data/config/rubocop.yml +57 -0
  18. data/equalizer.gemspec +6 -10
  19. data/lib/equalizer.rb +1 -3
  20. data/lib/equalizer/version.rb +1 -1
  21. data/spec/spec_helper.rb +29 -5
  22. data/spec/unit/equalizer/methods/{eql_spec.rb → eql_predicate_spec.rb} +1 -1
  23. data/spec/unit/equalizer/methods/{equal_value_spec.rb → equality_operator_spec.rb} +0 -0
  24. data/spec/unit/equalizer/{class_method/new_spec.rb → universal_spec.rb} +43 -27
  25. metadata +33 -106
  26. data/.rvmrc +0 -1
  27. data/spec/rcov.opts +0 -7
  28. data/spec/shared/command_method_behavior.rb +0 -7
  29. data/spec/shared/each_method_behaviour.rb +0 -15
  30. data/spec/shared/hash_method_behavior.rb +0 -17
  31. data/spec/shared/idempotent_method_behavior.rb +0 -7
  32. data/spec/shared/invertible_method_behaviour.rb +0 -9
  33. data/spec/spec.opts +0 -3
  34. data/tasks/metrics/ci.rake +0 -9
  35. data/tasks/metrics/flay.rake +0 -45
  36. data/tasks/metrics/flog.rake +0 -49
  37. data/tasks/metrics/heckle.rake +0 -208
  38. data/tasks/metrics/metric_fu.rake +0 -31
  39. data/tasks/metrics/roodi.rake +0 -19
  40. data/tasks/metrics/yardstick.rake +0 -25
  41. data/tasks/spec.rake +0 -60
  42. data/tasks/yard.rake +0 -11
@@ -0,0 +1,57 @@
1
+ AllCops:
2
+ Includes:
3
+ - '**/*.rake'
4
+ - 'Gemfile'
5
+ - 'Gemfile.devtools'
6
+ Excludes:
7
+ - '**/vendor/**'
8
+
9
+ # Avoid parameter lists longer than five parameters.
10
+ ParameterLists:
11
+ Max: 3
12
+ CountKeywordArgs: true
13
+
14
+ # Avoid more than `Max` levels of nesting.
15
+ BlockNesting:
16
+ Max: 3
17
+
18
+ # Align with the style guide.
19
+ CollectionMethods:
20
+ PreferredMethods:
21
+ collect: 'map'
22
+ inject: 'reduce'
23
+ find: 'detect'
24
+ find_all: 'select'
25
+
26
+ # Do not force public/protected/private keyword to be indented at the same
27
+ # level as the def keyword. My personal preference is to outdent these keywords
28
+ # because I think when scanning code it makes it easier to identify the
29
+ # sections of code and visually separate them. When the keyword is at the same
30
+ # level I think it sort of blends in with the def keywords and makes it harder
31
+ # to scan the code and see where the sections are.
32
+ AccessControl:
33
+ Enabled: false
34
+
35
+ # Disable documentation checking until a class needs to be documented once
36
+ Documentation:
37
+ Enabled: false
38
+
39
+ # Do not always use &&/|| instead of and/or.
40
+ AndOr:
41
+ Enabled: false
42
+
43
+ # Do not favor modifier if/unless usage when you have a single-line body
44
+ IfUnlessModifier:
45
+ Enabled: false
46
+
47
+ # Allow case equality operator (in limited use within the specs)
48
+ CaseEquality:
49
+ Enabled: false
50
+
51
+ # Constants do not always have to use SCREAMING_SNAKE_CASE
52
+ ConstantName:
53
+ Enabled: false
54
+
55
+ # Not all trivial readers/writers can be defined with attr_* methods
56
+ TrivialAccessors:
57
+ Enabled: false
@@ -6,20 +6,16 @@ Gem::Specification.new do |gem|
6
6
  gem.name = 'equalizer'
7
7
  gem.version = Equalizer::VERSION.dup
8
8
  gem.authors = ['Dan Kubb', 'Markus Schirp']
9
- gem.email = %w[dan.kubb@gmail.com mbj@seonic.net]
9
+ gem.email = %w[dan.kubb@gmail.com mbj@schirp-dso.com]
10
10
  gem.description = 'Module to define equality, equivalence and inspection methods'
11
11
  gem.summary = gem.description
12
12
  gem.homepage = 'https://github.com/dkubb/equalizer'
13
+ gem.licenses = 'MIT'
13
14
 
14
15
  gem.require_paths = %w[lib]
15
- gem.files = `git ls-files`.split($/)
16
- gem.test_files = `git ls-files -- {spec}/*`.split($/)
17
- gem.extra_rdoc_files = %w[LICENSE README.md TODO]
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- spec/{unit,integration}`.split("\n")
18
+ gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md TODO]
18
19
 
19
- gem.add_runtime_dependency('backports', [ '~> 3.0', '>= 3.0.3' ])
20
- gem.add_runtime_dependency('adamantium', '~> 0.0.6')
21
-
22
- gem.add_development_dependency('rake', '~> 10.0.3')
23
- gem.add_development_dependency('rspec', '~> 1.3.2')
24
- gem.add_development_dependency('yard', '~> 0.8.5')
20
+ gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
25
21
  end
@@ -1,10 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'adamantium'
4
-
5
3
  # Define equality, equivalence and inspection methods
6
4
  class Equalizer < Module
7
- include Adamantium
8
5
 
9
6
  # Initialize an Equalizer with the given keys
10
7
  #
@@ -20,6 +17,7 @@ class Equalizer < Module
20
17
  @keys = keys
21
18
  define_methods
22
19
  include_comparison_methods
20
+ freeze
23
21
  end
24
22
 
25
23
  private
@@ -3,6 +3,6 @@
3
3
  class Equalizer < Module
4
4
 
5
5
  # Gem version
6
- VERSION = '0.0.5'.freeze
6
+ VERSION = '0.0.7'.freeze
7
7
 
8
8
  end # class Equalizer
@@ -1,11 +1,35 @@
1
1
  # encoding: utf-8
2
2
 
3
+ if ENV['COVERAGE'] == 'true'
4
+ require 'simplecov'
5
+ require 'coveralls'
6
+
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter,
10
+ ]
11
+
12
+ SimpleCov.start do
13
+ command_name 'spec:unit'
14
+
15
+ add_filter 'config'
16
+ add_filter 'spec'
17
+ add_filter 'vendor'
18
+
19
+ minimum_coverage 100
20
+ end
21
+ end
22
+
23
+ require 'devtools/spec_helper'
3
24
  require 'equalizer'
4
- require 'spec'
5
- require 'spec/autorun'
6
25
 
7
- # require spec support files and shared behavior
8
- Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each { |f| require f }
26
+ # TODO: FIXME!
27
+ # Cache correct freezer in ice_nine before
28
+ # rspec2 infects the world...
29
+ Equalizer.new
9
30
 
10
- Spec::Runner.configure do |config|
31
+ RSpec.configure do |config|
32
+ config.expect_with :rspec do |expect_with|
33
+ expect_with.syntax = :expect
34
+ end
11
35
  end
@@ -12,7 +12,7 @@ describe Equalizer::Methods, '#eql?' do
12
12
  include Equalizer::Methods
13
13
 
14
14
  def cmp?(comparator, other)
15
- !!(comparator and other)
15
+ !!(comparator && other)
16
16
  end
17
17
  end
18
18
  end
@@ -3,6 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Equalizer, '.new' do
6
+
6
7
  let(:object) { described_class }
7
8
  let(:name) { 'User' }
8
9
  let(:klass) { ::Class.new }
@@ -23,20 +24,21 @@ describe Equalizer, '.new' do
23
24
  it { should be_frozen }
24
25
 
25
26
  it 'defines #hash and #inspect methods dynamically' do
26
- subject.public_instance_methods(false).map(&:to_s).should =~ %w[ hash inspect ]
27
+ expect(subject.public_instance_methods(false).map(&:to_s).sort)
28
+ .to eql(%w[hash inspect])
27
29
  end
28
30
 
29
31
  describe '#eql?' do
30
32
  context 'when the objects are similar' do
31
33
  let(:other) { instance.dup }
32
34
 
33
- it { instance.eql?(other).should be(true) }
35
+ it { expect(instance.eql?(other)).to be(true) }
34
36
  end
35
37
 
36
38
  context 'when the objects are different' do
37
- let(:other) { stub('other') }
39
+ let(:other) { double('other') }
38
40
 
39
- it { instance.eql?(other).should be(false) }
41
+ it { expect(instance.eql?(other)).to be(false) }
40
42
  end
41
43
  end
42
44
 
@@ -44,46 +46,47 @@ describe Equalizer, '.new' do
44
46
  context 'when the objects are similar' do
45
47
  let(:other) { instance.dup }
46
48
 
47
- it { (instance == other).should be(true) }
49
+ it { expect(instance == other).to be(true) }
48
50
  end
49
51
 
50
52
  context 'when the objects are different' do
51
- let(:other) { stub('other') }
53
+ let(:other) { double('other') }
52
54
 
53
- it { (instance == other).should be(false) }
55
+ it { expect(instance == other).to be(false) }
54
56
  end
55
57
  end
56
58
 
57
59
  describe '#hash' do
58
60
  it 'has the expected arity' do
59
- klass.instance_method(:hash).arity.should be(0)
61
+ expect(klass.instance_method(:hash).arity).to be(0)
60
62
  end
61
63
 
62
- it { instance.hash.should eql(klass.hash) }
64
+ it { expect(instance.hash).to eql(klass.hash) }
63
65
  end
64
66
 
65
67
  describe '#inspect' do
66
68
  it 'has the expected arity' do
67
- klass.instance_method(:inspect).arity.should be(0)
69
+ expect(klass.instance_method(:inspect).arity).to be(0)
68
70
  end
69
71
 
70
- it { instance.inspect.should eql('#<User>') }
72
+ it { expect(instance.inspect).to eql('#<User>') }
71
73
  end
72
74
  end
73
75
 
74
76
  context 'with keys' do
75
77
  subject { object.new(*keys) }
76
78
 
77
- let(:keys) { [ :first_name ].freeze }
78
- let(:first_name) { 'John' }
79
- let(:instance) { klass.new(first_name) }
79
+ let(:keys) { [:firstname, :lastname].freeze }
80
+ let(:firstname) { 'John' }
81
+ let(:lastname) { 'Doe' }
82
+ let(:instance) { klass.new(firstname, lastname) }
80
83
 
81
84
  let(:klass) do
82
85
  ::Class.new do
83
- attr_reader :first_name
86
+ attr_reader :firstname, :lastname
84
87
 
85
- def initialize(first_name)
86
- @first_name = first_name
88
+ def initialize(firstname, lastname)
89
+ @firstname, @lastname = firstname, lastname
87
90
  end
88
91
  end
89
92
  end
@@ -100,20 +103,21 @@ describe Equalizer, '.new' do
100
103
  it { should be_frozen }
101
104
 
102
105
  it 'defines #hash and #inspect methods dynamically' do
103
- subject.public_instance_methods(false).map(&:to_s).should =~ %w[ hash inspect ]
106
+ expect(subject.public_instance_methods(false).map(&:to_s).sort)
107
+ .to eql(%w[ hash inspect ])
104
108
  end
105
109
 
106
110
  describe '#eql?' do
107
111
  context 'when the objects are similar' do
108
112
  let(:other) { instance.dup }
109
113
 
110
- it { instance.eql?(other).should be(true) }
114
+ it { expect(instance.eql?(other)).to be(true) }
111
115
  end
112
116
 
113
117
  context 'when the objects are different' do
114
- let(:other) { stub('other') }
118
+ let(:other) { double('other') }
115
119
 
116
- it { instance.eql?(other).should be(false) }
120
+ it { expect(instance.eql?(other)).to be(false) }
117
121
  end
118
122
  end
119
123
 
@@ -121,22 +125,34 @@ describe Equalizer, '.new' do
121
125
  context 'when the objects are similar' do
122
126
  let(:other) { instance.dup }
123
127
 
124
- it { (instance == other).should be(true) }
128
+ it { expect(instance == other).to be(true) }
125
129
  end
126
130
 
127
- context 'when the objects are different' do
128
- let(:other) { stub('other') }
131
+ context 'when the objects are different type' do
132
+ let(:other) { klass.new('Foo', 'Bar') }
129
133
 
130
- it { (instance == other).should be(false) }
134
+ it { expect(instance == other).to be(false) }
135
+ end
136
+
137
+ context 'when the objects are from different type' do
138
+ let(:other) { double('other') }
139
+
140
+ it { expect(instance == other).to be(false) }
131
141
  end
132
142
  end
133
143
 
134
144
  describe '#hash' do
135
- it { instance.hash.should eql(klass.hash ^ first_name.hash) }
145
+ it 'returns the expected hash' do
146
+ expect(instance.hash)
147
+ .to eql(klass.hash ^ firstname.hash ^ lastname.hash)
148
+ end
136
149
  end
137
150
 
138
151
  describe '#inspect' do
139
- it { instance.inspect.should eql('#<User first_name="John">') }
152
+ it 'returns the expected string' do
153
+ expect(instance.inspect)
154
+ .to eql('#<User firstname="John" lastname="Doe">')
155
+ end
140
156
  end
141
157
  end
142
158
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equalizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Kubb
@@ -10,166 +9,94 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-03-01 00:00:00.000000000 Z
12
+ date: 2013-08-22 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- name: backports
15
+ name: bundler
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
22
- version: '3.0'
23
- - - ! '>='
20
+ version: '1.3'
21
+ - - '>='
24
22
  - !ruby/object:Gem::Version
25
- version: 3.0.3
26
- type: :runtime
27
- prerelease: false
28
- version_requirements: !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- - - ! '>='
35
- - !ruby/object:Gem::Version
36
- version: 3.0.3
37
- - !ruby/object:Gem::Dependency
38
- name: adamantium
39
- requirement: !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- version: 0.0.6
45
- type: :runtime
46
- prerelease: false
47
- version_requirements: !ruby/object:Gem::Requirement
48
- none: false
49
- requirements:
50
- - - ~>
51
- - !ruby/object:Gem::Version
52
- version: 0.0.6
53
- - !ruby/object:Gem::Dependency
54
- name: rake
55
- requirement: !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- version: 10.0.3
23
+ version: 1.3.5
61
24
  type: :development
62
25
  prerelease: false
63
26
  version_requirements: !ruby/object:Gem::Requirement
64
- none: false
65
27
  requirements:
66
28
  - - ~>
67
29
  - !ruby/object:Gem::Version
68
- version: 10.0.3
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ~>
75
- - !ruby/object:Gem::Version
76
- version: 1.3.2
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ~>
83
- - !ruby/object:Gem::Version
84
- version: 1.3.2
85
- - !ruby/object:Gem::Dependency
86
- name: yard
87
- requirement: !ruby/object:Gem::Requirement
88
- none: false
89
- requirements:
90
- - - ~>
91
- - !ruby/object:Gem::Version
92
- version: 0.8.5
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ~>
30
+ version: '1.3'
31
+ - - '>='
99
32
  - !ruby/object:Gem::Version
100
- version: 0.8.5
33
+ version: 1.3.5
101
34
  description: Module to define equality, equivalence and inspection methods
102
35
  email:
103
36
  - dan.kubb@gmail.com
104
- - mbj@seonic.net
37
+ - mbj@schirp-dso.com
105
38
  executables: []
106
39
  extensions: []
107
40
  extra_rdoc_files:
108
41
  - LICENSE
109
42
  - README.md
43
+ - CONTRIBUTING.md
110
44
  - TODO
111
45
  files:
112
46
  - .gitignore
113
- - .rvmrc
47
+ - .rspec
48
+ - .ruby-gemset
114
49
  - .travis.yml
50
+ - CONTRIBUTING.md
115
51
  - Gemfile
52
+ - Gemfile.devtools
116
53
  - Guardfile
117
54
  - LICENSE
118
55
  - README.md
119
56
  - Rakefile
120
57
  - TODO
58
+ - config/devtools.yml
121
59
  - config/flay.yml
122
60
  - config/flog.yml
61
+ - config/mutant.yml
62
+ - config/reek.yml
123
63
  - config/roodi.yml
124
- - config/site.reek
64
+ - config/rubocop.yml
125
65
  - config/yardstick.yml
126
66
  - equalizer.gemspec
127
67
  - lib/equalizer.rb
128
68
  - lib/equalizer/version.rb
129
- - spec/rcov.opts
130
- - spec/shared/command_method_behavior.rb
131
- - spec/shared/each_method_behaviour.rb
132
- - spec/shared/hash_method_behavior.rb
133
- - spec/shared/idempotent_method_behavior.rb
134
- - spec/shared/invertible_method_behaviour.rb
135
- - spec/spec.opts
136
69
  - spec/spec_helper.rb
137
70
  - spec/support/config_alias.rb
138
- - spec/unit/equalizer/class_method/new_spec.rb
139
- - spec/unit/equalizer/methods/eql_spec.rb
140
- - spec/unit/equalizer/methods/equal_value_spec.rb
141
- - tasks/metrics/ci.rake
142
- - tasks/metrics/flay.rake
143
- - tasks/metrics/flog.rake
144
- - tasks/metrics/heckle.rake
145
- - tasks/metrics/metric_fu.rake
146
- - tasks/metrics/roodi.rake
147
- - tasks/metrics/yardstick.rake
148
- - tasks/spec.rake
149
- - tasks/yard.rake
71
+ - spec/unit/equalizer/methods/eql_predicate_spec.rb
72
+ - spec/unit/equalizer/methods/equality_operator_spec.rb
73
+ - spec/unit/equalizer/universal_spec.rb
150
74
  homepage: https://github.com/dkubb/equalizer
151
- licenses: []
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
152
78
  post_install_message:
153
79
  rdoc_options: []
154
80
  require_paths:
155
81
  - lib
156
82
  required_ruby_version: !ruby/object:Gem::Requirement
157
- none: false
158
83
  requirements:
159
- - - ! '>='
84
+ - - '>='
160
85
  - !ruby/object:Gem::Version
161
86
  version: '0'
162
87
  required_rubygems_version: !ruby/object:Gem::Requirement
163
- none: false
164
88
  requirements:
165
- - - ! '>='
89
+ - - '>='
166
90
  - !ruby/object:Gem::Version
167
91
  version: '0'
168
92
  requirements: []
169
93
  rubyforge_project:
170
- rubygems_version: 1.8.23
94
+ rubygems_version: 2.0.2
171
95
  signing_key:
172
- specification_version: 3
96
+ specification_version: 4
173
97
  summary: Module to define equality, equivalence and inspection methods
174
- test_files: []
98
+ test_files:
99
+ - spec/unit/equalizer/methods/eql_predicate_spec.rb
100
+ - spec/unit/equalizer/methods/equality_operator_spec.rb
101
+ - spec/unit/equalizer/universal_spec.rb
175
102
  has_rdoc: