qonfig 0.9.0 → 0.10.0

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: 5ca1aaa94952636ee2ef114d513d68b4836f9162f02b2296ec0fb3fa16037761
4
- data.tar.gz: afc6d9158a2ce2a3c862987a22c20c922a4025d2025f01d5ca5d591429531c4a
3
+ metadata.gz: e73813f816c3ed07773bfd932c9d4d628688327326463d5d7a2755058acd49bc
4
+ data.tar.gz: 513fe5d381b2cbddddb6e5bc0f10f518b3cae24dce6f8689810600a22698396f
5
5
  SHA512:
6
- metadata.gz: 895e6bfe6c185e71d81f9a8f55740f48e12b2aff55cd3116ae12f9b68423b7726317263f33ab49e85cc670608a159de2efcc91882ec79dd00b40236f2f41d91f
7
- data.tar.gz: 82187c64659aad286d3370e7da6ae8e7506a988a4ff056181df8073aa0039b4bc9210fdaa70cd4a11f27b0fc3c2be26651f96ce42e5fa5c50b1d68739436c42c
6
+ metadata.gz: 1855afada5513df5986bd45b2d4ce8d747f6389886763841ace0b4cd6a2f1b063c69feaff8075da4b803cee23cc335c3b4a6cfa434a328d1d9b43080e7b65b54
7
+ data.tar.gz: 7990a53bd25a8c6d0f78c8daff1453b4e14d2c9b380dde31e813499829d28f9667d8ae30e886a51ea5f8c5d2392d3bef9c23315afd7314a8c54bb008bac77ae1
data/.rubocop.yml CHANGED
@@ -4,7 +4,7 @@ inherit_gem:
4
4
  - lib/rubocop.rspec.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.5.3
7
+ TargetRubyVersion: 2.6.1
8
8
  Include:
9
9
  - lib/**/*.rb
10
10
  - spec/**/*.rb
data/.travis.yml CHANGED
@@ -5,6 +5,7 @@ matrix:
5
5
  - rvm: 2.3.8
6
6
  - rvm: 2.4.5
7
7
  - rvm: 2.5.3
8
+ - rvm: 2.6.1
8
9
  - rvm: ruby-head
9
10
  - rvm: jruby-head
10
11
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.10.0] - 2019-02-26
5
+ ### Added
6
+ - `#slice_value` - get a slice of config options as a hash set and fetch the required value using the given key set;
7
+
4
8
  ## [0.9.0] - 2018-11-28
5
9
  ### Added
6
10
  - `#slice` - get a slice of config options as a hash set (works in a `#dig` manner);
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 Rustam Ibragimov
3
+ Copyright (c) 2018-2019 Rustam Ibragimov
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -22,6 +22,7 @@ require 'qonfig'
22
22
  ## Usage
23
23
 
24
24
  - [Definition and Settings Access](#definition-and-access)
25
+ - [Dynamic value calculation](???)
25
26
  - [Configuration](#configuration)
26
27
  - [Inheritance](#inheritance)
27
28
  - [Composition](#composition)
@@ -98,6 +99,12 @@ config.slice(:vendor_api) # => { 'vendor_api' => { 'host' => 'app_service', 'use
98
99
  config.slice(:vendor_api, :user) # => { 'user' => 'test_user' }
99
100
  config.slice(:project_api) # => Qonfig::UnknownSettingError # (key does not exist)
100
101
  config.slice(:vendor_api, :port) # => Qonfig::UnknownSettingError # (key does not exist)
102
+
103
+ # get value from the slice of setting options using the given key set (and fail when the required key does not exist) (works in slice manner)
104
+ config.slice_value(:vendor_api) # => { 'host' => 'app_service', 'user' => 'test_user' }
105
+ config.slice_value(:vendor_api, :user) # => 'test_user'
106
+ config.slice_value(:project_api) # => Qonfig::UnknownSettingError # (key does not exist)
107
+ config.slice_value(:vendor_api, :port) # => Qonfig::UnknownSettingError # (key does not exist)
101
108
  ```
102
109
 
103
110
  ---
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @api public
4
+ # @since 0.?.0
5
+ class Qonfig::DataSet::Validator
6
+ # TODO: think about validation layer
7
+ end
@@ -104,6 +104,15 @@ module Qonfig
104
104
  thread_safe_access { settings.__slice__(*keys) }
105
105
  end
106
106
 
107
+ # @param keys [Array<String, Symbol>]
108
+ # @return [Hash,Any]
109
+ #
110
+ # @api public
111
+ # @since 0.10.0
112
+ def slice_value(*keys)
113
+ thread_safe_access { settings.__slice_value__(*keys) }
114
+ end
115
+
107
116
  # @return [void]
108
117
  #
109
118
  # @api public
@@ -103,6 +103,15 @@ module Qonfig
103
103
  __lock__.thread_safe_access { __deep_slice__(*keys) }
104
104
  end
105
105
 
106
+ # @param keys [Array<String, Symbol>]
107
+ # @return [Hash, Any]
108
+ #
109
+ # @api private
110
+ # @since 0.10.0
111
+ def __slice_value__(*keys)
112
+ __lock__.thread_safe_access { __deep_slice_value__(*keys) }
113
+ end
114
+
106
115
  # @return [Hash]
107
116
  #
108
117
  # @api private
@@ -318,6 +327,19 @@ module Qonfig
318
327
  end
319
328
  end
320
329
 
330
+ # @param keys [Array<Symbol, String>]
331
+ # @return [Hash]
332
+ #
333
+ # @raise [Qonfig::ArgumentError]
334
+ # @raise [Qonfig::UnknownSettingError]
335
+ #
336
+ # @api private
337
+ # @since 0.1.0
338
+ def __deep_slice_value__(*keys)
339
+ required_key = __indifferently_accessable_option_key__(keys.last)
340
+ __deep_slice__(*keys)[required_key]
341
+ end
342
+
321
343
  # @param options_part [Hash]
322
344
  # @return [Hash]
323
345
  #
@@ -5,5 +5,5 @@ module Qonfig
5
5
  #
6
6
  # @api public
7
7
  # @since 0.1.0
8
- VERSION = '0.9.0'
8
+ VERSION = '0.10.0'
9
9
  end
data/qonfig.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'coveralls', '~> 0.8'
32
32
  spec.add_development_dependency 'simplecov', '~> 0.16'
33
33
  spec.add_development_dependency 'rspec', '~> 3.8'
34
- spec.add_development_dependency 'armitage-rubocop', '~> 0.12'
34
+ spec.add_development_dependency 'armitage-rubocop', '~> 0.21'
35
35
 
36
36
  spec.add_development_dependency 'bundler'
37
37
  spec.add_development_dependency 'rake'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qonfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-28 00:00:00.000000000 Z
11
+ date: 2019-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.12'
61
+ version: '0.21'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.12'
68
+ version: '0.21'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +145,7 @@ files:
145
145
  - lib/qonfig/configurable.rb
146
146
  - lib/qonfig/data_set.rb
147
147
  - lib/qonfig/data_set/class_builder.rb
148
+ - lib/qonfig/data_set/validator.rb
148
149
  - lib/qonfig/dsl.rb
149
150
  - lib/qonfig/error.rb
150
151
  - lib/qonfig/loaders/basic.rb
@@ -179,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
180
  - !ruby/object:Gem::Version
180
181
  version: '0'
181
182
  requirements: []
182
- rubyforge_project:
183
- rubygems_version: 2.7.6
183
+ rubygems_version: 3.0.2
184
184
  signing_key:
185
185
  specification_version: 4
186
186
  summary: Config object