Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package rubygem-dry-types for
openSUSE:Factory checked in at 2022-10-30 18:28:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-dry-types (Old)
and /work/SRC/openSUSE:Factory/.rubygem-dry-types.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-dry-types"
Sun Oct 30 18:28:48 2022 rev:3 rq:1032139 version:1.6.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-dry-types/rubygem-dry-types.changes
2021-07-02 13:28:33.772250457 +0200
+++
/work/SRC/openSUSE:Factory/.rubygem-dry-types.new.2275/rubygem-dry-types.changes
2022-10-30 18:28:59.282433686 +0100
@@ -1,0 +2,26 @@
+Fri Oct 28 04:55:43 UTC 2022 - Stephan Kulow <[email protected]>
+
+updated to version 1.6.1
+ see installed CHANGELOG.md
+
+ ## 1.6.1 2022-10-15
+
+
+ ### Changed
+
+ - Fix issues with internal const_missing and Inflector/Module constants
(@flash-gordon + @solnic)
+
+ [Compare
v1.6.0...v1.6.1](https://github.com/dry-rb/dry-types/compare/v1.6.0...v1.6.1)
+
+ ## 1.6.0 2022-10-15
+
+
+ ### Changed
+
+ - Optimize `PredicateRegistry` for Ruby 2.7+ (see #420 for more details)
(@casperisfine)
+ - Use zeitwerk for auto-loading (@flash-gordon)
+
+ [Compare
v1.5.1...v1.6.0](https://github.com/dry-rb/dry-types/compare/v1.5.1...v1.6.0)
+
+
+-------------------------------------------------------------------
Old:
----
dry-types-1.5.1.gem
New:
----
dry-types-1.6.1.gem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ rubygem-dry-types.spec ++++++
--- /var/tmp/diff_new_pack.RwdSMb/_old 2022-10-30 18:29:00.974442828 +0100
+++ /var/tmp/diff_new_pack.RwdSMb/_new 2022-10-30 18:29:00.978442849 +0100
@@ -1,7 +1,7 @@
#
# spec file for package rubygem-dry-types
#
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -24,12 +24,12 @@
#
Name: rubygem-dry-types
-Version: 1.5.1
+Version: 1.6.1
Release: 0
%define mod_name dry-types
%define mod_full_name %{mod_name}-%{version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: %{ruby >= 2.5.0}
+BuildRequires: %{ruby >= 2.7.0}
BuildRequires: %{rubygem gem2rpm}
BuildRequires: ruby-macros >= 5
URL: https://dry-rb.org/gems/dry-types
++++++ dry-types-1.5.1.gem -> dry-types-1.6.1.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md 2021-02-16 12:25:57.000000000 +0100
+++ new/CHANGELOG.md 2022-10-15 09:53:02.000000000 +0200
@@ -1,5 +1,24 @@
<!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
+## 1.6.1 2022-10-15
+
+
+### Changed
+
+- Fix issues with internal const_missing and Inflector/Module constants
(@flash-gordon + @solnic)
+
+[Compare
v1.6.0...v1.6.1](https://github.com/dry-rb/dry-types/compare/v1.6.0...v1.6.1)
+
+## 1.6.0 2022-10-15
+
+
+### Changed
+
+- Optimize `PredicateRegistry` for Ruby 2.7+ (see #420 for more details)
(@casperisfine)
+- Use zeitwerk for auto-loading (@flash-gordon)
+
+[Compare
v1.5.1...v1.6.0](https://github.com/dry-rb/dry-types/compare/v1.5.1...v1.6.0)
+
## 1.5.1 2021-02-16
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/LICENSE new/LICENSE
--- old/LICENSE 2021-02-16 12:25:57.000000000 +0100
+++ new/LICENSE 2022-10-15 09:53:02.000000000 +0200
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2015-2021 dry-rb team
+Copyright (c) 2015-2022 dry-rb team
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md 2021-02-16 12:25:57.000000000 +0100
+++ new/README.md 2022-10-15 09:53:02.000000000 +0200
@@ -1,3 +1,4 @@
+<!--- this file is synced from dry-rb/template-gem project -->
[gem]: https://rubygems.org/gems/dry-types
[actions]: https://github.com/dry-rb/dry-types/actions
[codacy]: https://www.codacy.com/gh/dry-rb/dry-types
@@ -10,19 +11,19 @@
[][actions]
[][codacy]
[][codacy]
-[][inchpages]
+[][inchpages]
## Links
-* [User documentation](http://dry-rb.org/gems/dry-types)
+* [User documentation](https://dry-rb.org/gems/dry-types)
* [API documentation](http://rubydoc.info/gems/dry-types)
## Supported Ruby versions
This library officially supports the following Ruby versions:
-* MRI >= `2.5`
-* jruby >= `9.2`
+* MRI `>= 2.7.0`
+* jruby `>= 9.3` (postponed until 2.7 is supported)
## License
Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/dry-types.gemspec new/dry-types.gemspec
--- old/dry-types.gemspec 2021-02-16 12:25:57.000000000 +0100
+++ new/dry-types.gemspec 2022-10-15 09:53:02.000000000 +0200
@@ -1,38 +1,40 @@
# frozen_string_literal: true
-# this file is managed by dry-rb/devtools project
-lib = File.expand_path('lib', __dir__)
+# this file is synced from dry-rb/template-gem project
+
+lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'dry/types/version'
+require "dry/types/version"
Gem::Specification.new do |spec|
- spec.name = 'dry-types'
+ spec.name = "dry-types"
spec.authors = ["Piotr Solnica"]
spec.email = ["[email protected]"]
- spec.license = 'MIT'
+ spec.license = "MIT"
spec.version = Dry::Types::VERSION.dup
spec.summary = "Type system for Ruby supporting coercions, constraints
and complex types like structs, value objects, enums etc"
spec.description = spec.summary
- spec.homepage = 'https://dry-rb.org/gems/dry-types'
+ spec.homepage = "https://dry-rb.org/gems/dry-types"
spec.files = Dir["CHANGELOG.md", "LICENSE", "README.md",
"dry-types.gemspec", "lib/**/*"]
- spec.bindir = 'bin'
+ spec.bindir = "bin"
spec.executables = []
- spec.require_paths = ['lib']
+ spec.require_paths = ["lib"]
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
- spec.metadata['changelog_uri'] =
'https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md'
- spec.metadata['source_code_uri'] = 'https://github.com/dry-rb/dry-types'
- spec.metadata['bug_tracker_uri'] =
'https://github.com/dry-rb/dry-types/issues'
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
+ spec.metadata["changelog_uri"] =
"https://github.com/dry-rb/dry-types/blob/main/CHANGELOG.md"
+ spec.metadata["source_code_uri"] = "https://github.com/dry-rb/dry-types"
+ spec.metadata["bug_tracker_uri"] =
"https://github.com/dry-rb/dry-types/issues"
- spec.required_ruby_version = ">= 2.5.0"
+ spec.required_ruby_version = ">= 2.7.0"
# to update dependencies edit project.yml
spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
spec.add_runtime_dependency "dry-container", "~> 0.3"
- spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
+ spec.add_runtime_dependency "dry-core", "~> 0.9", ">= 0.9"
spec.add_runtime_dependency "dry-inflector", "~> 0.1", ">= 0.1.2"
- spec.add_runtime_dependency "dry-logic", "~> 1.0", ">= 1.0.2"
+ spec.add_runtime_dependency "dry-logic", "~> 1.3", ">= 1.3"
+ spec.add_runtime_dependency "zeitwerk", "~> 2.6"
spec.add_development_dependency "bundler"
spec.add_development_dependency "dry-monads", "~> 1.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/array/constructor.rb
new/lib/dry/types/array/constructor.rb
--- old/lib/dry/types/array/constructor.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/array/constructor.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/constructor"
-
module Dry
module Types
# @api public
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/array/member.rb
new/lib/dry/types/array/member.rb
--- old/lib/dry/types/array/member.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/array/member.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/array/constructor"
-
module Dry
module Types
class Array < Nominal
@@ -72,7 +70,7 @@
# @return [Result,Logic::Result]
#
# @api public
- def try(input, &block)
+ def try(input, &block) # rubocop:disable Metrics/PerceivedComplexity
if primitive?(input)
output = []
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/array.rb new/lib/dry/types/array.rb
--- old/lib/dry/types/array.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/array.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require "dry/types/array/member"
-require "dry/types/array/constructor"
-
module Dry
module Types
# Array type can be used to define an array with optional member type
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/builder.rb new/lib/dry/types/builder.rb
--- old/lib/dry/types/builder.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/builder.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
-
module Dry
module Types
# Common API for building types and composition
@@ -76,7 +74,7 @@
" value every time. Call `.freeze` when setting the default"\
" or pass `shared: true` to discard this warning."\
"\n#{where}",
- tag: :'dry-types'
+ tag: :"dry-types"
)
end
@@ -105,7 +103,7 @@
if values.length == 1 && values[0].is_a?(::Hash)
values[0]
else
- ::Hash[values.zip(values)]
+ values.zip(values).to_h
end
Enum.new(constrained(included_in: mapping.keys), mapping: mapping)
@@ -147,7 +145,7 @@
# @return [Constructor]
#
# @api public
- def fallback(value = Undefined, shared: false, &_fallback)
+ def fallback(value = Undefined, shared: false, &_fallback) #
rubocop:disable Metrics/PerceivedComplexity
if Undefined.equal?(value) && !block_given?
raise ::ArgumentError, "fallback value or a block must be given"
end
@@ -167,7 +165,7 @@
" value every time. Call `.freeze` when setting the fallback"\
" or pass `shared: true` to discard this warning."\
"\n#{where}",
- tag: :'dry-types'
+ tag: :"dry-types"
)
end
@@ -184,9 +182,3 @@
end
end
end
-
-require "dry/types/default"
-require "dry/types/constrained"
-require "dry/types/enum"
-require "dry/types/lax"
-require "dry/types/sum"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/builder_methods.rb
new/lib/dry/types/builder_methods.rb
--- old/lib/dry/types/builder_methods.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/builder_methods.rb 2022-10-15 09:53:02.000000000
+0200
@@ -80,7 +80,7 @@
# @param [#call,nil] block Value constructor
#
# @return [Dry::Types::Type]
- def Constructor(klass, cons = nil, &block)
+ def Constructor(klass, cons = nil, &block) # rubocop:disable
Metrics/PerceivedComplexity:
if klass.is_a?(Type)
if cons || block
klass.constructor(cons || block)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/coercions/params.rb
new/lib/dry/types/coercions/params.rb
--- old/lib/dry/types/coercions/params.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/coercions/params.rb 2022-10-15 09:53:02.000000000
+0200
@@ -12,9 +12,10 @@
module Params
TRUE_VALUES = %w[1 on On ON t true True TRUE T y yes Yes YES Y].freeze
FALSE_VALUES = %w[0 off Off OFF f false False FALSE F n no No NO
N].freeze
- BOOLEAN_MAP = ::Hash[
- TRUE_VALUES.product([true]) + FALSE_VALUES.product([false])
- ].merge(true => true, false => false).freeze
+ BOOLEAN_MAP = EMPTY_HASH.merge(
+ [true, *TRUE_VALUES].to_h { |v| [v, true] },
+ [false, *FALSE_VALUES].to_h { |v| [v, false] }
+ ).freeze
extend Coercions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/compat.rb new/lib/dry/types/compat.rb
--- old/lib/dry/types/compat.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/compat.rb 2022-10-15 09:53:02.000000000 +0200
@@ -0,0 +1 @@
+# frozen_string_literal: true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/compiler.rb
new/lib/dry/types/compiler.rb
--- old/lib/dry/types/compiler.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/compiler.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,12 +1,10 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
-
module Dry
module Types
# @api private
class Compiler
- extend ::Dry::Core::Deprecations[:'dry-types']
+ extend ::Dry::Core::Deprecations[:"dry-types"]
attr_reader :registry
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/constrained.rb
new/lib/dry/types/constrained.rb
--- old/lib/dry/types/constrained.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/constrained.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,10 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/types/decorator"
-require "dry/types/constraints"
-require "dry/types/constrained/coercible"
-
module Dry
module Types
# Constrained types apply rules to the input
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/constraints.rb
new/lib/dry/types/constraints.rb
--- old/lib/dry/types/constraints.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/constraints.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,9 +1,5 @@
# frozen_string_literal: true
-require "dry/logic/rule_compiler"
-require "dry/logic/predicates"
-require "dry/logic/rule/predicate"
-
module Dry
# Helper methods for constraint types
#
@@ -17,8 +13,8 @@
def self.Rule(options)
rule_compiler.(
options.map { |key, val|
- Logic::Rule::Predicate.build(
- Logic::Predicates[:"#{key}?"]
+ ::Dry::Logic::Rule::Predicate.build(
+ ::Dry::Logic::Predicates[:"#{key}?"]
).curry(val).to_ast
}
).reduce(:and)
@@ -28,7 +24,7 @@
#
# @api private
def self.rule_compiler
- @rule_compiler ||= Logic::RuleCompiler.new(Logic::Predicates)
+ @rule_compiler ||=
::Dry::Logic::RuleCompiler.new(::Dry::Logic::Predicates)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/constructor/function.rb
new/lib/dry/types/constructor/function.rb
--- old/lib/dry/types/constructor/function.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/constructor/function.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
require "concurrent/map"
module Dry
@@ -62,17 +61,17 @@
::Module.new do
if safe
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
- def call(input, &block)
- @target.#{method}(input, &block)
- end
+ def call(input, &block) # def call(input,
&block)
+ @target.#{method}(input, &block) #
@target.coerve(input, &block)
+ end # end
RUBY
else
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
- def call(input, &block)
- @target.#{method}(input)
- rescue ::NoMethodError, ::TypeError, ::ArgumentError =>
error
- CoercionError.handle(error, &block)
- end
+ def call(input, &block)
# def call(input, &block)
+ @target.#{method}(input)
# @target.coerce(input)
+ rescue ::NoMethodError, ::TypeError, ::ArgumentError =>
error # rescue ::NoMethodError, ::TypeError, ::ArgumentError => error
+ CoercionError.handle(error, &block)
# CoercionError.handle(error, &block)
+ end
# end
RUBY
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/constructor.rb
new/lib/dry/types/constructor.rb
--- old/lib/dry/types/constructor.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/constructor.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,10 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/types/fn_container"
-require "dry/types/constructor/function"
-require "dry/types/constructor/wrapper"
-
module Dry
module Types
# Constructor types apply a function to the input that is supposed to
return
@@ -49,13 +44,12 @@
# @api private
def self.wrapper_type
- @wrapper_type ||= begin
+ @wrapper_type ||=
if self < Wrapper
self
else
const_set(:Wrapping, ::Class.new(self).include(Wrapper))
end
- end
end
# Instantiate a new constructor type instance
@@ -191,7 +185,7 @@
if type.respond_to?(method)
response = type.public_send(method, *args, &block)
- if response.is_a?(Type) && type.class.equal?(response.class)
+ if response.is_a?(Type) && response.instance_of?(type.class)
response.constructor_type[response, **options]
else
response
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/core.rb new/lib/dry/types/core.rb
--- old/lib/dry/types/core.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/core.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/any"
-
module Dry
module Types
# Primitives with {Kernel} coercion methods
@@ -60,7 +58,8 @@
# Register {KERNEL_COERCIBLE} types
KERNEL_COERCIBLE.each do |name, primitive|
- register("coercible.#{name}",
self["nominal.#{name}"].constructor(Kernel.method(primitive.name)))
+ register("coercible.#{name}",
+
self["nominal.#{name}"].constructor(Kernel.method(primitive.name)))
end
# Register {METHOD_COERCIBLE} types
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/decorator.rb
new/lib/dry/types/decorator.rb
--- old/lib/dry/types/decorator.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/decorator.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/options"
-
module Dry
module Types
# Common API for types
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/default.rb new/lib/dry/types/default.rb
--- old/lib/dry/types/default.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/default.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/types/decorator"
-
module Dry
module Types
# Default types are useful when a missing value should be replaced by a
default one
@@ -53,7 +50,7 @@
# @param [Object] value
#
# @api private
- def initialize(type, value, **options)
+ def initialize(type, value, **)
super
@value = value
end
@@ -65,8 +62,8 @@
# @return [Default]
#
# @api public
- def constrained(*args)
- type.constrained(*args).default(value)
+ def constrained(...)
+ type.constrained(...).default(value)
end
# @return [true]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/enum.rb new/lib/dry/types/enum.rb
--- old/lib/dry/types/enum.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/enum.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/types/decorator"
-
module Dry
module Types
# Enum types can be used to define an enum on top of an existing type
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/errors.rb new/lib/dry/types/errors.rb
--- old/lib/dry/types/errors.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/errors.rb 2022-10-15 09:53:02.000000000 +0200
@@ -51,6 +51,7 @@
# @param [Array<CoercionError>] errors
def initialize(errors)
+ super("")
@errors = errors
end
@@ -66,11 +67,22 @@
end
class SchemaError < CoercionError
+ # @return [String, Symbol]
+ attr_reader :key
+
+ # @return [Object]
+ attr_reader :value
+
# @param [String,Symbol] key
# @param [Object] value
# @param [String, #to_s] result
def initialize(key, value, result)
- super("#{value.inspect} (#{value.class}) has invalid type for :#{key}
violates constraints (#{result} failed)")
+ @key = key
+ @value = value
+ super(
+ "#{value.inspect} (#{value.class}) has invalid type "\
+ "for :#{key} violates constraints (#{result} failed)"
+ )
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/extensions/maybe.rb
new/lib/dry/types/extensions/maybe.rb
--- old/lib/dry/types/extensions/maybe.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/extensions/maybe.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,8 +1,6 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
require "dry/monads/maybe"
-require "dry/types/decorator"
module Dry
module Types
@@ -99,7 +97,7 @@
end
# @api private
- class Schema::Key
+ class Schema::Key # rubocop:disable Style/ClassAndModuleChildren
# @api private
def maybe
__new__(type.maybe)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/fn_container.rb
new/lib/dry/types/fn_container.rb
--- old/lib/dry/types/fn_container.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/fn_container.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/container"
-
module Dry
module Types
# Internal container for constructor functions used by the built-in types
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/hash/constructor.rb
new/lib/dry/types/hash/constructor.rb
--- old/lib/dry/types/hash/constructor.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/hash/constructor.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/constructor"
-
module Dry
module Types
# Hash type exposes additional APIs for working with schema hashes
@@ -24,8 +22,8 @@
# @see Dry::Types::Array#of
#
# @api public
- def schema(*args)
- type.schema(*args).constructor(fn, meta: meta)
+ def schema(...)
+ type.schema(...).constructor(fn, meta: meta)
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/hash.rb new/lib/dry/types/hash.rb
--- old/lib/dry/types/hash.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/hash.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/hash/constructor"
-
module Dry
module Types
# Hash types can be used to define maps and schemas
@@ -132,6 +130,3 @@
end
end
end
-
-require "dry/types/schema/key"
-require "dry/types/schema"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/lax.rb new/lib/dry/types/lax.rb
--- old/lib/dry/types/lax.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/lax.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
-require "dry/types/decorator"
-
module Dry
module Types
# Lax types rescue from type-related errors when constructors fail
@@ -68,7 +65,7 @@
end
end
- extend ::Dry::Core::Deprecations[:'dry-types']
+ extend ::Dry::Core::Deprecations[:"dry-types"]
Safe = Lax
deprecate_constant(:Safe)
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/map.rb new/lib/dry/types/map.rb
--- old/lib/dry/types/map.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/map.rb 2022-10-15 09:53:02.000000000 +0200
@@ -14,15 +14,17 @@
# # => {1 => 'right'}
#
# type.('1' => 'wrong')
- # # Dry::Types::MapError: "1" violates constraints (type?(Integer, "1")
AND gteq?(1, "1") AND lteq?(10, "1") failed)
+ # # Dry::Types::MapError: "1" violates constraints (type?(Integer, "1")
+ # # AND gteq?(1, "1")
+ # # AND lteq?(10, "1")
failed)
#
# type.(11 => 'wrong')
# # Dry::Types::MapError: 11 violates constraints (lteq?(10, 11) failed)
#
# @api public
class Map < Nominal
- def initialize(_primitive, key_type: Types["any"], value_type:
Types["any"], meta: EMPTY_HASH)
- super(_primitive, key_type: key_type, value_type: value_type, meta:
meta)
+ def initialize(primitive, key_type: Types["any"], value_type:
Types["any"], meta: EMPTY_HASH)
+ super(primitive, key_type: key_type, value_type: value_type, meta:
meta)
end
# @return [Type]
@@ -100,6 +102,8 @@
private
# @api private
+ # rubocop:disable Metrics/PerceivedComplexity
+ # rubocop:disable Metrics/AbcSize
def coerce(input)
unless primitive?(input)
return failure(
@@ -131,6 +135,8 @@
failure(input, MultipleError.new(failures))
end
end
+ # rubocop:enable Metrics/PerceivedComplexity
+ # rubocop:enable Metrics/AbcSize
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/module.rb new/lib/dry/types/module.rb
--- old/lib/dry/types/module.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/module.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,6 +1,5 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
require "dry/types/builder_methods"
module Dry
@@ -8,7 +7,7 @@
# Export types registered in a container as module constants.
# @example
# module Types
- # include Dry::Types(:strict, :coercible, :nominal, default: :strict)
+ # include Dry.Types(:strict, :coercible, :nominal, default: :strict)
# end
#
# Types.constants
@@ -26,10 +25,10 @@
extend(BuilderMethods)
if constants.key?(:Nominal)
- singleton_class.send(:define_method, :included) do |base|
+ singleton_class.define_method(:included) do |base|
super(base)
base.instance_exec(const_get(:Nominal, false)) do |nominal|
- extend Dry::Core::Deprecations[:'dry-types']
+ extend Dry::Core::Deprecations[:"dry-types"]
const_set(:Definition, nominal)
deprecate_constant(:Definition, message: "Nominal")
end
@@ -38,13 +37,16 @@
end
# @api private
+ # rubocop:disable Metrics/AbcSize
+ # rubocop:disable Metrics/CyclomaticComplexity
+ # rubocop:disable Metrics/PerceivedComplexity
def type_constants(*namespaces, default: Undefined, **aliases)
if namespaces.empty? && aliases.empty? && Undefined.equal?(default)
default_ns = :Strict
elsif Undefined.equal?(default)
default_ns = Undefined
else
- default_ns = Inflector.camelize(default).to_sym
+ default_ns = Types::Inflector.camelize(default).to_sym
end
tree = registry_tree
@@ -52,7 +54,9 @@
if namespaces.empty? && aliases.empty?
modules = tree.select { |_, v| v.is_a?(::Hash) }.map(&:first)
else
- modules = (namespaces + aliases.keys).map { |n|
Inflector.camelize(n).to_sym }
+ modules = (namespaces + aliases.keys).map { |n|
+ Types::Inflector.camelize(n).to_sym
+ }
end
tree.each_with_object({}) do |(key, value), constants|
@@ -64,13 +68,16 @@
constants.update(value) if key == default_ns
end
end
+ # rubocop:enable Metrics/AbcSize
+ # rubocop:enable Metrics/CyclomaticComplexity
+ # rubocop:enable Metrics/PerceivedComplexity
# @api private
def registry_tree
@registry_tree ||= @registry.keys.each_with_object({}) { |key, tree|
type = @registry[key]
*modules, const_name = key.split(".").map { |part|
- Inflector.camelize(part).to_sym
+ Types::Inflector.camelize(part).to_sym
}
next if modules.empty?
@@ -91,9 +98,11 @@
ns.to_sym unless path.empty?
}.compact.uniq
- (referenced.uniq - known).each do |name|
+ unknown = (referenced.uniq - known).first
+
+ if unknown
raise ArgumentError,
- "#{name.inspect} is not a known type namespace. "\
+ "#{unknown.inspect} is not a known type namespace. "\
"Supported options are #{known.map(&:inspect).join(", ")}"
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/nominal.rb new/lib/dry/types/nominal.rb
--- old/lib/dry/types/nominal.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/nominal.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,12 +1,5 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
-require "dry/core/equalizer"
-require "dry/types/builder"
-require "dry/types/result"
-require "dry/types/options"
-require "dry/types/meta"
-
module Dry
module Types
# Nominal types define a primitive class and do not apply any constructors
or constraints
@@ -20,7 +13,7 @@
include Meta
include Builder
include Printable
- include Dry::Equalizer(:primitive, :options, :meta, inspect: false,
immutable: true)
+ include ::Dry::Equalizer(:primitive, :options, :meta, inspect: false,
immutable: true)
# @return [Class]
attr_reader :primitive
@@ -199,12 +192,8 @@
end
end
- extend Dry::Core::Deprecations[:'dry-types']
+ extend ::Dry::Core::Deprecations[:"dry-types"]
Definition = Nominal
deprecate_constant(:Definition, message: "Nominal")
end
end
-
-require "dry/types/array"
-require "dry/types/hash"
-require "dry/types/map"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/predicate_inferrer.rb
new/lib/dry/types/predicate_inferrer.rb
--- old/lib/dry/types/predicate_inferrer.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/predicate_inferrer.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,9 +1,5 @@
# frozen_string_literal: true
-require "dry/core/cache"
-require "dry/core/class_attributes"
-require "dry/types/predicate_registry"
-
module Dry
module Types
# PredicateInferrer returns the list of predicates used by a type.
@@ -55,7 +51,7 @@
end
# @api private
- def infer_predicate(type)
+ def infer_predicate(type) # rubocop:disable Metrics/PerceivedComplexity
pred = TYPE_TO_PREDICATE.fetch(type) do
if type.name.nil? ||
self.class.infer_predicate_by_class_name.equal?(false)
nil
@@ -175,9 +171,9 @@
def visit_predicate(node)
pred, args = node
- if pred.equal?(:type?)
+ if pred.equal?(:type?) || !registry.key?(pred)
EMPTY_ARRAY
- elsif registry.key?(pred)
+ else
*curried, _ = args
values = curried.map { |_, v| v }
@@ -186,8 +182,6 @@
else
[pred => values[0]]
end
- else
- EMPTY_ARRAY
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/predicate_registry.rb
new/lib/dry/types/predicate_registry.rb
--- old/lib/dry/types/predicate_registry.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/predicate_registry.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/logic/predicates"
-
module Dry
module Types
# A registry with predicate objects from `Dry::Logic::Predicates`
@@ -14,21 +12,36 @@
# @api private
attr_reader :has_predicate
- # @api private
- def initialize(predicates = Logic::Predicates)
- @predicates = predicates
- @has_predicate =
::Kernel.instance_method(:respond_to?).bind(@predicates)
+ KERNEL_RESPOND_TO = ::Kernel.instance_method(:respond_to?)
+ private_constant(:KERNEL_RESPOND_TO)
+
+ if ::UnboundMethod.method_defined?(:bind_call)
+ # @api private
+ def initialize(predicates = Logic::Predicates)
+ @predicates = predicates
+ end
+
+ # @api private
+ def key?(name)
+ KERNEL_RESPOND_TO.bind_call(@predicates, name)
+ end
+ else
+ # @api private
+ def initialize(predicates = Logic::Predicates)
+ @predicates = predicates
+ @has_predicate = KERNEL_RESPOND_TO.bind(@predicates)
+ end
+
+ # @api private
+ def key?(name)
+ has_predicate.(name)
+ end
end
# @api private
def [](name)
predicates[name]
end
-
- # @api private
- def key?(name)
- has_predicate.(name)
- end
end
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/primitive_inferrer.rb
new/lib/dry/types/primitive_inferrer.rb
--- old/lib/dry/types/primitive_inferrer.rb 2021-02-16 12:25:57.000000000
+0100
+++ new/lib/dry/types/primitive_inferrer.rb 2022-10-15 09:53:02.000000000
+0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/core/cache"
-
module Dry
module Types
# PrimitiveInferrer returns the list of classes matching a type.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/printer.rb new/lib/dry/types/printer.rb
--- old/lib/dry/types/printer.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/printer.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,10 +1,12 @@
# frozen_string_literal: true
module Dry
+ # rubocop:disable Metrics/AbcSize
+ # rubocop:disable Metrics/PerceivedComplexity
module Types
# @api private
class Printer
- MAPPING = {
+ MAPPING = { # rubocop:disable Style/MutableConstant
Nominal => :visit_nominal,
Constructor => :visit_constructor,
Constrained => :visit_constrained,
@@ -94,13 +96,13 @@
strict_str = "strict " if options.delete(:strict)
- if key_fn = options.delete(:key_transform_fn)
+ if (key_fn = options.delete(:key_transform_fn))
visit_callable(key_fn) do |fn|
key_fn_str = "key_fn=#{fn} "
end
end
- if type_fn = options.delete(:type_transform_fn)
+ if (type_fn = options.delete(:type_transform_fn))
visit_callable(type_fn) do |fn|
type_fn_str = "type_fn=#{fn} "
end
@@ -109,7 +111,7 @@
keys = options.delete(:keys)
visit_options(options, schema.meta) do |opts|
- opts = "#{opts[1..-1]} " unless opts.empty?
+ opts = "#{opts[1..]} " unless opts.empty?
schema_parameters = "#{key_fn_str}#{type_fn_str}#{strict_str}#{opts}"
header = "Schema<#{schema_parameters}keys={"
@@ -236,7 +238,7 @@
options = hash.options.dup
type_fn_str = ""
- if type_fn = options.delete(:type_transform_fn)
+ if (type_fn = options.delete(:type_transform_fn))
visit_callable(type_fn) do |fn|
type_fn_str = "type_fn=#{fn}"
end
@@ -263,9 +265,9 @@
if line&.zero?
yield ".#{path}"
elsif path
- yield "#{path.sub(Dir.pwd + "/", EMPTY_STRING)}:#{line}"
+ yield "#{path.sub("#{Dir.pwd}/", EMPTY_STRING)}:#{line}"
else
- match = fn.to_s.match(/\A#<Proc:0x\h+\(&:(?<name>\w+)\)(:?
\(lambda\))?>\z/)
+ match = fn.to_s.match(/\A#<Proc:0x\h+\(&:(?<name>\w+)\)(:?
\(lambda\))?>\z/) # rubocop:disable Lint/MixedRegexpCaptureTypes
if match
yield ".#{match[:name]}"
@@ -286,7 +288,7 @@
end
end
- def visit_options(options, meta = EMPTY_HASH)
+ def visit_options(options, meta = EMPTY_HASH) # rubocop:disable
Metrics/PerceivedComplexity
if options.empty? && meta.empty?
yield ""
else
@@ -312,4 +314,6 @@
PRINTER = Printer.new.freeze
end
+ # rubocop:enable Metrics/AbcSize
+ # rubocop:enable Metrics/PerceivedComplexity
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/result.rb new/lib/dry/types/result.rb
--- old/lib/dry/types/result.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/result.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-
module Dry
module Types
# Result class used by {Type#try}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/schema/key.rb
new/lib/dry/types/schema/key.rb
--- old/lib/dry/types/schema/key.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/schema/key.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,8 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/core/deprecations"
-
module Dry
module Types
# Schema is a hash with explicit member types defined
@@ -15,7 +12,7 @@
#
# @see Dry::Types::Schema
class Key
- extend ::Dry::Core::Deprecations[:'dry-types']
+ extend ::Dry::Core::Deprecations[:"dry-types"]
include Type
include Dry::Equalizer(:name, :type, :options, inspect: false,
immutable: true)
include Decorator
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/schema.rb new/lib/dry/types/schema.rb
--- old/lib/dry/types/schema.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/schema.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require "dry/types/fn_container"
-
module Dry
module Types
# The built-in Hash type can be defined in terms of keys and associated
types
@@ -92,6 +90,8 @@
# @return [Object] if coercion fails and a block is given
#
# @api public
+ # rubocop:disable Metrics/AbcSize
+ # rubocop:disable Metrics/PerceivedComplexity
def try(input)
if primitive?(input)
success = true
@@ -138,6 +138,8 @@
failure
end
end
+ # rubocop:enable Metrics/AbcSize
+ # rubocop:enable Metrics/PerceivedComplexity
# @param meta [Boolean] Whether to dump the meta to the AST
#
@@ -167,7 +169,7 @@
# @return [Schema]
#
# @api public
- def strict(strict = true)
+ def strict(strict = true) # rubocop:disable
Style/OptionalBooleanParameter
with(strict: strict)
end
@@ -368,7 +370,7 @@
# Try to add missing keys to the hash
#
# @api private
- def resolve_missing_keys(hash, options)
+ def resolve_missing_keys(hash, options) # rubocop:disable
Metrics/PerceivedComplexity
skip_missing = options.fetch(:skip_missing, false)
resolve_defaults = options.fetch(:resolve_defaults, true)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/sum.rb new/lib/dry/types/sum.rb
--- old/lib/dry/types/sum.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/sum.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,9 +1,5 @@
# frozen_string_literal: true
-require "dry/core/equalizer"
-require "dry/types/options"
-require "dry/types/meta"
-
module Dry
module Types
# Sum type
@@ -121,10 +117,10 @@
# @api private
def failure(input, _error = nil)
- if !left.valid?(input)
- left.failure(input, left.try(input).error)
- else
+ if left.valid?(input)
right.failure(input, right.try(input).error)
+ else
+ left.failure(input, left.try(input).error)
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/type.rb new/lib/dry/types/type.rb
--- old/lib/dry/types/type.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/type.rb 2022-10-15 09:53:02.000000000 +0200
@@ -1,14 +1,12 @@
# frozen_string_literal: true
-require "dry/core/deprecations"
-
module Dry
module Types
# Common Type module denoting an object is a Type
#
# @api public
module Type
- extend ::Dry::Core::Deprecations[:'dry-types']
+ extend ::Dry::Core::Deprecations[:"dry-types"]
deprecate(:safe, :lax)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types/version.rb new/lib/dry/types/version.rb
--- old/lib/dry/types/version.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types/version.rb 2022-10-15 09:53:02.000000000 +0200
@@ -2,6 +2,6 @@
module Dry
module Types
- VERSION = "1.5.1"
+ VERSION = "1.6.1"
end
end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/lib/dry/types.rb new/lib/dry/types.rb
--- old/lib/dry/types.rb 2021-02-16 12:25:57.000000000 +0100
+++ new/lib/dry/types.rb 2022-10-15 09:53:02.000000000 +0200
@@ -3,37 +3,64 @@
require "bigdecimal"
require "date"
require "set"
+require "zeitwerk"
require "concurrent/map"
+require "dry/core"
require "dry/container"
-require "dry/core/extensions"
-require "dry/core/constants"
-require "dry/core/class_attributes"
+require "dry/logic"
+require "dry/types/constraints"
+require "dry/types/errors"
require "dry/types/version"
-require "dry/types/container"
+
+# This must be required explicitly as it may conflict with dry-inflector
require "dry/types/inflector"
-require "dry/types/type"
-require "dry/types/printable"
-require "dry/types/nominal"
-require "dry/types/constructor"
require "dry/types/module"
-require "dry/types/errors"
-
module Dry
# Main library namespace
#
# @api public
module Types
- extend Dry::Core::Extensions
- extend Dry::Core::ClassAttributes
- extend Dry::Core::Deprecations[:'dry-types']
- include Dry::Core::Constants
+ extend ::Dry::Core::Extensions
+ extend ::Dry::Core::ClassAttributes
+ extend ::Dry::Core::Deprecations[:"dry-types"]
+ include ::Dry::Core::Constants
TYPE_SPEC_REGEX = /(.+)<(.+)>/.freeze
+ def self.loader
+ @loader ||= ::Zeitwerk::Loader.new.tap do |loader|
+ root = ::File.expand_path("..", __dir__)
+ loader.tag = "dry-types"
+ loader.inflector = ::Zeitwerk::GemInflector.new("#{root}/dry-types.rb")
+ loader.inflector.inflect("json" => "JSON")
+ loader.push_dir(root)
+ loader.ignore(
+ "#{root}/dry-types.rb",
+ "#{root}/dry/types/extensions",
+ "#{root}/dry/types/spec/types.rb",
+ "#{root}/dry/types/{#{%w[
+ compat
+ constraints
+ core
+ errors
+ extensions
+ inflector
+ module
+ json
+ params
+ printer
+ version
+ ].join(",")}}.rb"
+ )
+ end
+ end
+
+ loader.setup
+
# @see Dry.Types
def self.module(*namespaces, default: :nominal, **aliases)
::Module.new(container, *namespaces, default: default, **aliases)
@@ -120,7 +147,7 @@
#
# @return [String]
def self.identifier(klass)
- Inflector.underscore(klass).tr("/", ".")
+ Types::Inflector.underscore(klass).tr("/", ".")
end
# Cached type map
@@ -134,7 +161,7 @@
# @api private
def self.const_missing(const)
- underscored = Inflector.underscore(const)
+ underscored = Types::Inflector.underscore(const)
if container.keys.any? { |key| key.split(".")[0] == underscored }
raise ::NameError,
@@ -180,7 +207,7 @@
#
# module Types
# # imports all types as constants, uses modules for namespaces
- # include Dry::Types()
+ # include Dry.Types()
# end
# # strict types are exported by default
# Types::Integer
@@ -191,7 +218,7 @@
# @example changing default types
#
# module Types
- # include Dry::Types(default: :nominal)
+ # include Dry.Types(default: :nominal)
# end
# Types::Integer
# # => #<Dry::Types[Nominal<Integer>]>
@@ -199,7 +226,7 @@
# @example cherry-picking namespaces
#
# module Types
- # include Dry::Types(:strict, :coercible)
+ # include Dry.Types(:strict, :coercible)
# end
# # cherry-picking discards default types,
# # provide the :default option along with the list of
@@ -208,7 +235,7 @@
#
# @example custom names
# module Types
- # include Dry::Types(coercible: :Kernel)
+ # include Dry.Types(coercible: :Kernel)
# end
# Types::Kernel::Integer
# # => #<Dry::Types[Constructor<Nominal<Integer> fn=Kernel.Integer>]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata 2021-02-16 12:25:57.000000000 +0100
+++ new/metadata 2022-10-15 09:53:02.000000000 +0200
@@ -1,14 +1,14 @@
--- !ruby/object:Gem::Specification
name: dry-types
version: !ruby/object:Gem::Version
- version: 1.5.1
+ version: 1.6.1
platform: ruby
authors:
- Piotr Solnica
autorequire:
bindir: bin
cert_chain: []
-date: 2021-02-16 00:00:00.000000000 Z
+date: 2022-10-15 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: concurrent-ruby
@@ -44,20 +44,20 @@
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '0.5'
+ version: '0.9'
- - ">="
- !ruby/object:Gem::Version
- version: '0.5'
+ version: '0.9'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '0.5'
+ version: '0.9'
- - ">="
- !ruby/object:Gem::Version
- version: '0.5'
+ version: '0.9'
- !ruby/object:Gem::Dependency
name: dry-inflector
requirement: !ruby/object:Gem::Requirement
@@ -84,20 +84,34 @@
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '1.0'
+ version: '1.3'
- - ">="
- !ruby/object:Gem::Version
- version: 1.0.2
+ version: '1.3'
type: :runtime
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - "~>"
- !ruby/object:Gem::Version
- version: '1.0'
+ version: '1.3'
- - ">="
- !ruby/object:Gem::Version
- version: 1.0.2
+ version: '1.3'
+- !ruby/object:Gem::Dependency
+ name: zeitwerk
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - "~>"
+ - !ruby/object:Gem::Version
+ version: '2.6'
+ type: :runtime
+ prerelease: false
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - "~>"
+ - !ruby/object:Gem::Version
+ version: '2.6'
- !ruby/object:Gem::Dependency
name: bundler
requirement: !ruby/object:Gem::Requirement
@@ -237,7 +251,7 @@
- MIT
metadata:
allowed_push_host: https://rubygems.org
- changelog_uri: https://github.com/dry-rb/dry-types/blob/master/CHANGELOG.md
+ changelog_uri: https://github.com/dry-rb/dry-types/blob/main/CHANGELOG.md
source_code_uri: https://github.com/dry-rb/dry-types
bug_tracker_uri: https://github.com/dry-rb/dry-types/issues
post_install_message:
@@ -248,14 +262,14 @@
requirements:
- - ">="
- !ruby/object:Gem::Version
- version: 2.5.0
+ version: 2.7.0
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: '0'
requirements: []
-rubygems_version: 3.1.4
+rubygems_version: 3.1.6
signing_key:
specification_version: 4
summary: Type system for Ruby supporting coercions, constraints and complex
types