processable 0.0.1 → 1.0.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/.gitignore +2 -1
- data/.rubocop_todo.yml +18 -1
- data/.ruby-version +1 -0
- data/Gemfile.lock +22 -20
- data/README.md +24 -8
- data/lib/processable.rb +25 -6
- data/processable.gemspec +1 -1
- data/processable.idea +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec61896c8cf47fe86e818a6c6aa4a188763603ec6eeaf7fd7cbb6d8331896995
|
|
4
|
+
data.tar.gz: 81fe69af1a31eb0014883fb7c149492dddb103aad7a2a5b7bc40961d506a9452
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c58eeb9c2e4a3c88431a28aff883e90ed340448c4708f6c7ed05a99de80bb0b4932a911e35208997220e87936608eddccdf5135b3d7d7804a21be5615fd38741
|
|
7
|
+
data.tar.gz: 0c57d85af3ed9c69a244be3d7051f948f1145742d67758cf3dd1799faf7a3dedc3f665f05643114fe2b329a44947bc908503996c22cb21a082c7af439e983a6f
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config --auto-gen-only-exclude`
|
|
3
|
-
# on
|
|
3
|
+
# on 2023-10-20 07:00:15 UTC using RuboCop version 0.93.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
Lint/ShadowingOuterLocalVariable:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'lib/processable.rb'
|
|
13
|
+
|
|
14
|
+
# Offense count: 1
|
|
15
|
+
# Configuration parameters: IgnoredMethods, Max.
|
|
16
|
+
Metrics/AbcSize:
|
|
17
|
+
Exclude:
|
|
18
|
+
- 'lib/processable.rb'
|
|
19
|
+
|
|
9
20
|
# Offense count: 1
|
|
10
21
|
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods.
|
|
11
22
|
# ExcludedMethods: refine
|
|
@@ -14,6 +25,12 @@ Metrics/BlockLength:
|
|
|
14
25
|
- '**/*.gemspec'
|
|
15
26
|
- 'spec/processable_spec.rb'
|
|
16
27
|
|
|
28
|
+
# Offense count: 1
|
|
29
|
+
# Configuration parameters: CountComments, Max, CountAsOne, ExcludedMethods.
|
|
30
|
+
Metrics/MethodLength:
|
|
31
|
+
Exclude:
|
|
32
|
+
- 'lib/processable.rb'
|
|
33
|
+
|
|
17
34
|
# Offense count: 2
|
|
18
35
|
Style/ClassVars:
|
|
19
36
|
Exclude:
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.5
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
processable (0.0
|
|
4
|
+
processable (1.0.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -10,26 +10,28 @@ GEM
|
|
|
10
10
|
byebug (11.1.3)
|
|
11
11
|
diff-lcs (1.5.0)
|
|
12
12
|
docile (1.4.0)
|
|
13
|
-
parallel (1.
|
|
14
|
-
parser (3.
|
|
13
|
+
parallel (1.23.0)
|
|
14
|
+
parser (3.2.2.4)
|
|
15
15
|
ast (~> 2.4.1)
|
|
16
|
+
racc
|
|
17
|
+
racc (1.7.1)
|
|
16
18
|
rainbow (3.1.1)
|
|
17
19
|
rake (13.0.6)
|
|
18
|
-
regexp_parser (2.
|
|
19
|
-
rexml (3.2.
|
|
20
|
-
rspec (3.
|
|
21
|
-
rspec-core (~> 3.
|
|
22
|
-
rspec-expectations (~> 3.
|
|
23
|
-
rspec-mocks (~> 3.
|
|
24
|
-
rspec-core (3.
|
|
25
|
-
rspec-support (~> 3.
|
|
26
|
-
rspec-expectations (3.
|
|
20
|
+
regexp_parser (2.8.2)
|
|
21
|
+
rexml (3.2.6)
|
|
22
|
+
rspec (3.12.0)
|
|
23
|
+
rspec-core (~> 3.12.0)
|
|
24
|
+
rspec-expectations (~> 3.12.0)
|
|
25
|
+
rspec-mocks (~> 3.12.0)
|
|
26
|
+
rspec-core (3.12.2)
|
|
27
|
+
rspec-support (~> 3.12.0)
|
|
28
|
+
rspec-expectations (3.12.3)
|
|
27
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
-
rspec-support (~> 3.
|
|
29
|
-
rspec-mocks (3.
|
|
30
|
+
rspec-support (~> 3.12.0)
|
|
31
|
+
rspec-mocks (3.12.6)
|
|
30
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
-
rspec-support (~> 3.
|
|
32
|
-
rspec-support (3.
|
|
33
|
+
rspec-support (~> 3.12.0)
|
|
34
|
+
rspec-support (3.12.1)
|
|
33
35
|
rubocop (0.93.1)
|
|
34
36
|
parallel (~> 1.10)
|
|
35
37
|
parser (>= 2.7.1.5)
|
|
@@ -39,12 +41,12 @@ GEM
|
|
|
39
41
|
rubocop-ast (>= 0.6.0)
|
|
40
42
|
ruby-progressbar (~> 1.7)
|
|
41
43
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
42
|
-
rubocop-ast (1.
|
|
43
|
-
parser (>= 3.
|
|
44
|
+
rubocop-ast (1.29.0)
|
|
45
|
+
parser (>= 3.2.1.0)
|
|
44
46
|
rubocop-rspec (1.44.1)
|
|
45
47
|
rubocop (~> 0.87)
|
|
46
48
|
rubocop-ast (>= 0.7.1)
|
|
47
|
-
ruby-progressbar (1.
|
|
49
|
+
ruby-progressbar (1.13.0)
|
|
48
50
|
simplecov (0.21.2)
|
|
49
51
|
docile (~> 1.1)
|
|
50
52
|
simplecov-html (~> 0.11)
|
|
@@ -66,4 +68,4 @@ DEPENDENCIES
|
|
|
66
68
|
simplecov (~> 0.21.2)
|
|
67
69
|
|
|
68
70
|
BUNDLED WITH
|
|
69
|
-
2.
|
|
71
|
+
2.4.20
|
data/README.md
CHANGED
|
@@ -13,10 +13,12 @@ class PrintGithubRepos < Processable
|
|
|
13
13
|
repos_json.except(:title, :description)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
step :print_to_console do |
|
|
17
|
-
print
|
|
16
|
+
step :print_to_console do |result_from_prev_step, current_step, list_of_steps|
|
|
17
|
+
print result_from_prev_step
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
PrintGithubRepos.new.process
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
## Installation
|
|
@@ -28,13 +30,14 @@ gem 'processable'
|
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
And then execute:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
```shell
|
|
34
|
+
bundle install
|
|
35
|
+
```
|
|
33
36
|
|
|
34
37
|
Or install it yourself as:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
```shell
|
|
39
|
+
gem install processable
|
|
40
|
+
```
|
|
38
41
|
## Usage
|
|
39
42
|
|
|
40
43
|
**Define new class with required behavior**
|
|
@@ -62,7 +65,7 @@ class SiteScrapper < Processable
|
|
|
62
65
|
end
|
|
63
66
|
```
|
|
64
67
|
|
|
65
|
-
**
|
|
68
|
+
**Trigger the process**
|
|
66
69
|
|
|
67
70
|
To start the process simply call...
|
|
68
71
|
|
|
@@ -70,6 +73,19 @@ To start the process simply call...
|
|
|
70
73
|
SiteScrapper.new.process
|
|
71
74
|
```
|
|
72
75
|
|
|
76
|
+
To run the process until some certain step you can pass the name of the step as an argument. Also keep in mind the step defined in run_until will not be executed as well.
|
|
77
|
+
|
|
78
|
+
```ruby
|
|
79
|
+
SiteScrapper.new.process(run_until: :save_to_database)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
To exec only one particular step you can pass the name of the step as an argument.
|
|
83
|
+
|
|
84
|
+
```ruby
|
|
85
|
+
SiteScrapper.new.process(exec_step: :save_to_database)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
|
|
73
89
|
## Development
|
|
74
90
|
|
|
75
91
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/processable.rb
CHANGED
|
@@ -19,7 +19,7 @@ class Processable
|
|
|
19
19
|
# Collections of steps like
|
|
20
20
|
# @type [String]
|
|
21
21
|
@@registered_steps = []
|
|
22
|
-
class
|
|
22
|
+
class StepNotFoundError < StandardError; end
|
|
23
23
|
|
|
24
24
|
class << self
|
|
25
25
|
# Adding new step to the process
|
|
@@ -31,21 +31,40 @@ class Processable
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Run steps in order as they were defined
|
|
34
|
-
def process
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
def process(run_until: nil)
|
|
35
|
+
steps_to_run = if run_until
|
|
36
|
+
run_until_index = @@registered_steps.find_index { |step_hash| step_hash[:name] == run_until }
|
|
37
|
+
raise StepNotFoundError, "Step '#{run_until}' not found" unless run_until_index
|
|
38
|
+
|
|
39
|
+
@@registered_steps[0..run_until_index]
|
|
40
|
+
else
|
|
41
|
+
@@registered_steps
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
steps_to_run.each_with_index do |step, index|
|
|
45
|
+
previous_step = index.zero? ? {} : steps_to_run[index - 1]
|
|
37
46
|
|
|
38
47
|
result = instance_exec(previous_step[:result],
|
|
39
48
|
step,
|
|
40
|
-
|
|
49
|
+
steps_to_run,
|
|
41
50
|
&step[:block])
|
|
42
51
|
|
|
43
52
|
step[:result] = result
|
|
44
53
|
end
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
steps_to_run.last[:result]
|
|
47
56
|
end
|
|
48
57
|
|
|
58
|
+
def exec_step(step_name:, options:)
|
|
59
|
+
step = @@registered_steps.find { |step| step[:name] == step_name }
|
|
60
|
+
|
|
61
|
+
raise StepNotFoundError, "Step '#{step_name}' not found" unless step
|
|
62
|
+
|
|
63
|
+
instance_exec(options, step, @@registered_steps, &step[:block])
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def initialize(*arguments); end
|
|
67
|
+
|
|
49
68
|
private
|
|
50
69
|
|
|
51
70
|
attr_accessor :registered_steps
|
data/processable.gemspec
CHANGED
data/processable.idea
CHANGED
|
@@ -20,6 +20,8 @@ class LocationsUploaderStep < Processable::Step
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# Order of steps as it's been defined
|
|
23
|
+
# Run process until
|
|
24
|
+
# Pass arguments to each step manually for test purpose
|
|
23
25
|
# In the result you will get either result of the last step
|
|
24
26
|
# Print every step (option to disable)
|
|
25
27
|
# How to validate?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: processable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Rukomoynikov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -23,6 +23,7 @@ files:
|
|
|
23
23
|
- ".rspec"
|
|
24
24
|
- ".rubocop.yml"
|
|
25
25
|
- ".rubocop_todo.yml"
|
|
26
|
+
- ".ruby-version"
|
|
26
27
|
- CODE_OF_CONDUCT.md
|
|
27
28
|
- Gemfile
|
|
28
29
|
- Gemfile.lock
|
|
@@ -55,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
56
|
- !ruby/object:Gem::Version
|
|
56
57
|
version: '0'
|
|
57
58
|
requirements: []
|
|
58
|
-
rubygems_version: 3.2.
|
|
59
|
+
rubygems_version: 3.2.33
|
|
59
60
|
signing_key:
|
|
60
61
|
specification_version: 4
|
|
61
62
|
summary: Ruby gem to help you organize any process into series of steps
|