activeinteractor 1.0.0.beta.1 → 1.0.0.beta.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: f04cfc71e44fdbf89253cb31c1252781a094fa107763c0d27aa853f9d008774e
4
- data.tar.gz: 2ca6bff9224913bd7420f74387c4d7cec2b704ac45f0d79ab5a4fa64ad46894b
3
+ metadata.gz: 1dcf3dc4d0f528400e6322827f343a2e4652fd71611061af586c0f984acc9e5e
4
+ data.tar.gz: b295be6c1061186c44094cc9aececec4be23719a3033dfd25a8dfb784a732e72
5
5
  SHA512:
6
- metadata.gz: 0d106d19d463424f0a406183713dc18ed27d6830fce6b685a96264a6f4396fd9ea18847c819b8dff12639cb319a42bb9ea22a5e5fbfade7e0678fe489a9fe25c
7
- data.tar.gz: 75e3ef76a19f93ca5f795572403ad10338ef42c23db7e97b582fbe1922db8eafa946da83e02c5b20c129e415feb67b4e7c135c89151fd45a3f415c00e4fd0bf0
6
+ metadata.gz: 5910c5d2c343125cd715894d646975c356737d66a62390240d0189e241fe98766099a05231ea7d7b382aa8cfdaa2ab44a4b12c3d3a178355130991bf47ec5ebd
7
+ data.tar.gz: 8892204ed0d17a68b595bda665947fc89ad67a6e1cd5d29ed303c18312a5fb3719252bf14684254ea68c20500daae38afce46e102d48c2e8b2f0793bb6005729
data/CHANGELOG.md CHANGED
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v1.0.0-beta.2] - 2020-01-07
11
+
12
+ ### Added
13
+
14
+ - [#102] `ActiveInteractor::Config`
15
+ - [#102] `ActiveInteractor.config`
16
+ - [#103] `ActiveInteractor::Rails`
17
+ - [#103] `ActiveInteractor::Rails::Config`
18
+ - [#102] `ActiveInteractor::Railtie`
19
+ - [#105] interactor, organizer, and context generators now accept context_attributes
20
+ as arguments.
21
+
22
+ ### Changed
23
+
24
+ - [#102] `ActiveInteractor.logger` is now part of `ActiveInteractor.config`
25
+ - [#104] Interactor generators will no longer generate separate context classes for
26
+ interactors if `ActiveInteractor.config.rails.generate_context_classes` is set to `false`
27
+
28
+ ### Fixed
29
+
30
+ - [#103] various generator fixes
31
+
32
+ ### Removed
33
+
34
+ - [#102] `ActiveInteractor.logger=` use `ActiveInteractor.config.logger=` instead
35
+
10
36
  ## [v1.0.0-beta.1] - 2020-01-06
11
37
 
12
38
  ### Added
@@ -108,7 +134,8 @@ and this project adheres to [Semantic Versioning].
108
134
 
109
135
  <!-- versions -->
110
136
 
111
- [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.0-beta.1..HEAD
137
+ [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.0-beta.2...HEAD
138
+ [v1.0.0-beta.2]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.0-beta.1...v1.0.0-beta.2
112
139
  [v1.0.0-beta.1]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.7...v1.0.0-beta.1
113
140
  [v0.1.7]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.6...v0.1.7
114
141
  [v0.1.6]: https://github.com/aaronmallen/activeinteractor/compare/v0.1.5...v0.1.6
@@ -134,3 +161,7 @@ and this project adheres to [Semantic Versioning].
134
161
  [#48]: https://github.com/aaronmallen/activeinteractor/pull/48
135
162
  [#51]: https://github.com/aaronmallen/activeinteractor/pull/51
136
163
  [#61]: https://github.com/aaronmallen/activeinteractor/pull/61
164
+ [#102]: https://github.com/aaronmallen/activeinteractor/pull/102
165
+ [#103]: https://github.com/aaronmallen/activeinteractor/pull/103
166
+ [#104]: https://github.com/aaronmallen/activeinteractor/pull/104
167
+ [#105]: https://github.com/aaronmallen/activeinteractor/pull/105
data/README.md CHANGED
@@ -768,11 +768,14 @@ If you're working with a rails project ActiveInteractor comes bundled with some
768
768
  to help speed up development. You should first run the install generator with:
769
769
 
770
770
  ```bash
771
- rails generate active_interactor:install
771
+ rails generate active_interactor:install [directory]
772
772
  ```
773
773
 
774
+ The `directory` option allows you to customize what directory interactors will live in within your
775
+ application (defaults to 'interactors').
776
+
774
777
  This will create an initializer a some new classes `ApplicationInteractor`, `ApplicationOrganizer` and
775
- `ApplicationContext` in the `app/interactors` directory.
778
+ `ApplicationContext` in the `app/<directory>` directory.
776
779
 
777
780
  You can then automatically generate interactors, organizers, and contexts with:
778
781
 
@@ -3,6 +3,7 @@
3
3
  require 'active_support/dependencies/autoload'
4
4
 
5
5
  require 'active_interactor/version'
6
+ require 'active_interactor/config'
6
7
 
7
8
  # Copyright (c) 2019 Aaron Allen
8
9
  #
@@ -33,18 +34,6 @@ module ActiveInteractor
33
34
  eager_autoload do
34
35
  autoload :Error
35
36
  end
36
-
37
- # The ActiveInteractor logger object
38
- # @return [Logger] an instance of Logger
39
- def self.logger
40
- @logger ||= Logger.new(STDOUT)
41
- end
42
-
43
- # Set the ActiveInteractor logger object
44
- # @example
45
- # ActiveInteractor.logger = ::Rails.logger
46
- # @return [Logger] an instance of Logger
47
- def self.logger=(logger)
48
- @logger = logger
49
- end
50
37
  end
38
+
39
+ require 'active_interactor/railtie' if defined?(::Rails)
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'logger'
4
+
5
+ module ActiveInteractor
6
+ # The ActiveInteractor configuration object
7
+ # @author Aaron Allen <hello@aaronmallen.me>
8
+ # @since 1.0.0
9
+ # @!attribute [rw] logger
10
+ # @return [Logger] an instance of Logger
11
+ class Config
12
+ # @return [Hash{Symbol=>*}] the default configuration options
13
+ DEFAULTS = {
14
+ logger: Logger.new(STDOUT)
15
+ }.freeze
16
+
17
+ attr_accessor :logger
18
+
19
+ # @param options [Hash] the options for the configuration
20
+ # @option options [Logger] :logger the configuration logger instance
21
+ # @return [Config] a new instance of {Config}
22
+ def initialize(options = {})
23
+ DEFAULTS.dup.merge(options).each do |key, value|
24
+ instance_variable_set("@#{key}", value)
25
+ end
26
+ end
27
+
28
+ # The rails configuration object
29
+ # @return [Rails::Config|nil] an instance of {Rails::Config} if `Rails` is
30
+ # defined or `nil`.
31
+ def rails
32
+ @rails ||= begin
33
+ return unless defined?(::Rails)
34
+
35
+ require 'active_interactor/rails/config'
36
+ Rails::Config.new
37
+ end
38
+ end
39
+ end
40
+
41
+ # The ActiveInteractor configuration
42
+ # @since 0.0.1
43
+ # @return [ActiveInteractor::Config] the configuration instance
44
+ def self.config
45
+ @config ||= Config.new
46
+ end
47
+
48
+ # Configures the ActiveInteractor gem
49
+ # @since 0.0.1
50
+ # @example Configure ActiveInteractor
51
+ # ActiveInteractor.configure do |config|
52
+ # config.logger = Rails.logger
53
+ # end
54
+ # @yield [ActiveInteractor#config]
55
+ def self.configure
56
+ yield config
57
+ end
58
+
59
+ # The ActiveInteractor logger object
60
+ # @since 0.0.1
61
+ # @return [Logger] an instance of Logger
62
+ def self.logger
63
+ config.logger
64
+ end
65
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveInteractor
4
+ # Rails specific classes, helpers, and utlities
5
+ # @author Aaron Allen <hello@aaronmallen.me>
6
+ # @since 1.0.0
7
+ module Rails
8
+ extend ActiveSupport::Autoload
9
+
10
+ autoload :Config
11
+ end
12
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveInteractor
4
+ module Rails
5
+ # The ActiveInteractor rails configuration object
6
+ # @author Aaron Allen <hello@aaronmallen.me>
7
+ # @since 1.0.0
8
+ # @!attribute [rw] directory
9
+ # @return [String] the directory interactors are stored in
10
+ # @!attribute [rw] generate_context_classes
11
+ # @return [Boolean] whether or not to generate a seperate
12
+ # context class for an interactor.
13
+ class Config
14
+ # @return [Hash{Symbol=>*}] the default configuration options
15
+ DEFAULTS = {
16
+ directory: 'interactors',
17
+ generate_context_classes: true
18
+ }.freeze
19
+
20
+ attr_accessor :directory, :generate_context_classes
21
+
22
+ # @param options [Hash] the options for the configuration
23
+ # @option options [String] :directory (defaults to: 'interactors') the configuration directory property
24
+ # @option options [Boolean] :generate_context_classes (defaults to: `true`) the configuration
25
+ # generate_context_class property.
26
+ # @return [Config] a new instance of {Config}
27
+ def initialize(options = {})
28
+ DEFAULTS.dup.merge(options).each do |key, value|
29
+ instance_variable_set("@#{key}", value)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_interactor'
4
+ require 'active_interactor/rails'
5
+
6
+ module ActiveInteractor
7
+ class Railtie < ::Rails::Railtie
8
+ config.active_interactor = ActiveInteractor.config
9
+ end
10
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ActiveInteractor
4
4
  # @return [String] the ActiveInteractor version
5
- VERSION = '1.0.0.beta.1'
5
+ VERSION = '1.0.0.beta.2'
6
6
  end
@@ -1,4 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rails/generators/named_base'
4
+ require 'active_interactor'
5
+
6
+ module ActiveInteractor
7
+ module Generators
8
+ module Generator
9
+ private
10
+
11
+ def interactor_directory
12
+ @interactor_directory ||= ActiveInteractor.config.rails.directory
13
+ end
14
+ end
15
+
16
+ module GeneratesContext
17
+ def self.included(base)
18
+ base.class_eval do
19
+ argument :context_attributes, type: :array, default: [], banner: 'attribute attribute'
20
+ class_option :skip_context, type: :boolean, desc: 'Whether or not to generate a context class'
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def skip_context?
27
+ options[:skip_context] == true || ActiveInteractor.config.rails.generate_context_classes == false
28
+ end
29
+ end
30
+
31
+ class Base < ::Rails::Generators::Base
32
+ include Generator
33
+ end
34
+
35
+ class NamedBase < ::Rails::Generators::NamedBase
36
+ include Generator
37
+ end
38
+ end
39
+ end
40
+
3
41
  Dir[File.expand_path('active_interactor/*.rb', __dir__)].sort.each { |file| require file }
4
42
  Dir[File.expand_path('interactor/*.rb', __dir__)].sort.each { |file| require file }
@@ -1,22 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module ActiveInteractor
6
6
  module Generators
7
- class ApplicationInteractorGenerator < ::Rails::Generators::Base
7
+ class ApplicationInteractorGenerator < Base
8
8
  source_root File.expand_path('templates', __dir__)
9
9
 
10
10
  def create_application_interactor
11
- template 'application_interactor.rb', Rails.root.join('app', 'interactors', 'application_interactor.rb')
11
+ template 'application_interactor.rb', File.join(target_path, 'application_interactor.rb')
12
12
  end
13
13
 
14
14
  def create_application_organizer
15
- template 'application_organizer.rb', Rails.root.join('app', 'interactors', 'application_organizer.rb')
15
+ template 'application_organizer.rb', File.join(target_path, 'application_organizer.rb')
16
16
  end
17
17
 
18
18
  def create_application_context
19
- template 'application_context.rb', Rails.root.join('app', 'interactors', 'application_context.rb')
19
+ return if ActiveInteractor.config.rails.generate_context_classes == false
20
+
21
+ template 'application_context.rb', File.join(target_path, 'application_context.rb')
22
+ end
23
+
24
+ private
25
+
26
+ def target_path
27
+ "app/#{interactor_directory}"
20
28
  end
21
29
  end
22
30
  end
@@ -1,30 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module ActiveInteractor
6
6
  module Generators
7
- class InstallGenerator < ::Rails::Generators::Base
7
+ class InstallGenerator < Base
8
8
  source_root File.expand_path('templates', __dir__)
9
9
  desc 'Install ActiveInteractor'
10
+ argument :directory, type: :string, default: 'interactors', banner: 'directory'
10
11
 
11
12
  def create_initializer
12
- template 'initializer.erb', Rails.root.join('config', 'initializers', 'active_interactor.rb')
13
+ template 'initializer.erb', File.join('config', 'initializers', 'active_interactor.rb')
13
14
  end
14
15
 
15
16
  def create_application_interactor_and_context
16
17
  generate :'active_interactor:application_interactor'
17
18
  end
18
-
19
- def autoload_interactors
20
- application do
21
- <<-CONFIG
22
- # autoload interactors
23
- config.autoload_paths += %w[app/interactors]
24
-
25
- CONFIG
26
- end
27
- end
28
19
  end
29
20
  end
30
21
  end
@@ -2,4 +2,18 @@
2
2
 
3
3
  require 'active_interactor'
4
4
 
5
- ActiveInteractor.logger = ::Rails.logger
5
+ ActiveInteractor.configure do |config|
6
+ # set ActiveInteractor.logger to Rails.logger
7
+ config.logger = ::Rails.logger
8
+
9
+ # set the default directory for interactors
10
+ <%- if directory != 'interactors' -%>
11
+ config.rails.directory = '<%= directory %>'
12
+ <%- else -%>
13
+ # config.rails.directory = 'interactors'
14
+ <%- end -%>
15
+
16
+ # do not automatically generate context classes
17
+ # when interactors are generated
18
+ # config.rails.generate_context_classes = false
19
+ end
@@ -1,18 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Context
7
7
  module Generators
8
- class RspecGenerator < ::Rails::Generators::NamedBase
8
+ class RspecGenerator < ActiveInteractor::Generators::NamedBase
9
9
  source_root File.expand_path('templates', __dir__)
10
10
  desc 'Generate an interactor spec'
11
11
 
12
12
  def create_spec
13
- file_path = Rails.root.join('spec/interactors', File.join(class_path), "#{file_name}_context_spec.rb")
14
13
  template 'rspec.erb', file_path
15
14
  end
15
+
16
+ private
17
+
18
+ def file_path
19
+ File.join('spec', interactor_directory, File.join(class_path), "#{file_name}_context_spec.rb")
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -1,18 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Context
7
7
  module Generators
8
- class TestUnitGenerator < ::Rails::Generators::NamedBase
8
+ class TestUnitGenerator < ActiveInteractor::Generators::NamedBase
9
9
  source_root File.expand_path('templates', __dir__)
10
10
  desc 'Generate an interactor unit test'
11
11
 
12
12
  def create_test
13
- file_path = Rails.root.join('test/interactors', File.join(class_path), "#{file_name}_context_test.rb")
14
13
  template 'test_unit.erb', file_path
15
14
  end
15
+
16
+ private
17
+
18
+ def file_path
19
+ File.join('test', interactor_directory, File.join(class_path), "#{file_name}_context_test.rb")
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -1,19 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
- class ContextGenerator < ::Rails::Generators::NamedBase
7
+ class ContextGenerator < ActiveInteractor::Generators::NamedBase
8
+ include ActiveInteractor::Generators::GeneratesContext
8
9
  source_root File.expand_path('templates', __dir__)
9
10
  desc 'Generate an interactor context'
10
- argument :interactors, type: :array, default: [], banner: 'name name'
11
11
 
12
12
  def create_context
13
- template 'context.erb', Rails.root.join('app/interactors', File.join(class_path), "#{file_name}_context.rb")
13
+ template 'context.erb', file_path
14
14
  end
15
15
 
16
16
  hook_for :test_framework, in: :'interactor:context'
17
+
18
+ private
19
+
20
+ def file_path
21
+ File.join('app', interactor_directory, File.join(class_path), "#{file_name}_context.rb")
22
+ end
17
23
  end
18
24
  end
19
25
  end
@@ -1,18 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../active_interactor'
4
4
 
5
- class InteractorGenerator < ::Rails::Generators::NamedBase
5
+ class InteractorGenerator < ActiveInteractor::Generators::NamedBase
6
+ include ActiveInteractor::Generators::GeneratesContext
6
7
  source_root File.expand_path('templates', __dir__)
7
8
  desc 'Generate an interactor'
8
9
 
9
10
  def create_interactor
10
- template 'interactor.erb', Rails.root.join('app/interactors', File.join(class_path), "#{file_name}.rb")
11
+ template 'interactor.erb', file_path
11
12
  end
12
13
 
13
14
  def create_context
14
- generate :'interactor:context', class_name
15
+ return if skip_context?
16
+
17
+ generate :'interactor:context', class_name, *context_attributes
15
18
  end
16
19
 
17
20
  hook_for :test_framework, in: :interactor
21
+
22
+ private
23
+
24
+ def file_path
25
+ File.join('app', interactor_directory, File.join(class_path), "#{file_name}.rb")
26
+ end
18
27
  end
@@ -1,23 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
- class OrganizerGenerator < ::Rails::Generators::NamedBase
7
+ class OrganizerGenerator < ActiveInteractor::Generators::NamedBase
8
8
  source_root File.expand_path('templates', __dir__)
9
9
  desc 'Generate an interactor organizer'
10
- argument :interactors, type: :array, default: [], banner: 'name name'
10
+ argument :interactors, type: :array, default: [], banner: 'interactor interactor'
11
+
12
+ class_option :context_attributes, type: :array, default: [], banner: 'attribute attribute',
13
+ desc: 'Attributes for the context'
14
+ class_option :skip_context, type: :boolean, desc: 'Whether or not to generate a context class'
11
15
 
12
16
  def create_organizer
13
- template 'organizer.erb', Rails.root.join('app/interactors', File.join(class_path), "#{file_name}.rb")
17
+ template 'organizer.erb', file_path
14
18
  end
15
19
 
16
20
  def create_context
17
- generate :'interactor:context', class_name
21
+ return if skip_context?
22
+
23
+ generate :'interactor:context', class_name, *context_attributes
18
24
  end
19
25
 
20
26
  hook_for :test_framework, in: :interactor
27
+
28
+ private
29
+
30
+ def context_attributes
31
+ options[:context_attributes]
32
+ end
33
+
34
+ def file_path
35
+ File.join('app', interactor_directory, File.join(class_path), "#{file_name}.rb")
36
+ end
37
+
38
+ def skip_context?
39
+ options[:skip_context] == true || ActiveInteractor.config.rails.generate_context_classes == false
40
+ end
21
41
  end
22
42
  end
23
43
  end
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
- class RspecGenerator < ::Rails::Generators::NamedBase
7
+ class RspecGenerator < ActiveInteractor::Generators::NamedBase
8
8
  source_root File.expand_path('templates', __dir__)
9
9
  desc 'Generate an interactor spec'
10
10
 
11
11
  def create_spec
12
- template 'rspec.erb', Rails.root.join('spec/interactors', File.join(class_path), "#{file_name}_spec.rb")
12
+ template 'rspec.erb', file_path
13
+ end
14
+
15
+ private
16
+
17
+ def file_path
18
+ File.join('spec', interactor_directory, File.join(class_path), "#{file_name}_spec.rb")
13
19
  end
14
20
  end
15
21
  end
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class <%= class_name %>Context < ApplicationContext
4
+ <%- unless context_attributes.empty? -%>
5
+ attributes <%= context_attributes.map { |a| ":#{a}" }.join(', ') %>
6
+ <%- end -%>
4
7
  end
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class <%= class_name %> < ApplicationInteractor
4
+ <%- if skip_context? && !context_attributes.empty? -%>
5
+ context_attributes <%= context_attributes.map { |a| ":#{a}" }.join(', ') %>
4
6
 
7
+ <%- end -%>
5
8
  def perform
6
9
  # TODO implement <%= class_name %> call
7
10
  end
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class <%= class_name %> < ApplicationOrganizer
4
+ <%- if skip_context? && !context_attributes.empty? -%>
5
+ context_attributes <%= context_attributes.map { |a| ":#{a}" }.join(', ') %>
4
6
 
7
+ <%- end -%>
5
8
  <%- if interactors.any? -%>
6
9
  organize <%= interactors.map(&:classify).join(", ") %>
7
10
  <%- else -%>
@@ -1,15 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rails/generators/named_base'
3
+ require_relative '../active_interactor'
4
4
 
5
5
  module Interactor
6
6
  module Generators
7
- class TestUnitGenerator < ::Rails::Generators::NamedBase
7
+ class TestUnitGenerator < ActiveInteractor::Generators::NamedBase
8
8
  source_root File.expand_path('templates', __dir__)
9
9
  desc 'Generate an interactor unit test'
10
10
 
11
11
  def create_test
12
- template 'test_unit.erb', Rails.root.join('test/interactors', File.join(class_path), "#{file_name}_test.rb")
12
+ template 'test_unit.erb', file_path
13
+ end
14
+
15
+ private
16
+
17
+ def file_path
18
+ File.join('test', interactor_directory, File.join(class_path), "#{file_name}_test.rb")
13
19
  end
14
20
  end
15
21
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ActiveInteractor::Config do
6
+ subject { described_class.new }
7
+ it { is_expected.to respond_to :logger }
8
+
9
+ describe '.rails' do
10
+ subject { described_class.new.rails }
11
+
12
+ context 'with ::Rails not defined' do
13
+ it { is_expected.to be_nil }
14
+ end
15
+
16
+ context 'with ::Rails defined' do
17
+ before { stub_const('::Rails', 'Rails') }
18
+
19
+ it { is_expected.not_to be_nil }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'active_interactor/rails'
5
+
6
+ RSpec.describe ActiveInteractor::Rails::Config do
7
+ subject { described_class.new }
8
+
9
+ it { is_expected.to respond_to :directory }
10
+ it { is_expected.to respond_to :generate_context_classes }
11
+ end
@@ -9,18 +9,21 @@ RSpec.describe ActiveInteractor do
9
9
  it { is_expected.to be_a String }
10
10
  end
11
11
 
12
- describe '.logger' do
13
- subject { described_class.logger }
12
+ describe '.config' do
13
+ subject { described_class.config }
14
14
 
15
- it { is_expected.to be_a Logger }
15
+ it { is_expected.to be_a ActiveInteractor::Config }
16
+ end
17
+
18
+ describe '.configure' do
19
+ it 'is expected to yield config' do
20
+ expect { |b| described_class.configure(&b) }.to yield_control
21
+ end
16
22
  end
17
23
 
18
- describe '.logger=' do
19
- subject { described_class.logger = logger }
20
- let!(:original_logger) { described_class.logger }
21
- let(:logger) { double(:logger) }
22
- after { described_class.logger = original_logger }
24
+ describe '.logger' do
25
+ subject { described_class.logger }
23
26
 
24
- it { expect { subject }.to change { described_class.logger }.to(logger) }
27
+ it { is_expected.to be_a Logger }
25
28
  end
26
29
  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: 1.0.0.beta.1
4
+ version: 1.0.0.beta.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: 2020-01-06 00:00:00.000000000 Z
11
+ date: 2020-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -106,6 +106,7 @@ files:
106
106
  - README.md
107
107
  - lib/active_interactor.rb
108
108
  - lib/active_interactor/base.rb
109
+ - lib/active_interactor/config.rb
109
110
  - lib/active_interactor/context.rb
110
111
  - lib/active_interactor/context/attributes.rb
111
112
  - lib/active_interactor/context/base.rb
@@ -116,6 +117,9 @@ files:
116
117
  - lib/active_interactor/interactor/context.rb
117
118
  - lib/active_interactor/interactor/worker.rb
118
119
  - lib/active_interactor/organizer.rb
120
+ - lib/active_interactor/rails.rb
121
+ - lib/active_interactor/rails/config.rb
122
+ - lib/active_interactor/railtie.rb
119
123
  - lib/active_interactor/version.rb
120
124
  - lib/rails/generators/active_interactor.rb
121
125
  - lib/rails/generators/active_interactor/application_interactor_generator.rb
@@ -139,10 +143,12 @@ files:
139
143
  - lib/rails/generators/interactor/templates/test_unit.erb
140
144
  - lib/rails/generators/interactor/test_unit_generator.rb
141
145
  - spec/active_interactor/base_spec.rb
146
+ - spec/active_interactor/config_spec.rb
142
147
  - spec/active_interactor/context/base_spec.rb
143
148
  - spec/active_interactor/error_spec.rb
144
149
  - spec/active_interactor/interactor/worker_spec.rb
145
150
  - spec/active_interactor/organizer_spec.rb
151
+ - spec/active_interactor/rails/config_spec.rb
146
152
  - spec/active_interactor_spec.rb
147
153
  - spec/integration/basic_callback_integration_spec.rb
148
154
  - spec/integration/basic_context_integration_spec.rb
@@ -160,10 +166,10 @@ licenses:
160
166
  - MIT
161
167
  metadata:
162
168
  bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
163
- changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.0.0.beta.1/CHANGELOG.md
164
- documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.0.0.beta.1
169
+ changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.0.0.beta.2/CHANGELOG.md
170
+ documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.0.0.beta.2
165
171
  hompage_uri: https://github.com/aaronmallen/activeinteractor
166
- source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.0.0.beta.1
172
+ source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.0.0.beta.2
167
173
  wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
168
174
  post_install_message:
169
175
  rdoc_options: []
@@ -185,20 +191,22 @@ signing_key:
185
191
  specification_version: 4
186
192
  summary: Ruby interactors with ActiveModel::Validations
187
193
  test_files:
188
- - spec/active_interactor_spec.rb
189
194
  - spec/spec_helper.rb
190
- - spec/integration/basic_validations_integration_spec.rb
195
+ - spec/active_interactor_spec.rb
191
196
  - spec/integration/basic_context_integration_spec.rb
197
+ - spec/integration/basic_validations_integration_spec.rb
192
198
  - spec/integration/basic_integration_spec.rb
193
199
  - spec/integration/basic_callback_integration_spec.rb
194
- - spec/active_interactor/error_spec.rb
195
- - spec/active_interactor/base_spec.rb
196
- - spec/active_interactor/context/base_spec.rb
197
- - spec/active_interactor/interactor/worker_spec.rb
198
- - spec/active_interactor/organizer_spec.rb
199
- - spec/support/spec_helpers.rb
200
200
  - spec/support/helpers/factories.rb
201
+ - spec/support/spec_helpers.rb
201
202
  - spec/support/shared_examples/a_class_with_interactor_methods_example.rb
203
+ - spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
202
204
  - spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
203
205
  - spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
204
- - spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
206
+ - spec/active_interactor/error_spec.rb
207
+ - spec/active_interactor/config_spec.rb
208
+ - spec/active_interactor/context/base_spec.rb
209
+ - spec/active_interactor/organizer_spec.rb
210
+ - spec/active_interactor/interactor/worker_spec.rb
211
+ - spec/active_interactor/base_spec.rb
212
+ - spec/active_interactor/rails/config_spec.rb