seam 1.1.2 → 2.0.0a1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9d5952bb7e0d86052efcc14e254ff5c7157c1b2a
4
- data.tar.gz: b56f6783e898afd0ee3d1a6fc836aef121c6bac3
2
+ SHA256:
3
+ metadata.gz: a88e2aad02f40f721466c0b33699643238246f56a848308cb1ae404182de8585
4
+ data.tar.gz: 5f19f1c35824bc75572ca253397d513b77d32aee827db78e6e11a0addefa3384
5
5
  SHA512:
6
- metadata.gz: c5756f019e6eacc0a1a90509021aa68e3753055ea6102d2d0ae42851062e38f4bba5ad508054d2e79d30543c32050613b23dfd3d30e3ce0b36a39a3191b4bd46
7
- data.tar.gz: d287f29a24f6533fb4e1f13202e272224b3bc2272f2db084361ca008d396a9ce950fa6fe8b2601f492f9bfac7fe48a926513b661153668161880e48576484660
6
+ metadata.gz: 6614aa8ec8df516ab4c54cbf0203b88efae9fd7f995de8754deddfed00bf5c7f64cdc2c61f28746b38bd5ff9d8268629282387db14fc5351324b6b73e93b455d
7
+ data.tar.gz: '03480dd4e1f12fb17f59cb6904734b3357e5c8f9a6d883944499be7b8a31caa527d644a57bfbd65c5fabc015cd293d4146b40698476e3e182203bd56cdf50522'
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- # Specify your gem's dependencies in seam.gemspec
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in seam.gemspec.
4
6
  gemspec
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
- Copyright (c) 2013 Darren Cauthon
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2021-2024 Seam Labs, Inc.
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
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
- included in all copies or substantial portions of the Software.
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
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
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
- Simple workflows in Ruby.
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
- ## Usage
6
+ SDK for the Seam API written in Ruby.
6
7
 
7
- Seam is meant for situations where you want to take some entity (user, order, ec.) through a long-running process that is comprised of multiple steps.
8
+ ## Description
8
9
 
9
- For example, if you want every new user a "hello" email after signup, then wait a few days, and then send a "gone so soon?" email if they haven't signed in again.
10
+ TODO
10
11
 
11
- This gem provides some simple tools for building and executing this process.
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
- To start, define a workflow.
14
+ Add this as a dependency to your project using [Bundler] with
17
15
 
18
- ````
19
- flow = Seam::Flow.new
20
- flow.send_order_to_warehouse
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
- A flow will convert any method call you make into a step that has to be completed.
20
+ [bundler]: https://bundler.io/
27
21
 
28
- You can also pass a hash to the method, which will be saved for later.
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
- ####Starting an instance of the flow####
26
+ ```
27
+ $ git clone https://github.com/seamapi/ruby-next.git
28
+ $ cd ruby-next
29
+ $ bundle install
30
+ ```
35
31
 
36
- Starting an instance of the flow is done with "start":
32
+ Run the command below
37
33
 
38
- ````
39
- flow.start order_id: '1234'
40
- ````
34
+ ```
35
+ $ bundle exec rake
36
+ ```
41
37
 
42
- An instance of this effort was created and saved in whatever persistence is being used (in-memory by default).
38
+ Open an interactive ruby console with
43
39
 
44
- This effort will start at the first step (send_order_to_warehouse) and then progress through the steps as they are completed.
40
+ ```
41
+ $ bundle exec rake
42
+ ```
45
43
 
46
- "start" also returns the effort that was created, and it will look like this:
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
- <Seam::Effort
50
- @completed_steps=[],
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
- So we have a unique instance of this flow and the instance has been saved in the database. The first step to be executed for this instance is "send_order_to_warehouse", so let's create a worker for this step.
52
+ [rake]: https://ruby.github.io/rake/
62
53
 
63
- ####Defining workers for each step####
54
+ ### Source code
64
55
 
65
- A workflow is comprised of steps, and each step needs a worker. Each worker will execute whatever it was meant to do, and then either:
56
+ The [source code] is hosted on GitHub.
57
+ Clone the project with
66
58
 
67
- 1. Pass the workflow instance to the next step on the process, or
68
- 2. Delay the step execution for a later date, or
69
- 3. End the entire workflow process for the instance.
59
+ ```
60
+ $ git clone git@github.com:seamapi/ruby-next.git
61
+ ```
70
62
 
71
- Since send_order_to_warehouse is the first step in this workflow, let's build the worker for it first:
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
- # by default, if this worker completes with no error the workflow instance will be sent to the next step
81
- end
82
- end
83
- ````
67
+ You will need [Ruby] with [Bundler].
84
68
 
85
- If you name your class as a camel-case version of the step, Seam will automatically bind up the worker to the step.
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
- To execute the worker, use:
72
+ ```
73
+ $ rbenv install
74
+ ```
88
75
 
89
- ````
90
- SendOrderToWarehouse.execute_all
91
- ````
76
+ Install the development dependencies with
92
77
 
93
- This method will look for all workflow instances that are currently ready for the step in question.
78
+ ```
79
+ $ bundle install
80
+ ```
94
81
 
95
- ####Progressing through the workflow####
82
+ [bundler]: https://bundler.io/
83
+ [ruby]: https://www.ruby-lang.org/
84
+ [rbenv]: https://github.com/rbenv/rbenv
96
85
 
97
- By default, steps are considered as being completed when the worker completes successfully. There might be times where you don't want to go quickly, like the next step in this example:
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
- "try_again_in" can be used to signal that the step has not been completed and should be retried later.
90
+ #### Automatic
111
91
 
112
- "eject" can also be used to signify that the entire workflow should be stopped, like so:
92
+ New versions are released automatically with [semantic-release]
93
+ as long as commits follow the [Angular Commit Message Conventions].
113
94
 
114
- ````
115
- class WaitForOrderToBeShippedWorker < Seam::Worker
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
- ####History####
98
+ #### Manual
126
99
 
127
- As workflow instances progress through each step, the history of every operation will be stored. A history of the "data" block before and after each step run is also stored.
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
- The history is available through:
103
+ This may be done on the web or using the [GitHub CLI] with
130
104
 
131
- ````
132
- effort.history
133
- ````
105
+ ```
106
+ $ gh workflow run version.yml --raw-field version=<version>
107
+ ```
134
108
 
135
- ####Waiting####
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
- Seam comes with a default worker for waiting. It can be defined by calling "wait" on a flow, like this.
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
- ## Installation
117
+ The following repository secrets must be set on [GitHub Actions]:
147
118
 
148
- Add this line to your application's Gemfile:
119
+ - `RUBYGEMS_API_KEY`: RubyGems.org token for publishing gems.
149
120
 
150
- gem 'seam'
121
+ These must be set manually.
151
122
 
152
- And then execute:
123
+ ### Secrets for Optional GitHub Actions
153
124
 
154
- $ bundle
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
- Or install it yourself as:
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
- $ gem install seam
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
- 1. Fork it
163
- 2. Create your feature branch (`git checkout -b my-new-feature`)
164
- 3. Commit your changes (`git commit -am 'Add some feature'`)
165
- 4. Push to the branch (`git push origin my-new-feature`)
166
- 5. Create new Pull Request
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
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Seam
4
+ class Todo
5
+ def todo
6
+ "TODO"
7
+ end
8
+ end
9
+ end
data/lib/seam/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Seam
2
- VERSION = "1.1.2"
4
+ VERSION = "2.0.0a1"
3
5
  end
data/lib/seam.rb CHANGED
@@ -1,16 +1,8 @@
1
- require 'active_support/all'
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
- module Seam
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