equalizer 0.0.11 → 1.0.0

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.
data/config/reek.yml DELETED
@@ -1,105 +0,0 @@
1
- ---
2
- Attribute:
3
- enabled: false
4
- exclude: []
5
- BooleanParameter:
6
- enabled: true
7
- exclude: []
8
- ClassVariable:
9
- enabled: true
10
- exclude: []
11
- ControlParameter:
12
- enabled: true
13
- exclude: []
14
- DataClump:
15
- enabled: true
16
- exclude: []
17
- max_copies: 2
18
- min_clump_size: 2
19
- DuplicateMethodCall:
20
- enabled: true
21
- exclude: []
22
- max_calls: 1
23
- allow_calls: []
24
- FeatureEnvy:
25
- enabled: true
26
- exclude: []
27
- IrresponsibleModule:
28
- enabled: true
29
- exclude: []
30
- LongParameterList:
31
- enabled: true
32
- exclude: []
33
- max_params: 2
34
- overrides:
35
- initialize:
36
- max_params: 3
37
- LongYieldList:
38
- enabled: true
39
- exclude: []
40
- max_params: 2
41
- NestedIterators:
42
- enabled: true
43
- exclude:
44
- - Equalizer#define_cmp_method
45
- - Equalizer#define_inspect_method
46
- max_allowed_nesting: 1
47
- ignore_iterators: []
48
- NilCheck:
49
- enabled: true
50
- exclude: []
51
- RepeatedConditional:
52
- enabled: true
53
- exclude: []
54
- max_ifs: 1
55
- TooManyInstanceVariables:
56
- enabled: true
57
- exclude: []
58
- max_instance_variables: 3
59
- TooManyMethods:
60
- enabled: true
61
- exclude: []
62
- max_methods: 6
63
- TooManyStatements:
64
- enabled: true
65
- exclude:
66
- - Equalizer#define_inspect_method
67
- max_statements: 5
68
- UncommunicativeMethodName:
69
- enabled: true
70
- exclude: []
71
- reject:
72
- - !ruby/regexp /^[a-z]$/
73
- - !ruby/regexp /[0-9]$/
74
- - !ruby/regexp /[A-Z]/
75
- accept: []
76
- UncommunicativeModuleName:
77
- enabled: true
78
- exclude: []
79
- reject:
80
- - !ruby/regexp /^.$/
81
- - !ruby/regexp /[0-9]$/
82
- accept: []
83
- UncommunicativeParameterName:
84
- enabled: true
85
- exclude: []
86
- reject:
87
- - !ruby/regexp /^.$/
88
- - !ruby/regexp /[0-9]$/
89
- - !ruby/regexp /[A-Z]/
90
- accept: []
91
- UncommunicativeVariableName:
92
- enabled: true
93
- exclude: []
94
- reject:
95
- - !ruby/regexp /^.$/
96
- - !ruby/regexp /[0-9]$/
97
- - !ruby/regexp /[A-Z]/
98
- accept: []
99
- UnusedParameters:
100
- enabled: true
101
- exclude: []
102
- UtilityFunction:
103
- enabled: true
104
- exclude: []
105
- max_helper_calls: 0
data/config/rubocop.yml DELETED
@@ -1,115 +0,0 @@
1
- # Avoid parameter lists longer than five parameters.
2
- ParameterLists:
3
- Max: 3
4
- CountKeywordArgs: true
5
-
6
- # Avoid more than `Max` levels of nesting.
7
- BlockNesting:
8
- Max: 3
9
-
10
- # Align with the style guide.
11
- CollectionMethods:
12
- PreferredMethods:
13
- collect: 'map'
14
- inject: 'reduce'
15
- find: 'detect'
16
- find_all: 'select'
17
-
18
- # Do not force public/protected/private keyword to be indented at the same
19
- # level as the def keyword. My personal preference is to outdent these keywords
20
- # because I think when scanning code it makes it easier to identify the
21
- # sections of code and visually separate them. When the keyword is at the same
22
- # level I think it sort of blends in with the def keywords and makes it harder
23
- # to scan the code and see where the sections are.
24
- AccessModifierIndentation:
25
- Enabled: false
26
-
27
- # Limit line length
28
- LineLength:
29
- Max: 106
30
-
31
- # Disable documentation checking until a class needs to be documented once
32
- Documentation:
33
- Enabled: false
34
-
35
- # Do not always use &&/|| instead of and/or.
36
- AndOr:
37
- Enabled: false
38
-
39
- # Do not favor modifier if/unless usage when you have a single-line body
40
- IfUnlessModifier:
41
- Enabled: false
42
-
43
- # Allow case equality operator (in limited use within the specs)
44
- CaseEquality:
45
- Enabled: false
46
-
47
- # Constants do not always have to use SCREAMING_SNAKE_CASE
48
- ConstantName:
49
- Enabled: false
50
-
51
- # Not all trivial readers/writers can be defined with attr_* methods
52
- TrivialAccessors:
53
- Enabled: false
54
-
55
- # Allow empty lines around class body
56
- EmptyLinesAroundClassBody:
57
- Enabled: false
58
-
59
- # Allow empty lines around module body
60
- EmptyLinesAroundModuleBody:
61
- Enabled: false
62
-
63
- # Allow empty lines around block body
64
- EmptyLinesAroundBlockBody:
65
- Enabled: false
66
-
67
- # Allow multiple line operations to not require indentation
68
- MultilineOperationIndentation:
69
- Enabled: false
70
-
71
- # Prefer String#% over Kernel#sprintf
72
- FormatString:
73
- Enabled: false
74
-
75
- # Use square brackets for literal Array objects
76
- PercentLiteralDelimiters:
77
- PreferredDelimiters:
78
- '%': '{}'
79
- '%i': '[]'
80
- '%q': ()
81
- '%Q': ()
82
- '%r': '{}'
83
- '%s': ()
84
- '%w': '[]'
85
- '%W': '[]'
86
- '%x': ()
87
-
88
- # Use %i[...] for arrays of symbols
89
- SymbolArray:
90
- Enabled: true
91
-
92
- # Align if/else blocks with the variable assignment
93
- EndAlignment:
94
- AlignWith: variable
95
-
96
- # Do not always align parameters when it is easier to read
97
- AlignParameters:
98
- Exclude:
99
- - spec/**/*_spec.rb
100
-
101
- # Prefer #kind_of? over #is_a?
102
- ClassCheck:
103
- EnforcedStyle: kind_of?
104
-
105
- # Do not prefer double quotes to be used when %q or %Q is more appropriate
106
- UnneededPercentQ:
107
- Enabled: false
108
-
109
- # Allow a maximum ABC score
110
- Metrics/AbcSize:
111
- Max: 8.6
112
-
113
- # Do not prefer lambda.call(...) over lambda.(...)
114
- LambdaCall:
115
- Enabled: false
data/config/yardstick.yml DELETED
@@ -1,34 +0,0 @@
1
- ---
2
- path: 'lib/**/*.rb'
3
- threshold: 100
4
- rules:
5
- ApiTag::Presence:
6
- enabled: true
7
- exclude: []
8
- ApiTag::Inclusion:
9
- enabled: true
10
- exclude: []
11
- ApiTag::ProtectedMethod:
12
- enabled: true
13
- exclude: []
14
- ApiTag::PrivateMethod:
15
- enabled: true
16
- exclude: []
17
- ExampleTag:
18
- enabled: true
19
- exclude: []
20
- ReturnTag:
21
- enabled: true
22
- exclude: []
23
- Summary::Presence:
24
- enabled: true
25
- exclude: []
26
- Summary::Length:
27
- enabled: true
28
- exclude: []
29
- Summary::Delimiter:
30
- enabled: true
31
- exclude: []
32
- Summary::SingleLine:
33
- enabled: true
34
- exclude: []
data/equalizer.gemspec DELETED
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../lib/equalizer/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = 'equalizer'
7
- gem.version = Equalizer::VERSION.dup
8
- gem.authors = ['Dan Kubb', 'Markus Schirp']
9
- gem.email = %w[dan.kubb@gmail.com mbj@schirp-dso.com]
10
- gem.description = 'Module to define equality, equivalence and inspection methods'
11
- gem.summary = gem.description
12
- gem.homepage = 'https://github.com/dkubb/equalizer'
13
- gem.licenses = 'MIT'
14
-
15
- gem.require_paths = %w[lib]
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]
19
-
20
- gem.required_ruby_version = '>= 1.8.7'
21
-
22
- gem.add_development_dependency('bundler', '~> 1.3', '>= 1.3.5')
23
- end
@@ -1,6 +0,0 @@
1
- # encoding: utf-8
2
-
3
- class Equalizer < Module
4
- # Gem version
5
- VERSION = '0.0.11'.freeze
6
- end # class Equalizer
data/spec/spec_helper.rb DELETED
@@ -1,31 +0,0 @@
1
- # encoding: utf-8
2
-
3
- if ENV['COVERAGE'] == 'true'
4
- require 'simplecov'
5
- require 'coveralls'
6
-
7
- SimpleCov.formatters = [
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 'equalizer'
24
-
25
- RSpec.configure do |config|
26
- config.raise_errors_for_deprecations!
27
-
28
- config.expect_with :rspec do |expect_with|
29
- expect_with.syntax = :expect
30
- end
31
- end
@@ -1,5 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'rbconfig'
4
-
5
- ::Config = RbConfig unless defined?(::Config)
@@ -1,50 +0,0 @@
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
- allow(described_class::Methods).to receive(: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
-
33
- superclass.class_eval do
34
- define_method(:included) do |_|
35
- # Only set the flag when an Equalizer instance is included.
36
- # Otherwise, other module includes (which get triggered internally
37
- # in RSpec when `change` is used for the first time, since it uses
38
- # autoloading for its matchers) will wrongly set this flag.
39
- included = true if self.kind_of?(Equalizer)
40
- end
41
- end
42
-
43
- expect { subject }.to change { included }.from(false).to(true)
44
- end
45
-
46
- it 'includes methods into the descendant' do
47
- subject
48
- expect(descendant.included_modules).to include(described_class::Methods)
49
- end
50
- end
@@ -1,65 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Equalizer::Methods, '#eql?' do
6
- subject { object.eql?(other) }
7
-
8
- let(:object) { described_class.new(true) }
9
-
10
- let(:described_class) do
11
- Class.new do
12
- include Equalizer::Methods
13
-
14
- attr_reader :boolean
15
-
16
- def initialize(boolean)
17
- @boolean = boolean
18
- end
19
-
20
- def cmp?(comparator, other)
21
- boolean.send(comparator, other.boolean)
22
- end
23
- end
24
- end
25
-
26
- context 'with the same object' do
27
- let(:other) { object }
28
-
29
- it { should be(true) }
30
-
31
- it 'is symmetric' do
32
- should eql(other.eql?(object))
33
- end
34
- end
35
-
36
- context 'with an equivalent object' do
37
- let(:other) { object.dup }
38
-
39
- it { should be(true) }
40
-
41
- it 'is symmetric' do
42
- should eql(other.eql?(object))
43
- end
44
- end
45
-
46
- context 'with an equivalent object of a subclass' do
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) }
58
-
59
- it { should be(false) }
60
-
61
- it 'is symmetric' do
62
- should eql(other.eql?(object))
63
- end
64
- end
65
- end
@@ -1,128 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Equalizer::Methods, '#==' do
6
- subject { object == other }
7
-
8
- let(:object) { described_class.new(true) }
9
- let(:described_class) { Class.new(super_class) }
10
-
11
- let(:super_class) do
12
- Class.new do
13
- include Equalizer::Methods
14
-
15
- attr_reader :boolean
16
-
17
- def initialize(boolean)
18
- @boolean = boolean
19
- end
20
-
21
- def cmp?(comparator, other)
22
- boolean.send(comparator, other.boolean)
23
- end
24
- end
25
- end
26
-
27
- context 'with the same object' do
28
- let(:other) { object }
29
-
30
- it { should be(true) }
31
-
32
- it 'is symmetric' do
33
- should eql(other == object)
34
- end
35
- end
36
-
37
- context 'with an equivalent object' do
38
- let(:other) { object.dup }
39
-
40
- it { should be(true) }
41
-
42
- it 'is symmetric' do
43
- should eql(other == object)
44
- end
45
- end
46
-
47
- context 'with a subclass instance having equivalent obervable state' do
48
- let(:other) { Class.new(described_class).new(true) }
49
-
50
- it { should be(true) }
51
-
52
- it 'is not symmetric' do
53
- # the subclass instance should maintain substitutability with the object
54
- # (in the LSP sense) the reverse is not true.
55
- should_not eql(other == object)
56
- end
57
- end
58
-
59
- context 'with a superclass instance having equivalent observable state' do
60
- let(:other) { super_class.new(true) }
61
-
62
- it { should be(false) }
63
-
64
- it 'is not symmetric' do
65
- should_not eql(other == object)
66
- end
67
- end
68
-
69
- context 'with an object of another class' do
70
- let(:other) { Class.new.new }
71
-
72
- it { should be(false) }
73
-
74
- it 'is symmetric' do
75
- should eql(other == object)
76
- end
77
- end
78
-
79
- context 'with an equivalent object after coercion' do
80
- let(:other) { Object.new }
81
-
82
- before do
83
- # declare a private #coerce method
84
- described_class.class_eval do
85
- def coerce(other)
86
- [self.class.new(![nil, false].include?(other)), self]
87
- end
88
- private :coerce
89
- end
90
- end
91
-
92
- it { should be(true) }
93
-
94
- it 'is not symmetric' do
95
- should_not eql(other == object)
96
- end
97
- end
98
-
99
- context 'with a different object after coercion' do
100
- let(:other) { nil }
101
-
102
- before do
103
- # declare a private #coerce method
104
- described_class.class_eval do
105
- def coerce(other)
106
- [self.class.new(![nil, false].include?(other)), self]
107
- end
108
- private :coerce
109
- end
110
- end
111
-
112
- it { should be(false) }
113
-
114
- it 'is symmetric' do
115
- should eql(other == object)
116
- end
117
- end
118
-
119
- context 'with a different object' do
120
- let(:other) { described_class.new(false) }
121
-
122
- it { should be(false) }
123
-
124
- it 'is symmetric' do
125
- should eql(other == object)
126
- end
127
- end
128
- end