attributor-flatpack 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +9 -8
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/Guardfile +6 -4
- data/Rakefile +2 -0
- data/attributor-flatpack.gemspec +5 -3
- data/benchmark/Gemfile +2 -0
- data/benchmark/bench.rb +3 -0
- data/bin/console +1 -0
- data/examples/sample_config.rb +2 -0
- data/lib/attributor/flatpack.rb +2 -0
- data/lib/attributor/flatpack/config.rb +17 -3
- data/lib/attributor/flatpack/config_dsl_compiler.rb +3 -0
- data/lib/attributor/flatpack/types/multiline_string.rb +2 -0
- data/lib/attributor/flatpack/undefined_key.rb +2 -0
- data/lib/attributor/flatpack/version.rb +3 -1
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db365c0a1ff2108322ecba38a9b6e9650f6240d49a88c3c1fe4376edb2a9a2dc
|
4
|
+
data.tar.gz: 2a1b329d98b419480521067bb372c26d1821de2b93b34f643dbd70c51146ed73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86cf6cdc35553c7ff6f6733c06cff72af7a34975f3e76f76f12336e482e4b8f5b393a20eb6e173b3f35755f16432ac8ac8764a2f4f34fab0e69a740374a82835
|
7
|
+
data.tar.gz: 5367d997b5590aa15ab14e72d1188f540bcd5bc19073fa771b9b5b440775ca8bb90a5cd36fce85dc49a7067e1c2045152e9cb921de95d6562b696b1057f7b4a5
|
data/.rubocop.yml
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
3
4
|
Style/Documentation:
|
4
5
|
Enabled: false
|
5
|
-
|
6
|
-
|
7
|
-
- lib/attributor/flatpack.rb
|
8
|
-
- lib/attributor/flatpack/config.rb
|
9
|
-
- lib/attributor/flatpack/config_dsl_compiler.rb
|
10
|
-
- lib/attributor/flatpack/undefined_key.rb
|
6
|
+
Metrics/AbcSize:
|
7
|
+
Max: 20
|
11
8
|
Metrics/MethodLength:
|
12
9
|
Enabled: false
|
13
10
|
Metrics/ClassLength:
|
14
11
|
Enabled: false
|
15
|
-
|
12
|
+
Layout/LineLength:
|
16
13
|
Max: 160
|
17
14
|
Exclude:
|
18
15
|
- "spec/**/*.rb"
|
@@ -23,3 +20,7 @@ Style/DoubleNegation:
|
|
23
20
|
Metrics/BlockLength:
|
24
21
|
Exclude:
|
25
22
|
- spec/**/*.rb
|
23
|
+
Style/RedundantFetchBlock:
|
24
|
+
Enabled: false
|
25
|
+
Style/HashEachMethods:
|
26
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.1
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# A sample Guardfile
|
2
4
|
# More info at https://github.com/guard/guard#readme
|
3
5
|
|
@@ -42,8 +44,8 @@ group :red_green_refactor, halt_on_fail: true do
|
|
42
44
|
dsl.watch_spec_files_for(ruby.lib_files)
|
43
45
|
end
|
44
46
|
|
45
|
-
guard :rubocop do
|
46
|
-
|
47
|
-
|
48
|
-
end
|
47
|
+
# guard :rubocop do
|
48
|
+
# watch(/.+\.rb$/)
|
49
|
+
# watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
50
|
+
# end
|
49
51
|
end
|
data/Rakefile
CHANGED
data/attributor-flatpack.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'attributor/flatpack/version'
|
@@ -20,7 +22,7 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
20
22
|
spec.require_paths = ['lib']
|
21
23
|
|
22
24
|
spec.add_dependency 'attributor', '>= 5'
|
23
|
-
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'bundler'
|
24
26
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
25
27
|
spec.add_development_dependency 'fuubar', '~> 2'
|
26
28
|
spec.add_development_dependency 'guard'
|
@@ -28,8 +30,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
28
30
|
spec.add_development_dependency 'guard-rubocop'
|
29
31
|
spec.add_development_dependency 'pry'
|
30
32
|
spec.add_development_dependency 'pry-byebug'
|
31
|
-
spec.add_development_dependency 'rake'
|
32
|
-
spec.add_development_dependency 'rspec'
|
33
|
+
spec.add_development_dependency 'rake'
|
34
|
+
spec.add_development_dependency 'rspec'
|
33
35
|
spec.add_development_dependency 'rspec-its'
|
34
36
|
spec.add_development_dependency 'simplecov'
|
35
37
|
end
|
data/benchmark/Gemfile
CHANGED
data/benchmark/bench.rb
CHANGED
data/bin/console
CHANGED
data/examples/sample_config.rb
CHANGED
data/lib/attributor/flatpack.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Attributor
|
2
4
|
module Flatpack
|
3
5
|
class Config < Attributor::Hash
|
4
|
-
@separator = '_'
|
6
|
+
@separator = '_'
|
5
7
|
@key_type = Symbol
|
6
8
|
|
7
9
|
class << self
|
@@ -19,6 +21,7 @@ module Attributor
|
|
19
21
|
@separator = sep
|
20
22
|
end
|
21
23
|
klass.options[:dsl_compiler] = ConfigDSLCompiler
|
24
|
+
klass.options[:allow_extra] = true
|
22
25
|
end
|
23
26
|
|
24
27
|
def self.from_hash(object, _context, **_opts)
|
@@ -118,7 +121,7 @@ module Attributor
|
|
118
121
|
end
|
119
122
|
|
120
123
|
def subselect(prefix)
|
121
|
-
prefix_match = /^#{prefix
|
124
|
+
prefix_match = /^#{prefix}#{self.class.separator}?(.*)/i
|
122
125
|
|
123
126
|
selected = @raw.collect do |(k, v)|
|
124
127
|
if (match = prefix_match.match(k))
|
@@ -148,7 +151,8 @@ module Attributor
|
|
148
151
|
# shamelessly copied from Attributor::Model's #validate :(
|
149
152
|
def validate(context = Attributor::DEFAULT_ROOT_CONTEXT)
|
150
153
|
self.validate_attributes(context) +
|
151
|
-
self.validate_requirements(context)
|
154
|
+
self.validate_requirements(context) +
|
155
|
+
self.validate_keys(context)
|
152
156
|
end
|
153
157
|
|
154
158
|
def validate_attributes(context)
|
@@ -165,6 +169,16 @@ module Attributor
|
|
165
169
|
end
|
166
170
|
end
|
167
171
|
|
172
|
+
def validate_keys(context)
|
173
|
+
return [] if self.class.options[:allow_extra]
|
174
|
+
|
175
|
+
errors = (@raw.keys.collect(&:to_s) - self.class.keys.keys.collect(&:to_s)).collect do |extra_key|
|
176
|
+
"Unknown key received: #{extra_key.inspect} for #{Attributor.humanize_context(context)}"
|
177
|
+
end
|
178
|
+
|
179
|
+
errors
|
180
|
+
end
|
181
|
+
|
168
182
|
def pretty_print(context: [])
|
169
183
|
self.collect do |k, v|
|
170
184
|
sub_context = context + [k]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Attributor
|
2
4
|
module Flatpack
|
3
5
|
class ConfigDSLCompiler < Attributor::HashDSLCompiler
|
@@ -10,6 +12,7 @@ module Attributor
|
|
10
12
|
if attr_type.nil? && block
|
11
13
|
sep = target.separator
|
12
14
|
# Ensure class for subkeys uses the same separator as the parent
|
15
|
+
opts[:allow_extra] = options[:allow_extra]
|
13
16
|
attr_type = ::Class.new(Attributor::Flatpack::Config) do
|
14
17
|
separator sep
|
15
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attributor-flatpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dane Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attributor
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: codeclimate-test-reporter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,30 +140,30 @@ dependencies:
|
|
140
140
|
name: rake
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - "
|
143
|
+
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '0'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - "
|
150
|
+
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rspec-its
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -243,8 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
- !ruby/object:Gem::Version
|
244
244
|
version: '0'
|
245
245
|
requirements: []
|
246
|
-
|
247
|
-
rubygems_version: 2.6.14.3
|
246
|
+
rubygems_version: 3.1.2
|
248
247
|
signing_key:
|
249
248
|
specification_version: 4
|
250
249
|
summary: Attributor type for loading configuration data
|