seam 1.1.2 → 2.0.0a1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +4 -2
- data/Gemfile.lock +105 -0
- data/LICENSE.txt +16 -18
- data/README.md +115 -115
- data/Rakefile +23 -0
- data/lib/seam/todo.rb +9 -0
- data/lib/seam/version.rb +3 -1
- data/lib/seam.rb +5 -13
- metadata +61 -91
- data/.gitignore +0 -18
- data/lib/seam/effort.rb +0 -86
- data/lib/seam/flow.rb +0 -53
- data/lib/seam/in_memory.rb +0 -13
- data/lib/seam/persistence.rb +0 -43
- data/lib/seam/step.rb +0 -33
- data/lib/seam/wait_worker.rb +0 -30
- data/lib/seam/worker.rb +0 -166
- data/seam.gemspec +0 -30
- data/spec/seam/effort_spec.rb +0 -43
- data/spec/seam/flow_spec.rb +0 -173
- data/spec/seam/step_spec.rb +0 -34
- data/spec/seam/wait_worker_spec.rb +0 -179
- data/spec/seam/worker_spec.rb +0 -959
- data/spec/spec_helper.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a88e2aad02f40f721466c0b33699643238246f56a848308cb1ae404182de8585
|
4
|
+
data.tar.gz: 5f19f1c35824bc75572ca253397d513b77d32aee827db78e6e11a0addefa3384
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6614aa8ec8df516ab4c54cbf0203b88efae9fd7f995de8754deddfed00bf5c7f64cdc2c61f28746b38bd5ff9d8268629282387db14fc5351324b6b73e93b455d
|
7
|
+
data.tar.gz: '03480dd4e1f12fb17f59cb6904734b3357e5c8f9a6d883944499be7b8a31caa527d644a57bfbd65c5fabc015cd293d4146b40698476e3e182203bd56cdf50522'
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
seam (2.0.0a1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.1)
|
12
|
+
docile (1.4.0)
|
13
|
+
gem-release (2.2.2)
|
14
|
+
json (2.7.2)
|
15
|
+
language_server-protocol (3.17.0.3)
|
16
|
+
lint_roller (1.1.0)
|
17
|
+
multi_json (1.15.0)
|
18
|
+
parallel (1.24.0)
|
19
|
+
parse_gemspec (1.0.0)
|
20
|
+
parse_gemspec-cli (1.0.0)
|
21
|
+
multi_json
|
22
|
+
parse_gemspec
|
23
|
+
thor
|
24
|
+
parser (3.3.0.5)
|
25
|
+
ast (~> 2.4.1)
|
26
|
+
racc
|
27
|
+
racc (1.7.3)
|
28
|
+
rainbow (3.1.1)
|
29
|
+
rake (13.2.1)
|
30
|
+
regexp_parser (2.9.0)
|
31
|
+
rexml (3.2.6)
|
32
|
+
rspec (3.13.0)
|
33
|
+
rspec-core (~> 3.13.0)
|
34
|
+
rspec-expectations (~> 3.13.0)
|
35
|
+
rspec-mocks (~> 3.13.0)
|
36
|
+
rspec-core (3.13.0)
|
37
|
+
rspec-support (~> 3.13.0)
|
38
|
+
rspec-expectations (3.13.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.13.0)
|
41
|
+
rspec-mocks (3.13.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.13.0)
|
44
|
+
rspec-support (3.13.1)
|
45
|
+
rubocop (1.62.1)
|
46
|
+
json (~> 2.3)
|
47
|
+
language_server-protocol (>= 3.17.0)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.3.0.2)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 1.8, < 3.0)
|
52
|
+
rexml (>= 3.2.5, < 4.0)
|
53
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
54
|
+
ruby-progressbar (~> 1.7)
|
55
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
56
|
+
rubocop-ast (1.31.2)
|
57
|
+
parser (>= 3.3.0.4)
|
58
|
+
rubocop-performance (1.20.2)
|
59
|
+
rubocop (>= 1.48.1, < 2.0)
|
60
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
61
|
+
ruby-progressbar (1.13.0)
|
62
|
+
simplecov (0.22.0)
|
63
|
+
docile (~> 1.1)
|
64
|
+
simplecov-html (~> 0.11)
|
65
|
+
simplecov_json_formatter (~> 0.1)
|
66
|
+
simplecov-console (0.9.1)
|
67
|
+
ansi
|
68
|
+
simplecov
|
69
|
+
terminal-table
|
70
|
+
simplecov-html (0.12.3)
|
71
|
+
simplecov_json_formatter (0.1.4)
|
72
|
+
standard (1.35.1)
|
73
|
+
language_server-protocol (~> 3.17.0.2)
|
74
|
+
lint_roller (~> 1.0)
|
75
|
+
rubocop (~> 1.62.0)
|
76
|
+
standard-custom (~> 1.0.0)
|
77
|
+
standard-performance (~> 1.3)
|
78
|
+
standard-custom (1.0.2)
|
79
|
+
lint_roller (~> 1.0)
|
80
|
+
rubocop (~> 1.50)
|
81
|
+
standard-performance (1.3.1)
|
82
|
+
lint_roller (~> 1.1)
|
83
|
+
rubocop-performance (~> 1.20.2)
|
84
|
+
terminal-table (3.0.2)
|
85
|
+
unicode-display_width (>= 1.1.1, < 3)
|
86
|
+
thor (1.3.1)
|
87
|
+
unicode-display_width (2.5.0)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
x86_64-linux
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
bundler (~> 2.0)
|
95
|
+
gem-release (~> 2.2)
|
96
|
+
parse_gemspec-cli (~> 1.0)
|
97
|
+
rake (~> 13.0)
|
98
|
+
rspec (~> 3.0)
|
99
|
+
seam!
|
100
|
+
simplecov (~> 0.21)
|
101
|
+
simplecov-console (~> 0.9)
|
102
|
+
standard (~> 1.3)
|
103
|
+
|
104
|
+
BUNDLED WITH
|
105
|
+
2.5.7
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2021-2024 Seam Labs, Inc.
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,166 +1,166 @@
|
|
1
|
-
# Seam
|
1
|
+
# Seam Ruby SDK
|
2
2
|
|
3
|
-
|
3
|
+
[![RubyGems.org](https://img.shields.io/gem/v/seam)](https://rubygems.org/gems/seam)
|
4
|
+
[![GitHub Actions](https://github.com/seamapi/ruby-next/actions/workflows/check.yml/badge.svg)](https://github.com/seamapi/ruby-next/actions/workflows/check.yml)
|
4
5
|
|
5
|
-
|
6
|
+
SDK for the Seam API written in Ruby.
|
6
7
|
|
7
|
-
|
8
|
+
## Description
|
8
9
|
|
9
|
-
|
10
|
+
TODO
|
10
11
|
|
11
|
-
|
12
|
-
It provides a way to define the process, break it up into separate components, and then send entities through the process.
|
13
|
-
|
14
|
-
####Define a workflow####
|
12
|
+
## Installation
|
15
13
|
|
16
|
-
|
14
|
+
Add this as a dependency to your project using [Bundler] with
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
flow.wait_for_order_to_be_shipped wait_up_to: 7.days
|
22
|
-
flow.send_shipping_email email_template: 'shipping_7'
|
23
|
-
flow.mark_order_as_fulfilled
|
24
|
-
````
|
16
|
+
```
|
17
|
+
$ bundle add seam
|
18
|
+
```
|
25
19
|
|
26
|
-
|
20
|
+
[bundler]: https://bundler.io/
|
27
21
|
|
28
|
-
|
22
|
+
## Development and Testing
|
29
23
|
|
30
|
-
|
31
|
-
flow.wait_for_order_to_be_shipped wait_up_to: 7.days
|
32
|
-
````
|
24
|
+
### Quickstart
|
33
25
|
|
34
|
-
|
26
|
+
```
|
27
|
+
$ git clone https://github.com/seamapi/ruby-next.git
|
28
|
+
$ cd ruby-next
|
29
|
+
$ bundle install
|
30
|
+
```
|
35
31
|
|
36
|
-
|
32
|
+
Run the command below
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
```
|
35
|
+
$ bundle exec rake
|
36
|
+
```
|
41
37
|
|
42
|
-
|
38
|
+
Open an interactive ruby console with
|
43
39
|
|
44
|
-
|
40
|
+
```
|
41
|
+
$ bundle exec rake
|
42
|
+
```
|
45
43
|
|
46
|
-
|
44
|
+
Primary development tasks are defined as [rake] tasks in the `Rakefile`
|
45
|
+
and available via `rake`.
|
46
|
+
View them with
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
@history=[],
|
52
|
-
@complete=false,
|
53
|
-
@id="1ecc4cbe-16af-45f6-8532-7f37493ec11c",
|
54
|
-
@created_at=2013-08-20 22:58:07 -0500,
|
55
|
-
@next_execute_at=2013-08-20 22:58:07 -0500,
|
56
|
-
@next_step="send_order_to_warehouse",
|
57
|
-
@flow={"steps"=>[{"name"=>"send_order_to_warehouse", "type"=>"do", "arguments"=>{}}, {"name"=>"wait_for_order_to_be_shipped", "type"=>"do", "arguments"=>{}}, {"name"=>"send_shipping_email", "type"=>"do", "arguments"=>{}}, {"name"=>"mark_order_as_fulfilled", "type"=>"do", "arguments"=>{}}]},
|
58
|
-
@data={"order_id"=>"1234"}>
|
59
|
-
````
|
48
|
+
```
|
49
|
+
$ bundle exec rake -T
|
50
|
+
```
|
60
51
|
|
61
|
-
|
52
|
+
[rake]: https://ruby.github.io/rake/
|
62
53
|
|
63
|
-
|
54
|
+
### Source code
|
64
55
|
|
65
|
-
|
56
|
+
The [source code] is hosted on GitHub.
|
57
|
+
Clone the project with
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
|
59
|
+
```
|
60
|
+
$ git clone git@github.com:seamapi/ruby-next.git
|
61
|
+
```
|
70
62
|
|
71
|
-
|
63
|
+
[source code]: https://github.com/seamapi/ruby-next
|
72
64
|
|
73
|
-
|
74
|
-
class SendOrderToWarehouseWorker < Seam::Worker
|
75
|
-
def process
|
76
|
-
# the current workflow instance is available as "effort"
|
77
|
-
order = Order.find effort.data['order_id']
|
78
|
-
warehouse_service.send order
|
65
|
+
### Requirements
|
79
66
|
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
83
|
-
````
|
67
|
+
You will need [Ruby] with [Bundler].
|
84
68
|
|
85
|
-
|
69
|
+
Be sure that all commands run under the correct Ruby version, e.g.,
|
70
|
+
if using [rbenv], install the correct version with
|
86
71
|
|
87
|
-
|
72
|
+
```
|
73
|
+
$ rbenv install
|
74
|
+
```
|
88
75
|
|
89
|
-
|
90
|
-
SendOrderToWarehouse.execute_all
|
91
|
-
````
|
76
|
+
Install the development dependencies with
|
92
77
|
|
93
|
-
|
78
|
+
```
|
79
|
+
$ bundle install
|
80
|
+
```
|
94
81
|
|
95
|
-
|
82
|
+
[bundler]: https://bundler.io/
|
83
|
+
[ruby]: https://www.ruby-lang.org/
|
84
|
+
[rbenv]: https://github.com/rbenv/rbenv
|
96
85
|
|
97
|
-
|
86
|
+
### Publishing
|
98
87
|
|
99
|
-
|
100
|
-
class WaitForOrderToBeShippedWorker < Seam::Worker
|
101
|
-
def process
|
102
|
-
effort.data["shipping_status"] = # some method that returns the shipping status
|
103
|
-
unless effort.data["shipping_status"] == "shipped"
|
104
|
-
try_again_in 4.hours
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
````
|
88
|
+
New versions are created with [gem release].
|
109
89
|
|
110
|
-
|
90
|
+
#### Automatic
|
111
91
|
|
112
|
-
|
92
|
+
New versions are released automatically with [semantic-release]
|
93
|
+
as long as commits follow the [Angular Commit Message Conventions].
|
113
94
|
|
114
|
-
|
115
|
-
|
116
|
-
def process
|
117
|
-
effort.data["shipping_status"] = # some method that returns the shipping status
|
118
|
-
if effort.data["shipping_status"] == "cancelled"
|
119
|
-
eject # no need to continue!
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
````
|
95
|
+
[Angular Commit Message Conventions]: https://semantic-release.gitbook.io/semantic-release/#commit-message-format
|
96
|
+
[semantic-release]: https://semantic-release.gitbook.io/
|
124
97
|
|
125
|
-
####
|
98
|
+
#### Manual
|
126
99
|
|
127
|
-
|
100
|
+
Publish a new version by triggering a [version workflow_dispatch on GitHub Actions].
|
101
|
+
The `version` input will be passed to the `--version` option of `gem bump`.
|
128
102
|
|
129
|
-
|
103
|
+
This may be done on the web or using the [GitHub CLI] with
|
130
104
|
|
131
|
-
|
132
|
-
|
133
|
-
|
105
|
+
```
|
106
|
+
$ gh workflow run version.yml --raw-field version=<version>
|
107
|
+
```
|
134
108
|
|
135
|
-
|
109
|
+
[gem release]: https://github.com/svenfuchs/gem-release
|
110
|
+
[GitHub CLI]: https://cli.github.com/
|
111
|
+
[version workflow_dispatch on GitHub Actions]: https://github.com/seamapi/ruby-next/actions?query=workflow%3Aversion
|
136
112
|
|
137
|
-
|
113
|
+
## GitHub Actions
|
138
114
|
|
139
|
-
|
140
|
-
flow = Seam::Flow.new
|
141
|
-
flow.send_order_to_warehouse
|
142
|
-
flow.wait 2.days
|
143
|
-
flow.check_if_the_order_has_been_fulfilled
|
144
|
-
````
|
115
|
+
_GitHub Actions should already be configured: this section is for reference only._
|
145
116
|
|
146
|
-
|
117
|
+
The following repository secrets must be set on [GitHub Actions]:
|
147
118
|
|
148
|
-
|
119
|
+
- `RUBYGEMS_API_KEY`: RubyGems.org token for publishing gems.
|
149
120
|
|
150
|
-
|
121
|
+
These must be set manually.
|
151
122
|
|
152
|
-
|
123
|
+
### Secrets for Optional GitHub Actions
|
153
124
|
|
154
|
-
|
125
|
+
The version, format, generate, and semantic-release GitHub actions
|
126
|
+
require a user with write access to the repository.
|
127
|
+
Set these additional secrets to enable the action:
|
155
128
|
|
156
|
-
|
129
|
+
- `GH_TOKEN`: A personal access token for the user.
|
130
|
+
- `GIT_USER_NAME`: The GitHub user's real name.
|
131
|
+
- `GIT_USER_EMAIL`: The GitHub user's email.
|
132
|
+
- `GPG_PRIVATE_KEY`: The GitHub user's [GPG private key].
|
133
|
+
- `GPG_PASSPHRASE`: The GitHub user's GPG passphrase.
|
157
134
|
|
158
|
-
|
135
|
+
[github actions]: https://github.com/features/actions
|
136
|
+
[gpg private key]: https://github.com/marketplace/actions/import-gpg#prerequisites
|
159
137
|
|
160
138
|
## Contributing
|
161
139
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
140
|
+
Please submit and comment on bug reports and feature requests.
|
141
|
+
|
142
|
+
To submit a patch:
|
143
|
+
|
144
|
+
1. Fork it (https://github.com/seamapi/ruby-next/fork).
|
145
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
146
|
+
3. Make changes.
|
147
|
+
4. Commit your changes (`git commit -am 'Add some feature'`).
|
148
|
+
5. Push to the branch (`git push origin my-new-feature`).
|
149
|
+
6. Create a new Pull Request.
|
150
|
+
|
151
|
+
## License
|
152
|
+
|
153
|
+
This Ruby gem is licensed under the MIT license.
|
154
|
+
|
155
|
+
## Warranty
|
156
|
+
|
157
|
+
This software is provided by the copyright holders and contributors "as is" and
|
158
|
+
any express or implied warranties, including, but not limited to, the implied
|
159
|
+
warranties of merchantability and fitness for a particular purpose are
|
160
|
+
disclaimed. In no event shall the copyright holder or contributors be liable for
|
161
|
+
any direct, indirect, incidental, special, exemplary, or consequential damages
|
162
|
+
(including, but not limited to, procurement of substitute goods or services;
|
163
|
+
loss of use, data, or profits; or business interruption) however caused and on
|
164
|
+
any theory of liability, whether in contract, strict liability, or tort
|
165
|
+
(including negligence or otherwise) arising in any way out of the use of this
|
166
|
+
software, even if advised of the possibility of such damage.
|
data/Rakefile
CHANGED
@@ -1 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "standard/rake"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.rspec_opts = "--pattern {spec,lib}/**/*_spec.rb"
|
9
|
+
end
|
10
|
+
|
11
|
+
task default: %i[lint test]
|
12
|
+
|
13
|
+
task test: "spec"
|
14
|
+
task lint: "standard"
|
15
|
+
task format: "standard:fix"
|
16
|
+
|
17
|
+
desc "Open an interactive ruby console"
|
18
|
+
task :console do
|
19
|
+
require "irb"
|
20
|
+
require "bundler/setup"
|
21
|
+
require "seam"
|
22
|
+
ARGV.clear
|
23
|
+
IRB.start
|
24
|
+
end
|
data/lib/seam/todo.rb
ADDED
data/lib/seam/version.rb
CHANGED
data/lib/seam.rb
CHANGED
@@ -1,16 +1,8 @@
|
|
1
|
-
|
2
|
-
require 'active_support/time'
|
3
|
-
require 'securerandom'
|
4
|
-
require 'json'
|
5
|
-
require_relative 'seam/worker'
|
6
|
-
Dir[File.dirname(__FILE__) + '/seam/*.rb'].each {|file| require file }
|
1
|
+
# frozen_string_literal: true
|
7
2
|
|
8
|
-
|
9
|
-
|
10
|
-
def self.steps_to_run
|
11
|
-
Seam::Persistence.find_something_to_do
|
12
|
-
.group_by { |x| x.next_step }
|
13
|
-
.map { |x| x[0] }
|
14
|
-
end
|
3
|
+
require_relative "seam/version"
|
4
|
+
require_relative "seam/todo"
|
15
5
|
|
6
|
+
module Seam
|
7
|
+
# TODO
|
16
8
|
end
|