sinclair 1.6.4 → 1.6.5

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: 7c4239fce273eaf2a9dd2f62219833a2dc035230ba115f1369bc881fac00da9a
4
- data.tar.gz: 45b56a8e12244c9adcf3c328d7d794d0036ded1dcf040d21401406294c139f30
3
+ metadata.gz: 82dceb39442cd887b9188fd91bc0b225aedae2504e180a61ba3f5ec6d18b6de3
4
+ data.tar.gz: '09dafbb7642c1021c47c7ab4db0732f5f514c881d61adba3a7d1cc3c6ac620ca'
5
5
  SHA512:
6
- metadata.gz: cfb6141258f4d0a62cde59dcfddfa69ad7c875a78c11a080fc2d0b5d6a688fd62fe39c71f3c30229ff01f1c95c12a595c1f35799799c21007f7b518e8f794955
7
- data.tar.gz: 99ac196abb1272d7c0224e358a90540eb81e8fca869abd36b371e21157b734779914a29946f5bcb951f3b1d12d6638eeda34591f3eac1a1ede08fbc09ea7426e
6
+ metadata.gz: 794343fe9272e52bd35a9b0a23c3b2e5e64d45a291f29b75d94335b6ff0f65e6d117585ca75562e9fad94b186d5cc1d66126caec9df3d06a4497cee5d6fe3fa8
7
+ data.tar.gz: ac6e7f371357b46111d9eceaf0b5d6a06816d1bd537665d4824d96713762e59ce7eb986048ac18d4219d9fd860e165f200c8d5cbfea34e62f04a0d7e7c641959
@@ -1,8 +1,24 @@
1
1
  version: 2
2
+ workflows:
3
+ version: 2
4
+ test-and-build:
5
+ jobs:
6
+ - test:
7
+ filters:
8
+ tags:
9
+ only: /.*/
10
+ - build-and-release:
11
+ requires: [test]
12
+ filters:
13
+ tags:
14
+ only: /\d+\.\d+\.\d+/
15
+ branches:
16
+ only:
17
+ - master
2
18
  jobs:
3
- build:
19
+ test:
4
20
  docker:
5
- - image: darthjee/circleci_ruby_gems:0.5.0
21
+ - image: darthjee/circleci_ruby_gems:0.5.3
6
22
  environment:
7
23
  PROJECT: sinclair
8
24
  steps:
@@ -34,3 +50,22 @@ jobs:
34
50
  - run:
35
51
  name: Check unit tests
36
52
  command: check_specs
53
+ build-and-release:
54
+ docker:
55
+ - image: darthjee/circleci_ruby_gems:0.5.3
56
+ environment:
57
+ PROJECT: sinclair
58
+ steps:
59
+ - checkout
60
+ - run:
61
+ name: Bundle Install
62
+ command: bundle install
63
+ - run:
64
+ name: Signin
65
+ command: build_gem.sh signin
66
+ - run:
67
+ name: Build Gem
68
+ command: build_gem.sh build
69
+ - run:
70
+ name: Push Gem
71
+ command: build_gem.sh push
data/Dockerfile CHANGED
@@ -1,6 +1,6 @@
1
- FROM darthjee/scripts:0.1.7 as scripts
1
+ FROM darthjee/scripts:0.1.8 as scripts
2
2
 
3
- FROM darthjee/ruby_gems:0.5.0 as base
3
+ FROM darthjee/ruby_gems:0.5.3 as base
4
4
 
5
5
  COPY --chown=app:app ./ /home/app/app/
6
6
 
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.4](https://www.rubydoc.info/gems/sinclair/1.6.4)
18
+ [https://www.rubydoc.info/gems/sinclair/1.6.5](https://www.rubydoc.info/gems/sinclair/1.6.5)
19
19
 
20
20
  Installation
21
21
  ---------------
@@ -409,7 +409,7 @@ Configurations can also be done through custom classes
409
409
  Client.config.url # returns 'http://interstella.com:8080'
410
410
  ```
411
411
 
412
- ### Sinclair::Settable
412
+ ### Sinclair::EnvSettable
413
413
 
414
414
  Settable allows classes to extract configuration from environments through
415
415
  a simple meta-programable way
@@ -89,6 +89,30 @@ class Sinclair
89
89
  end
90
90
  end
91
91
 
92
+ # Returns a hash with the current options
93
+ #
94
+ # @return [Hash]
95
+ #
96
+ # @example
97
+ # class ConnectionOptions < Sinclair::Options
98
+ # with_options :timeout, :retries, port: 443, protocol: 'https'
99
+ # end
100
+ #
101
+ # options = ConnectionOptions.new(retries: 10, port: 8080)
102
+ #
103
+ # options.to_h # returns
104
+ # # {
105
+ # # port: 8080,
106
+ # # retries: 10,
107
+ # # timeout: nil,
108
+ # # protocol: 'https'
109
+ # # }
110
+ def to_h
111
+ self.class.allowed_options.inject({}) do |hash, option|
112
+ hash.merge(option => public_send(option))
113
+ end
114
+ end
115
+
92
116
  # returns if other equals to self
93
117
  #
94
118
  # @param other [Object] object to be compared
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Sinclair
4
- VERSION = '1.6.4'
4
+ VERSION = '1.6.5'
5
5
  end
@@ -4,13 +4,24 @@ require 'spec_helper'
4
4
 
5
5
  describe Sinclair::Options do
6
6
  describe 'yard' do
7
- it 'creates options object' do
8
- options = ConnectionOptions.new(retries: 10, port: 8080)
7
+ describe 'usage' do
8
+ it 'creates options object' do
9
+ options = ConnectionOptions.new(retries: 10, port: 8080)
9
10
 
10
- expect(options.timeout).to be_nil
11
- expect(options.retries).to eq(10)
12
- expect(options.port).to eq(8080)
13
- expect(options.protocol).to eq('https')
11
+ expect(options.timeout).to be_nil
12
+ expect(options.retries).to eq(10)
13
+ expect(options.port).to eq(8080)
14
+ expect(options.protocol).to eq('https')
15
+ end
16
+ end
17
+
18
+ describe '#to_h' do
19
+ it 'returns options hash' do
20
+ options = ConnectionOptions.new(retries: 10, port: 8080)
21
+
22
+ expect(options.to_h)
23
+ .to eq({ port: 8080, retries: 10, timeout: nil, protocol: 'https' })
24
+ end
14
25
  end
15
26
  end
16
27
  end
@@ -355,6 +355,44 @@ describe Sinclair::Options do
355
355
  end
356
356
  end
357
357
 
358
+ describe '#to_h' do
359
+ let(:klass) { Class.new(described_class) }
360
+
361
+ context 'without defined options' do
362
+ it { expect(options.to_h).to be_a(Hash) }
363
+
364
+ it { expect(options.to_h).to be_empty }
365
+ end
366
+
367
+ context 'with defined options' do
368
+ before do
369
+ klass.send(:with_options, :timeout, retries: 10, 'protocol' => 'https')
370
+ end
371
+
372
+ it { expect(options.to_h).to be_a(Hash) }
373
+
374
+ it { expect(options.to_h).not_to be_empty }
375
+
376
+ it do
377
+ expect(options.to_h)
378
+ .to eq(timeout: nil, retries: 10, protocol: 'https')
379
+ end
380
+
381
+ context 'when initialized with values' do
382
+ subject(:options) { klass.new(retries: 20, timeout: 5) }
383
+
384
+ it { expect(options.to_h).to be_a(Hash) }
385
+
386
+ it { expect(options.to_h).not_to be_empty }
387
+
388
+ it 'uses values from initialization' do
389
+ expect(options.to_h)
390
+ .to eq(timeout: 5, retries: 20, protocol: 'https')
391
+ end
392
+ end
393
+ end
394
+ end
395
+
358
396
  describe '#==' do
359
397
  let(:klass) { ConnectionOptions }
360
398
 
@@ -365,7 +403,7 @@ describe Sinclair::Options do
365
403
  end
366
404
 
367
405
  context 'when initializing with same values' do
368
- let(:first_option) { klass.new(protocol: nil) }
406
+ let(:first_option) { klass.new(protocol: nil) }
369
407
  let(:second_option) { klass.new(protocol: nil) }
370
408
 
371
409
  it { expect(first_option).to eq(second_option) }
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
4
+ version: 1.6.5
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-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport