interactor-rails 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0bca65a85b90ff68610e82220b275faf616b80a
4
+ data.tar.gz: 51f17d71cca0017ee509b37f3aa41c936db590f8
5
+ SHA512:
6
+ metadata.gz: b00e58241eca2e87687fc1b2a1cdebe15dddfb42f10e716b32350c8da4c4fafd44bb6e6fdcba28870b1df6cc2d1f52100fc5c0d0d593324fc83fcee80bd57b73
7
+ data.tar.gz: 52620fdc3f02c27ff6be85d1e525fe49bf749cb87c7b27c140251837772f2e5ca45b9727f903e94f087eedfc9a5fff41cd075de93cd38284df02c9947fd90486
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /coverage
4
+ /gemfiles/*.gemfile.lock
5
+ /pkg
6
+ /tmp
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ branches:
2
+ only:
3
+ - master
4
+ gemfile:
5
+ - gemfiles/rails30.gemfile
6
+ - gemfiles/rails31.gemfile
7
+ - gemfiles/rails32.gemfile
8
+ - gemfiles/rails40.gemfile
9
+ language: ruby
10
+ rvm:
11
+ - 1.9.3
12
+ - 2.0.0
13
+ script: rspec
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem "aruba", "~> 0.5.3"
7
+ gem "coveralls", "~> 0.6.7", require: false
8
+ gem "rspec", "~> 2.14"
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steve Richert
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.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # Interactor Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/interactor-rails.png)](http://badge.fury.io/rb/interactor-rails)
4
+ [![Build Status](https://travis-ci.org/collectiveidea/interactor-rails.png?branch=master)](https://travis-ci.org/collectiveidea/interactor-rails)
5
+ [![Code Climate](https://codeclimate.com/github/collectiveidea/interactor-rails.png)](https://codeclimate.com/github/collectiveidea/interactor-rails)
6
+ [![Coverage Status](https://coveralls.io/repos/collectiveidea/interactor-rails/badge.png?branch=master)](https://coveralls.io/r/collectiveidea/interactor-rails?branch=master)
7
+ [![Dependency Status](https://gemnasium.com/collectiveidea/interactor-rails.png)](https://gemnasium.com/collectiveidea/interactor-rails)
8
+
9
+ Interactor Rails provides Rails support for the
10
+ [Interactor](https://github.com/collectiveidea/interactor) gem.
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem "interactor-rails", "~> 1.0"
18
+ ```
19
+
20
+ Interactor Rails is compatible with Ruby 1.9 or 2.0 on Rails 3 or 4.
21
+
22
+ ## Usage
23
+
24
+ Interactor Rails ensures that `app/interactors` is included in your autoload
25
+ paths, and provides generators for your convenience.
26
+
27
+ ```bash
28
+ rails generate interactor authenticate_user
29
+ ```
30
+
31
+ adds to `app/interactors/authenticate_user.rb`:
32
+
33
+ ```ruby
34
+ class AuthenticateUser
35
+ include Interactor
36
+
37
+ def perform
38
+ # TODO
39
+ end
40
+ end
41
+ ```
42
+
43
+ There is also a generator for organizers.
44
+
45
+ ```bash
46
+ rails generate interactor:organizer place_order charge_card send_thank_you fulfill_order
47
+ ```
48
+
49
+ adds to `app/interactors/place_order.rb`:
50
+
51
+ ```ruby
52
+ class PlaceOrder
53
+ include Interactor::Organizer
54
+
55
+ organize ChargeCard, SendThankYou, FulfillOrder
56
+ end
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ Interactor is open source and contributions from the community are encouraged!
62
+ No contribution is too small. Please consider:
63
+
64
+ * adding an awesome feature
65
+ * fixing a terrible bug
66
+ * updating documentation
67
+ * fixing a not-so-bad bug
68
+ * fixing typos
69
+
70
+ For the best chance of having your changes merged, please:
71
+
72
+ 1. Ask us! We'd love to hear what you're up to.
73
+ 2. Fork the project.
74
+ 3. Commit your changes and tests (if applicable (they're applicable)).
75
+ 4. Submit a pull request with a thorough explanation and at least one animated GIF.
76
+
77
+ ## Thanks
78
+
79
+ A very special thank you to [Attila Domokos](https://github.com/adomokos) for
80
+ his fantastic work on [LightService](https://github.com/adomokos/light-service).
81
+ Interactor is inspired heavily by the concepts put to code by Attila.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "~> 3.0.0"
6
+
7
+ group :test do
8
+ gem "aruba", "~> 0.5.3"
9
+ gem "coveralls", "~> 0.6.7", require: false
10
+ gem "rspec", "~> 2.14"
11
+ end
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "~> 3.1.0"
6
+
7
+ group :test do
8
+ gem "aruba", "~> 0.5.3"
9
+ gem "coveralls", "~> 0.6.7", require: false
10
+ gem "rspec", "~> 2.14"
11
+ end
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "~> 3.2.0"
6
+
7
+ group :test do
8
+ gem "aruba", "~> 0.5.3"
9
+ gem "coveralls", "~> 0.6.7", require: false
10
+ gem "rspec", "~> 2.14"
11
+ end
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rails", "~> 4.0.0"
6
+
7
+ group :test do
8
+ gem "aruba", "~> 0.5.3"
9
+ gem "coveralls", "~> 0.6.7", require: false
10
+ gem "rspec", "~> 2.14"
11
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "interactor-rails"
5
+ spec.version = "1.0.0"
6
+
7
+ spec.author = "Collective Idea"
8
+ spec.email = "info@collectiveidea.com"
9
+ spec.description = "Interactor Rails provides Rails support for the Interactor gem."
10
+ spec.summary = "Rails support for Interactor"
11
+ spec.homepage = "https://github.com/collectiveidea/interactor-rails"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.test_files = spec.files.grep(/^spec/)
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "interactor", "~> 1.0"
19
+ spec.add_dependency "rails", ">= 3", "< 5"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake", "~> 10.1"
23
+ end
@@ -0,0 +1,11 @@
1
+ module Interactor
2
+ class Generator < ::Rails::Generators::NamedBase
3
+ def self.source_root
4
+ File.expand_path("../templates", __FILE__)
5
+ end
6
+
7
+ def generate
8
+ template "#{self.class.generator_name}.erb", "app/interactors/#{file_name}.rb"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require "generators/interactor"
2
+
3
+ module Interactor
4
+ class OrganizerGenerator < Interactor::Generator
5
+ argument :interactors, type: :array, default: [], banner: "name name"
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require "generators/interactor"
2
+
3
+ class InteractorGenerator < Interactor::Generator
4
+ end
@@ -0,0 +1,7 @@
1
+ class <%= class_name %>
2
+ include Interactor
3
+
4
+ def perform
5
+ # TODO
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class <%= class_name %>
2
+ include Interactor::Organizer
3
+
4
+ <%- if interactors.any? -%>
5
+ organize <%= interactors.map(&:classify).join(", ") %>
6
+ <%- else -%>
7
+ # organize Interactor1, Interactor2
8
+ <%- end -%>
9
+ end
@@ -0,0 +1,4 @@
1
+ module Interactor
2
+ module Rails
3
+ end
4
+ end
@@ -0,0 +1,101 @@
1
+ require "spec_helper"
2
+
3
+ module Interactor
4
+ describe Rails do
5
+ before do
6
+ run_simple <<-CMD
7
+ bundle exec rails new example \
8
+ --skip-gemfile \
9
+ --skip-bundle \
10
+ --skip-git \
11
+ --skip-keeps \
12
+ --skip-active-record \
13
+ --skip-sprockets \
14
+ --skip-javascript \
15
+ --skip-test-unit \
16
+ --quiet
17
+ CMD
18
+ cd "example"
19
+ write_file "Gemfile", <<-EOF
20
+ gem "rails"
21
+ gem "interactor-rails", path: "#{ROOT}"
22
+ EOF
23
+ run_simple "bundle install"
24
+ end
25
+
26
+ context "rails generate" do
27
+ context "interactor" do
28
+ it "generates an interactor" do
29
+ run_simple "bundle exec rails generate interactor place_order"
30
+
31
+ path = "app/interactors/place_order.rb"
32
+ check_file_presence([path], true)
33
+ check_exact_file_content(path, <<-EOF)
34
+ class PlaceOrder
35
+ include Interactor
36
+
37
+ def perform
38
+ # TODO
39
+ end
40
+ end
41
+ EOF
42
+ end
43
+
44
+ it "requires a name" do
45
+ run_simple "bundle exec rails generate interactor"
46
+
47
+ check_file_presence(["app/interactors/place_order.rb"], false)
48
+ assert_partial_output("rails generate interactor NAME", all_stdout)
49
+ end
50
+ end
51
+
52
+ context "interactor:organizer" do
53
+ it "generates an organizer" do
54
+ run_simple <<-CMD
55
+ bundle exec rails generate interactor:organizer place_order
56
+ CMD
57
+
58
+ path = "app/interactors/place_order.rb"
59
+ check_file_presence([path], true)
60
+ check_exact_file_content(path, <<-EOF)
61
+ class PlaceOrder
62
+ include Interactor::Organizer
63
+
64
+ # organize Interactor1, Interactor2
65
+ end
66
+ EOF
67
+ end
68
+
69
+ it "generates an organizer with interactors" do
70
+ run_simple <<-CMD
71
+ bundle exec rails generate interactor:organizer place_order \
72
+ charge_card fulfill_order
73
+ CMD
74
+
75
+ path = "app/interactors/place_order.rb"
76
+ check_file_presence([path], true)
77
+ check_exact_file_content(path, <<-EOF)
78
+ class PlaceOrder
79
+ include Interactor::Organizer
80
+
81
+ organize ChargeCard, FulfillOrder
82
+ end
83
+ EOF
84
+ end
85
+
86
+ it "requires a name" do
87
+ run_simple "bundle exec rails generate interactor:organizer"
88
+
89
+ check_file_presence(["app/interactors/place_order.rb"], false)
90
+ assert_partial_output("rails generate interactor:organizer NAME", all_stdout)
91
+ end
92
+ end
93
+ end
94
+
95
+ it "auto-loads interactors" do
96
+ run_simple "bundle exec rails generate interactor place_order"
97
+
98
+ run_simple "bundle exec rails runner PlaceOrder"
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,11 @@
1
+ require "coveralls"
2
+ Coveralls.wear!
3
+
4
+ require "interactor/rails"
5
+
6
+ require "bundler"
7
+ Bundler.require(:test)
8
+
9
+ ROOT = File.expand_path("../..", __FILE__)
10
+
11
+ Dir[File.expand_path("../support/*.rb", __FILE__)].each { |f| require f }
@@ -0,0 +1,11 @@
1
+ require "aruba/api"
2
+
3
+ RSpec.configure do |config|
4
+ config.include(Aruba::Api)
5
+
6
+ config.before do
7
+ @aruba_timeout_seconds = 60
8
+ FileUtils.rm_rf(current_dir)
9
+ unset_bundler_env_vars
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.order = "random"
3
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interactor-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Collective Idea
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: interactor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3'
34
+ - - <
35
+ - !ruby/object:Gem::Version
36
+ version: '5'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '3'
44
+ - - <
45
+ - !ruby/object:Gem::Version
46
+ version: '5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '1.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '10.1'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: '10.1'
75
+ description: Interactor Rails provides Rails support for the Interactor gem.
76
+ email: info@collectiveidea.com
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - .gitignore
82
+ - .travis.yml
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - gemfiles/rails30.gemfile
88
+ - gemfiles/rails31.gemfile
89
+ - gemfiles/rails32.gemfile
90
+ - gemfiles/rails40.gemfile
91
+ - interactor-rails.gemspec
92
+ - lib/generators/interactor.rb
93
+ - lib/generators/interactor/organizer_generator.rb
94
+ - lib/generators/interactor_generator.rb
95
+ - lib/generators/templates/interactor.erb
96
+ - lib/generators/templates/organizer.erb
97
+ - lib/interactor/rails.rb
98
+ - spec/interactor/rails_spec.rb
99
+ - spec/spec_helper.rb
100
+ - spec/support/aruba.rb
101
+ - spec/support/random.rb
102
+ homepage: https://github.com/collectiveidea/interactor-rails
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.5
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Rails support for Interactor
126
+ test_files:
127
+ - spec/interactor/rails_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/support/aruba.rb
130
+ - spec/support/random.rb