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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c7ba5d07df3cd10ee6e98585c8b11179a9076277
4
- data.tar.gz: 3086f4ea1f236e744771245993917855eff749e2
2
+ SHA256:
3
+ metadata.gz: db365c0a1ff2108322ecba38a9b6e9650f6240d49a88c3c1fe4376edb2a9a2dc
4
+ data.tar.gz: 2a1b329d98b419480521067bb372c26d1821de2b93b34f643dbd70c51146ed73
5
5
  SHA512:
6
- metadata.gz: 939304f1c55c7a9efcd26b0d2b9aa06f97b4b0941d6f1df24bb714ed5e4dd1c4d9424c02b932c05a61a3b7e4c3b4b12a3283c5f9c0c3790e4a9cb564154f087b
7
- data.tar.gz: 21b3fa39b3701e4e28d42c9798c2cb64a70740304e5e5857afa09e7af39a0207337552ebe73107f2018c341242488fcf9de3de155e2878241fe8f4afc8a8ffc0
6
+ metadata.gz: 86cf6cdc35553c7ff6f6733c06cff72af7a34975f3e76f76f12336e482e4b8f5b393a20eb6e173b3f35755f16432ac8ac8764a2f4f34fab0e69a740374a82835
7
+ data.tar.gz: 5367d997b5590aa15ab14e72d1188f540bcd5bc19073fa771b9b5b440775ca8bb90a5cd36fce85dc49a7067e1c2045152e9cb921de95d6562b696b1057f7b4a5
@@ -1,18 +1,15 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.2
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
3
4
  Style/Documentation:
4
5
  Enabled: false
5
- Exclude:
6
- - lib/attributor/flatpack/version.rb
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
- Metrics/LineLength:
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
@@ -1 +1 @@
1
- 2.4.5
1
+ 2.7.1
@@ -1,5 +1,9 @@
1
1
  # attributor-flatpack changelog
2
2
 
3
+ ## 1.4
4
+
5
+ - Respect `allow_extra: true` option when validating.
6
+
3
7
  ## 1.3
4
8
 
5
9
  - Add `Attributor::Flatpack::MultilineString` type to handle multiline strings from environment variables.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in attributor-flatpack.gemspec
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
- watch(/.+\.rb$/)
47
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -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', '~> 1.11'
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', '~> 10.0'
32
- spec.add_development_dependency 'rspec', '~> 3.0'
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  gem 'attributor-flatpack', path: '../'
3
5
  gem 'benchmark-ips'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  Bundler.require
3
5
 
@@ -26,6 +28,7 @@ ConfigStruct = Struct.new(:home, :path)
26
28
 
27
29
  class Poro
28
30
  attr_accessor :home, :path
31
+
29
32
  def initialize(home, path)
30
33
  @home = home
31
34
  @path = path
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'attributor/flatpack'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pp'
2
4
  require 'bundler/setup'
3
5
  require 'pry'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'attributor'
2
4
 
3
5
  require 'attributor/flatpack/version'
@@ -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 = '_'.freeze
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.to_s}#{self.class.separator}?(.*)/i
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Sometimes a multline string when read in by ruby has escaped newlines, sometimes not.
2
4
  # This type will remove any escaping of newline from a string.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Attributor
2
4
  module Flatpack
3
5
  class UndefinedKey < Attributor::LoadError
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Attributor
2
4
  module Flatpack
3
- VERSION = '1.3.0'.freeze
5
+ VERSION = '1.4.0'
4
6
  end
5
7
  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.3.0
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: 2019-01-17 00:00:00.000000000 Z
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: '1.11'
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: '1.11'
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: '10.0'
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: '10.0'
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: '3.0'
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: '3.0'
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
- rubyforge_project:
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