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 +4 -4
- data/.rubocop.yml +1 -0
- data/README.md +21 -1
- data/lib/sinclair/options/builder.rb +12 -1
- data/lib/sinclair/version.rb +1 -1
- data/spec/integration/readme/sinclair/options_spec.rb +19 -0
- data/spec/lib/sinclair/options_spec.rb +24 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15c8c49649134851cc9f1fb6a92d4ea19ff82cc2e68ce2d09339987b2623a5d4
|
4
|
+
data.tar.gz: def1468dbdf88b1f700edc6fd172cc6dc06d56b9aba07171cb6d7c3a7bcdc32e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcaf42f0c6ee8b2cdb4986e003b487f1f53184d9486c9479477fcfe4fb38550ff9deecc4b3029da563812179152ecee68c379b5673f60eedfb7df9a4f945b30c
|
7
|
+
data.tar.gz: 622f77edaeb7d9b247a15c071ecb80981e82d915124dbeb57851c86153c1790bd301ea7be067b9020281dc9aeecd6cec54ec4403a74972bf7f8d9d89cf444020
|
data/.rubocop.yml
CHANGED
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.
|
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:
|
59
|
+
add_method(option, cached: :full) { value }
|
49
60
|
klass.allowed_options.push(option.to_sym)
|
50
61
|
end
|
51
62
|
end
|
data/lib/sinclair/version.rb
CHANGED
@@ -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.
|
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-
|
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
|