sinclair 1.6.1 → 1.6.2

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: a9873a31c5a1ab56553a834bb0acdae13abeb3189b19a79789911d914c72f52c
4
- data.tar.gz: cb209f36a4bd60319e6133e6526a4145a58649bc78a2fd68632e63ef0c157255
3
+ metadata.gz: 15c8c49649134851cc9f1fb6a92d4ea19ff82cc2e68ce2d09339987b2623a5d4
4
+ data.tar.gz: def1468dbdf88b1f700edc6fd172cc6dc06d56b9aba07171cb6d7c3a7bcdc32e
5
5
  SHA512:
6
- metadata.gz: 8cb67cbeb1032f090809daaebb92f57e9f3bb5db023e413f3101aa79415f319089ef22080a9086772c37ba03870553825be651c6ed1568cb21d9f39db398e47b
7
- data.tar.gz: 2852f036aec1df4ecdd7be65497c83389fd481aecf0e9783f55258646fbb8e18d064e1cfa23b0b8f901e4bfa8a1e4b33ac9b114a2ebb5e8f268b945e9d37ba24
6
+ metadata.gz: fcaf42f0c6ee8b2cdb4986e003b487f1f53184d9486c9479477fcfe4fb38550ff9deecc4b3029da563812179152ecee68c379b5673f60eedfb7df9a4f945b30c
7
+ data.tar.gz: 622f77edaeb7d9b247a15c071ecb80981e82d915124dbeb57851c86153c1790bd301ea7be067b9020281dc9aeecd6cec54ec4403a74972bf7f8d9d89cf444020
@@ -28,6 +28,7 @@ RSpec/DescribedClass:
28
28
  RSpec/ExampleLength:
29
29
  Exclude:
30
30
  - 'spec/integration/yard/**/*_spec.rb'
31
+ - 'spec/integration/readme/**/*_spec.rb'
31
32
 
32
33
  RSpec/MultipleExpectations:
33
34
  Exclude:
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.1](https://www.rubydoc.info/gems/sinclair/1.6.1)
18
+ [https://www.rubydoc.info/gems/sinclair/1.6.2](https://www.rubydoc.info/gems/sinclair/1.6.2)
19
19
 
20
20
  Installation
21
21
  ---------------
@@ -446,6 +446,25 @@ a simple meta-programable way
446
446
  ServiceClient.default # returns #<ServiceClient:0x0000556fa1b366e8 @username="my-login", @password=nil, @port=80, @hostname="host.com">'
447
447
  ```
448
448
 
449
+ ### Sinclair::Options
450
+ Options allows projects to have an easy to configure option object
451
+
452
+ ```ruby
453
+ class ConnectionOptions < Sinclair::Options
454
+ with_options :timeout, :retries, port: 443, protocol: 'https'
455
+ end
456
+
457
+ options = ConnectionOptions.new(
458
+ timeout: 10,
459
+ protocol: 'http'
460
+ )
461
+
462
+ options.timeout # returns 10
463
+ options.retries # returns nil
464
+ options.protocol # returns 'http'
465
+ options.port # returns 443
466
+ ```
467
+
449
468
  RSspec matcher
450
469
  ---------------
451
470
 
@@ -529,3 +548,4 @@ Projects Using
529
548
  ---------------
530
549
 
531
550
  - [Arstotzka](https://github.com/darthjee/arstotzka)
551
+ - [Azeroth](https://github.com/darthjee/azeroth)
@@ -25,8 +25,19 @@ class Sinclair
25
25
  super(klass)
26
26
 
27
27
  @attributes = Sinclair::InputHash.input_hash(*options)
28
+ end
28
29
 
30
+ # Finish building options
31
+ #
32
+ # Add options to allowed options
33
+ # and adds all methods
34
+ #
35
+ # @see Sinclair#build
36
+ # @return (see Sinclair#build)
37
+ def build
29
38
  add_all_methods
39
+
40
+ super
30
41
  end
31
42
 
32
43
  private
@@ -45,7 +56,7 @@ class Sinclair
45
56
  # @return [Array<MethodDefinition>]
46
57
  def add_all_methods
47
58
  attributes.each do |option, value|
48
- add_method(option, cached: true) { value }
59
+ add_method(option, cached: :full) { value }
49
60
  klass.allowed_options.push(option.to_sym)
50
61
  end
51
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Sinclair
4
- VERSION = '1.6.1'
4
+ VERSION = '1.6.2'
5
5
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Sinclair::Options do
6
+ describe 'readme' do
7
+ it 'creates options object' do
8
+ options = ConnectionOptions.new(
9
+ timeout: 10,
10
+ protocol: 'http'
11
+ )
12
+
13
+ expect(options.timeout).to eq(10)
14
+ expect(options.retries).to eq(nil)
15
+ expect(options.protocol).to eq('http')
16
+ expect(options.port).to eq(443)
17
+ end
18
+ end
19
+ end
@@ -169,6 +169,30 @@ describe Sinclair::Options do
169
169
  expect { klass.new('timeout' => 20, retries: 30) }
170
170
  .not_to raise_error
171
171
  end
172
+
173
+ context 'when calling the method' do
174
+ let(:options) { klass.new('timeout' => 20, retries: 30) }
175
+
176
+ it 'sets value of string key' do
177
+ expect(options.timeout).to eq(20)
178
+ end
179
+
180
+ it 'sets value of symbol key' do
181
+ expect(options.retries).to eq(30)
182
+ end
183
+ end
184
+ end
185
+
186
+ context 'when overriding values with nil' do
187
+ let(:options) { klass.new(protocol: nil) }
188
+
189
+ it { expect(options.protocol).to be_nil }
190
+ end
191
+
192
+ context 'when overriding values with false' do
193
+ let(:options) { klass.new(protocol: false) }
194
+
195
+ it { expect(options.protocol).to eq(false) }
172
196
  end
173
197
  end
174
198
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinclair
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DarthJee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-03 00:00:00.000000000 Z
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -309,6 +309,7 @@ files:
309
309
  - spec/integration/readme/sinclair/configurable_spec.rb
310
310
  - spec/integration/readme/sinclair/env_settable_spec.rb
311
311
  - spec/integration/readme/sinclair/matchers_spec.rb
312
+ - spec/integration/readme/sinclair/options_spec.rb
312
313
  - spec/integration/readme/sinclair_spec.rb
313
314
  - spec/integration/yard/my_builder_spec.rb
314
315
  - spec/integration/yard/sinclair/config_builder_spec.rb