rung 0.0.1.pre.alpha → 0.1
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/.circleci/config.yml +72 -0
- data/.config/cucumber.yml +1 -0
- data/.gitignore +3 -0
- data/.rspec +0 -1
- data/.rubocop.yml +22 -0
- data/Gemfile +6 -2
- data/Gemfile.lock +23 -1
- data/README.adoc +111 -0
- data/Rakefile +19 -4
- data/features/{steps_definition.feature → 010_operation.feature} +29 -6
- data/features/{state.feature → 020_state.feature} +17 -4
- data/features/{failure.feature → 030_failure.feature} +29 -6
- data/features/040_failure_step.feature +118 -0
- data/features/050_other_steps.feature +135 -0
- data/features/051_fail_fast.feature +66 -0
- data/features/060_step_wrappers.feature +170 -0
- data/features/070_operation_wrappers.feature +41 -0
- data/features/080_exceptions_handling.feature +57 -0
- data/features/090_around_step_wrapper.feature +130 -0
- data/features/200_misc.feature +18 -0
- data/features/step_definitions/output.rb +8 -3
- data/features/step_definitions/temporary_code_scope.rb +8 -7
- data/lib/rung.rb +7 -6
- data/lib/rung/definition/callback.rb +14 -0
- data/lib/rung/definition/nested_step.rb +16 -0
- data/lib/rung/definition/operation_dsl.rb +31 -0
- data/lib/rung/definition/step.rb +43 -0
- data/lib/rung/definition/steps_dsl.rb +33 -18
- data/lib/rung/{base.rb → operation.rb} +3 -2
- data/lib/rung/runner/call_helper.rb +30 -12
- data/lib/rung/runner/run_context.rb +23 -6
- data/lib/rung/runner/runner.rb +34 -14
- data/lib/rung/state.rb +35 -0
- data/lib/rung/value_object.rb +12 -0
- data/lib/rung/version.rb +1 -1
- data/rung.gemspec +15 -16
- data/target/cukedoctor-intro.adoc +1 -0
- data/target/cukedoctor.css +3 -0
- metadata +39 -23
- data/README.md +0 -79
- data/lib/rung/definition/steps/nested_step.rb +0 -20
- data/lib/rung/definition/steps/step.rb +0 -30
- data/lib/rung/definition/steps_definition.rb +0 -13
- data/lib/rung/runner/result.rb +0 -24
- data/lib/rung/runner/run_state.rb +0 -12
data/README.md
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
# Rung
|
2
|
-
|
3
|
-
Rung is service object/business operation/Railway DSL, inspired by [Trailblazer Operation](http://trailblazer.to/gems/operation).
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'rung'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install rung
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
Example:
|
24
|
-
```ruby
|
25
|
-
class CreateOrder < Rung::Base
|
26
|
-
step do |state|
|
27
|
-
state[:order_id] = "order-#{SecureRandom.uuid }"
|
28
|
-
end
|
29
|
-
step ValidateMagazineState
|
30
|
-
step :log_start
|
31
|
-
|
32
|
-
wrap WithBenchmark do
|
33
|
-
step CreateTemporaryOrder
|
34
|
-
step :place_order
|
35
|
-
end
|
36
|
-
|
37
|
-
step :log_success
|
38
|
-
failure :log_failure
|
39
|
-
|
40
|
-
def log_start(state)
|
41
|
-
state[:logger].log("Creating order #{state[:order_id]}")
|
42
|
-
end
|
43
|
-
|
44
|
-
def log_success(state)
|
45
|
-
state[:logger].log("Order #{state[:order_id]} created successfully")
|
46
|
-
end
|
47
|
-
|
48
|
-
def log_failure(state)
|
49
|
-
state[:logger].log("Order #{state[:order_id]} not created")
|
50
|
-
end
|
51
|
-
|
52
|
-
def place_order(state)
|
53
|
-
status = OrdersRepository.create(state[:order_id])
|
54
|
-
|
55
|
-
# Step return value is important.
|
56
|
-
# If step returns falsy value then the operation is considered as a failure.
|
57
|
-
status == :success
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
result = CreateOrder.call(logger: Rails.logger)
|
62
|
-
if result.success?
|
63
|
-
print "Created order #{result[:order_id]}"
|
64
|
-
end
|
65
|
-
```
|
66
|
-
|
67
|
-
## Development
|
68
|
-
|
69
|
-
After checking out the repo, run `bundle` to install dependencies. Then, run `rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
70
|
-
|
71
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
72
|
-
|
73
|
-
## Contributing
|
74
|
-
|
75
|
-
Bug reports and pull requests are welcome on GitHub.
|
76
|
-
|
77
|
-
## License
|
78
|
-
|
79
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Rung
|
2
|
-
module Definition
|
3
|
-
class NestedStep
|
4
|
-
def initialize(operation, nested_steps)
|
5
|
-
@operation = operation
|
6
|
-
@nested_steps = nested_steps
|
7
|
-
end
|
8
|
-
|
9
|
-
attr_reader :operation, :nested_steps
|
10
|
-
|
11
|
-
def run?(_success)
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
def nested?
|
16
|
-
true
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module Rung
|
2
|
-
module Definition
|
3
|
-
class Step
|
4
|
-
def initialize(operation, from_block: false, run_on: :success)
|
5
|
-
@operation = operation
|
6
|
-
@from_block = from_block if from_block
|
7
|
-
@run_on = run_on
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_reader :operation, :from_block
|
11
|
-
|
12
|
-
def run?(success)
|
13
|
-
case @run_on
|
14
|
-
when :success
|
15
|
-
success
|
16
|
-
when :failure
|
17
|
-
!success
|
18
|
-
when :any
|
19
|
-
true
|
20
|
-
else
|
21
|
-
false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def nested?
|
26
|
-
false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/rung/runner/result.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module Rung
|
2
|
-
module Runner
|
3
|
-
class Result
|
4
|
-
def initialize(success, state)
|
5
|
-
@success = success
|
6
|
-
@state = state
|
7
|
-
end
|
8
|
-
|
9
|
-
def success?
|
10
|
-
!!@success
|
11
|
-
end
|
12
|
-
|
13
|
-
def failure?
|
14
|
-
!success?
|
15
|
-
end
|
16
|
-
|
17
|
-
def [](key)
|
18
|
-
state[key]
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :state
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|