sinclair 1.6.3 → 1.6.4

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
2
  SHA256:
3
- metadata.gz: e73aaf0289f39dd23b05bbd256c7bbd98de3d5a2a963bddd096315241ad81d6b
4
- data.tar.gz: ed6e16a5b51ef93cc7bd083c6ae304121df91dfc67ac71b8804cc340c63a002a
3
+ metadata.gz: 7c4239fce273eaf2a9dd2f62219833a2dc035230ba115f1369bc881fac00da9a
4
+ data.tar.gz: 45b56a8e12244c9adcf3c328d7d794d0036ded1dcf040d21401406294c139f30
5
5
  SHA512:
6
- metadata.gz: a38a73d5ddca24d0dfacb8c535255a83978f84b0913c940f7eda1e6a5f162fd14c314b063df67d35673c2b83d55fc0d42ed7a8aaa2fbfa7093f0e23e7bef5abc
7
- data.tar.gz: 1bb0387bd0cc01250985b5b000fac058e34a39b37b352cf89a953ab36fef069fda576121ff59ef0d95ab3521cce2879e0940085d95d4ccd95feb1e169d06da47
6
+ metadata.gz: cfb6141258f4d0a62cde59dcfddfa69ad7c875a78c11a080fc2d0b5d6a688fd62fe39c71f3c30229ff01f1c95c12a595c1f35799799c21007f7b518e8f794955
7
+ data.tar.gz: 99ac196abb1272d7c0224e358a90540eb81e8fca869abd36b371e21157b734779914a29946f5bcb951f3b1d12d6638eeda34591f3eac1a1ede08fbc09ea7426e
data/README.md CHANGED
@@ -15,7 +15,7 @@ methods
15
15
 
16
16
  Yard Documentation
17
17
  -------------------
18
- [https://www.rubydoc.info/gems/sinclair/1.6.3](https://www.rubydoc.info/gems/sinclair/1.6.3)
18
+ [https://www.rubydoc.info/gems/sinclair/1.6.4](https://www.rubydoc.info/gems/sinclair/1.6.4)
19
19
 
20
20
  Installation
21
21
  ---------------
@@ -19,6 +19,7 @@ rules:
19
19
  - Sinclair::Configurable#config
20
20
  - Sinclair::Configurable#reset_config
21
21
  - Sinclair::Configurable#configure
22
+ - Sinclair::Options#==
22
23
  - Sinclair::OptionsParser#options
23
24
  - Sinclair::OptionsParser#options_object
24
25
  ReturnTag:
@@ -45,8 +45,6 @@ class Sinclair
45
45
  allowed_options << name.to_sym
46
46
  end
47
47
 
48
- private
49
-
50
48
  # @api private
51
49
  # @private
52
50
  #
@@ -54,24 +52,10 @@ class Sinclair
54
52
  #
55
53
  # @return [Set<Symbol>]
56
54
  def allowed_options
57
- @allowed_options ||= build_allowed_options
55
+ @allowed_options ||= superclass.try(:allowed_options).dup || Set.new
58
56
  end
59
57
 
60
- # @api private
61
- # @private
62
- #
63
- # Build set of allowed options
64
- #
65
- # When class is descendent of {Options}
66
- # a duplication of it's parents allowed_options is
67
- # returned
68
- #
69
- # @return (see allowed_options)
70
- def build_allowed_options
71
- superclass.send(:allowed_options).dup
72
- rescue NoMethodError
73
- Set.new
74
- end
58
+ private
75
59
 
76
60
  # @api public
77
61
  # @!visibility public
@@ -105,6 +89,19 @@ class Sinclair
105
89
  end
106
90
  end
107
91
 
92
+ # returns if other equals to self
93
+ #
94
+ # @param other [Object] object to be compared
95
+ #
96
+ # @return [TrueClass,FalseClass]
97
+ def ==(other)
98
+ return false unless self.class == other.class
99
+
100
+ self.class.allowed_options.all? do |name|
101
+ public_send(name) == other.public_send(name)
102
+ end
103
+ end
104
+
108
105
  private
109
106
 
110
107
  # @private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Sinclair
4
- VERSION = '1.6.3'
4
+ VERSION = '1.6.4'
5
5
  end
@@ -197,6 +197,51 @@ describe Sinclair::Options do
197
197
  end
198
198
  end
199
199
 
200
+ describe '.allowed_options' do
201
+ let(:klass) { Class.new(described_class) }
202
+
203
+ context 'when class has not been changed' do
204
+ it { expect(klass.allowed_options).to be_a(Set) }
205
+ end
206
+
207
+ context 'when initializing with with options' do
208
+ let(:expected) do
209
+ Set.new %i[timeout retries port protocol]
210
+ end
211
+
212
+ before do
213
+ klass.send(
214
+ :with_options,
215
+ :timeout, :retries, port: 443, protocol: 'https'
216
+ )
217
+ end
218
+
219
+ it do
220
+ expect(klass.allowed_options)
221
+ .to eq(expected)
222
+ end
223
+
224
+ context 'when class is descendent' do
225
+ let(:descendent_class) { Class.new(klass) }
226
+ let(:expected) do
227
+ Set.new %i[timeout retries port protocol name]
228
+ end
229
+
230
+ before do
231
+ descendent_class.send(
232
+ :with_options,
233
+ :name
234
+ )
235
+ end
236
+
237
+ it do
238
+ expect(descendent_class.allowed_options)
239
+ .to eq(expected)
240
+ end
241
+ end
242
+ end
243
+ end
244
+
200
245
  describe '#initialize' do
201
246
  let(:klass) { ConnectionOptions }
202
247
 
@@ -309,4 +354,28 @@ describe Sinclair::Options do
309
354
  it { expect(options.protocol).to eq(false) }
310
355
  end
311
356
  end
357
+
358
+ describe '#==' do
359
+ let(:klass) { ConnectionOptions }
360
+
361
+ context 'with black initialization' do
362
+ it do
363
+ expect(klass.new).to eq(klass.new)
364
+ end
365
+ end
366
+
367
+ context 'when initializing with same values' do
368
+ let(:first_option) { klass.new(protocol: nil) }
369
+ let(:second_option) { klass.new(protocol: nil) }
370
+
371
+ it { expect(first_option).to eq(second_option) }
372
+ end
373
+
374
+ context 'when initializing with different values' do
375
+ let(:first_option) { klass.new(protocol: nil) }
376
+ let(:second_option) { klass.new }
377
+
378
+ it { expect(first_option).not_to eq(second_option) }
379
+ end
380
+ end
312
381
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinclair
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarthJee