steppy 0.1.0 → 0.5.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/Gemfile.lock +2 -2
- data/lib/steppy.rb +25 -8
- data/lib/steppy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c0018ed2b1fb27c1825a10881930b947c258e5f6d0f456d2c060488da6ce30
|
4
|
+
data.tar.gz: 1e3ce8842b65d6043f46913bdb947a95f0293b6f12e782245ae0a19085e7fda6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab6c8040e0623533702d77bd1d560373bc0e965c5fc20250f00c5bed709482b17ae4dc962d191b9b1774b2318be2c9bc8bc7eb8f6d2cf8f44d27445404da0de4
|
7
|
+
data.tar.gz: cf04255913350e155ef2929d8c352d16692488e6dc1734ca34848ba73b63a8bbcd39a09d3b3b678b30edad5e684d64040caad5e96d91a688e4cd803b98ed43c2
|
data/Gemfile.lock
CHANGED
data/lib/steppy.rb
CHANGED
@@ -13,8 +13,8 @@ module Steppy
|
|
13
13
|
# Steppy class methods that will be added to your included classes.
|
14
14
|
module ClassMethods
|
15
15
|
if !defined? step
|
16
|
-
def step(method, **args)
|
17
|
-
steppy_add step_method: method, step_args: args
|
16
|
+
def step(method, **args, &block)
|
17
|
+
steppy_add step_method: method, step_args: args, step_block: block
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -50,7 +50,8 @@ module Steppy
|
|
50
50
|
|
51
51
|
# Steppy instance methods that will be added.
|
52
52
|
module InstanceMethods
|
53
|
-
def steppy(attributes)
|
53
|
+
def steppy(attributes, prefix: :step)
|
54
|
+
@steppy_prefix = prefix
|
54
55
|
@steppy = { attributes: attributes.freeze }
|
55
56
|
|
56
57
|
steppy_run(
|
@@ -94,18 +95,34 @@ module Steppy
|
|
94
95
|
end
|
95
96
|
end
|
96
97
|
|
97
|
-
def steppy_step(step_method:, step_args:)
|
98
|
-
method_name = "
|
98
|
+
def steppy_step(step_method:, step_args:, step_block:)
|
99
|
+
method_name = "#{@steppy_prefix}_#{step_method}"
|
99
100
|
|
100
101
|
steppy_if(step_args[:if]) && return
|
101
102
|
|
103
|
+
result = if step_block
|
104
|
+
steppy_run_block(step_block, steppy_attributes)
|
105
|
+
else
|
106
|
+
steppy_run_method(method_name, steppy_attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
steppy_set(step_args[:set], result)
|
110
|
+
end
|
111
|
+
|
112
|
+
def steppy_run_method(method_name, steppy_attributes)
|
102
113
|
if method(method_name).arity > 0
|
103
|
-
|
114
|
+
public_send(method_name, steppy_attributes)
|
104
115
|
else
|
105
|
-
|
116
|
+
public_send(method_name)
|
106
117
|
end
|
118
|
+
end
|
107
119
|
|
108
|
-
|
120
|
+
def steppy_run_block(step_block, steppy_attributes)
|
121
|
+
if step_block.arity > 0
|
122
|
+
instance_exec(steppy_attributes, &step_block)
|
123
|
+
else
|
124
|
+
instance_exec(&step_block)
|
125
|
+
end
|
109
126
|
end
|
110
127
|
|
111
128
|
def steppy_if(step_if)
|
data/lib/steppy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: steppy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cj
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|