interactify 0.3.0.pre.RC1 → 0.3.0.pre.alpha.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
  SHA256:
3
- metadata.gz: 319dd56313d82aa987c8eaec40691e43c58e8b72513969e2a6a7a83de17ae311
4
- data.tar.gz: 3f5e4ad0464157910bca7bfd1300fa8e23ab825068c84a4c5c0ef5ad0cdb29d6
3
+ metadata.gz: 918f4f6ae335bb5b8a748603af6a2e9d91dc11ad3d887803bbb2c7b2ba41730e
4
+ data.tar.gz: fe6506fe246a82d48f5a614d5c576cf74e49f38953c1d4ae98d52f1649f03aaf
5
5
  SHA512:
6
- metadata.gz: fea0120a4456f108b41ccd48c994e365762bad8ff6424eba9d7ecd0c09c6858805e0456df0655eec86042ed7dc9fa589ffb8f3bdb49a14e79a7e05e30b6737ae
7
- data.tar.gz: 64345da2e8b036ad65c639bddb9c0f90f93b1fdbc1415a5cb29f26596fa9169c6a9b0309d9d0ecbb515706251ff473f4ac98f7b41be7d89c089ce3b8537ade54
6
+ metadata.gz: ce377154a79b527f6eaebe3258d76aadd327521abbe86847b8c9d87b5710e1782bdb02b20b3ef3661ac6dc4ee1d0c6843fdd819ccf6dda8f701e9d95063d5a9c
7
+ data.tar.gz: 553271645575873bc2a95968c2ff7f01a556dd24527974b6a7bb958a8eeb9f8bb66504bdace2c3736e6faac82c1a438f07d27afa85c3fdc8ac5b051cac4e20c5
data/CHANGELOG.md CHANGED
@@ -11,12 +11,3 @@
11
11
  ## [0.3.0-alpha.1] - 2023-12-29
12
12
 
13
13
  - Added support for `{if: :condition, then: A, else: B}` in organizers
14
-
15
- ## [0.3.0-alpha.2] - 2023-12-29
16
-
17
- - Remove deep_matching development dependency
18
-
19
- ## [0.3.0-RC1] - 2023-12-29
20
-
21
- - Fixed to work with and make optional dependencies for sidekiq and railties. Confirmed as working with ruby >= 3.1.4
22
-
data/README.md CHANGED
@@ -1,18 +1,6 @@
1
1
  # Interactify
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/interactify.svg)](https://badge.fury.io/rb/interactify)
4
- ![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=markburns/interactify)
5
- [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
- ![Ruby 3.3.0](https://img.shields.io/badge/ruby-3.3.0-green.svg)
7
- ![Ruby 3.2.2](https://img.shields.io/badge/ruby-3.2.2-green.svg)
8
- ![Ruby 3.1.4](https://img.shields.io/badge/ruby-3.1.4-green.svg)
9
- [![Code Climate](https://codeclimate.com/github/markburns/interactify/badges/gpa.svg)](https://codeclimate.com/github/markburns/interactify)
10
-
11
- Interactify enhances Rails applications by simplifying complex interactor chains.
12
- This gem builds on [interactors](https://github.com/collectiveidea/interactor) and [interactor-contracts](https://github.com/michaelherold/interactor-contracts) to improve readability and maintainability of business logic.
13
- We depend on activesupport, and optionally on railties and sidekiq. So it's a good fit for Rails projects using Sidekiq, offering advanced features for chain management and debugging.
14
- Interactify is about making interactor usage in Rails more efficient and less error-prone, reducing the overhead of traditional interactor orchestration.
15
-
3
+ Interactify enhances Rails applications by simplifying complex interactor chains. This gem builds on [interactors](https://github.com/collectiveidea/interactor) and [interactor-contracts](https://github.com/michaelherold/interactor-contracts) to improve readability and maintainability of business logic. It's optimized for Rails projects using Sidekiq, offering advanced features for chain management and debugging. Interactify is about making interactor usage in Rails more efficient and less error-prone, reducing the overhead of traditional interactor orchestration.
16
4
  ## Installation
17
5
 
18
6
  ```ruby
@@ -22,7 +10,6 @@ gem 'interactify'
22
10
  ## Usage
23
11
 
24
12
  ### Initializer
25
-
26
13
  ```ruby
27
14
  # in config/initializers/interactify.rb
28
15
  Interactify.configure do |config|
@@ -224,16 +211,26 @@ class OuterThing
224
211
  # ... boilerplate ...
225
212
  organize \
226
213
  SetupStep,
227
-
228
- # lambda conditional
229
214
  self.if(->(c){ c.thing == 'a' }, DoThingA, DoThingB),
215
+ end
230
216
 
231
- # context conditional
232
- self.if(:some_key_on_context, DoThingA, DoThingB),
233
-
234
- # alternative hash syntax
217
+ # or hash syntax
218
+ class OuterThing
219
+ # ... boilerplate ...
220
+ organize \
235
221
  {if: :key_set_on_context, then: DoThingA, else: DoThingB},
236
- AfterDoThis
222
+ AfterBothCases
223
+ end
224
+ ```
225
+
226
+ ### Conditionals with a key from the context
227
+
228
+ ```ruby
229
+ class OuterThing
230
+ # ... boilerplate ...
231
+ organize \
232
+ self.if(:key_set_on_context, DoThingA, DoThingB),
233
+ AfterBothCases
237
234
  end
238
235
  ```
239
236
 
@@ -253,7 +250,6 @@ class SomeOrganizer
253
250
  end
254
251
 
255
252
  ```
256
-
257
253
  ### Contract validation failures
258
254
  Sometimes contract validation fails at runtime as an exception. It's something unexpected and you'll have an `Interactor::Failure` sent to rollbar/sentry/honeybadger.
259
255
  If the context is large it's often hard to spot what the actual problem is or where it occurred.
@@ -302,6 +298,7 @@ Actual promises are:
302
298
  step1
303
299
  ```
304
300
 
301
+
305
302
  ### Interactor wiring specs
306
303
  Sometimes you have an interactor chain that fails because something is expected deeper down the chain and not provided further up the chain.
307
304
  The existing way to solve this is with enough integration specs to catch them, hunting and sticking a `byebug`, `debugger` or `binding.pry` in at suspected locations and inferring where in the chain the wiring went awry.
@@ -341,7 +338,17 @@ expect(described_class).to promise_outputs(:order)
341
338
  ### Sidekiq Jobs
342
339
  Sometimes you want to asyncify an interactor.
343
340
 
344
- #### before
341
+ ```ruby
342
+ # before
343
+ class SomeInteractor
344
+ include Interactify
345
+
346
+ def call
347
+ # ...
348
+ end
349
+ end
350
+ ```
351
+
345
352
  ```diff
346
353
  - SomeInteractor.call(*args)
347
354
  + class SomeInteractorJob
@@ -355,14 +362,24 @@ Sometimes you want to asyncify an interactor.
355
362
  + SomeInteractorJob.perform_async(*args)
356
363
  ```
357
364
 
358
- #### after
365
+ ```ruby
366
+ # after
367
+ class SomeInteractor
368
+ include Interactify
369
+
370
+ def call
371
+ # ...
372
+ end
373
+ end
374
+ ```
375
+
376
+ No need to manually create a job class or handle the perform/call impedance mismatch
377
+
359
378
  ```diff
360
379
  - SomeInteractor.call!(*args)
361
380
  + SomeInteractor::Async.call!(*args)
362
381
  ```
363
382
 
364
- No need to manually create a job class or handle the perform/call impedance mismatch
365
-
366
383
  This also makes it easy to add cron jobs to run interactors. As any interactor can be asyncified.
367
384
  By using it's internal Async class.
368
385
 
@@ -67,7 +67,7 @@ module Interactify
67
67
 
68
68
  def interactor_klass?(object)
69
69
  return unless object.is_a?(Class) && object.ancestors.include?(Interactor)
70
- return if Interactify.sidekiq? && object.is_a?(Sidekiq::Job)
70
+ return if object.is_a?(Sidekiq::Job)
71
71
 
72
72
  true
73
73
  end
@@ -116,9 +116,9 @@ module Interactify
116
116
  .gsub(root.to_s, "") # "/namespace/sub_namespace/class_name.rb"
117
117
  .gsub("/concerns", "") # concerns directory is ignored by Zeitwerk
118
118
  .split("/") # "['', 'namespace', 'sub_namespace', 'class_name.rb']
119
- .reject(&:blank?) # "['namespace', 'sub_namespace', 'class_name.rb']
119
+ .compact_blank # "['namespace', 'sub_namespace', 'class_name.rb']
120
120
  .join("/") # 'namespace/sub_namespace/class_name.rb'
121
- .gsub(/\.rb\z/, "") # 'namespace/sub_namespace/class_name'
121
+ .gsub(/\.rb\z/, "") # 'namespace/sub_namespace/class_name'
122
122
  end
123
123
  end
124
124
  end
@@ -10,7 +10,7 @@ module Interactify
10
10
  class InteractorWiring
11
11
  attr_reader :root, :ignore
12
12
 
13
- def initialize(root:, ignore: [])
13
+ def initialize(root: Rails.root, ignore: [])
14
14
  @root = root.to_s.gsub(%r{/$}, "")
15
15
  @ignore = ignore
16
16
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sidekiq"
4
+ require "sidekiq/job"
5
+
3
6
  require "interactify/async_job_klass"
4
- require "interactify/null_job"
5
7
 
6
8
  module Interactify
7
9
  class JobMaker
@@ -22,8 +24,6 @@ module Interactify
22
24
  private
23
25
 
24
26
  def define_job_klass
25
- return NullJob if Interactify.sidekiq_missing?
26
-
27
27
  this = self
28
28
 
29
29
  invalid_keys = this.opts.symbolize_keys.keys - %i[queue retry dead backtrace pool tags]
@@ -11,8 +11,6 @@ module Interactify
11
11
  #
12
12
  # then let's make sure to define Klass::Job separately
13
13
  included do |base|
14
- next if Interactify.sidekiq_missing?
15
-
16
14
  def base.inherited(klass)
17
15
  super_klass = klass.superclass
18
16
  super_job = super_klass::Job # really spiffing
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Interactify
4
- VERSION = "0.3.0-RC1"
4
+ VERSION = "0.3.0-alpha.1"
5
5
  end
data/lib/interactify.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "interactor"
4
4
  require "interactor-contracts"
5
+ require "rails"
5
6
  require "active_support/all"
6
7
 
7
8
  require "interactify/version"
@@ -10,52 +11,6 @@ require "interactify/dsl"
10
11
  require "interactify/interactor_wiring"
11
12
  require "interactify/promising"
12
13
 
13
- module Interactify
14
- def self.railties_missing?
15
- @railties_missing
16
- end
17
-
18
- def self.railties_missing!
19
- @railties_missing = true
20
- end
21
-
22
- def self.railties
23
- railties?
24
- end
25
-
26
- def self.railties?
27
- !railties_missing?
28
- end
29
-
30
- def self.sidekiq_missing?
31
- @sidekiq_missing
32
- end
33
-
34
- def self.sidekiq_missing!
35
- @sidekiq_missing = true
36
- end
37
-
38
- def self.sidekiq
39
- sidekiq?
40
- end
41
-
42
- def self.sidekiq?
43
- !sidekiq_missing?
44
- end
45
- end
46
-
47
- begin
48
- require "sidekiq"
49
- rescue LoadError
50
- Interactify.sidekiq_missing!
51
- end
52
-
53
- begin
54
- require 'rails/railtie'
55
- rescue LoadError
56
- Interactify.railties_missing!
57
- end
58
-
59
14
  module Interactify
60
15
  extend ActiveSupport::Concern
61
16
 
@@ -64,14 +19,6 @@ module Interactify
64
19
  Interactify::InteractorWiring.new(root: Interactify.configuration.root, ignore:).validate_app
65
20
  end
66
21
 
67
- def sidekiq_missing?
68
- @sidekiq_missing
69
- end
70
-
71
- def sidekiq_missing!
72
- @sidekiq_missing = true
73
- end
74
-
75
22
  def reset
76
23
  @on_contract_breach = nil
77
24
  @before_raise_hook = nil
@@ -162,11 +109,7 @@ module Interactify
162
109
  attr_writer :root
163
110
 
164
111
  def root
165
- @root ||= fallback
166
- end
167
-
168
- def fallback
169
- Rails.root / "app" if Interactify.railties?
112
+ @root ||= Rails.root / "app"
170
113
  end
171
114
  end
172
115
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interactify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.RC1
4
+ version: 0.3.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Burns
@@ -39,19 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: activesupport
42
+ name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 6.0.0
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 6.0.0
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sidekiq
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: debug
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: appraisal
84
+ name: deep_matching
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -96,25 +110,10 @@ extra_rdoc_files: []
96
110
  files:
97
111
  - ".rspec"
98
112
  - ".rubocop.yml"
99
- - ".ruby-version"
100
- - Appraisals
101
113
  - CHANGELOG.md
102
114
  - LICENSE.txt
103
115
  - README.md
104
116
  - Rakefile
105
- - gemfiles/.bundle/config
106
- - gemfiles/no_railties_no_sidekiq.gemfile
107
- - gemfiles/no_railties_no_sidekiq.gemfile.lock
108
- - gemfiles/railties_6.gemfile
109
- - gemfiles/railties_6.gemfile.lock
110
- - gemfiles/railties_6_no_sidekiq.gemfile
111
- - gemfiles/railties_6_no_sidekiq.gemfile.lock
112
- - gemfiles/railties_6_sidekiq.gemfile
113
- - gemfiles/railties_6_sidekiq.gemfile.lock
114
- - gemfiles/railties_7_no_sidekiq.gemfile
115
- - gemfiles/railties_7_no_sidekiq.gemfile.lock
116
- - gemfiles/railties_7_sidekiq.gemfile
117
- - gemfiles/railties_7_sidekiq.gemfile.lock
118
117
  - lib/interactify.rb
119
118
  - lib/interactify/async_job_klass.rb
120
119
  - lib/interactify/call_wrapper.rb
@@ -132,7 +131,6 @@ files:
132
131
  - lib/interactify/job_maker.rb
133
132
  - lib/interactify/jobable.rb
134
133
  - lib/interactify/mismatching_promise_error.rb
135
- - lib/interactify/null_job.rb
136
134
  - lib/interactify/organizer.rb
137
135
  - lib/interactify/promising.rb
138
136
  - lib/interactify/rspec/matchers.rb
@@ -156,14 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
154
  requirements:
157
155
  - - ">="
158
156
  - !ruby/object:Gem::Version
159
- version: 2.7.8
157
+ version: '3.2'
160
158
  required_rubygems_version: !ruby/object:Gem::Requirement
161
159
  requirements:
162
160
  - - ">"
163
161
  - !ruby/object:Gem::Version
164
162
  version: 1.3.1
165
163
  requirements: []
166
- rubygems_version: 3.3.26
164
+ rubygems_version: 3.4.19
167
165
  signing_key:
168
166
  specification_version: 4
169
167
  summary: Interactors with bells and whistles
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.1.4
data/Appraisals DELETED
@@ -1,21 +0,0 @@
1
- appraise "railties-7-sidekiq" do
2
- gem "railties", "7"
3
- gem "sidekiq", "7"
4
- end
5
-
6
- appraise "railties-7-no-sidekiq" do
7
- gem "railties", "7"
8
- end
9
-
10
- appraise "railties-6-sidekiq" do
11
- gem "railties", "6"
12
- gem "sidekiq", "7"
13
- end
14
-
15
- appraise "railties-6-no-sidekiq" do
16
- gem "railties", "6"
17
- end
18
-
19
- appraise "no-railties-no-sidekiq" do
20
- # nothing extra
21
- end
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_RETRY: "1"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rake", "~> 13.0"
6
-
7
- group :development do
8
- gem "bundler", "~> 2.0"
9
- end
10
-
11
- group :test do
12
- gem "simplecov", require: false
13
- gem "rspec", "~> 3.0"
14
- end
15
-
16
- gemspec path: "../"
@@ -1,127 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- interactify (0.3.0.pre.alpha.2)
5
- activesupport (>= 6.0.0)
6
- interactor
7
- interactor-contracts
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- activesupport (7.1.2)
13
- base64
14
- bigdecimal
15
- concurrent-ruby (~> 1.0, >= 1.0.2)
16
- connection_pool (>= 2.2.5)
17
- drb
18
- i18n (>= 1.6, < 2)
19
- minitest (>= 5.1)
20
- mutex_m
21
- tzinfo (~> 2.0)
22
- appraisal (2.5.0)
23
- bundler
24
- rake
25
- thor (>= 0.14.0)
26
- base64 (0.2.0)
27
- bigdecimal (3.1.5)
28
- concurrent-ruby (1.2.2)
29
- connection_pool (2.4.1)
30
- debug (1.9.1)
31
- irb (~> 1.10)
32
- reline (>= 0.3.8)
33
- diff-lcs (1.5.0)
34
- docile (1.4.0)
35
- drb (2.2.0)
36
- ruby2_keywords
37
- dry-configurable (1.0.1)
38
- dry-core (~> 1.0, < 2)
39
- zeitwerk (~> 2.6)
40
- dry-core (1.0.0)
41
- concurrent-ruby (~> 1.0)
42
- zeitwerk (~> 2.6)
43
- dry-inflector (1.0.0)
44
- dry-initializer (3.1.1)
45
- dry-logic (1.5.0)
46
- concurrent-ruby (~> 1.0)
47
- dry-core (~> 1.0, < 2)
48
- zeitwerk (~> 2.6)
49
- dry-schema (1.13.3)
50
- concurrent-ruby (~> 1.0)
51
- dry-configurable (~> 1.0, >= 1.0.1)
52
- dry-core (~> 1.0, < 2)
53
- dry-initializer (~> 3.0)
54
- dry-logic (>= 1.4, < 2)
55
- dry-types (>= 1.7, < 2)
56
- zeitwerk (~> 2.6)
57
- dry-types (1.7.1)
58
- concurrent-ruby (~> 1.0)
59
- dry-core (~> 1.0)
60
- dry-inflector (~> 1.0)
61
- dry-logic (~> 1.4)
62
- zeitwerk (~> 2.6)
63
- dry-validation (1.10.0)
64
- concurrent-ruby (~> 1.0)
65
- dry-core (~> 1.0, < 2)
66
- dry-initializer (~> 3.0)
67
- dry-schema (>= 1.12, < 2)
68
- zeitwerk (~> 2.6)
69
- i18n (1.14.1)
70
- concurrent-ruby (~> 1.0)
71
- interactor (3.1.2)
72
- interactor-contracts (0.3.0)
73
- dry-validation (~> 1.0)
74
- interactor (~> 3)
75
- io-console (0.7.1)
76
- irb (1.11.0)
77
- rdoc
78
- reline (>= 0.3.8)
79
- minitest (5.20.0)
80
- mutex_m (0.2.0)
81
- psych (5.1.2)
82
- stringio
83
- rake (13.1.0)
84
- rdoc (6.6.2)
85
- psych (>= 4.0.0)
86
- reline (0.4.1)
87
- io-console (~> 0.5)
88
- rspec (3.12.0)
89
- rspec-core (~> 3.12.0)
90
- rspec-expectations (~> 3.12.0)
91
- rspec-mocks (~> 3.12.0)
92
- rspec-core (3.12.2)
93
- rspec-support (~> 3.12.0)
94
- rspec-expectations (3.12.3)
95
- diff-lcs (>= 1.2.0, < 2.0)
96
- rspec-support (~> 3.12.0)
97
- rspec-mocks (3.12.6)
98
- diff-lcs (>= 1.2.0, < 2.0)
99
- rspec-support (~> 3.12.0)
100
- rspec-support (3.12.1)
101
- ruby2_keywords (0.0.5)
102
- simplecov (0.22.0)
103
- docile (~> 1.1)
104
- simplecov-html (~> 0.11)
105
- simplecov_json_formatter (~> 0.1)
106
- simplecov-html (0.12.3)
107
- simplecov_json_formatter (0.1.4)
108
- stringio (3.1.0)
109
- thor (1.3.0)
110
- tzinfo (2.0.6)
111
- concurrent-ruby (~> 1.0)
112
- zeitwerk (2.6.12)
113
-
114
- PLATFORMS
115
- ruby
116
-
117
- DEPENDENCIES
118
- appraisal
119
- bundler (~> 2.0)
120
- debug
121
- interactify!
122
- rake (~> 13.0)
123
- rspec (~> 3.0)
124
- simplecov
125
-
126
- BUNDLED WITH
127
- 2.4.22
@@ -1,14 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "simplecov", require: false
6
- gem "rake", "~> 13.0"
7
- gem "railties", "6"
8
- gem "sidekiq", "7"
9
-
10
- group :test do
11
- gem "rspec", "~> 3.0"
12
- end
13
-
14
- gemspec path: "../"