activeinteractor 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 4872bd78ecedca5b6277acdca57fd623b66823adb067fa002f00208e2128ce98
4
- data.tar.gz: 3445c265ef4ba5a9338f67e5ef347cf63bf60412a6320de2250c697fe6b049f6
3
+ metadata.gz: e933d8615e2b55bf47049e291b801193e2341b03e3c0a29bb8d8f7c8166adee3
4
+ data.tar.gz: afc759ee08f37bbbba50e2ac6c1508afb0d303c0f37ca5cdfcf75d6347e210b0
5
5
  SHA512:
6
- metadata.gz: 7f8ff6addc793b5179d67d6f522a0c1527c3bcede0b851a8a6e5dd7c833c2fd2d27b7480c39525deb7fcaad294313563f2fdd72bf34c29ad86b5563d511c1940
7
- data.tar.gz: ef2a2ef6abe7aaf86b84cdf9ca99bc19d97aca78b85bf6c83c50862d40520c2a80209ec91b178bd4c1a1673a122d08f538ca0313464077c82af89fb21080472a
6
+ metadata.gz: 8edc74485608e067bb6e9e9df3a19d9c0651df4351c9e56239b41ce1fb39fa4d7595e08366799fcbcfa79390e0fe1a1f1b0a652e01f8855905d93dcc53d05b69
7
+ data.tar.gz: 0d8b82c2ebfce20b413a4563eb0244081b1ca3910186de9ad9880cc246408df68e282ef0ec21adb4f89eda7947fe79c62555f1c24c8795a08dff15bd7dec621d
data/CHANGELOG.md CHANGED
@@ -7,12 +7,18 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v0.1.2] - 2019-04-01
11
+
12
+ ### Added
13
+
14
+ - #22: Allow the directory interactors are generated in to be configurable
15
+
10
16
  ## [v0.1.1] - 2019-03-30
11
17
 
12
18
  ### Fixed
13
19
 
14
- - #15: NameError (uninitialized constant ActiveInteractor::Organizer)
15
- - #16: NoMethodError (undefined method `merge' for #<ActiveInteractor::Context::Base>)
20
+ - #15: `NameError` (uninitialized constant `ActiveInteractor::Organizer`)
21
+ - #16: `NoMethodError` (undefined method `merge` for `ActiveInteractor::Context::Base`)
16
22
 
17
23
  ## v0.1.0 - 2019-03-30
18
24
 
@@ -21,5 +27,6 @@ and this project adheres to [Semantic Versioning].
21
27
  [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
22
28
  [Semantic Versioning]: https://semver.org/spec/v2.0.0.html
23
29
 
24
- [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.1...HEAD
30
+ [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.2...HEAD
31
+ [v0.1.2]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.1...v0.1.2
25
32
  [v0.1.1]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.0...v0.1.1
@@ -8,6 +8,7 @@ module ActiveInteractor
8
8
  # @version 0.1
9
9
  class Base
10
10
  include Interactor
11
+
11
12
  # A new instance of {Base}
12
13
  # @param context [Hash, nil] the properties of the context
13
14
  # @return [ActiveInteractor::Base] a new instance of {Base}
@@ -12,11 +12,14 @@ module ActiveInteractor
12
12
  class Configuration
13
13
  # The default configuration options for {Configuration}
14
14
  # @return [Hash{Symbol => *}]
15
+ # * :logger - The Logger instance to use for logging
16
+ # * :dir_name - The directory interactors are generated in
15
17
  DEFAULTS = {
16
- logger: Logger.new(STDOUT)
18
+ logger: Logger.new(STDOUT),
19
+ dir_name: 'interactors'
17
20
  }.freeze
18
21
 
19
- attr_accessor :logger
22
+ attr_accessor :logger, :dir_name
20
23
 
21
24
  # A new instance of {Configuration}
22
25
  # @param options [Hash{Symbol => *}] the options to initialize the
@@ -5,14 +5,8 @@ module ActiveInteractor
5
5
  module Execution
6
6
  extend ActiveSupport::Concern
7
7
 
8
- DELEGATED_WORKER_METHODS = %i[
9
- execute_perform
10
- execute_perform!
11
- execute_rollback
12
- ].freeze
13
-
14
8
  included do
15
- delegate(*DELEGATED_WORKER_METHODS, to: :worker)
9
+ delegate :execute_perform, :execute_perform!, :execute_rollback, to: :worker
16
10
  end
17
11
 
18
12
  private
@@ -38,7 +38,9 @@ module ActiveInteractor
38
38
  # in favor of this default implementation.
39
39
  def perform
40
40
  self.class.organized.each do |interactor|
41
- self.context = interactor.new(context).tap(&:skip_clean_context!).execute_perform!
41
+ self.context = interactor.new(context)
42
+ .tap(&:skip_clean_context!)
43
+ .execute_perform!
42
44
  end
43
45
  end
44
46
  end
@@ -3,5 +3,5 @@
3
3
  module ActiveInteractor
4
4
  # The ActiveInteractor gem version
5
5
  # @return [String] the gem version
6
- VERSION = '0.1.1'
6
+ VERSION = '0.1.2'
7
7
  end
@@ -6,22 +6,22 @@ module ActiveInteractor
6
6
  module Generators
7
7
  class InstallGenerator < Base
8
8
  def create_initializer
9
- template 'initializer.rb', File.join('config', 'initializers', 'active_interactor.rb')
9
+ template 'initializer.rb', Rails.root.join('config', 'initializers', 'active_interactor.rb')
10
10
  end
11
11
 
12
12
  def create_application_interactor
13
- template 'application_interactor.erb', File.join('app', 'interactors', 'application_interactor.rb')
13
+ template 'application_interactor.erb', Rails.root.join('app', app_dir_name, 'application_interactor.rb')
14
14
  end
15
15
 
16
16
  def create_interactor_concerns
17
- create_file 'app/interactors/concerns/.keep'
17
+ create_file Rails.root.join('app', app_dir_name, 'concerns', '.keep')
18
18
  end
19
19
 
20
20
  def autoload_interactors
21
21
  application do
22
22
  <<~CONFIG
23
23
  # autoload interactors
24
- config.autoload_paths += %w[app/interactors]
24
+ config.autoload_paths += %w[app/#{app_dir_name}]
25
25
 
26
26
  CONFIG
27
27
  end
@@ -11,7 +11,7 @@ module ActiveInteractor
11
11
  extend ActiveSupport::Concern
12
12
 
13
13
  class_methods do
14
- def self.base_root
14
+ def base_root
15
15
  __dir__
16
16
  end
17
17
 
@@ -19,6 +19,10 @@ module ActiveInteractor
19
19
  File.expand_path('templates', __dir__)
20
20
  end
21
21
  end
22
+
23
+ def app_dir_name
24
+ ActiveInteractor.configuration.dir_name
25
+ end
22
26
  end
23
27
 
24
28
  class Base < ::Rails::Generators::Base
@@ -6,7 +6,7 @@ class InteractorGenerator < ActiveInteractor::Generators::NamedBase
6
6
  desc 'Generate an interactor'
7
7
 
8
8
  def create_interactor
9
- template 'interactor.erb', File.join('app', 'interactors', class_path, "#{file_name}.rb")
9
+ template 'interactor.erb', Rails.root.join('app', app_dir_name, File.join(class_path), "#{file_name}.rb")
10
10
  end
11
11
 
12
12
  hook_for :test_framework, in: :interactor
@@ -9,7 +9,7 @@ module Interactor
9
9
  argument :interactors, type: :array, default: [], banner: 'name name'
10
10
 
11
11
  def create_organizer
12
- template 'organizer.erb', File.join('app', 'interactors', class_path, "#{file_name}.rb")
12
+ template 'organizer.erb', Rails.root.join('app', app_dir_name, File.join(class_path), "#{file_name}.rb")
13
13
  end
14
14
 
15
15
  hook_for :test_framework, in: :interactor
@@ -8,7 +8,7 @@ module Interactor
8
8
  desc 'Generate an interactor spec'
9
9
 
10
10
  def create_spec
11
- template 'rspec.erb', File.join('spec', 'interactors', class_path, "#{file_name}_spec.rb")
11
+ template 'rspec.erb', Rails.root.join('spec', app_dir_name, File.join(class_path), "#{file_name}_spec.rb")
12
12
  end
13
13
  end
14
14
  end
@@ -8,7 +8,7 @@ module Interactor
8
8
  desc 'Generate an interactor unit test'
9
9
 
10
10
  def create_test
11
- template 'test_unit.erb', File.join('test', 'interactors', class_path, "#{file_name}_test.rb")
11
+ template 'test_unit.erb', Rails.root.join('test', app_dir_name, File.join(class_path), "#{file_name}_test.rb")
12
12
  end
13
13
  end
14
14
  end
@@ -5,4 +5,11 @@ require 'active_interactor'
5
5
  ActiveInteractor.configure do |config|
6
6
  # Set the ActiveInteractor.logger to Rails.logger
7
7
  config.logger = Rails.logger
8
+
9
+ # Set the default directory for interactors
10
+ # NOTE: if this is changed after `active_interactor:install`
11
+ # is generated you will need to update
12
+ # config/application.rb autoload paths with the
13
+ # new directory name.
14
+ # config.dir_name = 'interactors'
8
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeinteractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-30 00:00:00.000000000 Z
11
+ date: 2019-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -244,10 +244,10 @@ licenses:
244
244
  - MIT
245
245
  metadata:
246
246
  bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
247
- changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v0.1.1/CHANGELOG.md
248
- documentation_uri: https://www.rubydoc.info/gems/activeinteractor/0.1.1
247
+ changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v0.1.2/CHANGELOG.md
248
+ documentation_uri: https://www.rubydoc.info/gems/activeinteractor/0.1.2
249
249
  hompage_uri: https://github.com/aaronmallen/activeinteractor
250
- source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v0.1.1
250
+ source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v0.1.2
251
251
  wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
252
252
  post_install_message:
253
253
  rdoc_options: []