simple_service 2.1.5 → 2.1.6
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/build_master.yml +41 -0
- data/README.md +22 -24
- data/lib/simple_service/version.rb +1 -1
- data/simple_service.gemspec +9 -2
- metadata +11 -23
- data/.github/workflows/gem-push.yml +0 -45
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 407aa35e8ec13960f5cc0509d5e1152b5f94fed9bf7d035aa20e759b27e4de80
|
|
4
|
+
data.tar.gz: 9fbaaf4c5afbf37dd68814032312e3a1d8b98e0a1f5d511c111c2679f881296e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4f17ce95877a995c8b0b48a12b57c1147360115bd1b94b365c30a8a618bfa591197d66f107594923cf71cd81ec80e38b6101be28a93967bf6b3b96adfe69927
|
|
7
|
+
data.tar.gz: 61e3058fe33d2294255fa1933901146f417199c45b83fdb428d6d7c835df78d2e222b25cce2862025b1dcd1b5ececf698abb885adb2c70ca4e0411c76b89c0f8
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
name: Build Master
|
|
2
|
+
|
|
3
|
+
env:
|
|
4
|
+
CC_TEST_REPORTER_URL: https://codeclimate.com/downloads/test-reporter/test-reporter-0.7.0-linux-amd64
|
|
5
|
+
CC_TEST_REPORTER_ID: ${{ secrets.SIMPLE_SERVICE_CODECLIMATE_ID }}
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
|
|
10
|
+
push:
|
|
11
|
+
branches:
|
|
12
|
+
- master
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
os: [ubuntu-latest]
|
|
19
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
|
20
|
+
ruby: ["2.7.0", "3.2.2"]
|
|
21
|
+
runs-on: ${{ matrix.os }}
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v3
|
|
24
|
+
- uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
|
27
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: |
|
|
31
|
+
gem install bundler -v 2.4.14
|
|
32
|
+
bundle install --jobs 3 --retry 3
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: RUBYOPT="-E UTF-8" bundle exec rake
|
|
36
|
+
|
|
37
|
+
- name: Code Climate Test Reporter
|
|
38
|
+
uses: aktions/codeclimate-test-reporter@v1
|
|
39
|
+
with:
|
|
40
|
+
codeclimate-test-reporter-id: ${{ secrets.SIMPLE_SERVICE_CODECLIMATE_ID }}
|
|
41
|
+
command: after-build
|
data/README.md
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# SimpleService
|
|
2
2
|
|
|
3
3
|
[](http://badge.fury.io/rb/simple_service)
|
|
4
|
-
[](https://travis-ci.org/jspillers/simple_service)
|
|
7
|
-
<!---->
|
|
4
|
+
[](https://codeclimate.com/github/jspillers/simple_service/maintainability)
|
|
5
|
+
[](https://codeclimate.com/github/jspillers/simple_service/test_coverage)
|
|
8
6
|
|
|
9
7
|
SimpleService facilitates the creation of Ruby service objects into highly discreet, reusable,
|
|
10
|
-
and composable units of business logic. The core concept of SimpleService is the definition of
|
|
11
|
-
"Command" objects/methods. Commands are very small classes or methods that perform exactly one task.
|
|
8
|
+
and composable units of business logic. The core concept of SimpleService is the definition of
|
|
9
|
+
"Command" objects/methods. Commands are very small classes or methods that perform exactly one task.
|
|
12
10
|
When properly designed, these command objects can be composited together or even nested to create
|
|
13
11
|
complex flows.
|
|
14
12
|
|
|
15
13
|
# 2.0.0 update notes
|
|
16
14
|
|
|
17
|
-
This update is a major refactor from previous 1.x.x versions. After revisiting this codebase I decided that
|
|
15
|
+
This update is a major refactor from previous 1.x.x versions. After revisiting this codebase I decided that
|
|
18
16
|
I needed to make SimpleService actually simple in both use and implementation. The gem has now been paired down
|
|
19
17
|
to about 150 lines of code.
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
- All functionality is added to your service class via module inclusion instead of inheritance
|
|
20
|
+
- The concept of an Organizer has been removed
|
|
21
|
+
- The DSL for defining interfaces has been removed in favor of simple keyword arguments
|
|
22
|
+
- `#success` or `#failure` must be called within each command or call method
|
|
23
|
+
- Services are always invoked via the class method `.call`. Previously you could use either `#call` or `.call`.
|
|
26
24
|
|
|
27
25
|
## Installation
|
|
28
26
|
|
|
@@ -40,10 +38,10 @@ Or install it yourself as:
|
|
|
40
38
|
|
|
41
39
|
# Setup and Basic Usage:
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
- load the gem
|
|
42
|
+
- include the SimpleService module into your service object class
|
|
43
|
+
- define one or more comamnds that it will perform, must accept either keyword arguments or a hash argument
|
|
44
|
+
- call `#success` or `#failure` with any values you wish to pass along to the next command (or wish to return if it is the last command)
|
|
47
45
|
|
|
48
46
|
```ruby
|
|
49
47
|
require 'rubygems'
|
|
@@ -100,7 +98,7 @@ You can also use ClassNames as commands and to organize them into other files. I
|
|
|
100
98
|
defined and no other commands are defined via `command` or `commands` then SimpleService will
|
|
101
99
|
automatically use `#call` as the default command
|
|
102
100
|
|
|
103
|
-
```ruby
|
|
101
|
+
```ruby
|
|
104
102
|
require 'rubygems'
|
|
105
103
|
require 'simple_service'
|
|
106
104
|
|
|
@@ -144,7 +142,7 @@ result.value #=> {something: 'went wrong'}
|
|
|
144
142
|
```
|
|
145
143
|
|
|
146
144
|
If you would like your service to process an enumerable you can override `.call`
|
|
147
|
-
on your service object. Invoking `#super` in your definition and passing along
|
|
145
|
+
on your service object. Invoking `#super` in your definition and passing along
|
|
148
146
|
the appropriate arguments will allow your command chain to proceed as normal, but
|
|
149
147
|
called multiple times via a loop. The Result object returned from each call to `#super`
|
|
150
148
|
can be passed in as an argument to the next iteration or you can collect the result objects
|
|
@@ -162,11 +160,11 @@ class LoopingService
|
|
|
162
160
|
def self.call(count:)
|
|
163
161
|
count = kwargs
|
|
164
162
|
|
|
165
|
-
# In this example the result object from super overwrites
|
|
166
|
-
# the previous result/initial args. You could also capture
|
|
163
|
+
# In this example the result object from super overwrites
|
|
164
|
+
# the previous result/initial args. You could also capture
|
|
167
165
|
# results in an array or hash for further manipulation.
|
|
168
166
|
# If you do not need to do anything with the result object
|
|
169
|
-
# then there is no need to assign it back to anything.
|
|
167
|
+
# then there is no need to assign it back to anything.
|
|
170
168
|
3.times do
|
|
171
169
|
count = super(count)
|
|
172
170
|
end
|
|
@@ -179,13 +177,13 @@ class LoopingService
|
|
|
179
177
|
end
|
|
180
178
|
end
|
|
181
179
|
|
|
182
|
-
result = LoopingService.call(count: 0)
|
|
180
|
+
result = LoopingService.call(count: 0)
|
|
183
181
|
result.is_a?(SimpleService::Result) #=> true
|
|
184
182
|
result.value #=> {count: 3}
|
|
185
183
|
```
|
|
186
184
|
|
|
187
|
-
If you are using this with a Rails app, placing top level services in
|
|
188
|
-
`app/services/` and all nested commands in `app/services/commands/` is
|
|
185
|
+
If you are using this with a Rails app, placing top level services in
|
|
186
|
+
`app/services/` and all nested commands in `app/services/commands/` is
|
|
189
187
|
recommended. Even if not using rails, a similar structure also works well.
|
|
190
188
|
|
|
191
189
|
## Contributing
|
data/simple_service.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.version = SimpleService::VERSION
|
|
9
9
|
spec.authors = ['Jarrod Spillers']
|
|
10
10
|
spec.email = ['jarrod@stacktact.com']
|
|
11
|
-
spec.description = %q{A minimal service object composer
|
|
11
|
+
spec.description = %q{A minimal service object composer and orchestrator}
|
|
12
12
|
spec.summary = spec.description
|
|
13
13
|
spec.homepage = 'https://github.com/jspillers/simple_service'
|
|
14
14
|
spec.license = 'MIT'
|
|
@@ -18,10 +18,17 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
20
|
|
|
21
|
+
spec.metadata = {
|
|
22
|
+
"bug_tracker_uri" => "#{spec.homepage}/issues",
|
|
23
|
+
"changelog_uri" => "#{spec.homepage}/blob/main/CHANGELOG.md",
|
|
24
|
+
"documentation_uri" => spec.homepage.to_s,
|
|
25
|
+
"homepage_uri" => spec.homepage.to_s,
|
|
26
|
+
"source_code_uri" => spec.homepage.to_s,
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
spec.add_development_dependency 'bundler'
|
|
22
30
|
spec.add_development_dependency 'rake', '~> 12.3.3'
|
|
23
31
|
spec.add_development_dependency 'rspec', '~> 3.12.0'
|
|
24
32
|
spec.add_development_dependency 'pry', '~> 0.14.2'
|
|
25
33
|
spec.add_development_dependency 'simplecov'
|
|
26
|
-
spec.add_development_dependency 'codeclimate-test-reporter'
|
|
27
34
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_service
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jarrod Spillers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-08-
|
|
11
|
+
date: 2023-08-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -80,32 +80,16 @@ dependencies:
|
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
82
|
version: '0'
|
|
83
|
-
|
|
84
|
-
name: codeclimate-test-reporter
|
|
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: A minimal service object composer with support for individual commands
|
|
98
|
-
and top level organizer objects
|
|
83
|
+
description: A minimal service object composer and orchestrator
|
|
99
84
|
email:
|
|
100
85
|
- jarrod@stacktact.com
|
|
101
86
|
executables: []
|
|
102
87
|
extensions: []
|
|
103
88
|
extra_rdoc_files: []
|
|
104
89
|
files:
|
|
105
|
-
- ".github/workflows/
|
|
90
|
+
- ".github/workflows/build_master.yml"
|
|
106
91
|
- ".gitignore"
|
|
107
92
|
- ".rspec"
|
|
108
|
-
- ".travis.yml"
|
|
109
93
|
- Gemfile
|
|
110
94
|
- LICENSE
|
|
111
95
|
- LICENSE.txt
|
|
@@ -128,7 +112,12 @@ files:
|
|
|
128
112
|
homepage: https://github.com/jspillers/simple_service
|
|
129
113
|
licenses:
|
|
130
114
|
- MIT
|
|
131
|
-
metadata:
|
|
115
|
+
metadata:
|
|
116
|
+
bug_tracker_uri: https://github.com/jspillers/simple_service/issues
|
|
117
|
+
changelog_uri: https://github.com/jspillers/simple_service/blob/main/CHANGELOG.md
|
|
118
|
+
documentation_uri: https://github.com/jspillers/simple_service
|
|
119
|
+
homepage_uri: https://github.com/jspillers/simple_service
|
|
120
|
+
source_code_uri: https://github.com/jspillers/simple_service
|
|
132
121
|
post_install_message:
|
|
133
122
|
rdoc_options: []
|
|
134
123
|
require_paths:
|
|
@@ -147,8 +136,7 @@ requirements: []
|
|
|
147
136
|
rubygems_version: 3.4.10
|
|
148
137
|
signing_key:
|
|
149
138
|
specification_version: 4
|
|
150
|
-
summary: A minimal service object composer
|
|
151
|
-
top level organizer objects
|
|
139
|
+
summary: A minimal service object composer and orchestrator
|
|
152
140
|
test_files:
|
|
153
141
|
- spec/simple_service_spec.rb
|
|
154
142
|
- spec/spec_helper.rb
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
name: Ruby Gem
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "master" ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ "master" ]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
build:
|
|
11
|
-
name: Build + Publish
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
permissions:
|
|
14
|
-
contents: read
|
|
15
|
-
packages: write
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- uses: actions/checkout@v3
|
|
19
|
-
- name: Set up Ruby 2.6
|
|
20
|
-
uses: actions/setup-ruby@v1
|
|
21
|
-
with:
|
|
22
|
-
ruby-version: 2.6.x
|
|
23
|
-
|
|
24
|
-
- name: Publish to GPR
|
|
25
|
-
run: |
|
|
26
|
-
mkdir -p $HOME/.gem
|
|
27
|
-
touch $HOME/.gem/credentials
|
|
28
|
-
chmod 0600 $HOME/.gem/credentials
|
|
29
|
-
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
30
|
-
gem build *.gemspec
|
|
31
|
-
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
|
32
|
-
env:
|
|
33
|
-
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
|
34
|
-
OWNER: ${{ github.repository_owner }}
|
|
35
|
-
|
|
36
|
-
- name: Publish to RubyGems
|
|
37
|
-
run: |
|
|
38
|
-
mkdir -p $HOME/.gem
|
|
39
|
-
touch $HOME/.gem/credentials
|
|
40
|
-
chmod 0600 $HOME/.gem/credentials
|
|
41
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
42
|
-
gem build *.gemspec
|
|
43
|
-
gem push *.gem
|
|
44
|
-
env:
|
|
45
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|