active_interaction 2.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: ec03f8a492e5db88366e50b9a918ff40a4e008b3
4
- data.tar.gz: 356b91990bfac14981a6d36dffcaafb4e3dd2d33
3
+ metadata.gz: d65a75d08fc8be7355ec025ebaed8b08873819c0
4
+ data.tar.gz: 3d75fd27e50013507a73176b40ba466e949b937f
5
5
  SHA512:
6
- metadata.gz: a68094094d6dbf8a395a3f709ffd993944512c6edc921ce36f99b4383792de041954cc2d73271a0748102782f89c4e457bb63288ee56eb34e42ff6cb38fbcbd5
7
- data.tar.gz: d682f33e94ea7bd25f4f9cf89e2fe3924bc501e608c6d32f469da42d92782f88aca01b43605c69adb5de62e36b2cafe3857307ff927a2306dbbb25ef334c4f93
6
+ metadata.gz: d807465b1015098c9c77c33c4429cd685fdf2eb268c83388ecd8b57110f12d1716309f1100c42fd2fda9b4bbefc9c612545c74905e6a17117fed45710ad5925c
7
+ data.tar.gz: 10c78c1906541dc8b89060c16bc957a44a9cd9519988e0633382c9609d4b101fa82ce9420df5fbf8b83a6f7ae9db4f76549c7075f5656d41a9423a52becd89db
@@ -1,5 +1,14 @@
1
+ # [2.0.1][] (2015-05-27)
2
+
3
+ ## Fixed
4
+
5
+ - [#286][]: Change `file` filter to check for `rewind` instead of `eof?`.
6
+ - [#289][]: Actually removed `model` filter, which was deprecated in v1.6.0.
7
+
1
8
  # [2.0.0][] (2015-05-06)
2
9
 
10
+ For help upgrading to version 2, please read [the announcement post][].
11
+
3
12
  ## Changed
4
13
 
5
14
  - [#250][]: Replaced symbolic errors with Rails 5-style detailed errors.
@@ -414,6 +423,7 @@
414
423
 
415
424
  - Initial release.
416
425
 
426
+ [2.0.1]: https://github.com/orgsync/active_interaction/compare/v2.0.0...v2.0.1
417
427
  [2.0.0]: https://github.com/orgsync/active_interaction/compare/v1.6.0...v2.0.0
418
428
  [1.6.0]: https://github.com/orgsync/active_interaction/compare/v1.5.1...v1.6.0
419
429
  [1.5.1]: https://github.com/orgsync/active_interaction/compare/v1.5.0...v1.5.1
@@ -544,3 +554,7 @@
544
554
  [#264]: https://github.com/orgsync/active_interaction/issues/264
545
555
  [#265]: https://github.com/orgsync/active_interaction/issues/265
546
556
  [#269]: https://github.com/orgsync/active_interaction/issues/269
557
+ [#286]: https://github.com/orgsync/active_interaction/issues/286
558
+ [#289]: https://github.com/orgsync/active_interaction/issues/289
559
+
560
+ [the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
@@ -10,10 +10,4 @@
10
10
 
11
11
  Running the tests using `rake` (with no args) or within `guard` will also check for style issues in the code. Ideally all submissions would pass these checks. If the code style is causing issues (particularly the method or class size) we can work with you to correct it. Don't let it stop you from contributing.
12
12
 
13
- # Vagrant
14
-
15
- If you like to use [Vagrant][] we've provided a [Vagrantfile][] for your convenience.
16
-
17
13
  [fork]: https://github.com/orgsync/active_interaction/fork
18
- [Vagrant]: http://www.vagrantup.com
19
- [Vagrantfile]: Vagrantfile
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 to 2015 Aaron Lasseigne and Taylor Fausak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -14,11 +14,11 @@
14
14
  </p>
15
15
 
16
16
  <p align="center">
17
- <a href="https://rubygems.org/gems/active_interaction"><img alt="" src="https://img.shields.io/gem/v/active_interaction.svg?label=version&amp;style=flat-square"></a>
18
- <a href="https://travis-ci.org/orgsync/active_interaction"><img alt="" src="https://img.shields.io/travis/orgsync/active_interaction/master.svg?label=build&amp;style=flat-square"></a>
19
- <a href="https://coveralls.io/r/orgsync/active_interaction"><img alt="" src="https://img.shields.io/coveralls/orgsync/active_interaction/master.svg?label=coverage&amp;style=flat-square"></a>
20
- <a href="https://codeclimate.com/github/orgsync/active_interaction"><img alt="" src="https://img.shields.io/codeclimate/github/orgsync/active_interaction.svg?label=climate&amp;style=flat-square"></a>
21
- <a href="https://gemnasium.com/orgsync/active_interaction"><img alt="" src="https://img.shields.io/gemnasium/orgsync/active_interaction.svg?label=dependencies&amp;style=flat-square"></a>
17
+ <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>
18
+ <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>
19
+ <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>
20
+ <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>
21
+ <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>
22
22
  </p>
23
23
 
24
24
  <hr>
@@ -85,7 +85,8 @@ $ gem install active_interaction --version '~> 2.0'
85
85
  ```
86
86
 
87
87
  This project uses [Semantic Versioning][]. Check out [the change log][] for a
88
- detailed list of changes.
88
+ detailed list of changes. For help upgrading to version 2, please read [the
89
+ announcement post][].
89
90
 
90
91
  ActiveInteraction works with all supported versions of Ruby (2.0 through 2.2)
91
92
  and ActiveModel (3.2 through 4.2).
@@ -1079,9 +1080,12 @@ end
1079
1080
 
1080
1081
  ### Forms
1081
1082
 
1082
- The outcome returned by `.run` can be used in forms as though it were an ActiveModel object. You can also create a form object by calling `.new` on the interaction.
1083
+ The outcome returned by `.run` can be used in forms as though it were an
1084
+ ActiveModel object. You can also create a form object by calling `.new` on the
1085
+ interaction.
1083
1086
 
1084
- Given an application with an `Account` model we'll create a new `Account` using the `CreateAccount` interaction.
1087
+ Given an application with an `Account` model we'll create a new `Account` using
1088
+ the `CreateAccount` interaction.
1085
1089
 
1086
1090
  ```rb
1087
1091
  # GET /accounts/new
@@ -1102,9 +1106,10 @@ def create
1102
1106
  end
1103
1107
  ```
1104
1108
 
1105
- The form used to create a new `Account` has slightly more information on the `form_for` call than you might expect.
1109
+ The form used to create a new `Account` has slightly more information on the
1110
+ `form_for` call than you might expect.
1106
1111
 
1107
- ```rb
1112
+ ```erb
1108
1113
  <%= form_for @account, as: :account, url: accounts_path do |f| %>
1109
1114
  <%= f.text_field :first_name %>
1110
1115
  <%= f.text_field :last_name %>
@@ -1112,11 +1117,13 @@ The form used to create a new `Account` has slightly more information on the `fo
1112
1117
  <% end %>
1113
1118
  ```
1114
1119
 
1115
- This is necessary because we want the form to act like it is creating a new `Account`. Defining `to_model` on the `CreateAccount` interaction tells the form to treat our interaction like an `Account`.
1120
+ This is necessary because we want the form to act like it is creating a new
1121
+ `Account`. Defining `to_model` on the `CreateAccount` interaction tells the
1122
+ form to treat our interaction like an `Account`.
1116
1123
 
1117
1124
  ```rb
1118
1125
  class CreateAccount < ActiveInteraction::Base
1119
- ...
1126
+ # ...
1120
1127
 
1121
1128
  def to_model
1122
1129
  Account.new
@@ -1124,16 +1131,35 @@ class CreateAccount < ActiveInteraction::Base
1124
1131
  end
1125
1132
  ```
1126
1133
 
1127
- Now our `form_for` call knows how to generate the correct URL and param name (i.e. `params[:account]`).
1134
+ Now our `form_for` call knows how to generate the correct URL and param name
1135
+ (i.e. `params[:account]`).
1128
1136
 
1129
- ```rb
1137
+ ```erb
1130
1138
  # app/views/accounts/new.html.erb
1131
1139
  <%= form_for @account do |f| %>
1132
- ...
1140
+ <%# ... %>
1133
1141
  <% end %>
1134
1142
  ```
1135
1143
 
1136
- ActiveInteraction also supports [formtastic][] and [simple_form][]. The filters used to define the inputs on your interaction will relay type information to these gems. As a result, form fields will automatically use the appropriate input type.
1144
+ If you have an interaction that updates an `Account`, you can define `to_model`
1145
+ to return the object you're updating.
1146
+
1147
+ ```rb
1148
+ class UpdateAccount < ActiveInteraction::Base
1149
+ # ...
1150
+
1151
+ object :account
1152
+
1153
+ def to_model
1154
+ account
1155
+ end
1156
+ end
1157
+ ```
1158
+
1159
+ ActiveInteraction also supports [formtastic][] and [simple_form][]. The filters
1160
+ used to define the inputs on your interaction will relay type information to
1161
+ these gems. As a result, form fields will automatically use the appropriate
1162
+ input type.
1137
1163
 
1138
1164
  ### Predicates
1139
1165
 
@@ -1227,6 +1253,7 @@ Logo design by [Tyler Lee][].
1227
1253
  [the full documentation]: http://rubydoc.info/github/orgsync/active_interaction
1228
1254
  [semantic versioning]: http://semver.org/spec/v2.0.0.html
1229
1255
  [the change log]: CHANGELOG.md
1256
+ [the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
1230
1257
  [active_model-errors_details]: https://github.com/cowbell/active_model-errors_details
1231
1258
  [aaron lasseigne]: https://github.com/AaronLasseigne
1232
1259
  [taylor fausak]: https://github.com/tfausak
@@ -1235,7 +1262,7 @@ Logo design by [Tyler Lee][].
1235
1262
  [mutations]: https://github.com/cypriss/mutations
1236
1263
  [our contribution guidelines]: CONTRIBUTING.md
1237
1264
  [complete list of contributors]: https://github.com/orgsync/active_interaction/graphs/contributors
1238
- [the mit license]: LICENSE.txt
1265
+ [the mit license]: LICENSE.md
1239
1266
  [formtastic]: https://rubygems.org/gems/formtastic
1240
1267
  [simple_form]: https://rubygems.org/gems/simple_form
1241
1268
  [tyler lee]: https://github.com/tylerlee
@@ -9,19 +9,8 @@ require 'active_model'
9
9
  #
10
10
  # @since 1.0.0
11
11
  #
12
- # @version 2.0.0
12
+ # @version 2.0.1
13
13
  module ActiveInteraction
14
- DEPRECATOR =
15
- if ::ActiveSupport::Deprecation.respond_to?(:new)
16
- ::ActiveSupport::Deprecation.new('2', 'ActiveInteraction')
17
- end
18
- private_constant :DEPRECATOR
19
-
20
- def self.deprecate(klass, method, message = nil)
21
- options = { method => message }
22
- options.merge!(deprecator: DEPRECATOR) if DEPRECATOR
23
- klass.deprecate(options)
24
- end
25
14
  end
26
15
 
27
16
  require 'active_interaction/version'
@@ -99,11 +99,6 @@ module ActiveInteraction
99
99
  end
100
100
  end
101
101
 
102
- def model(*)
103
- super
104
- end
105
- ActiveInteraction.deprecate self, :model, 'use `object` instead'
106
-
107
102
  private
108
103
 
109
104
  # @param klass [Class]
@@ -54,11 +54,6 @@ module ActiveInteraction
54
54
  end
55
55
  end
56
56
 
57
- def model(*)
58
- super
59
- end
60
- ActiveInteraction.deprecate self, :model, 'use `object` instead'
61
-
62
57
  private
63
58
 
64
59
  # @return [Array<Class>]
@@ -4,8 +4,9 @@ module ActiveInteraction
4
4
  class Base
5
5
  # @!method self.file(*attributes, options = {})
6
6
  # Creates accessors for the attributes and ensures that values passed to
7
- # the attributes respond to the `eof?` method. This is useful when passing
8
- # in Rails params that include a file upload or another generic IO object.
7
+ # the attributes respond to the `rewind` method. This is useful when
8
+ # passing in Rails params that include a file upload or another generic
9
+ # IO object.
9
10
  #
10
11
  # @!macro filter_method_params
11
12
  #
@@ -24,7 +25,7 @@ module ActiveInteraction
24
25
  private
25
26
 
26
27
  def methods
27
- [:eof?]
28
+ [:rewind]
28
29
  end
29
30
  end
30
31
  end
@@ -49,11 +49,6 @@ module ActiveInteraction
49
49
  end
50
50
  end
51
51
 
52
- def model(*)
53
- super
54
- end
55
- ActiveInteraction.deprecate self, :model, 'use `object` instead'
56
-
57
52
  private
58
53
 
59
54
  def clean_value(h, name, filter, value)
@@ -5,5 +5,5 @@ module ActiveInteraction
5
5
  # The version number.
6
6
  #
7
7
  # @return [Gem::Version]
8
- VERSION = Gem::Version.new('2.0.0')
8
+ VERSION = Gem::Version.new('2.0.1')
9
9
  end
@@ -2,15 +2,15 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- InteractionWithFilter = Class.new(TestInteraction) do
5
+ class InteractionWithFilter < TestInteraction
6
6
  float :thing
7
7
  end
8
8
 
9
- InteractionWithDateFilter = Class.new(TestInteraction) do
9
+ class InteractionWithDateFilter < TestInteraction
10
10
  date :thing
11
11
  end
12
12
 
13
- AddInteraction = Class.new(TestInteraction) do
13
+ class AddInteraction < TestInteraction
14
14
  float :x, :y
15
15
 
16
16
  def execute
@@ -18,7 +18,7 @@ AddInteraction = Class.new(TestInteraction) do
18
18
  end
19
19
  end
20
20
 
21
- InterruptInteraction = Class.new(TestInteraction) do
21
+ class InterruptInteraction < TestInteraction
22
22
  object :x, :y,
23
23
  class: Object,
24
24
  default: nil
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- InteractionWithFloatFilter = Class.new(TestInteraction) do
5
+ class InteractionWithFloatFilter < TestInteraction
6
6
  float :thing
7
7
  end
8
8
 
@@ -25,8 +25,8 @@ describe ActiveInteraction::FileFilter, :filter do
25
25
  end
26
26
  end
27
27
 
28
- context 'with an object that responds to #eof?' do
29
- let(:value) { double(eof?: true) }
28
+ context 'with an object that responds to #rewind' do
29
+ let(:value) { double(rewind: nil) }
30
30
 
31
31
  it 'returns the object' do
32
32
  expect(result).to eq value
@@ -12,7 +12,7 @@ describe ActiveInteraction do
12
12
  end
13
13
  end
14
14
 
15
- I18nInteraction = Class.new(TestInteraction) do
15
+ class I18nInteraction < TestInteraction
16
16
  hash :a do
17
17
  hash :x
18
18
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- ArrayInteraction = Class.new(TestInteraction) do
5
+ class ArrayInteraction < TestInteraction
6
6
  array :a do
7
7
  array
8
8
  end
@@ -1,7 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'spec_helper'
4
+ require 'action_dispatch'
4
5
 
5
- describe 'FileInteraction' do
6
+ class FileInteraction < TestInteraction
7
+ file :a
8
+ end
9
+
10
+ describe FileInteraction do
11
+ include_context 'interactions'
6
12
  it_behaves_like 'an interaction', :file, -> { File.open(__FILE__) }
13
+
14
+ it 'works with an uploaded file' do
15
+ file = File.open(__FILE__)
16
+ uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: file)
17
+ inputs[:a] = uploaded_file
18
+ expect(outcome).to be_valid
19
+ end
7
20
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- HashInteraction = Class.new(TestInteraction) do
5
+ class HashInteraction < TestInteraction
6
6
  hash :a do
7
7
  hash :x
8
8
  end
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
  require 'json'
5
5
  require 'yaml'
6
6
 
7
- InterfaceInteraction = Class.new(TestInteraction) do
7
+ class InterfaceInteraction < TestInteraction
8
8
  interface :anything
9
9
  end
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- ObjectInteraction = Class.new(TestInteraction) do
5
+ class ObjectInteraction < TestInteraction
6
6
  object :object
7
7
  end
8
8
 
@@ -25,7 +25,7 @@ TimeWithZone = Class.new do
25
25
  end
26
26
  end
27
27
 
28
- TimeInteraction = Class.new(TestInteraction) do
28
+ class TimeInteraction < TestInteraction
29
29
  time :a
30
30
  end
31
31
 
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.0.0
4
+ version: 2.0.1
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-05-06 00:00:00.000000000 Z
12
+ date: 2015-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -31,6 +31,26 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5'
34
+ - !ruby/object:Gem::Dependency
35
+ name: actionpack
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ - - "<"
42
+ - !ruby/object:Gem::Version
43
+ version: '5'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '3.2'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '5'
34
54
  - !ruby/object:Gem::Dependency
35
55
  name: bundler
36
56
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +189,7 @@ extra_rdoc_files: []
169
189
  files:
170
190
  - CHANGELOG.md
171
191
  - CONTRIBUTING.md
172
- - LICENSE.txt
192
+ - LICENSE.md
173
193
  - README.md
174
194
  - lib/active_interaction.rb
175
195
  - lib/active_interaction/backports.rb
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Aaron Lasseigne
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.