dry-schema 1.13.0 → 1.13.1

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: 9899c8cf36335581b0f5f757c5a2c17d7a542b47138eb6f76dd1f8bda8ed3c65
4
- data.tar.gz: 1d10a271359578fb471a6e6fd477e690f4b11888b936f92242b51c2d143b8f36
3
+ metadata.gz: e1949729f55d95db1df478e3d2bf0077728c2cfaa5a66ac3d6d00bdbaaf55347
4
+ data.tar.gz: 574d9ebd59457187c161730f8b2f232d299ff813fb6af10c680b57ce17c5ee46
5
5
  SHA512:
6
- metadata.gz: f6156af8cad80db7b37a2062079053cddd8d40195d50d2d0db119c4163be1c8105855a1b61bd29de82cd8ee8e96a2329c4346139190d560a8b5c858cf7401b12
7
- data.tar.gz: 9bcdbb0a8feb2127bd170036904007ddc3ec6228b8a888f868e70eb3055aac718ffd5d4ee5734a10618efa545f4ea0bcb102bf760db16fe47049bac57c65b48e
6
+ metadata.gz: 520e01dc0ab8454bb981fcba032d3a1099fb7fad15b7eaf4008a094fae381178ab389b143a83b2f9f46522722aa14498bcf9a85e9708537d773a3b8f07c81635
7
+ data.tar.gz: 6d3c13d9d1c13dd632368fd4a3ff34aaa8fec5573a5001540552eadd3debe413160d54bbc8051822deb029c9bf20ffe301a120dbd97f2a569eac398de767053e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 1.13.1 2023-04-07
4
+
5
+
6
+ ### Fixed
7
+
8
+ - Support sum types of hashes (issue #446 fixed via #457) (@segiddins)
9
+
10
+
11
+ [Compare v1.13.0...v1.13.1](https://github.com/dry-rb/dry-schema/compare/v1.13.0...v1.13.1)
12
+
3
13
  ## 1.13.0 2022-11-24
4
14
 
5
15
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2022 dry-rb team
3
+ Copyright (c) 2015-2023 dry-rb team
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -14,8 +14,8 @@
14
14
 
15
15
  This library officially supports the following Ruby versions:
16
16
 
17
- * MRI `>= 2.7.0`
18
- * jruby `>= 9.3` (postponed until 2.7 is supported)
17
+ * MRI `>= 3.0.0`
18
+ * jruby `>= 9.4` (not tested on CI)
19
19
 
20
20
  ## License
21
21
 
data/dry-schema.gemspec CHANGED
@@ -31,14 +31,14 @@ Gem::Specification.new do |spec|
31
31
  spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-schema"
32
32
  spec.metadata["bug_tracker_uri"] = "https://github.com/dry-rb/dry-schema/issues"
33
33
 
34
- spec.required_ruby_version = ">= 2.7.0"
34
+ spec.required_ruby_version = ">= 2.7"
35
35
 
36
36
  # to update dependencies edit project.yml
37
37
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
38
38
  spec.add_runtime_dependency "dry-configurable", "~> 1.0", ">= 1.0.1"
39
39
  spec.add_runtime_dependency "dry-core", "~> 1.0", "< 2"
40
40
  spec.add_runtime_dependency "dry-initializer", "~> 3.0"
41
- spec.add_runtime_dependency "dry-logic", ">= 1.5", "< 2"
41
+ spec.add_runtime_dependency "dry-logic", ">= 1.4", "< 2"
42
42
  spec.add_runtime_dependency "dry-types", ">= 1.7", "< 2"
43
43
  spec.add_runtime_dependency "zeitwerk", "~> 2.6"
44
44
 
@@ -293,8 +293,8 @@ module Dry
293
293
  # @return [Dry::Types::Safe]
294
294
  #
295
295
  # @api private
296
- def new(**options, &block)
297
- self.class.new(**options, processor_type: processor_type, config: config, &block)
296
+ def new(klass: self.class, **options, &block)
297
+ klass.new(**options, processor_type: processor_type, config: config, &block)
298
298
  end
299
299
 
300
300
  # Set a type for the given key name
@@ -122,7 +122,6 @@ module Dry
122
122
  macro.call(...)
123
123
  end
124
124
  end
125
- ruby2_keywords :schema if respond_to?(:ruby2_keywords, true)
126
125
 
127
126
  # Specify a nested hash with enforced `hash?` type-check
128
127
  #
@@ -137,7 +136,6 @@ module Dry
137
136
  macro.call(...)
138
137
  end
139
138
  end
140
- ruby2_keywords :hash if respond_to?(:ruby2_keywords, true)
141
139
 
142
140
  # Specify predicates that should be applied to each element of an array
143
141
  #
@@ -161,7 +159,6 @@ module Dry
161
159
  macro.value(...)
162
160
  end
163
161
  end
164
- ruby2_keywords :each if respond_to?(:ruby2_keywords, true)
165
162
 
166
163
  # Like `each` but sets `array?` type-check
167
164
  #
@@ -181,7 +178,6 @@ module Dry
181
178
  macro.value(...)
182
179
  end
183
180
  end
184
- ruby2_keywords :array if respond_to?(:ruby2_keywords, true)
185
181
 
186
182
  # Set type spec
187
183
  #
@@ -220,6 +216,8 @@ module Dry
220
216
  end
221
217
 
222
218
  # @api private
219
+ # rubocop: disable Metrics/AbcSize
220
+ # rubocop: disable Metrics/CyclomaticComplexity
223
221
  # rubocop: disable Metrics/PerceivedComplexity
224
222
  def extract_type_spec(args, nullable: false, set_type: true)
225
223
  type_spec = args[0] unless schema_or_predicate?(args[0])
@@ -232,6 +230,10 @@ module Dry
232
230
 
233
231
  if type_spec.is_a?(::Array)
234
232
  type_rule = type_spec.map { |ts| new(chain: false).value(ts) }.reduce(:|)
233
+ elsif type_spec.is_a?(Dry::Types::Sum) && set_type
234
+ type_rule = [type_spec.left, type_spec.right].map { |ts|
235
+ new(klass: Core, chain: false).value(ts)
236
+ }.reduce(:|)
235
237
  else
236
238
  type_predicates = predicate_inferrer[resolved_type]
237
239
 
@@ -249,6 +251,8 @@ module Dry
249
251
  yield(*predicates, type_spec: type_spec, type_rule: nil)
250
252
  end
251
253
  end
254
+ # rubocop: enable Metrics/AbcSize
255
+ # rubocop: enable Metrics/CyclomaticComplexity
252
256
  # rubocop: enable Metrics/PerceivedComplexity
253
257
 
254
258
  # @api private
@@ -26,7 +26,6 @@ module Dry
26
26
  (filter_schema_dsl[name] || filter_schema_dsl.optional(name)).value(...)
27
27
  self
28
28
  end
29
- ruby2_keywords(:filter) if respond_to?(:ruby2_keywords, true)
30
29
 
31
30
  # Coerce macro to a rule
32
31
  #
@@ -13,7 +13,7 @@ module Dry
13
13
  # @api public
14
14
  class YAML < Abstract
15
15
  LOCALE_TOKEN = "%<locale>s"
16
- TOKEN_REGEXP = /%{(\w*)}/.freeze
16
+ TOKEN_REGEXP = /%{(\w*)}/
17
17
  EMPTY_CONTEXT = Object.new.tap { |ctx|
18
18
  def ctx.context
19
19
  binding
@@ -72,6 +72,8 @@ module Dry
72
72
  # Dump result to a hash returning processed and validated data
73
73
  #
74
74
  # @return [Hash]
75
+ #
76
+ # @api private
75
77
  def output
76
78
  path.equal?(Path::EMPTY) ? @output : @output.dig(*path)
77
79
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Schema
5
- VERSION = "1.13.0"
5
+ VERSION = "1.13.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-24 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -84,7 +84,7 @@ dependencies:
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: '1.5'
87
+ version: '1.4'
88
88
  - - "<"
89
89
  - !ruby/object:Gem::Version
90
90
  version: '2'
@@ -94,7 +94,7 @@ dependencies:
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '1.5'
97
+ version: '1.4'
98
98
  - - "<"
99
99
  - !ruby/object:Gem::Version
100
100
  version: '2'
@@ -274,14 +274,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
274
  requirements:
275
275
  - - ">="
276
276
  - !ruby/object:Gem::Version
277
- version: 2.7.0
277
+ version: '2.7'
278
278
  required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  requirements:
280
280
  - - ">="
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.1.6
284
+ rubygems_version: 3.3.26
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: Coercion and validation for data structures