trailblazer 2.1.2 → 2.1.3
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/ci.yml +2 -5
- data/CHANGES.md +15 -19
- data/README.md +59 -153
- data/lib/trailblazer/version.rb +1 -1
- data/test/test_helper.rb +1 -36
- data/test/trailblazer_test.rb +99 -0
- data/trailblazer.gemspec +7 -5
- metadata +64 -12
- data/.github/workflows/ci_jruby.yml +0 -19
- data/.github/workflows/ci_legacy.yml +0 -19
- data/.github/workflows/ci_truffleruby.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d0ac4db20919678e762365a02e94e4882b21f933e8fec565ab277fc081a5d5b
|
4
|
+
data.tar.gz: d150482451d566d56d3ef1815d6d080c756001ca619769db3fe4ab914466de50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48bc5c565745d3ee6293b4cc6b50c44e71618151d93e5e091a8338b8d1b38f45793b24daec644e458b71700f4cbd58f5a934813e314f4e18f843fcbc8de7676
|
7
|
+
data.tar.gz: f30443b34b86d148f2a9a35d60a97b593157c3f346a365664be96b7987df42d6bd29378e451000359a2eca289cd948f9a13f2c5043a82dcc4dcfee04a2082d5c
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
## This file is managed by Terraform.
|
2
|
-
## Do not modify this file directly, as it may be overwritten.
|
3
|
-
## Please open an issue instead.
|
4
1
|
name: CI
|
5
2
|
on: [push, pull_request]
|
6
3
|
jobs:
|
@@ -8,12 +5,12 @@ jobs:
|
|
8
5
|
strategy:
|
9
6
|
fail-fast: false
|
10
7
|
matrix:
|
11
|
-
ruby: [2.7, '3.0', '3.1']
|
8
|
+
ruby: [2.5, 2.6, 2.7, '3.0', '3.1', '3.2', 'head', 'jruby']
|
12
9
|
runs-on: ubuntu-latest
|
13
10
|
steps:
|
14
11
|
- uses: actions/checkout@v3
|
15
12
|
- uses: ruby/setup-ruby@v1
|
16
13
|
with:
|
17
14
|
ruby-version: ${{ matrix.ruby }}
|
18
|
-
bundler-cache: true
|
15
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
19
16
|
- run: bundle exec rake
|
data/CHANGES.md
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
+
# 2.1.3
|
1
2
|
|
3
|
+
* Require `trailblazer-developer` 0.1 line which brings tracing performance increase by
|
4
|
+
factor 4-10.
|
5
|
+
* Introduce `Operation.left` as an alias for `#fail`.
|
6
|
+
* Better debugging API for the upcoming web debugger.
|
2
7
|
|
3
|
-
# 2.1
|
8
|
+
# 2.1.2
|
9
|
+
|
10
|
+
* Use `trailblazer-activity-dsl-linear` >= 1.1.0.
|
11
|
+
|
12
|
+
# 2.1.1
|
13
|
+
|
14
|
+
* Use `trailblazer-activity-dsl-linear` >= 1.0.0.
|
15
|
+
|
16
|
+
# 2.1.0
|
4
17
|
|
18
|
+
* Remove `declarative` dependency.
|
5
19
|
* Macros now always have to provide an `:id`. This was a bit fuzzy in 2.0.
|
6
20
|
|
7
21
|
* Nested
|
@@ -23,27 +37,9 @@
|
|
23
37
|
|
24
38
|
Always write to `options`.
|
25
39
|
|
26
|
-
* self[] removed
|
27
40
|
* Fixed `Guard` where procs could receive one argument, only. Guards follow the step interface: `Policy::Guard( ->(options, **) { .. } )
|
28
41
|
* Removed `Operation::Callback` which was a poor idea and luckily no one was using it.
|
29
42
|
|
30
|
-
TODO:
|
31
|
-
document Task API and define step API
|
32
|
-
deprecate step->(options) ?
|
33
|
-
injectable, per-operation step arguments strategy?
|
34
|
-
|
35
|
-
# 2.1.2
|
36
|
-
|
37
|
-
* Use `trailblazer-activity-dsl-linear` >= 1.1.0.
|
38
|
-
|
39
|
-
# 2.1.1
|
40
|
-
|
41
|
-
* Use `trailblazer-activity-dsl-linear` >= 1.0.0.
|
42
|
-
|
43
|
-
# 2.1.0
|
44
|
-
|
45
|
-
* Remove `declarative` dependency.
|
46
|
-
|
47
43
|
# 2.1.0.rc13
|
48
44
|
|
49
45
|
* Use newest `macro` and `macro-context`. They use symbols keys now everywhere.
|
data/README.md
CHANGED
@@ -1,203 +1,109 @@
|
|
1
1
|
# Trailblazer
|
2
2
|
|
3
|
-
|
3
|
+
_Battle-tested Ruby framework to help structuring your business logic._
|
4
4
|
|
5
|
-
[](https://trailblazer.zulipchat.com)
|
6
|
-
[](http://trailblazer.to/newsletter/)
|
7
5
|
[](http://badge.fury.io/rb/trailblazer)
|
8
|
-
[](https://www.codetriage.com/trailblazer/trailblazer)
|
9
6
|
|
10
|
-
##
|
11
|
-
|
12
|
-
* **The current version is Trailblazer 2.1.** We do have [comprehensive API documenation](https://trailblazer.to/2.1/docs/trailblazer.html) ready for you. If you're new to TRB start with our [LEARN page](https://trailblazer.to/2.1/learn.html).
|
13
|
-
* A migration guide from 2.0 can be found [on our website](https://trailblazer.to/2.1/docs/trailblazer.html#trailblazer-2-1-migration).
|
14
|
-
* The [1.x documentation is here](http://trailblazer.to/2.0/gems/operation/1.1/index.html).
|
15
|
-
|
16
|
-
Make sure to check out the new beginner's guide to learning Trailblazer. The [brand-new book](https://leanpub.com/buildalib) discusses all aspects in a step-wise approach you need to understand Trailblazer's mechanics and design ideas.
|
17
|
-
|
18
|
-
<a href="https://leanpub.com/buildalib"><img src="https://trailblazer.to/images/2.1/buildalib-cover.png"></a>
|
19
|
-
|
20
|
-
## Screencasts
|
21
|
-
|
22
|
-
Watch our series of screencasts [**TRAILBLAZER TALES**](https://www.youtube.com/channel/UCi2P0tFMtjMUsWLYAD1Ezsw) if you prefer learning from videos!
|
23
|
-
|
24
|
-
<a href="https://www.youtube.com/embed/9elpobV4HSw"><img src="https://trailblazer.to/images/2.1/01-operation-basics.png"></a>
|
25
|
-
|
26
|
-
## Trailblazer In A Nutshell
|
27
|
-
|
28
|
-
1. All business logic is encapsulated in [operations](#operation) (service objects).
|
29
|
-
3. [Controllers](#controllers) instantly delegate to an operation. No business code in controllers, only HTTP-specific logic.
|
30
|
-
4. [Models](#models) are persistence-only and solely define associations and scopes. No business code is to be found here. No validations, no callbacks.
|
31
|
-
5. The presentation layer offers optional [view models](#views) (Cells) and [representers](#representers) for document APIs.
|
32
|
-
6. More complex business flows and life-cycles are modeled using workflows.
|
33
|
-
|
34
|
-
Want code? Jump [right here](#controllers)!
|
35
|
-
|
36
|
-
## Mission
|
37
|
-
|
38
|
-
While _Trailblazer_ offers you abstraction layers for all aspects of Ruby On Rails, it does _not_ missionize you. Wherever you want, you may fall back to the "Rails Way" with fat models, monolithic controllers, global helpers, etc. This is not a bad thing, but allows you to step-wise introduce Trailblazer's encapsulation in your app without having to rewrite it.
|
39
|
-
|
40
|
-
Trailblazer is all about structure. It helps re-organize existing code into smaller components where different concerns are handled in separated classes.
|
7
|
+
## What's Trailblazer?
|
41
8
|
|
42
|
-
|
9
|
+
Trailblazer introduces new abstraction layers into Ruby applications to help you structure your business logic.
|
43
10
|
|
44
|
-
|
11
|
+
It ships with our canonical "service object" implementation called *operation*, many conventions, gems for testing, Rails support, optional form objects and much more.
|
45
12
|
|
46
|
-
##
|
13
|
+
## Should I use Trailblazer?
|
47
14
|
|
48
|
-
|
15
|
+
Give us a chance if you say "yes" to this!
|
49
16
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
│ │ │ ├── create.rb
|
56
|
-
│ │ │ ├── update.rb
|
57
|
-
│ │ ├── contract
|
58
|
-
│ │ │ ├── create.rb
|
59
|
-
│ │ │ ├── update.rb
|
60
|
-
│ │ ├── cell
|
61
|
-
│ │ │ ├── show.rb
|
62
|
-
│ │ │ ├── index.rb
|
63
|
-
│ │ ├── view
|
64
|
-
│ │ │ ├── show.haml
|
65
|
-
│ │ │ ├── index.rb
|
66
|
-
│ │ │ ├── song.css.sass
|
67
|
-
```
|
68
|
-
|
69
|
-
Instead of grouping by technology, classes and views are structured by *concept*, and then by technology. A concept can relate to a model, or can be a completely abstract concern such as `invoicing`.
|
70
|
-
|
71
|
-
Within a concept, you can have any level of nesting. For example, `invoicing/pdf/` could be one.
|
72
|
-
|
73
|
-
|
74
|
-
## Architecture
|
75
|
-
|
76
|
-
Trailblazer extends the conventional MVC stack in Rails. Keep in mind that adding layers doesn't necessarily mean adding more code and complexity.
|
77
|
-
|
78
|
-
The opposite is the case: Controller, view and model become lean endpoints for HTTP, rendering and persistence. Redundant code gets eliminated by putting very little application code into the right layer.
|
17
|
+
* You hate messy controller code but don't know where to put it?
|
18
|
+
* Moving business code into the "fat model" gives you nightmares?
|
19
|
+
* "Service objects" are great?
|
20
|
+
* Anyhow, you're tired of 12 different "service object" implementations throughout your app?
|
21
|
+
* You keep asking for additional layers such as forms, policies, decorators?
|
79
22
|
|
80
|
-
|
23
|
+
Yes? Then we got a well-seasoned framework for you: [Trailblazer](https://trailblazer.to/2.1).
|
81
24
|
|
82
|
-
|
25
|
+
Here are the main concepts.
|
83
26
|
|
84
|
-
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
Rails.application.routes.draw do
|
88
|
-
resources :songs
|
89
|
-
end
|
90
|
-
```
|
91
|
-
|
92
|
-
## Controllers
|
93
|
-
|
94
|
-
Controllers are lean endpoints for HTTP. They do not contain any business logic. Actions immediately dispatch to an operation.
|
27
|
+
## Operation
|
95
28
|
|
96
|
-
|
97
|
-
class SongsController < ApplicationController
|
98
|
-
def create
|
99
|
-
run Song::Create # Song::Create is an operation class.
|
100
|
-
end
|
101
|
-
end
|
102
|
-
```
|
29
|
+
The operation encapsulates business logic and is the heart of the Trailblazer architecture.
|
103
30
|
|
104
|
-
|
31
|
+
An operation is not just a monolithic replacement for your business code. It's a simple orchestrator between the form objects, models, your business code and all other layers needed to get the job done.
|
105
32
|
|
106
33
|
```ruby
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
34
|
+
# app/concepts/song/operation/create.rb
|
35
|
+
module Song::Operation
|
36
|
+
class Create < Trailblazer::Operation
|
37
|
+
step :create_model
|
38
|
+
step :validate
|
39
|
+
left :handle_errors
|
40
|
+
step :notify
|
41
|
+
|
42
|
+
def create_model(ctx, **)
|
43
|
+
# do whatever you feel like.
|
44
|
+
ctx[:model] = Song.new
|
111
45
|
end
|
112
46
|
|
113
|
-
|
47
|
+
def validate(ctx, params:, **)
|
48
|
+
# ..
|
49
|
+
end
|
50
|
+
# ...
|
114
51
|
end
|
115
52
|
end
|
116
53
|
```
|
117
54
|
|
118
|
-
|
55
|
+
The `step` DSL takes away the pain of flow control and error handling. You focus on _what_ happens: creating models, validating data, sending out notifications.
|
119
56
|
|
120
|
-
|
121
|
-
|
122
|
-
## Operation
|
57
|
+
### Control flow
|
123
58
|
|
124
|
-
|
59
|
+
The operation takes care _when_ things happen: the flow control. Internally, this works as depicted in this beautiful diagram.
|
125
60
|
|
126
|
-
|
61
|
+

|
127
62
|
|
128
|
-
|
129
|
-
|
130
|
-
An operation is not just a monolithic replacement for your business code. It's a simple orchestrator between the form objects, models, your business code and all other layers needed to get the job done.
|
63
|
+
The best part: the only way to invoke this operation is `Operation.call`. The single entry-point saves programmers from shenanigans with instances and internal state - it's proven to be an almost bullet-proof concept in the past 10 years.
|
131
64
|
|
132
65
|
```ruby
|
133
|
-
|
134
|
-
step :model
|
135
|
-
step :validate
|
136
|
-
|
137
|
-
def model(ctx, **)
|
138
|
-
# do whatever you feel like.
|
139
|
-
ctx[:model] = Song.new
|
140
|
-
end
|
141
|
-
|
142
|
-
def validate(ctx, params:, **)
|
143
|
-
# ..
|
144
|
-
end
|
145
|
-
end
|
146
|
-
```
|
147
|
-
|
148
|
-
Operations define the flow of their logic using the DSL and implement the particular steps with pure Ruby.
|
66
|
+
result = Song::Operation::Create.(params: {title: "Hear Us Out", band: "Rancid"})
|
149
67
|
|
150
|
-
|
151
|
-
|
152
|
-
```ruby
|
153
|
-
Song::Create.(params: {whatever: "goes", in: "here"})
|
68
|
+
result.success? #=> true
|
69
|
+
result[:model] #=> #<Song title="Hear Us Out" ...>
|
154
70
|
```
|
155
71
|
|
156
|
-
|
72
|
+
Data, computed values, statuses or models from within the operation run are exposed through the `result` object.
|
157
73
|
|
158
|
-
[
|
74
|
+
Operations can be nested, use composition and inheritance patterns, provide [variable mapping](https://trailblazer.to/2.1/docs/activity#activity-variable-mapping) around each step, support dependency injection, and save you from reinventing the wheel - over and over, again.
|
159
75
|
|
160
|
-
|
76
|
+
Leveraging those functional mechanics, operations encourage a high degree of encapsulation while giving you all the conventions and tools for free (except for a bit of a learning curve).
|
161
77
|
|
162
|
-
|
78
|
+
### Tracing
|
163
79
|
|
164
|
-
In
|
80
|
+
In the past years, we learnt from some old mistakes and improved developer experience. As a starter, check out our built-in tracing!
|
165
81
|
|
166
82
|
```ruby
|
167
|
-
|
168
|
-
belongs_to :thing
|
169
|
-
|
170
|
-
scope :latest, lambda { all.limit(9).order("id DESC") }
|
171
|
-
end
|
83
|
+
result = Song::Operation::Create.wtf?(params: {title: "", band: "Rancid"})
|
172
84
|
```
|
173
85
|
|
174
|
-
|
86
|
+

|
175
87
|
|
176
|
-
|
88
|
+
Within a second you know which step failed - a thing that might seem trivial, but when things grow and a deeply nested step in an iteration fails, you will start loving `#wtf?`! It has saved us days of debugging.
|
177
89
|
|
178
|
-
|
90
|
+
We even provide a [visual debugger](https://trailblazer.to/2.1/pro) to inspect traces on the webs.
|
179
91
|
|
180
|
-
|
92
|
+
## There's a lot more
|
181
93
|
|
182
|
-
|
183
|
-
describe Song::Update do
|
184
|
-
let(:song) { Song::Create.(song: {body: "[That](http://trailblazer.to)!"}) }
|
185
|
-
end
|
186
|
-
```
|
94
|
+
All our abstraction layers such as [operations](https://trailblazer.to/2.1/docs/operation), [form objects](https://trailblazer.to/2.1/docs/reform.html), [view components](https://trailblazer.to/2.1/docs/cells.html), [test gems](https://trailblazer.to/2.1/docs/test) and much more are used in [hundreds of OSS projects](https://github.com/trailblazer/trailblazer/network/dependents) and commercial applications in the Ruby world.
|
187
95
|
|
188
|
-
|
189
|
-
Operations are a great way to clean up controllers and models. However, Trailblazer goes further and provides an approach to model entire life-cycles of business objects, such as "a song" or "the root user" using workflow ([`pro feature`](https://2019.trailblazer.to/2.1/docs/pro.html#pro-1)). Also, you don't have to use the DSL but can use the [`editor`](https://2019.trailblazer.to/2.1/docs/pro.html#pro-editor) instead (cool for more complex, long-running flows). Here comes a sample screenshot.
|
96
|
+
We provide a [visual debugger](https://pro.trailblazer.to), a [BPMN editor](https://trailblazer.to/2.1/docs/workflow) for long-running business processes, [thorough documentation](https://trailblazer.to/2.1/docs/trailblazer.html) and a growing list of onboarding videos ([**TRAILBLAZER TALES**](https://www.youtube.com/channel/UCi2P0tFMtjMUsWLYAD1Ezsw)).
|
190
97
|
|
191
|
-
|
98
|
+
Trailblazer is both used for refactoring legacy apps (we support Ruby 2.5+) and helps big teams organizing, structuring and debugging modern, growing (Rails) applications.
|
192
99
|
|
193
|
-
##
|
100
|
+
## Documentation
|
194
101
|
|
195
|
-
The
|
102
|
+
* **The current version is Trailblazer 2.1.** We do have comprehensive [API documenation](https://trailblazer.to/2.1/docs/trailblazer.html) ready for you. If you're new to TRB start with our [LEARN page](https://trailblazer.to/2.1/learn.html).
|
103
|
+
* A migration guide from 2.0 can be found [on our website](https://trailblazer.to/2.1/docs/trailblazer.html#trailblazer-2-1-migration).
|
104
|
+
* The [1.x documentation is here](http://trailblazer.to/2.0/gems/operation/1.1/index.html).
|
196
105
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
gem "trailblazer-cells"
|
201
|
-
```
|
106
|
+
Make sure to check out the new beginner's guide to learning Trailblazer. The [new book](https://leanpub.com/buildalib) discusses all aspects in a step-wise approach you need to understand Trailblazer's mechanics and design ideas.
|
107
|
+
|
108
|
+

|
202
109
|
|
203
|
-
Cells is _not_ required per default! Add it if you use it, which is highly recommended.
|
data/lib/trailblazer/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -1,38 +1,3 @@
|
|
1
|
-
require "pp"
|
2
|
-
require "delegate"
|
3
|
-
require "trailblazer"
|
4
1
|
require "minitest/autorun"
|
5
2
|
|
6
|
-
|
7
|
-
require "reform"
|
8
|
-
require "reform/form/active_model/validations"
|
9
|
-
Reform::Form.class_eval do
|
10
|
-
include Reform::Form::ActiveModel::Validations
|
11
|
-
end
|
12
|
-
# require "trailblazer/deprecation/context.rb"
|
13
|
-
|
14
|
-
module Mock
|
15
|
-
class Result
|
16
|
-
def initialize(bool); @bool = bool end
|
17
|
-
def success?; @bool end
|
18
|
-
def errors; ["hihi"] end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Test
|
23
|
-
module ReturnCall
|
24
|
-
def self.included(includer)
|
25
|
-
includer._insert :_insert, ReturnResult, {replace: Trailblazer::Operation::Result::Build}, ReturnResult, ""
|
26
|
-
end
|
27
|
-
end
|
28
|
-
ReturnResult = ->(last, input, options) { input }
|
29
|
-
end
|
30
|
-
|
31
|
-
Minitest::Spec::Operation = Trailblazer::Operation
|
32
|
-
|
33
|
-
Memo = Struct.new(:id, :body) do
|
34
|
-
def self.find(id)
|
35
|
-
return new(id, "Yo!") if id
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end
|
3
|
+
require "trailblazer"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "reform/form/dry"
|
3
|
+
require "trailblazer/macro"
|
4
|
+
require "trailblazer/macro/contract"
|
5
|
+
|
6
|
+
class TrailblazerTest < Minitest::Spec
|
7
|
+
Song = Struct.new(:title)
|
8
|
+
|
9
|
+
|
10
|
+
class Create < Trailblazer::Operation
|
11
|
+
class Form < Reform::Form
|
12
|
+
include Reform::Form::Dry
|
13
|
+
property :title
|
14
|
+
|
15
|
+
validation do
|
16
|
+
params do
|
17
|
+
required(:title).filled(min_size?: 2)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
step Model(Song, :new)
|
23
|
+
step Contract::Build(constant: Form)
|
24
|
+
step Contract::Validate()
|
25
|
+
step Contract::Persist(method: :sync)
|
26
|
+
end
|
27
|
+
|
28
|
+
it do
|
29
|
+
result = nil
|
30
|
+
|
31
|
+
output, _ = capture_io do
|
32
|
+
result = Create.wtf?(params: {title: "Dead and Gone"})
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_equal output, %(TrailblazerTest::Create
|
36
|
+
|-- \e[32mStart.default\e[0m
|
37
|
+
|-- \e[32mmodel.build\e[0m
|
38
|
+
|-- \e[32mcontract.build\e[0m
|
39
|
+
|-- contract.default.validate
|
40
|
+
| |-- \e[32mStart.default\e[0m
|
41
|
+
| |-- \e[32mcontract.default.params_extract\e[0m
|
42
|
+
| |-- \e[32mcontract.default.call\e[0m
|
43
|
+
| `-- End.success
|
44
|
+
|-- \e[32mpersist.save\e[0m
|
45
|
+
`-- End.success
|
46
|
+
)
|
47
|
+
assert_equal result.success?, true
|
48
|
+
assert_equal result[:model].to_h, {:title=>"Dead and Gone"}
|
49
|
+
|
50
|
+
# invalid!
|
51
|
+
result = Create.wtf?(params: {})
|
52
|
+
output, _ = capture_io do
|
53
|
+
result = Create.wtf?(params: {})
|
54
|
+
end
|
55
|
+
|
56
|
+
assert_equal output, %(TrailblazerTest::Create
|
57
|
+
|-- \e[32mStart.default\e[0m
|
58
|
+
|-- \e[32mmodel.build\e[0m
|
59
|
+
|-- \e[32mcontract.build\e[0m
|
60
|
+
|-- contract.default.validate
|
61
|
+
| |-- \e[32mStart.default\e[0m
|
62
|
+
| |-- \e[32mcontract.default.params_extract\e[0m
|
63
|
+
| |-- \e[33mcontract.default.call\e[0m
|
64
|
+
| `-- End.failure
|
65
|
+
`-- End.failure
|
66
|
+
)
|
67
|
+
|
68
|
+
assert_equal result.success?, false
|
69
|
+
assert_equal result[:mode].to_h, {}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Song = Struct.new(:title)
|
74
|
+
# class Song
|
75
|
+
# module Operation
|
76
|
+
# class Create < Trailblazer::Operation
|
77
|
+
# step :create_model
|
78
|
+
# step :validate
|
79
|
+
# fail :handle_errors
|
80
|
+
# step :notify
|
81
|
+
|
82
|
+
# def create_model(ctx, **)
|
83
|
+
# # do whatever you feel like.
|
84
|
+
# ctx[:model] = Song.new
|
85
|
+
# end
|
86
|
+
|
87
|
+
# def validate(ctx, params:, **)
|
88
|
+
# # ..
|
89
|
+
# end
|
90
|
+
|
91
|
+
# def handle_errors(ctx, **)
|
92
|
+
# true
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
|
96
|
+
# end
|
97
|
+
# end
|
98
|
+
|
99
|
+
# Song::Operation::Create.wtf?(params: {})
|
data/trailblazer.gemspec
CHANGED
@@ -7,9 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = Trailblazer::Version::VERSION
|
8
8
|
spec.authors = ["Nick Sutterer"]
|
9
9
|
spec.email = ["apotonick@gmail.com"]
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.homepage = "http://trailblazer.to"
|
10
|
+
spec.summary = %q{Ruby framework for structuring your business logic.}
|
11
|
+
spec.homepage = "https://trailblazer.to"
|
13
12
|
spec.license = "LGPL-3.0"
|
14
13
|
spec.metadata = {
|
15
14
|
"bug_tracker_uri" => "https://github.com/trailblazer/trailblazer/issues",
|
@@ -27,14 +26,17 @@ Gem::Specification.new do |spec|
|
|
27
26
|
spec.test_files = `git ls-files -z test`.split("\x0")
|
28
27
|
spec.require_paths = ["lib"]
|
29
28
|
|
30
|
-
spec.add_dependency "trailblazer-macro", ">= 2.1.
|
29
|
+
spec.add_dependency "trailblazer-macro", ">= 2.1.15", "< 2.2.0"
|
30
|
+
spec.add_dependency "trailblazer-developer", ">= 0.1.0", "< 0.2.0"
|
31
31
|
spec.add_dependency "trailblazer-macro-contract", ">= 2.1.4", "< 2.2.0"
|
32
32
|
spec.add_dependency "trailblazer-operation", ">= 0.9.0", "< 1.0.0"
|
33
|
+
spec.add_dependency "trailblazer-activity-dsl-linear", ">= 1.2.3", "< 1.3.0" # this can be removed at some point.
|
33
34
|
|
34
35
|
spec.add_development_dependency "bundler"
|
35
36
|
spec.add_development_dependency "rake"
|
36
37
|
spec.add_development_dependency "minitest"
|
37
38
|
spec.add_development_dependency "minitest-line"
|
39
|
+
spec.add_development_dependency "dry-validation"
|
38
40
|
|
39
|
-
spec.required_ruby_version = '>= 2.
|
41
|
+
spec.required_ruby_version = '>= 2.5.0'
|
40
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trailblazer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trailblazer-macro
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.1.
|
19
|
+
version: 2.1.15
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 2.2.0
|
@@ -26,10 +26,30 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.1.
|
29
|
+
version: 2.1.15
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.2.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: trailblazer-developer
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.1.0
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.2.0
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.1.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.2.0
|
33
53
|
- !ruby/object:Gem::Dependency
|
34
54
|
name: trailblazer-macro-contract
|
35
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,6 +90,26 @@ dependencies:
|
|
70
90
|
- - "<"
|
71
91
|
- !ruby/object:Gem::Version
|
72
92
|
version: 1.0.0
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: trailblazer-activity-dsl-linear
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 1.2.3
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.0
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.3
|
110
|
+
- - "<"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.3.0
|
73
113
|
- !ruby/object:Gem::Dependency
|
74
114
|
name: bundler
|
75
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -126,8 +166,21 @@ dependencies:
|
|
126
166
|
- - ">="
|
127
167
|
- !ruby/object:Gem::Version
|
128
168
|
version: '0'
|
129
|
-
|
130
|
-
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: dry-validation
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
type: :development
|
177
|
+
prerelease: false
|
178
|
+
version_requirements: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
description:
|
131
184
|
email:
|
132
185
|
- apotonick@gmail.com
|
133
186
|
executables: []
|
@@ -136,9 +189,6 @@ extra_rdoc_files: []
|
|
136
189
|
files:
|
137
190
|
- ".github/dependabot.yml"
|
138
191
|
- ".github/workflows/ci.yml"
|
139
|
-
- ".github/workflows/ci_jruby.yml"
|
140
|
-
- ".github/workflows/ci_legacy.yml"
|
141
|
-
- ".github/workflows/ci_truffleruby.yml"
|
142
192
|
- ".gitignore"
|
143
193
|
- CHANGES.md
|
144
194
|
- COMM-LICENSE
|
@@ -151,8 +201,9 @@ files:
|
|
151
201
|
- lib/trailblazer.rb
|
152
202
|
- lib/trailblazer/version.rb
|
153
203
|
- test/test_helper.rb
|
204
|
+
- test/trailblazer_test.rb
|
154
205
|
- trailblazer.gemspec
|
155
|
-
homepage:
|
206
|
+
homepage: https://trailblazer.to
|
156
207
|
licenses:
|
157
208
|
- LGPL-3.0
|
158
209
|
metadata:
|
@@ -171,7 +222,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
222
|
requirements:
|
172
223
|
- - ">="
|
173
224
|
- !ruby/object:Gem::Version
|
174
|
-
version: 2.
|
225
|
+
version: 2.5.0
|
175
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
227
|
requirements:
|
177
228
|
- - ">="
|
@@ -181,6 +232,7 @@ requirements: []
|
|
181
232
|
rubygems_version: 3.2.3
|
182
233
|
signing_key:
|
183
234
|
specification_version: 4
|
184
|
-
summary:
|
235
|
+
summary: Ruby framework for structuring your business logic.
|
185
236
|
test_files:
|
186
237
|
- test/test_helper.rb
|
238
|
+
- test/trailblazer_test.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
## This file is managed by Terraform.
|
2
|
-
## Do not modify this file directly, as it may be overwritten.
|
3
|
-
## Please open an issue instead.
|
4
|
-
name: CI JRuby
|
5
|
-
on: [push, pull_request]
|
6
|
-
jobs:
|
7
|
-
test:
|
8
|
-
strategy:
|
9
|
-
fail-fast: false
|
10
|
-
matrix:
|
11
|
-
ruby: [jruby, jruby-head]
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v3
|
15
|
-
- uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
18
|
-
bundler-cache: true
|
19
|
-
- run: bundle exec rake
|
@@ -1,19 +0,0 @@
|
|
1
|
-
## This file is managed by Terraform.
|
2
|
-
## Do not modify this file directly, as it may be overwritten.
|
3
|
-
## Please open an issue instead.
|
4
|
-
name: CI with EOL ruby versions
|
5
|
-
on: [push, pull_request]
|
6
|
-
jobs:
|
7
|
-
test:
|
8
|
-
strategy:
|
9
|
-
fail-fast: false
|
10
|
-
matrix:
|
11
|
-
ruby: [2.5, 2.6]
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v3
|
15
|
-
- uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
18
|
-
bundler-cache: true
|
19
|
-
- run: bundle exec rake
|
@@ -1,19 +0,0 @@
|
|
1
|
-
## This file is managed by Terraform.
|
2
|
-
## Do not modify this file directly, as it may be overwritten.
|
3
|
-
## Please open an issue instead.
|
4
|
-
name: CI TruffleRuby
|
5
|
-
on: [push, pull_request]
|
6
|
-
jobs:
|
7
|
-
test:
|
8
|
-
strategy:
|
9
|
-
fail-fast: false
|
10
|
-
matrix:
|
11
|
-
ruby: [truffleruby, truffleruby-head]
|
12
|
-
runs-on: ubuntu-latest
|
13
|
-
steps:
|
14
|
-
- uses: actions/checkout@v3
|
15
|
-
- uses: ruby/setup-ruby@v1
|
16
|
-
with:
|
17
|
-
ruby-version: ${{ matrix.ruby }}
|
18
|
-
bundler-cache: true
|
19
|
-
- run: bundle exec rake
|