active_interaction 3.6.2 → 3.7.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 +13 -0
- data/LICENSE.md +2 -1
- data/README.md +11 -11
- data/lib/active_interaction/backports.rb +5 -1
- data/lib/active_interaction/errors.rb +30 -28
- data/lib/active_interaction/modules/input_processor.rb +3 -0
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/errors_spec.rb +15 -0
- metadata +5 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5876e7199c749e87440e2a3d4efec4685e2d0b42ab167e5089ee9b014a44850
|
4
|
+
data.tar.gz: 046dcc3fe7bd76e1572922904b6ea4568ff29674dc815a303a5e891d5ecf9019
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6491e9403f720062ecf1ac841b50d30f70f5309ae1ab6a35bcb473dd10030995676a0913c8ad6aec7698042f564a58a465281e5da0668fb6563422d169bf6f7
|
7
|
+
data.tar.gz: 7078526498db343ee4d8893f57d44be58f40440fda73417e330e40ef944473261deef31e73eb16a685b0e4c5d57d3ac07e5d82c795f834b559f8a0881188ce31
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# [3.7.0][] (2019-02-10)
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- [#454][] Support for Rails 6.
|
6
|
+
|
7
|
+
## Fixed
|
8
|
+
|
9
|
+
- [#435][] Errors using the `:message` option were not properly merged.
|
10
|
+
|
1
11
|
# [3.6.2][] (2018-08-21)
|
2
12
|
|
3
13
|
## Fixed
|
@@ -735,6 +745,7 @@ Example.run
|
|
735
745
|
|
736
746
|
- Initial release.
|
737
747
|
|
748
|
+
[3.7.0]: https://github.com/orgsync/active_interaction/compare/v3.6.2...v3.7.0
|
738
749
|
[3.6.2]: https://github.com/orgsync/active_interaction/compare/v3.6.1...v3.6.2
|
739
750
|
[3.6.1]: https://github.com/orgsync/active_interaction/compare/v3.6.0...v3.6.1
|
740
751
|
[3.6.0]: https://github.com/orgsync/active_interaction/compare/v3.5.3...v3.6.0
|
@@ -923,3 +934,5 @@ Example.run
|
|
923
934
|
[#422]: https://github.com/orgsync/active_interaction/pull/422
|
924
935
|
[#425]: https://github.com/orgsync/active_interaction/pull/425
|
925
936
|
[#429]: https://github.com/orgsync/active_interaction/pull/429
|
937
|
+
[#435]: https://github.com/orgsync/active_interaction/pull/435
|
938
|
+
[#454]: https://github.com/orgsync/active_interaction/pull/454
|
data/LICENSE.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2013 to
|
3
|
+
Copyright (c) 2013 to 2016 Aaron Lasseigne and Taylor Fausak
|
4
|
+
Copyright (c) 2017 to 2019 Aaron Lasseigne
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
ActiveInteraction manages application-specific business logic.
|
4
4
|
It's an implementation of the command pattern in Ruby.
|
5
5
|
|
6
|
-
[![Version](https://
|
7
|
-
[![Build](https://
|
8
|
-
[![Coverage](https://
|
9
|
-
[![Climate](https://
|
6
|
+
[![Version](https://img.shields.io/gem/v/active_interaction.svg?style=flat-square)](https://rubygems.org/gems/active_interaction)
|
7
|
+
[![Build](https://img.shields.io/travis/AaronLasseigne/active_interaction.svg?style=flat-square)](https://travis-ci.org/AaronLasseigne/active_interaction)
|
8
|
+
[![Coverage](https://img.shields.io/coveralls/github/AaronLasseigne/active_interaction.svg?style=flat-square)](https://coveralls.io/r/orgsync/active_interaction)
|
9
|
+
[![Climate](https://img.shields.io/codeclimate/maintainability/orgsync/active_interaction.svg?style=flat-square)](https://codeclimate.com/github/orgsync/active_interaction)
|
10
10
|
|
11
11
|
---
|
12
12
|
|
@@ -66,21 +66,21 @@ handles your verbs.
|
|
66
66
|
Add it to your Gemfile:
|
67
67
|
|
68
68
|
``` rb
|
69
|
-
gem 'active_interaction', '~> 3.
|
69
|
+
gem 'active_interaction', '~> 3.7'
|
70
70
|
```
|
71
71
|
|
72
72
|
Or install it manually:
|
73
73
|
|
74
74
|
``` sh
|
75
|
-
$ gem install active_interaction --version '~> 3.
|
75
|
+
$ gem install active_interaction --version '~> 3.7'
|
76
76
|
```
|
77
77
|
|
78
78
|
This project uses [Semantic Versioning][]. Check out [GitHub releases][] for a
|
79
79
|
detailed list of changes. For help upgrading to version 2, please read [the
|
80
80
|
announcement post][].
|
81
81
|
|
82
|
-
ActiveInteraction works with Ruby 2.0 through 2.
|
83
|
-
|
82
|
+
ActiveInteraction works with Ruby 2.0 through 2.6 and ActiveModel 4.0 through
|
83
|
+
6.0. If you want to use ActiveInteraction with an older version of Ruby or
|
84
84
|
ActiveModel, use ActiveInteraction < 3.0.0.
|
85
85
|
|
86
86
|
## Basic usage
|
@@ -492,12 +492,12 @@ StringInteraction.run!(name: 'Taylor')
|
|
492
492
|
# => "Hello, Taylor!"
|
493
493
|
```
|
494
494
|
|
495
|
-
|
496
|
-
`strip` option to `
|
495
|
+
String filter strips leading and trailing whitespace by default. To disable it, set the
|
496
|
+
`strip` option to `false`.
|
497
497
|
|
498
498
|
``` rb
|
499
499
|
string :comment,
|
500
|
-
strip:
|
500
|
+
strip: false
|
501
501
|
```
|
502
502
|
|
503
503
|
### Symbol
|
@@ -14,6 +14,8 @@ module ActiveInteraction
|
|
14
14
|
|
15
15
|
CALLBACKS_OPTIONS = ::ActiveModel::Errors::CALLBACKS_OPTIONS
|
16
16
|
private_constant :CALLBACKS_OPTIONS
|
17
|
+
MESSAGE_OPTIONS = [:message].freeze
|
18
|
+
private_constant :MESSAGE_OPTIONS
|
17
19
|
|
18
20
|
included do
|
19
21
|
attr_reader :details
|
@@ -35,7 +37,9 @@ module ActiveInteraction
|
|
35
37
|
|
36
38
|
def add_with_details(attribute, message = :invalid, options = {})
|
37
39
|
message = message.call if message.respond_to?(:call)
|
38
|
-
|
40
|
+
|
41
|
+
error = options.except(*CALLBACKS_OPTIONS + MESSAGE_OPTIONS)
|
42
|
+
.merge(error: message)
|
39
43
|
details[attribute].push(error)
|
40
44
|
add_without_details(attribute, message, options)
|
41
45
|
end
|
@@ -107,49 +107,51 @@ module ActiveInteraction
|
|
107
107
|
|
108
108
|
private
|
109
109
|
|
110
|
+
def attribute?(attribute)
|
111
|
+
@base.respond_to?(attribute)
|
112
|
+
end
|
113
|
+
|
114
|
+
def detailed_error?(detail)
|
115
|
+
detail[:error].is_a?(Symbol)
|
116
|
+
end
|
117
|
+
|
110
118
|
def merge_messages!(other)
|
111
119
|
other.messages.each do |attribute, messages|
|
112
120
|
messages.each do |message|
|
113
|
-
|
114
|
-
message = full_message(attribute, message)
|
115
|
-
attribute = :base
|
116
|
-
end
|
117
|
-
add(attribute, message) unless added?(attribute, message)
|
121
|
+
merge_message!(attribute, message)
|
118
122
|
end
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
122
|
-
def
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
error = detail.delete(:error)
|
127
|
-
|
128
|
-
merge_detail!(other, attribute, detail, error)
|
129
|
-
end
|
126
|
+
def merge_message!(attribute, message)
|
127
|
+
unless attribute?(attribute)
|
128
|
+
message = full_message(attribute, message)
|
129
|
+
attribute = :base
|
130
130
|
end
|
131
|
+
add(attribute, message) unless added?(attribute, message)
|
131
132
|
end
|
132
133
|
|
133
|
-
def
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
def merge_details!(other)
|
135
|
+
other.messages.each do |attribute, messages|
|
136
|
+
messages.zip(other.details[attribute]) do |message, detail|
|
137
|
+
if detailed_error?(detail)
|
138
|
+
merge_detail!(attribute, detail, message)
|
139
|
+
else
|
140
|
+
merge_message!(attribute, message)
|
141
|
+
end
|
142
|
+
end
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
144
|
-
def
|
145
|
-
|
146
|
-
|
146
|
+
def merge_detail!(attribute, detail, message)
|
147
|
+
if attribute?(attribute) || attribute == :base
|
148
|
+
options = detail.dup
|
149
|
+
error = options.delete(:error)
|
150
|
+
options[:message] = message
|
147
151
|
|
148
|
-
|
149
|
-
if error.is_a?(Symbol)
|
150
|
-
other.generate_message(attribute, error, detail)
|
152
|
+
add(attribute, error, options) unless added?(attribute, error, options)
|
151
153
|
else
|
152
|
-
|
154
|
+
merge_message!(attribute, message)
|
153
155
|
end
|
154
156
|
end
|
155
157
|
end
|
@@ -12,8 +12,11 @@ module ActiveInteraction
|
|
12
12
|
GROUPED_INPUT_PATTERN = /\A(.+)\((\d+)i\)\z/
|
13
13
|
private_constant :GROUPED_INPUT_PATTERN
|
14
14
|
|
15
|
+
# Checking `syscall` is the result of what appears to be a bug in Ruby.
|
16
|
+
# https://bugs.ruby-lang.org/issues/15597
|
15
17
|
def reserved?(name)
|
16
18
|
name.to_s.start_with?('_interaction_') ||
|
19
|
+
name == :syscall ||
|
17
20
|
Base.method_defined?(name) ||
|
18
21
|
Base.private_method_defined?(name)
|
19
22
|
end
|
@@ -91,6 +91,21 @@ describe ActiveInteraction::Errors do
|
|
91
91
|
expect(errors.details[:base]).to eql [{ error: message }]
|
92
92
|
end
|
93
93
|
end
|
94
|
+
|
95
|
+
context 'that uses the :message option' do
|
96
|
+
let(:message) { SecureRandom.hex }
|
97
|
+
let(:error_name) { :some_error }
|
98
|
+
|
99
|
+
before do
|
100
|
+
other.add(:base, error_name, message: message)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'adds the error' do
|
104
|
+
errors.merge!(other)
|
105
|
+
expect(errors.details[:base]).to eql [{ error: error_name }]
|
106
|
+
expect(errors.messages[:base]).to eql [message]
|
107
|
+
end
|
108
|
+
end
|
94
109
|
end
|
95
110
|
|
96
111
|
context 'with an interpolated detailed error' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '4'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '7'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '4'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '7'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: actionpack
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,20 +59,6 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.7'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: bundler
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.12'
|
69
|
-
type: :development
|
70
|
-
prerelease: false
|
71
|
-
version_requirements: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.12'
|
76
62
|
- !ruby/object:Gem::Dependency
|
77
63
|
name: coveralls
|
78
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -278,8 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
264
|
- !ruby/object:Gem::Version
|
279
265
|
version: '0'
|
280
266
|
requirements: []
|
281
|
-
|
282
|
-
rubygems_version: 2.7.6
|
267
|
+
rubygems_version: 3.0.1
|
283
268
|
signing_key:
|
284
269
|
specification_version: 4
|
285
270
|
summary: Manage application specific business logic.
|