active_interaction 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +32 -21
- data/lib/active_interaction.rb +1 -1
- data/lib/active_interaction/concerns/runnable.rb +9 -7
- data/lib/active_interaction/errors.rb +0 -15
- data/lib/active_interaction/locale/fr.yml +23 -0
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/concerns/runnable_spec.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a54101dfa80812134a34c6977fa538e23d67c7f
|
4
|
+
data.tar.gz: 3a3d21348e1f37a649ca23801a1b01f5974c9399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04fe6f23d9235893ca47203481f9f4a7709acffebb0d8f24f3769ccfe07dc8b52133e3e82f2f1be039eaf8a4859572536c106d0bc5fffcf96fffb767c3a4226a
|
7
|
+
data.tar.gz: df1cf833864649ddb7d402a3da8b657987863da264728f755657625d3cda9293c58968509608b2ae6a12831a71d91141d5c638e7650d10050c666407b0c71945
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# [2.1.5][] (2015-12-11)
|
2
|
+
|
3
|
+
## Added
|
4
|
+
|
5
|
+
- [#330][]: Added a French translation.
|
6
|
+
|
1
7
|
# [2.1.4][] (2015-11-03)
|
2
8
|
|
3
9
|
## Fixed
|
@@ -476,6 +482,7 @@ For help upgrading to version 2, please read [the announcement post][].
|
|
476
482
|
|
477
483
|
- Initial release.
|
478
484
|
|
485
|
+
[2.1.5]: https://github.com/orgsync/active_interaction/compare/v2.1.4...v2.1.5
|
479
486
|
[2.1.4]: https://github.com/orgsync/active_interaction/compare/v2.1.3...v2.1.4
|
480
487
|
[2.1.3]: https://github.com/orgsync/active_interaction/compare/v2.1.2...v2.1.3
|
481
488
|
[2.1.2]: https://github.com/orgsync/active_interaction/compare/v2.1.1...v2.1.2
|
@@ -623,5 +630,6 @@ For help upgrading to version 2, please read [the announcement post][].
|
|
623
630
|
[#310]: https://github.com/orgsync/active_interaction/issues/310
|
624
631
|
[#311]: https://github.com/orgsync/active_interaction/issues/311
|
625
632
|
[#320]: https://github.com/orgsync/active_interaction/issues/320
|
633
|
+
[#330]: https://github.com/orgsync/active_interaction/pull/330
|
626
634
|
|
627
635
|
[the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
|
data/README.md
CHANGED
@@ -1,23 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<a href="https://travis-ci.org/orgsync/active_interaction"><img alt="Build" src="https://img.shields.io/travis/orgsync/active_interaction/master.svg?label=build&style=flat-square"></a>
|
15
|
-
<a href="https://coveralls.io/r/orgsync/active_interaction"><img alt="Coverage" src="https://img.shields.io/coveralls/orgsync/active_interaction/master.svg?label=coverage&style=flat-square"></a>
|
16
|
-
<a href="https://codeclimate.com/github/orgsync/active_interaction"><img alt="Climate" src="https://img.shields.io/codeclimate/github/orgsync/active_interaction.svg?label=climate&style=flat-square"></a>
|
17
|
-
<a href="https://gemnasium.com/orgsync/active_interaction"><img alt="Dependencies" src="https://img.shields.io/gemnasium/orgsync/active_interaction.svg?label=dependencies&style=flat-square"></a>
|
18
|
-
</p>
|
19
|
-
|
20
|
-
<hr>
|
1
|
+
# [ActiveInteraction][]
|
2
|
+
|
3
|
+
ActiveInteraction manages application-specific business logic.
|
4
|
+
It's an implementation of the command pattern in Ruby.
|
5
|
+
|
6
|
+
[](https://rubygems.org/gems/active_interaction)
|
7
|
+
[](https://travis-ci.org/orgsync/active_interaction)
|
8
|
+
[](https://coveralls.io/r/orgsync/active_interaction)
|
9
|
+
[](https://codeclimate.com/github/orgsync/active_interaction)
|
10
|
+
[](http://www.libgrader.com/libraries/ruby/active_interaction)
|
11
|
+
[](https://gemnasium.com/orgsync/active_interaction)
|
12
|
+
|
13
|
+
---
|
21
14
|
|
22
15
|
ActiveInteraction gives you a place to put your business logic. It also helps
|
23
16
|
you write safer code by validating that your inputs conform to your
|
@@ -62,6 +55,7 @@ Read more on [the project page][] or check out [the full documentation][].
|
|
62
55
|
- [Descriptions](#descriptions)
|
63
56
|
- [Errors](#errors)
|
64
57
|
- [Forms](#forms)
|
58
|
+
- [Grouped inputs](#grouped-inputs)
|
65
59
|
- [Optional inputs](#optional-inputs)
|
66
60
|
- [Predicates](#predicates)
|
67
61
|
- [Translations](#translations)
|
@@ -878,7 +872,8 @@ end
|
|
878
872
|
|
879
873
|
We recommend putting your interactions in `app/interactions`. It's also very
|
880
874
|
helpful to group them by model. That way you can look in
|
881
|
-
`app/interactions/accounts` for all the ways you can interact with accounts.
|
875
|
+
`app/interactions/accounts` for all the ways you can interact with accounts.
|
876
|
+
In order to use this structure add `config.autoload_paths += Dir.glob("#{config.root}/app/interactions/*")` in your `application.rb`
|
882
877
|
|
883
878
|
```
|
884
879
|
- app/
|
@@ -1165,6 +1160,20 @@ used to define the inputs on your interaction will relay type information to
|
|
1165
1160
|
these gems. As a result, form fields will automatically use the appropriate
|
1166
1161
|
input type.
|
1167
1162
|
|
1163
|
+
### Grouped inputs
|
1164
|
+
|
1165
|
+
It can be convenient to apply the same options to a bunch of inputs. One common
|
1166
|
+
use case is making many inputs optional. Instead of setting `default: nil` on
|
1167
|
+
each one of them, you can use [`with_options`][] to reduce duplication.
|
1168
|
+
|
1169
|
+
``` rb
|
1170
|
+
with_options default: nil do
|
1171
|
+
date :birthday
|
1172
|
+
string :name
|
1173
|
+
boolean :wants_cake
|
1174
|
+
end
|
1175
|
+
```
|
1176
|
+
|
1168
1177
|
### Optional inputs
|
1169
1178
|
|
1170
1179
|
Optional inputs can be defined by using the `:default` option as described in
|
@@ -1298,6 +1307,7 @@ available on GitHub.
|
|
1298
1307
|
|
1299
1308
|
ActiveInteraction is licensed under [the MIT License][].
|
1300
1309
|
|
1310
|
+
[activeinteraction]: https://github.com/orgsync/active_interaction
|
1301
1311
|
[the project page]: http://orgsync.github.io/active_interaction/
|
1302
1312
|
[the full documentation]: http://rubydoc.info/github/orgsync/active_interaction
|
1303
1313
|
[semantic versioning]: http://semver.org/spec/v2.0.0.html
|
@@ -1317,3 +1327,4 @@ ActiveInteraction is licensed under [the MIT License][].
|
|
1317
1327
|
[the filters section]: #filters
|
1318
1328
|
[the optional inputs section]: #optional-inputs
|
1319
1329
|
[aire]: example
|
1330
|
+
[`with_options`]: http://api.rubyonrails.org/classes/Object.html#method-i-with_options
|
data/lib/active_interaction.rb
CHANGED
@@ -58,15 +58,13 @@ module ActiveInteraction
|
|
58
58
|
# @param (see ClassMethods.run)
|
59
59
|
#
|
60
60
|
# @return (see #result)
|
61
|
-
#
|
62
|
-
# @raise [Interrupt]
|
63
61
|
def compose(other, *args)
|
64
62
|
outcome = other.run(*args)
|
65
63
|
|
66
64
|
if outcome.valid?
|
67
65
|
outcome.result
|
68
66
|
else
|
69
|
-
|
67
|
+
throw :interrupt, outcome.errors
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
@@ -75,11 +73,15 @@ module ActiveInteraction
|
|
75
73
|
def run
|
76
74
|
return unless valid?
|
77
75
|
|
76
|
+
result_or_errors = catch(:interrupt) do
|
77
|
+
run_callbacks(:execute) { execute }
|
78
|
+
end
|
79
|
+
|
78
80
|
self.result =
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
if result_or_errors.is_a?(ActiveInteraction::Errors)
|
82
|
+
merge_errors_onto_base(result_or_errors)
|
83
|
+
else
|
84
|
+
result_or_errors
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
@@ -74,21 +74,6 @@ module ActiveInteraction
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
# Used by {Runnable} to signal a failure when composing.
|
78
|
-
#
|
79
|
-
# @private
|
80
|
-
class Interrupt < Error
|
81
|
-
attr_reader :outcome
|
82
|
-
|
83
|
-
# @param outcome [Runnable]
|
84
|
-
def initialize(outcome)
|
85
|
-
super()
|
86
|
-
|
87
|
-
@outcome = outcome
|
88
|
-
end
|
89
|
-
end
|
90
|
-
private_constant :Interrupt
|
91
|
-
|
92
77
|
# An extension that provides the ability to merge other errors into itself.
|
93
78
|
class Errors < ActiveModel::Errors
|
94
79
|
# Merge other errors into this one.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
fr:
|
2
|
+
active_interaction:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
invalid: est invalide
|
6
|
+
invalid_nested: possède une nested value invalide (%{name} => %{value})
|
7
|
+
invalid_type: n'est pas un %{type}
|
8
|
+
missing: est obligatoire
|
9
|
+
types:
|
10
|
+
array: array
|
11
|
+
boolean: boolean
|
12
|
+
date: date
|
13
|
+
date_time: date time
|
14
|
+
decimal: decimal
|
15
|
+
file: file
|
16
|
+
float: float
|
17
|
+
hash: hash
|
18
|
+
integer: integer
|
19
|
+
interface: interface
|
20
|
+
object: object
|
21
|
+
string: string
|
22
|
+
symbol: symbol
|
23
|
+
time: time
|
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: 2.1.
|
4
|
+
version: 2.1.5
|
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: 2015-
|
12
|
+
date: 2015-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -141,28 +141,28 @@ dependencies:
|
|
141
141
|
requirements:
|
142
142
|
- - "~>"
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: '3.
|
144
|
+
version: '3.4'
|
145
145
|
type: :development
|
146
146
|
prerelease: false
|
147
147
|
version_requirements: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - "~>"
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: '3.
|
151
|
+
version: '3.4'
|
152
152
|
- !ruby/object:Gem::Dependency
|
153
153
|
name: rubocop
|
154
154
|
requirement: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - "~>"
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0.
|
158
|
+
version: '0.35'
|
159
159
|
type: :development
|
160
160
|
prerelease: false
|
161
161
|
version_requirements: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - "~>"
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: '0.
|
165
|
+
version: '0.35'
|
166
166
|
- !ruby/object:Gem::Dependency
|
167
167
|
name: yard
|
168
168
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,6 +221,7 @@ files:
|
|
221
221
|
- lib/active_interaction/filters/time_filter.rb
|
222
222
|
- lib/active_interaction/grouped_input.rb
|
223
223
|
- lib/active_interaction/locale/en.yml
|
224
|
+
- lib/active_interaction/locale/fr.yml
|
224
225
|
- lib/active_interaction/modules/input_processor.rb
|
225
226
|
- lib/active_interaction/modules/validation.rb
|
226
227
|
- lib/active_interaction/version.rb
|
@@ -291,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
292
|
version: '0'
|
292
293
|
requirements: []
|
293
294
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.4.5
|
295
|
+
rubygems_version: 2.4.5.1
|
295
296
|
signing_key:
|
296
297
|
specification_version: 4
|
297
298
|
summary: Manage application specific business logic.
|