dry-initializer 3.1.0 → 3.1.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: 49644712268c1c8896eb7b9d067d5f3abf65789330d465f0acad780a4f50644e
4
- data.tar.gz: 102ef164a75b9d4849400753a21046d5753217806de6c8963476ef8fafeb780d
3
+ metadata.gz: 6f8c224268e3e35d66bade7dde3eaa5cf3423d931e0755930f5086c2151ccfc1
4
+ data.tar.gz: 07275ac52d641a42609e47472c47b2f2e643e97e41a338ca4365ee2074ef8356
5
5
  SHA512:
6
- metadata.gz: '07780a5de808586056b92a3b9a2f1169f5fea4d7879abd1080fc27a7e6123b22d2a07878e9ca9203995c9f01c3e5a47b030b5dc7004d67a4a540413aabdb5890'
7
- data.tar.gz: e352bf6de1a4aae2cf183be62ef4f64a4c70daf0f329122b0d6cd00a7e6081767aa745e938ae4464e52d322bfb08ce943a3312b4f92e02d87c1b968edf0498c4
6
+ metadata.gz: 7e1275ca3ad8bec808814d88c3217ba8dd81e70a1c6de0a089560737edc2531f9aa9180fef77be430501ede727e414b9addc0cf4fd1345705923a7d729a0c6cb
7
+ data.tar.gz: afb4438bb4a9e26ea815166764a12c34309c1bbe53322a948dae9851c983d74f6e5e0696715ab2a7108552e1e3436123c4bb652aad74ba1a441aba4728cd970f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  <!--- DO NOT EDIT THIS FILE - IT'S AUTOMATICALLY GENERATED VIA DEVTOOLS --->
2
2
 
3
+ ## 3.1.1 2022-01-19
4
+
5
+
6
+ ### Changed
7
+
8
+ - Improved error messages were rolled back, they created an implicit dependency on dry-types (@flash-gordon)
9
+
10
+ [Compare v3.1.0...v3.1.1](https://github.com/dry-rb/dry-initializer/compare/v3.1.0...v3.1.1)
11
+
3
12
  ## 3.1.0 2022-01-16
4
13
 
5
14
 
@@ -53,7 +53,7 @@ module Dry
53
53
 
54
54
  def required_reader
55
55
  "#{@val} = #{@opts}.fetch(:'#{@source}')" \
56
- " { raise KeyError, \"\#{self.class}: #{@definition} is required\" }"
56
+ " { raise KeyError, \"\#{self.class}: #{@definition} is required\" }"
57
57
  end
58
58
 
59
59
  def definition_line
@@ -72,23 +72,17 @@ module Dry
72
72
  return unless @type
73
73
 
74
74
  arity = @type.is_a?(Proc) ? @type.arity : @type.method(:call).arity
75
- type_call_params = \
76
- arity.equal?(1) || arity.negative? ? @val : "#{@val}, self"
77
-
78
- <<-COERCE
79
- begin
80
- unless #{@null} == #{@val}
81
- #{@val} = #{@item}.type.call(#{type_call_params})
82
- end
83
- rescue Dry::Types::ConstraintError => e
84
- raise Dry::Initializer::CoercionError.new(e, '#{@source}')
85
- end
86
- COERCE
75
+
76
+ if arity.equal?(1) || arity.negative?
77
+ "#{@val} = #{@item}.type.call(#{@val}) unless #{@null} == #{@val}"
78
+ else
79
+ "#{@val} = #{@item}.type.call(#{@val}, self) unless #{@null} == #{@val}"
80
+ end
87
81
  end
88
82
 
89
83
  def assignment_line
90
84
  "#{@ivar} = #{@val}" \
91
- " unless #{@null} == #{@val} && instance_variable_defined?(:#{@ivar})"
85
+ " unless #{@null} == #{@val} && instance_variable_defined?(:#{@ivar})"
92
86
  end
93
87
  end
94
88
  end
@@ -35,7 +35,7 @@ module Dry
35
35
 
36
36
  def undef_line
37
37
  "undef :__dry_initializer_initialize__" \
38
- " if private_method_defined? :__dry_initializer_initialize__"
38
+ " if private_method_defined? :__dry_initializer_initialize__"
39
39
  end
40
40
 
41
41
  def define_line
@@ -28,8 +28,8 @@ module Dry
28
28
 
29
29
  def undef_line
30
30
  "undef :#{@target} if method_defined?(:#{@target})" \
31
- " || private_method_defined?(:#{@target})" \
32
- " || protected_method_defined?(:#{@target})"
31
+ " || private_method_defined?(:#{@target})" \
32
+ " || protected_method_defined?(:#{@target})"
33
33
  end
34
34
 
35
35
  def attribute_line
@@ -177,7 +177,7 @@ module Dry
177
177
  current
178
178
  elsif optional
179
179
  raise SyntaxError, "#{extended_class}: required #{current}" \
180
- " goes after optional #{optional}"
180
+ " goes after optional #{optional}"
181
181
  else
182
182
  optional
183
183
  end
@@ -38,8 +38,8 @@ module Dry
38
38
 
39
39
  def invalid!(default)
40
40
  raise TypeError, "The #{default.inspect} should be" \
41
- " either convertable to proc with no arguments," \
42
- " or respond to #call without arguments."
41
+ " either convertable to proc with no arguments," \
42
+ " or respond to #call without arguments."
43
43
  end
44
44
  end
45
45
  end
@@ -9,7 +9,7 @@ module Dry
9
9
  # @deprecated
10
10
  def self.extended(klass)
11
11
  warn "[DEPRECATED] Use Dry::Initializer instead of its alias" \
12
- " Dry::Initializer::Mixin. The later will be removed in v2.1.0"
12
+ " Dry::Initializer::Mixin. The later will be removed in v2.1.0"
13
13
  super
14
14
  end
15
15
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Dry
4
4
  module Initializer
5
- VERSION = "3.1.0"
5
+ VERSION = "3.1.1"
6
6
  end
7
7
  end
@@ -15,7 +15,6 @@ module Dry
15
15
  require_relative "initializer/config"
16
16
  require_relative "initializer/mixin"
17
17
  require_relative "initializer/dispatchers"
18
- require_relative "initializer/errors"
19
18
 
20
19
  # Adds methods [.[]] and [.define]
21
20
  extend DSL
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-initializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Kochnev (marshall-lee)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-01-16 00:00:00.000000000 Z
12
+ date: 2022-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -71,7 +71,6 @@ files:
71
71
  - lib/dry/initializer/dispatchers/unwrap_type.rb
72
72
  - lib/dry/initializer/dispatchers/wrap_type.rb
73
73
  - lib/dry/initializer/dsl.rb
74
- - lib/dry/initializer/errors.rb
75
74
  - lib/dry/initializer/mixin.rb
76
75
  - lib/dry/initializer/mixin/local.rb
77
76
  - lib/dry/initializer/mixin/root.rb
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dry
4
- module Initializer
5
- class CoercionError < ::StandardError
6
- def initialize(constraint_error, field)
7
- @constraint_error = constraint_error
8
- @field = field
9
- super(message)
10
- end
11
-
12
- # Ensure that the field name is in the error message
13
- def message
14
- if @constraint_error.message =~ /#{@field}/
15
- @constraint_error.message
16
- else
17
- "#{@constraint_error.message} for field :#{@field}"
18
- end
19
- end
20
- end
21
- end
22
- end