Class: Diddy::Step
- Inherits:
-
Object
- Object
- Diddy::Step
- Defined in:
- lib/diddy/step.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#description ⇒ Object
Returns the value of attribute description.
-
#run_result ⇒ Object
Returns the value of attribute run_result.
-
#steps_instance ⇒ Object
Returns the value of attribute steps_instance.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Step
constructor
Initializes step.
-
#run ⇒ Object
Runs the step.
Constructor Details
#initialize(attrs) ⇒ Step
Initializes step
9 10 11 |
# File 'lib/diddy/step.rb', line 9 def initialize(attrs) attrs.each { |k,v| send("#{k}=", v) } end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
4 5 6 |
# File 'lib/diddy/step.rb', line 4 def context @context end |
#definition ⇒ Object
Returns the value of attribute definition.
4 5 6 |
# File 'lib/diddy/step.rb', line 4 def definition @definition end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/diddy/step.rb', line 4 def description @description end |
#run_result ⇒ Object
Returns the value of attribute run_result.
4 5 6 |
# File 'lib/diddy/step.rb', line 4 def run_result @run_result end |
#steps_instance ⇒ Object
Returns the value of attribute steps_instance.
4 5 6 |
# File 'lib/diddy/step.rb', line 4 def steps_instance @steps_instance end |
Instance Method Details
#run ⇒ Object
Runs the step
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/diddy/step.rb', line 16 def run # set the sub steps to 0 steps_instance.sub_steps = [] # write to screen print(blue(". #{description}")) # and to log run_result.run_step(description) # eval the step steps_instance.current_step = self steps_instance.context = context # run the step itself result = steps_instance.instance_eval(&definition) # check if there were any sub steps # if so, the result is dependent of those substeps if steps_instance.sub_steps.size > 0 # check result of all sub_steps result = steps_instance.sub_steps.all? { |step| step[:valid] } # also log steps_instance.sub_steps.each do |sub_step| run_result.run_sub_step(sub_step[:description]) run_result.set_sub_step_result(sub_step[:valid]) end # faulty print("\n") else print("\r") if result print(green("✓ #{description}")) else print(red(bold("✕ #{description}"))) end end # log result of step run_result.set_step_result(result) # next line print("\n") # return the result result end |