henry-container 0.0.28 → 0.0.35

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/.gitignore CHANGED
@@ -3,3 +3,5 @@ vendor
3
3
  bundle
4
4
  .bundle
5
5
  *.gem
6
+ doc/
7
+ .yardoc
@@ -3,7 +3,7 @@ module Henry
3
3
  class Container
4
4
 
5
5
  # Current Gem version
6
- VERSION = '0.0.28'
6
+ VERSION = '0.0.35'
7
7
 
8
8
  end
9
9
 
@@ -11,7 +11,9 @@ module Henry
11
11
  # Henry Container
12
12
  class Container
13
13
 
14
- # Nothing to be done here yet...
14
+ # Initialize the Container with the given options
15
+ #
16
+ # @param [Hash] the execution given options.
15
17
  def initialize(opts)
16
18
  @opts = opts
17
19
  end
@@ -20,8 +22,10 @@ module Henry
20
22
  def execute
21
23
  self.before_execution
22
24
 
23
- self.tasks.each do |task|
24
- self.tasks_results << task.execute(self.task_params(task.name)) if task.enabled?
25
+ self.tasks.select {|task| task.enabled?}.each do |task|
26
+ task.configure(self.task_params(task.name))
27
+ task.execute
28
+ self.tasks_results << task.report
25
29
  end
26
30
 
27
31
  self.update_results
@@ -0,0 +1,16 @@
1
+ require 'henry/input'
2
+
3
+ module Henry
4
+
5
+ # Henry Environmet.
6
+ # To be used as proxy to access the Task execution params from the tests
7
+ class Environment
8
+
9
+ # Imports and returs the Task execution parameters.
10
+ #
11
+ # @return [Hash] the Task execution parameters
12
+ def self.params
13
+ @@params ||= Input.import!.params
14
+ end
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ module Henry
2
+
3
+ # Henry Execution
4
+ class Execution
5
+
6
+ # Accessors for task_name, code, message, output and backtrace.
7
+ attr_accessor :task_name, :code, :message, :output, :backtrace
8
+
9
+ # Returns the json ready hash report of the Task Execution
10
+ #
11
+ # @return [Hash]
12
+ def report
13
+ {
14
+ name: self.task_name,
15
+ code: self.code,
16
+ message: self.message,
17
+ returnedData: {
18
+ output: self.output,
19
+ backtrace: self.backtrace
20
+ }
21
+ }
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,49 @@
1
+ module Henry
2
+
3
+ # Henry Input
4
+ class Input
5
+ attr_reader :params
6
+
7
+ # ENV key where the Input will be exported to/imported from.
8
+ EXPORT_KEY = 'HENRY_INPUT'
9
+
10
+ # Initialize the Input with the given params or empty.
11
+ #
12
+ # @param params [Hash] the Input params.
13
+ def initialize(params={})
14
+ @params = params
15
+ end
16
+
17
+ # Initialize and export the Input to the target ENV namespace.
18
+ #
19
+ # @param params [Hash] the Input params to be exported.
20
+ # @return [Input]
21
+ def self.export!(params)
22
+ self.new(params).export!
23
+ end
24
+
25
+ # Exports the Input to the target ENV namespace.
26
+ #
27
+ # @return [Input]
28
+ def export!
29
+ ENV[EXPORT_KEY] = JSON.dump(@params)
30
+ self
31
+ end
32
+
33
+ # Initialize and import the Input from the target ENV namespece.
34
+ #
35
+ # @return [Input]
36
+ def self.import!
37
+ self.new.import!
38
+ end
39
+
40
+ # Imports the Input from the target ENV namespace.
41
+ #
42
+ # @return [Input]
43
+ def import!
44
+ @params = JSON.parse(ENV[EXPORT_KEY])
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -7,46 +7,39 @@ module Henry
7
7
 
8
8
  # The Henry Task implementation for Cucumber
9
9
  class CucumberTask < Task
10
-
11
- # Makes available the cucumber rake task.
12
- Cucumber::Rake::Task.new do |t|
13
- t.cucumber_opts = %w{--out cucumber.out}
14
- t.fork = false
15
- end
16
10
 
17
11
  # Executes the CucumberTask and returns its results.
18
12
  #
19
13
  # @return [Hash] the CucumberTask results.
20
- def execute(params)
14
+ def execute
21
15
  begin
22
- File.open('cucumber.out', 'w') { |f| }
23
-
24
- #tail_pid = Process.spawn('tail -f cucumber.out')
25
-
26
16
  Rake.application['cucumber'].invoke
27
-
28
- #Process.kill(:SIGINT, tail_pid)
29
-
30
- {
31
- name: self.name,
32
- code: 'OK',
33
- message: 'OK',
34
- returnedData: {
35
- output: File.open('cucumber.out', 'r').read
36
- }
37
- }
17
+
18
+ self.execution.code = 'OK'
19
+ self.execution.message = 'OK'
20
+ self.execution.output = File.open('cucumber.out', 'r').read
38
21
  rescue Exception => e
39
- {
40
- name: self.name,
41
- code: 'ERROR',
42
- message: 'ERROR',
43
- returnedData: {
44
- output: File.open('cucumber.out', 'r').read,
45
- backtrace: e.message
46
- }
47
- }
22
+ self.execution.code = 'ERROR'
23
+ self.execution.message = 'ERROR'
24
+ self.execution.output = File.open('cucumber.out', 'r').read
25
+ self.execution.backtrace = e.message
48
26
  end
49
27
  end
28
+
29
+ # Configures the Task.
30
+ #
31
+ # @param [Hash] params the task params.
32
+ def configure(params)
33
+ File.open('cucumber.out', 'w') { |f| }
34
+
35
+ # Makes available the cucumber rake task.
36
+ Cucumber::Rake::Task.new do |t|
37
+ t.cucumber_opts = %w{--out cucumber.out}
38
+ t.fork = false
39
+ end
40
+
41
+ self.export_params(params)
42
+ end
50
43
 
51
44
  end
52
45
 
@@ -8,48 +8,37 @@ module Henry
8
8
  # The Henry Task implementation for Rspec
9
9
  class RspecTask < Task
10
10
 
11
- # Executes the CucumberTask and returns its results.
12
- #
13
- # @return [Hash] the CucumberTask results.
14
- def execute(params)
11
+ # Executes the Task and returns its results.
12
+ def execute
15
13
  begin
16
- File.open('rspec.out', 'w') { |f| }
17
-
18
- # tail_pid = Process.spawn('tail -f rspec.out')
19
-
20
- # Makes available the spec rake task.
21
- RSpec::Core::RakeTask.new do |t|
22
- t.pattern = self.data.options['pattern'] || '*'
23
- t.rspec_opts = '--out rspec.out'
24
- end
25
-
26
- ENV['HENRY_INPUT'] = JSON.dump(params)
27
-
28
14
  Rake.application['spec'].invoke
29
15
 
30
- # Process.kill(:SIGINT, tail_pid)
31
-
32
- {
33
- name: self.name,
34
- code: 'OK',
35
- message: 'OK',
36
- returnedData: {
37
- output: File.open('rspec.out', 'r').read
38
- }
39
- }
16
+ self.execution.code = 'OK'
17
+ self.execution.message = 'OK'
18
+ self.execution.output = File.open('rspec.out', 'r').read
40
19
  rescue Exception => e
41
- {
42
- name: self.name,
43
- code: 'ERROR',
44
- message: 'ERROR',
45
- returnedData: {
46
- output: File.open('rspec.out', 'r').read,
47
- backtrace: e.message
48
- }
49
- }
20
+ self.execution.code = 'ERROR'
21
+ self.execution.message = 'ERROR'
22
+ self.execution.output = File.open('rspec.out', 'r').read
23
+ self.execution.backtrace = e.message
50
24
  end
51
25
  end
52
26
 
27
+ # Configures the Task.
28
+ #
29
+ # @param [Hash] params the task params.
30
+ def configure(params)
31
+ File.open('rspec.out', 'w') { |f| }
32
+
33
+ # Makes available the spec rake task.
34
+ RSpec::Core::RakeTask.new do |t|
35
+ t.pattern = (self.data.options && self.data.options['pattern']) || 'spec/*'
36
+ t.rspec_opts = '--out rspec.out'
37
+ end
38
+
39
+ self.export_params(params)
40
+ end
41
+
53
42
  end
54
43
 
55
44
  end
data/lib/henry/task.rb CHANGED
@@ -6,11 +6,11 @@ module Henry
6
6
  # Henry Task
7
7
  class Task
8
8
 
9
- # Accessors for name and data
9
+ # Accessors for name, data and enabled
10
10
  attr_accessor :name, :data, :enabled
11
11
 
12
12
  # Returns an instance of the target Task class.
13
- # @note Factory to create XTask instances.
13
+ # @note Factory to create X Task instances.
14
14
  #
15
15
  # @return [Task]
16
16
  def self.create(name, data)
@@ -22,6 +22,28 @@ module Henry
22
22
  self.name = name
23
23
  self.data = OpenStruct.new(data)
24
24
  self.enabled = true
25
+ self.execution.task_name = self.name
26
+ end
27
+
28
+ # Returns the json ready hash report of the task execution.
29
+ #
30
+ # @return [Hash]
31
+ def report
32
+ self.execution.report
33
+ end
34
+
35
+ # Exports the Task params to the ENV.
36
+ #
37
+ # @param [Hash] params the Task params to be exported.
38
+ def export_params(params)
39
+ Input.export!(params)
40
+ end
41
+
42
+ # Returns the Task Execution.
43
+ #
44
+ # @return [Execution]
45
+ def execution
46
+ @execution ||= Execution.new
25
47
  end
26
48
 
27
49
  # Returns true whenever the Task is enabled.
@@ -48,8 +70,14 @@ module Henry
48
70
  self.enabled = false
49
71
  end
50
72
 
51
- # Nothing to be done here yet...
52
- def execute(params)
73
+ # The execution code should be defined under this method on the specific Task class.
74
+ def execute
75
+ abort "Your task class ('#{self.class}' may be?) MUST define this method with its execution logic."
76
+ end
77
+
78
+ # Nothing to be done here...
79
+ # The Task configuration code should be defined under this method on the specific Task class.
80
+ def configure(params)
53
81
  end
54
82
 
55
83
  end
data/lib/henry.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require_relative 'henry/task'
2
2
  require_relative 'henry/container'
3
+ require_relative 'henry/execution'
4
+ require_relative 'henry/input'
3
5
 
4
6
  # Henry
5
7
  module Henry
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henry-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.35
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-26 00:00:00.000000000 Z
12
+ date: 2012-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -117,31 +117,9 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
119
  - .rvmrc
120
- - .yardoc/checksums
121
- - .yardoc/object_types
122
- - .yardoc/objects/root.dat
123
- - .yardoc/proxy_types
124
120
  - Gemfile
125
121
  - Rakefile
126
122
  - bin/henry-ruby-container
127
- - doc/Henry.html
128
- - doc/Henry/Container.html
129
- - doc/Henry/Task.html
130
- - doc/Henry/Task/CucumberTask.html
131
- - doc/Henry/Task/RspecTask.html
132
- - doc/_index.html
133
- - doc/class_list.html
134
- - doc/css/common.css
135
- - doc/css/full_list.css
136
- - doc/css/style.css
137
- - doc/file_list.html
138
- - doc/frames.html
139
- - doc/index.html
140
- - doc/js/app.js
141
- - doc/js/full_list.js
142
- - doc/js/jquery.js
143
- - doc/method_list.html
144
- - doc/top-level-namespace.html
145
123
  - henry-container.gemspec
146
124
  - henry-context.yml.sample
147
125
  - in.henry.sample
@@ -156,6 +134,9 @@ files:
156
134
  - lib/henry/.yardoc/proxy_types
157
135
  - lib/henry/container.rb
158
136
  - lib/henry/container/version.rb
137
+ - lib/henry/environment.rb
138
+ - lib/henry/execution.rb
139
+ - lib/henry/input.rb
159
140
  - lib/henry/task.rb
160
141
  - lib/henry/task/cucumber_task.rb
161
142
  - lib/henry/task/rspec_task.rb
data/.yardoc/checksums DELETED
@@ -1,6 +0,0 @@
1
- lib/henry.rb a099cbeab3003a8afbd3295a05937c64fa0af1ce
2
- lib/henry/task.rb 1c480c5547ca6f7574755d437104036431f03c72
3
- lib/henry/container.rb 60b90d0fdfafdbe35424ab386633414092594fa3
4
- lib/henry/task/rspec_task.rb 84b6a26d0b5582416ac69207d055089656144a39
5
- lib/henry/container/version.rb c6756bb3a6c79d109d282f032f4e4e1466470d86
6
- lib/henry/task/cucumber_task.rb bd09e4b6c60fd358151a41cf3803d5e56f74bdec
data/.yardoc/object_types DELETED
Binary file
Binary file
data/.yardoc/proxy_types DELETED
Binary file