dry-types 1.1.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +378 -206
- data/LICENSE +17 -17
- data/README.md +14 -13
- data/dry-types.gemspec +27 -31
- data/lib/dry/types.rb +7 -11
- data/lib/dry/types/any.rb +2 -2
- data/lib/dry/types/array/member.rb +3 -3
- data/lib/dry/types/builder.rb +5 -1
- data/lib/dry/types/builder_methods.rb +22 -8
- data/lib/dry/types/coercions.rb +6 -0
- data/lib/dry/types/coercions/params.rb +1 -1
- data/lib/dry/types/compiler.rb +2 -2
- data/lib/dry/types/constrained.rb +2 -2
- data/lib/dry/types/constructor.rb +7 -34
- data/lib/dry/types/constructor/function.rb +17 -31
- data/lib/dry/types/core.rb +3 -1
- data/lib/dry/types/decorator.rb +3 -9
- data/lib/dry/types/default.rb +2 -2
- data/lib/dry/types/enum.rb +2 -2
- data/lib/dry/types/errors.rb +5 -5
- data/lib/dry/types/extensions.rb +4 -0
- data/lib/dry/types/extensions/maybe.rb +14 -14
- data/lib/dry/types/extensions/monads.rb +29 -0
- data/lib/dry/types/hash.rb +3 -2
- data/lib/dry/types/lax.rb +2 -5
- data/lib/dry/types/meta.rb +3 -3
- data/lib/dry/types/module.rb +3 -3
- data/lib/dry/types/nominal.rb +1 -1
- data/lib/dry/types/params.rb +6 -0
- data/lib/dry/types/predicate_inferrer.rb +197 -0
- data/lib/dry/types/predicate_registry.rb +34 -0
- data/lib/dry/types/primitive_inferrer.rb +97 -0
- data/lib/dry/types/printer.rb +7 -3
- data/lib/dry/types/result.rb +2 -2
- data/lib/dry/types/schema.rb +23 -2
- data/lib/dry/types/schema/key.rb +16 -3
- data/lib/dry/types/spec/types.rb +14 -1
- data/lib/dry/types/sum.rb +5 -5
- data/lib/dry/types/version.rb +1 -1
- metadata +26 -45
- data/.codeclimate.yml +0 -15
- data/.gitignore +0 -11
- data/.rspec +0 -2
- data/.travis.yml +0 -27
- data/.yardopts +0 -9
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -27
- data/Rakefile +0 -22
- data/benchmarks/hash_schemas.rb +0 -55
- data/benchmarks/lax_schema.rb +0 -15
- data/benchmarks/profile_invalid_input.rb +0 -15
- data/benchmarks/profile_lax_schema_valid.rb +0 -16
- data/benchmarks/profile_valid_input.rb +0 -15
- data/benchmarks/schema_valid_vs_invalid.rb +0 -21
- data/benchmarks/setup.rb +0 -17
data/benchmarks/lax_schema.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'setup'
|
4
|
-
|
5
|
-
schema = Dry::Types['params.hash'].schema(
|
6
|
-
email?: 'string',
|
7
|
-
age?: 'params.integer'
|
8
|
-
).lax
|
9
|
-
|
10
|
-
params = { email: 'jane@doe.org', age: '19' }
|
11
|
-
|
12
|
-
Benchmark.ips do |x|
|
13
|
-
x.report("valid input") { schema.(params) }
|
14
|
-
x.compare!
|
15
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'setup'
|
4
|
-
|
5
|
-
Schema = Dry::Types['params.hash'].schema(
|
6
|
-
email?: 'string',
|
7
|
-
age?: 'coercible.integer'
|
8
|
-
).lax
|
9
|
-
|
10
|
-
ValidInput = { email: 'jane@doe.org', age: '19' }.freeze
|
11
|
-
|
12
|
-
profile do
|
13
|
-
10_000.times do
|
14
|
-
Schema.(ValidInput)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'setup'
|
4
|
-
|
5
|
-
VALID_INPUT = {
|
6
|
-
name: 'John',
|
7
|
-
age: 20,
|
8
|
-
email: 'john@doe.com'
|
9
|
-
}
|
10
|
-
|
11
|
-
INVALID_INPUT = {
|
12
|
-
name: :John,
|
13
|
-
age: '20',
|
14
|
-
email: nil
|
15
|
-
}
|
16
|
-
|
17
|
-
Benchmark.ips do |x|
|
18
|
-
x.report("valid input") { PersonSchema.(VALID_INPUT) }
|
19
|
-
x.report("invalid input") { PersonSchema.(INVALID_INPUT) }
|
20
|
-
x.compare!
|
21
|
-
end
|
data/benchmarks/setup.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'benchmark/ips'
|
4
|
-
require 'hotch'
|
5
|
-
ENV['HOTCH_VIEWER'] ||= 'open'
|
6
|
-
|
7
|
-
require 'dry/types'
|
8
|
-
|
9
|
-
PersonSchema = Dry::Types['hash'].schema(
|
10
|
-
name: 'string',
|
11
|
-
age: 'integer',
|
12
|
-
email: 'string'
|
13
|
-
).lax
|
14
|
-
|
15
|
-
def profile(&block)
|
16
|
-
Hotch(filter: 'Dry', &block)
|
17
|
-
end
|