interactify 0.1.0.pre.alpha.1
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 +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +363 -0
- data/Rakefile +8 -0
- data/lib/interactify/call_wrapper.rb +15 -0
- data/lib/interactify/contract_helpers.rb +71 -0
- data/lib/interactify/dsl.rb +67 -0
- data/lib/interactify/each_chain.rb +80 -0
- data/lib/interactify/if_interactor.rb +64 -0
- data/lib/interactify/interactor_wiring.rb +305 -0
- data/lib/interactify/job_maker.rb +105 -0
- data/lib/interactify/jobable.rb +90 -0
- data/lib/interactify/organizer_call_monkey_patch.rb +40 -0
- data/lib/interactify/rspec/matchers.rb +69 -0
- data/lib/interactify/version.rb +5 -0
- data/lib/interactify.rb +89 -0
- data/sig/interactify.rbs +4 -0
- metadata +157 -0
data/lib/interactify.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'interactor'
|
4
|
+
require 'interactor-contracts'
|
5
|
+
require 'rails'
|
6
|
+
require 'active_support/all'
|
7
|
+
|
8
|
+
require 'interactify/version'
|
9
|
+
require 'interactify/contract_helpers'
|
10
|
+
require 'interactify/dsl'
|
11
|
+
require 'interactify/interactor_wiring'
|
12
|
+
|
13
|
+
module Interactify
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def validate_app(ignore: [])
|
18
|
+
Interactify::InteractorWiring.new(root: Interactify.configuration.root, ignore:).validate_app
|
19
|
+
end
|
20
|
+
|
21
|
+
def trigger_contract_breach_hook(...)
|
22
|
+
@on_contract_breach&.call(...)
|
23
|
+
end
|
24
|
+
|
25
|
+
def on_contract_breach(&block)
|
26
|
+
@on_contract_breach = block
|
27
|
+
end
|
28
|
+
|
29
|
+
def trigger_before_raise_hook(...)
|
30
|
+
@before_raise_hook&.call(...)
|
31
|
+
end
|
32
|
+
|
33
|
+
def before_raise(&block)
|
34
|
+
@before_raise_hook = block
|
35
|
+
end
|
36
|
+
|
37
|
+
def configure
|
38
|
+
yield configuration
|
39
|
+
end
|
40
|
+
|
41
|
+
def configuration
|
42
|
+
@configuration ||= Configuration.new
|
43
|
+
end
|
44
|
+
|
45
|
+
delegate :root, to: :configuration
|
46
|
+
end
|
47
|
+
|
48
|
+
included do |base|
|
49
|
+
base.extend Interactify::Dsl
|
50
|
+
|
51
|
+
base.include Interactor::Organizer
|
52
|
+
base.include Interactor::Contracts
|
53
|
+
base.include Interactify::ContractHelpers
|
54
|
+
|
55
|
+
# defines two classes on the receiver class
|
56
|
+
# the first is the job class
|
57
|
+
# the second is the async class
|
58
|
+
# the async class is a wrapper around the job class
|
59
|
+
# that allows it to be used in an interactor chain
|
60
|
+
#
|
61
|
+
# E.g.
|
62
|
+
#
|
63
|
+
# class ExampleInteractor
|
64
|
+
# include Interactify
|
65
|
+
# expect :foo
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
# ExampleInteractor::Job is a class availabe to be used in a sidekiq yaml file
|
69
|
+
#
|
70
|
+
# doing the following will immediately enqueue a job
|
71
|
+
# that calls the interactor ExampleInteractor with (foo: 'bar')
|
72
|
+
#
|
73
|
+
# ExampleInteractor::Async.call(foo: 'bar')
|
74
|
+
include Interactify::Jobable
|
75
|
+
interactor_job
|
76
|
+
end
|
77
|
+
|
78
|
+
class Configuration
|
79
|
+
attr_writer :root
|
80
|
+
|
81
|
+
def root
|
82
|
+
@root ||= Rails.root / 'app'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def called_klass_list
|
87
|
+
context._called.map(&:class)
|
88
|
+
end
|
89
|
+
end
|
data/sig/interactify.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: interactify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Burns
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-12-26 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: interactor-contracts
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: debug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: deep_matching
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: |
|
98
|
+
Adds the following to your interactor chains
|
99
|
+
- lambda support
|
100
|
+
- iteration
|
101
|
+
- conditionals
|
102
|
+
- verify expectations in chains. never again expect something not previously expected or promised
|
103
|
+
- autogenerated async sidekiq job classes. Just append `::Async` to your interactor class name to add a job to sidekiq
|
104
|
+
- everything can be an organizer or an interactor
|
105
|
+
email:
|
106
|
+
- markburns@users.noreply.github.com
|
107
|
+
executables: []
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ".rspec"
|
112
|
+
- CHANGELOG.md
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- lib/interactify.rb
|
117
|
+
- lib/interactify/call_wrapper.rb
|
118
|
+
- lib/interactify/contract_helpers.rb
|
119
|
+
- lib/interactify/dsl.rb
|
120
|
+
- lib/interactify/each_chain.rb
|
121
|
+
- lib/interactify/if_interactor.rb
|
122
|
+
- lib/interactify/interactor_wiring.rb
|
123
|
+
- lib/interactify/job_maker.rb
|
124
|
+
- lib/interactify/jobable.rb
|
125
|
+
- lib/interactify/organizer_call_monkey_patch.rb
|
126
|
+
- lib/interactify/rspec/matchers.rb
|
127
|
+
- lib/interactify/version.rb
|
128
|
+
- sig/interactify.rbs
|
129
|
+
homepage: https://github.com/markburns/interactify
|
130
|
+
licenses:
|
131
|
+
- MIT
|
132
|
+
metadata:
|
133
|
+
allowed_push_host: https://rubygems.org
|
134
|
+
homepage_uri: https://github.com/markburns/interactify
|
135
|
+
source_code_uri: https://github.com/markburns/interactify
|
136
|
+
changelog_uri: https://github.com/markburns/interactify/blob/main/CHANGELOG.md
|
137
|
+
rubygems_mfa_required: 'true'
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '3.2'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.3.1
|
152
|
+
requirements: []
|
153
|
+
rubygems_version: 3.4.19
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Interactors with bells and whistles
|
157
|
+
test_files: []
|