quickstep 0.1.0 → 0.2.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/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/lib/quickstep/result.rb +53 -0
- data/lib/quickstep/version.rb +5 -0
- data/lib/quickstep.rb +37 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 346e59b0747f25796c6903ce007daf080a63e88ed9f19897fb9ef61f12e4dbcc
|
4
|
+
data.tar.gz: c3ba62ba1c119ca5b534482d2cd0c106c7161dbcdc3940026897862a1699a43b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c78591ee480a7835663e2ca8c136c48cc566df56937dfe34c40067b50799eccb1808de158b741653083dc2e498991f74107559fb08f26acea0c03f5c00bf891
|
7
|
+
data.tar.gz: 42a6abae6b2d76ebee7dbe7644270220d1864ef8df2d76f0f3ee72bcfe35d9c4a6379b9a903f52818f264bbf7c47b3601181bd23f17781227872086598303cbc
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Igor Korepanov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
[](https://badge.fury.io/rb/quickstep)
|
2
|
+

|
3
|
+
|
4
|
+
# Quickstep
|
5
|
+
|
6
|
+
Quickstep is a lightweight business operation tool inspired by [dry-operation](https://github.com/dry-rb/dry-operation). It provides a structured way to execute multi-step operations with built-in success and failure handling.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'quickstep'
|
14
|
+
```
|
15
|
+
|
16
|
+
Or install it manually:
|
17
|
+
|
18
|
+
```sh
|
19
|
+
gem install quickstep
|
20
|
+
```
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### Defining an Operation
|
25
|
+
|
26
|
+
Operations in Quickstep are composed of sequential steps. Each step returns either a `Success` or a `Failure`. If any step fails, the operation halts immediately.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'quickstep'
|
30
|
+
|
31
|
+
class MyOperation
|
32
|
+
include Quickstep
|
33
|
+
|
34
|
+
def call(input)
|
35
|
+
step validate(input)
|
36
|
+
step process(input)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def validate(input)
|
42
|
+
input[:valid] ? Success(input) : Failure(:invalid_input)
|
43
|
+
end
|
44
|
+
|
45
|
+
def process(input)
|
46
|
+
Success(result: input[:value] * 2)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
result = MyOperation.new.call(valid: true, value: 5)
|
51
|
+
# or
|
52
|
+
# result = MyOperation.call(valid: true, value: 5)
|
53
|
+
|
54
|
+
if result.success?
|
55
|
+
puts "Success: #{result.value}"
|
56
|
+
else
|
57
|
+
puts "Failure: #{result.value}"
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
Quickstep is available under the MIT License.
|
64
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Quickstep
|
4
|
+
module Result
|
5
|
+
class Success
|
6
|
+
attr_reader :value
|
7
|
+
|
8
|
+
def initialize(value)
|
9
|
+
@value = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def success?
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
def failure?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def inspect
|
21
|
+
"Success(#{value.inspect})"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Failure
|
26
|
+
attr_reader :value
|
27
|
+
|
28
|
+
def initialize(value)
|
29
|
+
@value = value
|
30
|
+
end
|
31
|
+
|
32
|
+
def success?
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def failure?
|
37
|
+
true
|
38
|
+
end
|
39
|
+
|
40
|
+
def inspect
|
41
|
+
"Failure(#{value.inspect})"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def Success(value)
|
46
|
+
Success.new(value)
|
47
|
+
end
|
48
|
+
|
49
|
+
def Failure(value)
|
50
|
+
Failure.new(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/quickstep.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'quickstep/version'
|
4
|
+
require_relative 'quickstep/result'
|
5
|
+
|
6
|
+
module Quickstep
|
7
|
+
include Quickstep::Result
|
8
|
+
|
9
|
+
def self.included(base)
|
10
|
+
base.extend(ClassMethods)
|
11
|
+
base.prepend(InstanceMethods)
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def call(*args)
|
16
|
+
catch :halt do
|
17
|
+
new.call(*args)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module InstanceMethods
|
23
|
+
def call(*args)
|
24
|
+
catch :halt do
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def step(result)
|
31
|
+
if result.success?
|
32
|
+
result
|
33
|
+
else
|
34
|
+
throw :halt, result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,22 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quickstep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Korepanov
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-05-07 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
|
-
description:
|
13
|
-
|
12
|
+
description: |2
|
13
|
+
Quickstep provides a structured way to execute multi-step business operations with built-in success and
|
14
|
+
failure handling.
|
14
15
|
email:
|
15
16
|
- korepanovigor87@gmail.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
|
-
files:
|
20
|
+
files:
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.md
|
23
|
+
- lib/quickstep.rb
|
24
|
+
- lib/quickstep/result.rb
|
25
|
+
- lib/quickstep/version.rb
|
20
26
|
homepage: https://github.com/igorkorepanov/quickstep
|
21
27
|
licenses:
|
22
28
|
- MIT
|
@@ -38,5 +44,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
44
|
requirements: []
|
39
45
|
rubygems_version: 3.6.2
|
40
46
|
specification_version: 4
|
41
|
-
summary: A lightweight
|
47
|
+
summary: A lightweight business operation tool.
|
42
48
|
test_files: []
|