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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a82290d24f562e44617bf6deba80d915d78113f
4
- data.tar.gz: c6e08917700fe184b5bfe9acd9443fce727f5138
3
+ metadata.gz: 7a54101dfa80812134a34c6977fa538e23d67c7f
4
+ data.tar.gz: 3a3d21348e1f37a649ca23801a1b01f5974c9399
5
5
  SHA512:
6
- metadata.gz: 804a4044b041fa61133131811df899bc7c934fb153662f4438cb21e18f780624e76e30ecb6fa0b4894ad24dbfd89050a437a9e712972460e490939b859ad1d99
7
- data.tar.gz: a896550485474632bf0111ba1665eac326091b025e79c9ea1f0826bc079d8a0cde2000e5692884058a85ed37a15d001452e5b09a9f4bed9d24036255ccfc30d5
6
+ metadata.gz: 04fe6f23d9235893ca47203481f9f4a7709acffebb0d8f24f3769ccfe07dc8b52133e3e82f2f1be039eaf8a4859572536c106d0bc5fffcf96fffb767c3a4226a
7
+ data.tar.gz: df1cf833864649ddb7d402a3da8b657987863da264728f755657625d3cda9293c58968509608b2ae6a12831a71d91141d5c638e7650d10050c666407b0c71945
@@ -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
- <h1 align="center">
2
- <a href="https://github.com/orgsync/active_interaction">
3
- ActiveInteraction
4
- </a>
5
- </h1>
6
-
7
- <p align="center">
8
- ActiveInteraction manages application-specific business logic.
9
- It's an implementation of the command pattern in Ruby.
10
- </p>
11
-
12
- <p align="center">
13
- <a href="https://rubygems.org/gems/active_interaction"><img alt="Version" src="https://img.shields.io/gem/v/active_interaction.svg?label=version&amp;style=flat-square"></a>
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&amp;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&amp;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&amp;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&amp;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
+ [![Version](https://img.shields.io/gem/v/active_interaction.svg?label=version)](https://rubygems.org/gems/active_interaction)
7
+ [![Build](https://img.shields.io/travis/orgsync/active_interaction/master.svg?label=build)](https://travis-ci.org/orgsync/active_interaction)
8
+ [![Coverage](https://img.shields.io/coveralls/orgsync/active_interaction/master.svg?label=coverage)](https://coveralls.io/r/orgsync/active_interaction)
9
+ [![Climate](https://img.shields.io/codeclimate/github/orgsync/active_interaction.svg?label=climate)](https://codeclimate.com/github/orgsync/active_interaction)
10
+ [![Grade](https://img.shields.io/badge/grade-A-brightgreen.svg)](http://www.libgrader.com/libraries/ruby/active_interaction)
11
+ [![Dependencies](https://img.shields.io/gemnasium/orgsync/active_interaction.svg?label=dependencies)](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
@@ -9,7 +9,7 @@ require 'active_model'
9
9
  #
10
10
  # @since 1.0.0
11
11
  #
12
- # @version 2.1.4
12
+ # @version 2.1.5
13
13
  module ActiveInteraction
14
14
  end
15
15
 
@@ -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
- fail Interrupt, outcome
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
- begin
80
- run_callbacks(:execute) { execute }
81
- rescue Interrupt => interrupt
82
- merge_errors_onto_base(interrupt.outcome.errors)
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
@@ -5,5 +5,5 @@ module ActiveInteraction
5
5
  # The version number.
6
6
  #
7
7
  # @return [Gem::Version]
8
- VERSION = Gem::Version.new('2.1.4')
8
+ VERSION = Gem::Version.new('2.1.5')
9
9
  end
@@ -43,7 +43,7 @@ describe ActiveInteraction::Runnable do
43
43
  context name do
44
44
  it 'does not raise an error' do
45
45
  expect do
46
- klass.set_callback name, :before, -> _ {}
46
+ klass.set_callback name, :before, -> {}
47
47
  end.to_not raise_error
48
48
  end
49
49
 
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
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-11-03 00:00:00.000000000 Z
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.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.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.34'
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.34'
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.