stairway 0.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 +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +1 -0
- data/lib/stairway/version.rb +3 -0
- data/lib/stairway.rb +5 -0
- data/stairway.gemspec +23 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 991f7c1a984f7ba0288ce5f67c93cc96714aeb4f
|
4
|
+
data.tar.gz: 7635b04e3800dc5314a02055bdaa515ab46d4eac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0bab126c567ecdb508b0822090285f6c5777ce2ef8ae6c571eeddc14e8661a5e3b188507ac98152df8d316c8f2dd4c1531ccddacfc25a3a182260c1c73081515
|
7
|
+
data.tar.gz: 39f2697bb8b338e1d757901e03009bd3cf18f7995d62f2f185dc1425a38e606617aef05ea6b2a32e04916b0a803f7c7908a51ac0ee341480ff07b9848bc5d204
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Samuel Garneau
|
2
|
+
|
3
|
+
MIT License
|
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:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# Stairway
|
2
|
+
Easy and intuitive step by step processing of your business logic.
|
3
|
+
|
4
|
+
---
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```
|
11
|
+
gem 'stairway'
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
First, create a new *initializer* to define the different steps of your Stairway:
|
17
|
+
|
18
|
+
```
|
19
|
+
# config/initializers/stairways.rb
|
20
|
+
|
21
|
+
import = Stairway.new(:import)
|
22
|
+
import.steps = {
|
23
|
+
download: ImportSchedule::Download.new,
|
24
|
+
unzip: ImportSchedule::Unzip.new,
|
25
|
+
convert_sql: ImportSchedule::ConvertToSQL.new,
|
26
|
+
import: ImportSchedule::Import.new
|
27
|
+
clean: ImportSchedule::Cleanup.new
|
28
|
+
}
|
29
|
+
|
30
|
+
Stairway.register(import)
|
31
|
+
```
|
32
|
+
|
33
|
+
Now, you can run the logic from anywhere in your application using:
|
34
|
+
|
35
|
+
```
|
36
|
+
Stairway.mount(:import).run(options)
|
37
|
+
```
|
38
|
+
|
39
|
+
## Define your steps
|
40
|
+
|
41
|
+
In the above section, you can see a `DownloadContent` class being intanciated. All your step should at least, respond to the `run` method. This method will be automatically called.
|
42
|
+
|
43
|
+
```
|
44
|
+
class DownloadContent
|
45
|
+
|
46
|
+
def run(context, options)
|
47
|
+
…do stuff here…
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
## Break the flow
|
54
|
+
|
55
|
+
At any time, if you want to stop the processing for whatever reason, you can do this:
|
56
|
+
|
57
|
+
```
|
58
|
+
class DownloadContent
|
59
|
+
|
60
|
+
def run(context, options)
|
61
|
+
begin
|
62
|
+
…download your content…
|
63
|
+
rescue DownloadError
|
64
|
+
Stairway.stop
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
## Run a single step
|
72
|
+
|
73
|
+
Sometime, I guess, you'll want to run a single step.
|
74
|
+
|
75
|
+
```
|
76
|
+
Stairway.mount(:import).run_step(:download, context, options)
|
77
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/stairway.rb
ADDED
data/stairway.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'stairway/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stairway"
|
8
|
+
spec.version = Stairway::VERSION
|
9
|
+
spec.authors = ["Samuel Garneau"]
|
10
|
+
spec.email = ["samgarneau@gmail.com"]
|
11
|
+
spec.description = %q{Easy and intuitive step by step processing of your business logic.}
|
12
|
+
spec.summary = %q{Easy and intuitive step by step processing of your business logic.}
|
13
|
+
spec.homepage = "https://github.com/garno/stairway"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stairway
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Garneau
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Easy and intuitive step by step processing of your business logic.
|
42
|
+
email:
|
43
|
+
- samgarneau@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.txt
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/stairway.rb
|
53
|
+
- lib/stairway/version.rb
|
54
|
+
- stairway.gemspec
|
55
|
+
homepage: https://github.com/garno/stairway
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.0.0
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Easy and intuitive step by step processing of your business logic.
|
79
|
+
test_files: []
|