pathway 0.11.3 → 0.12.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 +4 -4
- data/.github/workflows/tests.yml +28 -0
- data/CHANGELOG.md +5 -0
- data/README.md +3 -3
- data/lib/pathway/plugins/auto_deconstruct_state/ruby3.rb +21 -0
- data/lib/pathway/plugins/auto_deconstruct_state.rb +12 -0
- data/lib/pathway/plugins/dry_validation/v1_0.rb +6 -6
- data/lib/pathway/plugins/responder.rb +2 -2
- data/lib/pathway/plugins/sequel_models.rb +2 -2
- data/lib/pathway/version.rb +1 -1
- data/lib/pathway.rb +18 -15
- data/pathway.gemspec +6 -4
- metadata +43 -13
- data/.circleci/config.yml +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2a1f9207d8b2db81dbf655234010e4cb8c622299cb69c1dfaa9486f824a7e86
|
4
|
+
data.tar.gz: 25e380e764a1b1585b86ae847b2cbc107a83fa23f1a1205e4e1e5e1a2c021c50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393014838fece86b27409c08ef0f5ccb9d7dacf5f5012d956bbf0e7ca3869175e4090c6dd23cf6c8f61bfcecd15839a738b87afcf911c226a06ea36e8cb91dc3
|
7
|
+
data.tar.gz: 1dd63c594d299837fb1b595f14fd2056ac39f81fdd508254c331fb9ef4b3a67262e0f47683bb5e0296708076d88c12aef0dd981c8864391d43f0bc6083ad9422
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: [2.6, 2.7, 3.0, 3.1]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- name: Set up Ruby
|
18
|
+
uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby-version }}
|
21
|
+
bundler-cache: true
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rake
|
24
|
+
- name: Coveralls GitHub Action
|
25
|
+
if: matrix.ruby-version == '3.1'
|
26
|
+
uses: coverallsapp/github-action@1.1.3
|
27
|
+
with:
|
28
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.12.0] - 2022-05-31
|
2
|
+
### Changed
|
3
|
+
- Improve compatibility with Ruby 3.0
|
4
|
+
- Add plugin `:auto_deconstruct_state` to help migrating old apps to Ruby 3.0
|
5
|
+
|
1
6
|
## [0.11.3] - 2020-07-22
|
2
7
|
### Changed
|
3
8
|
- Use default error message on `:fetch_model` step, at `:sequel_models` plugin, if model type cannot be determined
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Pathway
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/pathway)
|
4
|
-
[](https://github.com/oabloh/pathway/actions?query=workflow%3ATests)
|
5
5
|
[](https://coveralls.io/github/pabloh/pathway?branch=master)
|
6
6
|
|
7
7
|
Pathway encapsulates your business logic into simple operation objects (AKA application services on the [DDD](https://en.wikipedia.org/wiki/Domain-driven_design) lingo).
|
@@ -273,11 +273,11 @@ class CreateNugget < Pathway::Operation
|
|
273
273
|
|
274
274
|
def create_nugget(:params, **)
|
275
275
|
Nugget.create(owner: current_user, **params)
|
276
|
-
|
276
|
+
end
|
277
277
|
|
278
278
|
def notify(:nugget, **)
|
279
279
|
Notifier.notify(:new_nugget, nugget)
|
280
|
-
|
280
|
+
end
|
281
281
|
end
|
282
282
|
```
|
283
283
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pathway
|
4
|
+
module Plugins
|
5
|
+
module AutoDeconstructState
|
6
|
+
module DSLMethods
|
7
|
+
private
|
8
|
+
|
9
|
+
def _callable(callable)
|
10
|
+
if callable.is_a?(Symbol) && @operation.respond_to?(callable, true) &&
|
11
|
+
@operation.method(callable).parameters.all? { _1 in [:key|:keyreq|:keyrest|:block,*] }
|
12
|
+
|
13
|
+
-> state { @operation.send(callable, **state) }
|
14
|
+
else
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -19,7 +19,7 @@ module Pathway
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def params(*args, &block)
|
22
|
+
ruby2_keywords def params(*args, &block)
|
23
23
|
contract { params(*args, &block) }
|
24
24
|
end
|
25
25
|
|
@@ -29,8 +29,8 @@ module Pathway
|
|
29
29
|
@builded_contract = @contract_options.empty? && klass.schema ? klass.new : nil
|
30
30
|
end
|
31
31
|
|
32
|
-
def build_contract(opts
|
33
|
-
@builded_contract || contract_class.new(opts)
|
32
|
+
def build_contract(**opts)
|
33
|
+
@builded_contract || contract_class.new(**opts)
|
34
34
|
end
|
35
35
|
|
36
36
|
def inherited(subclass)
|
@@ -57,12 +57,12 @@ module Pathway
|
|
57
57
|
with ||= contract_options.zip(contract_options).to_h
|
58
58
|
end
|
59
59
|
opts = Hash(with).map { |to, from| [to, state[from]] }.to_h
|
60
|
-
validate_with(state[:input], opts)
|
60
|
+
validate_with(state[:input], **opts)
|
61
61
|
.then { |params| state.update(params: params) }
|
62
62
|
end
|
63
63
|
|
64
|
-
def validate_with(input, opts
|
65
|
-
result = contract(opts).call(input)
|
64
|
+
def validate_with(input, **opts)
|
65
|
+
result = contract(**opts).call(input)
|
66
66
|
|
67
67
|
result.success? ? wrap(result.values.to_h) : error(:validation, details: result.errors.to_h)
|
68
68
|
end
|
@@ -4,8 +4,8 @@ module Pathway
|
|
4
4
|
module Plugins
|
5
5
|
module Responder
|
6
6
|
module ClassMethods
|
7
|
-
def call(
|
8
|
-
result = super(
|
7
|
+
ruby2_keywords def call(*args, &bl)
|
8
|
+
result = super(*args)
|
9
9
|
block_given? ? Responder.respond(result, &bl) : result
|
10
10
|
end
|
11
11
|
end
|
data/lib/pathway/version.rb
CHANGED
data/lib/pathway.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ruby2_keywords'
|
3
4
|
require 'forwardable'
|
4
5
|
require 'dry/inflector'
|
5
6
|
require 'contextualizer'
|
@@ -9,21 +10,23 @@ require 'pathway/result'
|
|
9
10
|
module Pathway
|
10
11
|
Inflector = Dry::Inflector.new
|
11
12
|
class Operation
|
12
|
-
|
13
|
-
|
13
|
+
class << self
|
14
|
+
ruby2_keywords def plugin(name, *args)
|
15
|
+
require "pathway/plugins/#{Inflector.underscore(name)}" if name.is_a?(Symbol)
|
14
16
|
|
15
|
-
|
17
|
+
plugin = name.is_a?(Module) ? name : Plugins.const_get(Inflector.camelize(name))
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
self.extend plugin::ClassMethods if plugin.const_defined? :ClassMethods
|
20
|
+
self.include plugin::InstanceMethods if plugin.const_defined? :InstanceMethods
|
21
|
+
self::DSL.include plugin::DSLMethods if plugin.const_defined? :DSLMethods
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
plugin.apply(self, *args) if plugin.respond_to?(:apply)
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
def inherited(subclass)
|
27
|
+
super
|
28
|
+
subclass.const_set :DSL, Class.new(self::DSL)
|
29
|
+
end
|
27
30
|
end
|
28
31
|
|
29
32
|
class DSL
|
@@ -90,7 +93,7 @@ module Pathway
|
|
90
93
|
end
|
91
94
|
end
|
92
95
|
|
93
|
-
def call(ctx, *params)
|
96
|
+
ruby2_keywords def call(ctx, *params)
|
94
97
|
new(ctx).call(*params)
|
95
98
|
end
|
96
99
|
|
@@ -137,7 +140,7 @@ module Pathway
|
|
137
140
|
end
|
138
141
|
|
139
142
|
# Execute step and preserve the former state
|
140
|
-
def step(callable, *args)
|
143
|
+
ruby2_keywords def step(callable, *args)
|
141
144
|
bl = _callable(callable)
|
142
145
|
|
143
146
|
@result = @result.tee { |state| bl.call(state, *args) }
|
@@ -190,9 +193,9 @@ module Pathway
|
|
190
193
|
def _callable(callable)
|
191
194
|
case callable
|
192
195
|
when Proc
|
193
|
-
-> *args { @operation.instance_exec(*args, &callable) }
|
196
|
+
-> *args { @operation.instance_exec(*args, &callable) }.ruby2_keywords
|
194
197
|
when Symbol
|
195
|
-
-> *args { @operation.send(callable, *args) }
|
198
|
+
-> *args { @operation.send(callable, *args) }.ruby2_keywords
|
196
199
|
else
|
197
200
|
callable
|
198
201
|
end
|
data/pathway.gemspec
CHANGED
@@ -31,13 +31,15 @@ Gem::Specification.new do |spec|
|
|
31
31
|
|
32
32
|
spec.add_dependency "dry-inflector", ">= 0.1.0"
|
33
33
|
spec.add_dependency "contextualizer", "~> 0.0.4"
|
34
|
+
spec.add_dependency "ruby2_keywords"
|
34
35
|
|
35
36
|
spec.add_development_dependency "dry-validation", ">= 0.11"
|
36
|
-
spec.add_development_dependency "bundler", "
|
37
|
-
spec.add_development_dependency "sequel", "~> 5.
|
37
|
+
spec.add_development_dependency "bundler", "~> 2.3.7"
|
38
|
+
spec.add_development_dependency "sequel", "~> 5.0"
|
38
39
|
spec.add_development_dependency "rake", "~> 13.0"
|
39
|
-
spec.add_development_dependency "rspec", "~> 3.
|
40
|
-
spec.add_development_dependency "
|
40
|
+
spec.add_development_dependency "rspec", "~> 3.11"
|
41
|
+
spec.add_development_dependency "simplecov-lcov", '~> 0.8.0'
|
42
|
+
spec.add_development_dependency "simplecov"
|
41
43
|
spec.add_development_dependency "pry"
|
42
44
|
spec.add_development_dependency "pry-byebug"
|
43
45
|
spec.add_development_dependency "pry-doc"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pathway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Herrero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.0.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby2_keywords
|
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'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: dry-validation
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,30 +70,30 @@ dependencies:
|
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - "
|
73
|
+
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 2.3.7
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - "
|
80
|
+
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 2.3.7
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: sequel
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 5.
|
89
|
+
version: '5.0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 5.
|
96
|
+
version: '5.0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,16 +114,30 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '3.
|
117
|
+
version: '3.11'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.11'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov-lcov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.8.0
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
138
|
+
version: 0.8.0
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
140
|
+
name: simplecov
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
114
142
|
requirements:
|
115
143
|
- - ">="
|
@@ -171,7 +199,7 @@ executables: []
|
|
171
199
|
extensions: []
|
172
200
|
extra_rdoc_files: []
|
173
201
|
files:
|
174
|
-
- ".
|
202
|
+
- ".github/workflows/tests.yml"
|
175
203
|
- ".gitignore"
|
176
204
|
- ".rspec"
|
177
205
|
- CHANGELOG.md
|
@@ -185,6 +213,8 @@ files:
|
|
185
213
|
- bin/rspec
|
186
214
|
- bin/setup
|
187
215
|
- lib/pathway.rb
|
216
|
+
- lib/pathway/plugins/auto_deconstruct_state.rb
|
217
|
+
- lib/pathway/plugins/auto_deconstruct_state/ruby3.rb
|
188
218
|
- lib/pathway/plugins/dry_validation.rb
|
189
219
|
- lib/pathway/plugins/dry_validation/v0_11.rb
|
190
220
|
- lib/pathway/plugins/dry_validation/v0_12.rb
|
@@ -225,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
255
|
- !ruby/object:Gem::Version
|
226
256
|
version: '0'
|
227
257
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.3.7
|
229
259
|
signing_key:
|
230
260
|
specification_version: 4
|
231
261
|
summary: Define your business logic in simple steps.
|
data/.circleci/config.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
version: 2.0
|
2
|
-
shared: &shared
|
3
|
-
steps:
|
4
|
-
- checkout
|
5
|
-
- run:
|
6
|
-
name: Bundle gems
|
7
|
-
command: |
|
8
|
-
echo '--no-rdoc --no-ri' > '.gemrc'
|
9
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
10
|
-
- run:
|
11
|
-
name: Run tests
|
12
|
-
command: bundle exec rspec --format documentation --color --format progress spec
|
13
|
-
|
14
|
-
jobs:
|
15
|
-
"ruby-2.4":
|
16
|
-
<<: *shared
|
17
|
-
docker:
|
18
|
-
- image: circleci/ruby:2.4
|
19
|
-
|
20
|
-
"ruby-2.5":
|
21
|
-
<<: *shared
|
22
|
-
docker:
|
23
|
-
- image: circleci/ruby:2.5
|
24
|
-
|
25
|
-
"ruby-2.6":
|
26
|
-
<<: *shared
|
27
|
-
docker:
|
28
|
-
- image: circleci/ruby:2.6
|
29
|
-
environment:
|
30
|
-
REPORT_COVERAGE: 'true'
|
31
|
-
|
32
|
-
workflows:
|
33
|
-
version: 2
|
34
|
-
build:
|
35
|
-
jobs:
|
36
|
-
- "ruby-2.4"
|
37
|
-
- "ruby-2.5"
|
38
|
-
- "ruby-2.6"
|