diddy 0.8.0 → 0.9.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.
data/diddy.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "diddy"
7
- gem.version = '0.8.0'
7
+ gem.version = '0.9.0'
8
8
  gem.authors = ["Diederick Lawson", "Marcel de Graaf"]
9
9
  gem.email = ["diederick@altovista.nl", "mail@marceldegraaf.net"]
10
10
  gem.description = %q{Diddy script runner}
data/lib/diddy/context.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  module Diddy
2
2
  class Context
3
- attr_accessor :options
3
+ def initialize(vars)
4
+ @vars = vars
5
+ end
4
6
 
5
- def initialize(options)
6
- self.options = options
7
+ def [](key)
8
+ @vars[key.to_sym]
7
9
  end
8
10
  end
9
11
  end
@@ -2,6 +2,10 @@ module Diddy
2
2
  class RunResult
3
3
  attr_accessor :scripts
4
4
 
5
+ def result
6
+ scripts.all? { |script| script.result }
7
+ end
8
+
5
9
  #
6
10
  # Starts the run of a script. Call this before running a scenario.
7
11
  #
@@ -0,0 +1,28 @@
1
+ module Diddy
2
+ class RunResultMailer
3
+ attr_accessor :run_result
4
+
5
+ def initialize(run_result)
6
+ self.run_result = run_result
7
+ end
8
+
9
+ #
10
+ #
11
+ #
12
+ def mail(from, to)
13
+ mail_text = RunResultPrinter.new(run_result).to_html
14
+ result = run_result.result ? 'succes' : 'failure'
15
+
16
+ Mail.deliver do
17
+ to to
18
+ from from
19
+ subject "[Diddy] Run complete: #{result}"
20
+
21
+ html_part do
22
+ content_type 'text/html; charset=UTF-8'
23
+ body mail_text
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -65,6 +65,8 @@ module Diddy
65
65
  # run proc on this instance as scope
66
66
  begin
67
67
  step.run_result = run_result
68
+ step.context = context
69
+
68
70
  result = step.run
69
71
 
70
72
  rescue Exception => exception
data/lib/diddy/script.rb CHANGED
@@ -51,6 +51,7 @@ module Diddy
51
51
 
52
52
  # run all the steps within the scenario
53
53
  scenario.run_result = run_result
54
+ scenario.context = context
54
55
  scenario.run
55
56
 
56
57
  puts("\n")
@@ -1,17 +1,13 @@
1
1
  module Diddy
2
2
  class SharedScope
3
- def method_missing(method, *args)
4
- if method =~ /=$/
5
- vars[method.to_s[0..-2]] = args.first
6
- elsif args.size == 0
7
- vars[method.to_s]
8
- end
3
+ def [](key)
4
+ @vars ||= {}
5
+ @vars[key.to_sym]
9
6
  end
10
7
 
11
- private
12
-
13
- def vars
8
+ def []=(key, value)
14
9
  @vars ||= {}
10
+ @vars[key.to_sym] = value
15
11
  end
16
12
  end
17
13
  end
data/lib/diddy/step.rb CHANGED
@@ -1,12 +1,7 @@
1
1
  # encoding: utf-8
2
2
  module Diddy
3
3
  class Step
4
- STATE_OK = 1
5
- STATE_FAILED = 2
6
- STATE_EXCEPTION = 3
7
- STATE_PENDING = 4
8
-
9
- attr_accessor :description, :definition, :steps_instance, :run_result
4
+ attr_accessor :description, :definition, :steps_instance, :run_result, :context
10
5
 
11
6
  #
12
7
  # Initializes step
@@ -30,6 +25,7 @@ module Diddy
30
25
 
31
26
  # eval the step
32
27
  steps_instance.current_step = self
28
+ steps_instance.context = context
33
29
 
34
30
  # run the step itself
35
31
  result = steps_instance.instance_eval(&definition)
data/lib/diddy/steps.rb CHANGED
@@ -3,7 +3,7 @@ module Diddy
3
3
  class Steps
4
4
  include Helpers
5
5
 
6
- attr_accessor :sub_steps, :current_step
6
+ attr_accessor :sub_steps, :current_step, :context
7
7
 
8
8
  def initialize(shared_scope)
9
9
  @shared_scope = shared_scope
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -46,6 +46,7 @@ files:
46
46
  - lib/diddy/context.rb
47
47
  - lib/diddy/helpers.rb
48
48
  - lib/diddy/run_result.rb
49
+ - lib/diddy/run_result_mailer.rb
49
50
  - lib/diddy/run_result_printer.rb
50
51
  - lib/diddy/scenario.rb
51
52
  - lib/diddy/script.rb