henry-container 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -0
- data/.yardoc/checksums +5 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/bin/henry-ruby-container +5 -0
- data/doc/Henry/Container.html +319 -0
- data/doc/Henry/Task/CucumberTask.html +287 -0
- data/doc/Henry/Task.html +551 -0
- data/doc/Henry.html +128 -0
- data/doc/_index.html +138 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file_list.html +52 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +138 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +116 -0
- data/doc/top-level-namespace.html +112 -0
- data/henry-container.gemspec +22 -0
- data/henry-context.yml.sample +4 -0
- data/in.henry.sample +14 -0
- data/lib/.yardoc/checksums +0 -0
- data/lib/.yardoc/object_types +0 -0
- data/lib/.yardoc/objects/root.dat +0 -0
- data/lib/.yardoc/proxy_types +0 -0
- data/lib/henry/.yardoc/checksums +0 -0
- data/lib/henry/.yardoc/object_types +0 -0
- data/lib/henry/.yardoc/objects/root.dat +0 -0
- data/lib/henry/.yardoc/proxy_types +0 -0
- data/lib/henry/container/version.rb +11 -0
- data/lib/henry/container.rb +121 -0
- data/lib/henry/task/cucumber_task.rb +50 -0
- data/lib/henry/task.rb +31 -0
- data/lib/henry.rb +8 -0
- metadata +137 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative 'container/version'
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'ostruct'
|
5
|
+
require 'json'
|
6
|
+
require 'rake'
|
7
|
+
|
8
|
+
module Henry
|
9
|
+
|
10
|
+
# Henry Container
|
11
|
+
class Container
|
12
|
+
|
13
|
+
# Nothing to be done here yet...
|
14
|
+
def initialize
|
15
|
+
end
|
16
|
+
|
17
|
+
# Executes the loaded tasks and stores their results.
|
18
|
+
def execute
|
19
|
+
self.tasks_results = self.tasks.collect do |task|
|
20
|
+
task.execute(self.task_params(task.name))
|
21
|
+
end
|
22
|
+
|
23
|
+
self.update_results
|
24
|
+
|
25
|
+
self.dump_results
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
# Initial state the conteiner execution results.
|
31
|
+
#
|
32
|
+
# @return [Hash] the results template.
|
33
|
+
RESULTS_TEMPLATE = {
|
34
|
+
summary: {
|
35
|
+
total: 0,
|
36
|
+
tasks_results: [],
|
37
|
+
breakdown_by_status_code: {
|
38
|
+
0 => 0,
|
39
|
+
1 => 0,
|
40
|
+
2 => 0
|
41
|
+
},
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
# Loads and parses the in.henry params.
|
46
|
+
#
|
47
|
+
# @return [{String => String}] the execution params.
|
48
|
+
def params
|
49
|
+
@params ||= JSON.parse(File.read('in.henry'))
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns the default params.
|
53
|
+
# @note Custom task_params will overwrite the defaults.
|
54
|
+
#
|
55
|
+
# @return [Hash] the default params.
|
56
|
+
def default_params
|
57
|
+
@default_params ||= self.params['all']
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the custom params for the given task.
|
61
|
+
# @note default_params will be used for undefined keys.
|
62
|
+
#
|
63
|
+
# @param [String] task_name the target Task name.
|
64
|
+
# @return [Hash] the Task custom params.
|
65
|
+
def task_params(task_name)
|
66
|
+
self.default_params.merge(self.params[task_name])
|
67
|
+
end
|
68
|
+
|
69
|
+
# Load and parses the henry-context.yml params.
|
70
|
+
#
|
71
|
+
# @return [{String => String}] the execution context.
|
72
|
+
def context
|
73
|
+
@context ||= OpenStruct.new(YAML.load_file('henry-context.yml'))
|
74
|
+
end
|
75
|
+
|
76
|
+
# Returns the tasks to be executed based on the context.
|
77
|
+
#
|
78
|
+
# @return [<Task>] tasks to be executed.
|
79
|
+
def tasks
|
80
|
+
@tasks ||= self.context.tasks.collect { |task_data| Task.create(task_data["name"], task_data) }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns the execution's current results.
|
84
|
+
#
|
85
|
+
# @return [Hash] the execution's current resutls.
|
86
|
+
def results
|
87
|
+
@results ||= RESULTS_TEMPLATE
|
88
|
+
end
|
89
|
+
|
90
|
+
# Returns the tasks_results node from the results hash.
|
91
|
+
#
|
92
|
+
# @return [Array]
|
93
|
+
def tasks_results
|
94
|
+
self.results[:summary][:tasks_results]
|
95
|
+
end
|
96
|
+
|
97
|
+
# Serts the tasks_results node of the results hash.
|
98
|
+
#
|
99
|
+
# @param [Array] results the tasks_results collection.
|
100
|
+
def tasks_results=(results)
|
101
|
+
self.results[:summary][:tasks_results] = results
|
102
|
+
end
|
103
|
+
|
104
|
+
# Updates the results attributes based on the task_results.
|
105
|
+
def update_results
|
106
|
+
self.tasks_results.each do |task_results|
|
107
|
+
self.results[:summary][:total] += 1
|
108
|
+
|
109
|
+
self.results[:summary][:breakdown_by_status_code][task_results[:code]] += 1
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Writes into out.henry the execution results.
|
114
|
+
def dump_results
|
115
|
+
File.open('out.henry', 'w') { |f| f.write(results.to_json) }
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'cucumber/rake/task'
|
3
|
+
|
4
|
+
module Henry
|
5
|
+
|
6
|
+
class Task
|
7
|
+
|
8
|
+
# The Henry Task implementation for Cucumber
|
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
|
+
end
|
15
|
+
|
16
|
+
# Executes the CucumberTask and returns its results.
|
17
|
+
#
|
18
|
+
# @return [Hash] the CucumberTask results.
|
19
|
+
def execute(params)
|
20
|
+
begin
|
21
|
+
File.open('cucumber.out', 'w') { |f| }
|
22
|
+
|
23
|
+
tail_thread = Thread.new { system('tail -f cucumber.out') }
|
24
|
+
|
25
|
+
Rake.application['cucumber'].invoke
|
26
|
+
|
27
|
+
tail_thread.kill
|
28
|
+
|
29
|
+
{
|
30
|
+
code:0,
|
31
|
+
message:"OK",
|
32
|
+
data:File.open('cucumber.out', 'r').read,
|
33
|
+
stacktrace:nil
|
34
|
+
}
|
35
|
+
rescue Exception => e
|
36
|
+
{
|
37
|
+
code:2,
|
38
|
+
message:e.message,
|
39
|
+
data:File.open('cucumber.out', 'r').read,
|
40
|
+
stacktrace:e.backtrace
|
41
|
+
}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/lib/henry/task.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'task/cucumber_task'
|
2
|
+
|
3
|
+
module Henry
|
4
|
+
|
5
|
+
# Henry Task
|
6
|
+
class Task
|
7
|
+
|
8
|
+
# Accessors for name and data
|
9
|
+
attr_accessor :name, :data
|
10
|
+
|
11
|
+
# Returns an instance of the target Task class.
|
12
|
+
# @note Factory to create XTask instances.
|
13
|
+
#
|
14
|
+
# @return [Task]
|
15
|
+
def self.create(name, data)
|
16
|
+
return Kernel.eval(data['class_name']).new(name, data)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Initialize the Task with the given name and data.
|
20
|
+
def initialize(name, data)
|
21
|
+
self.name = name
|
22
|
+
self.data = OpenStruct.new(data)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Nothing to be done here yet...
|
26
|
+
def execute(params)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/henry.rb
ADDED
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: henry-container
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Roberto Decurnex
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: cucumber
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: The Ruby Container for Henry
|
63
|
+
email:
|
64
|
+
- decurnex.roberto@gmail.com
|
65
|
+
executables:
|
66
|
+
- henry-ruby-container
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .rvmrc
|
72
|
+
- .yardoc/checksums
|
73
|
+
- .yardoc/object_types
|
74
|
+
- .yardoc/objects/root.dat
|
75
|
+
- .yardoc/proxy_types
|
76
|
+
- Gemfile
|
77
|
+
- Rakefile
|
78
|
+
- bin/henry-ruby-container
|
79
|
+
- doc/Henry.html
|
80
|
+
- doc/Henry/Container.html
|
81
|
+
- doc/Henry/Task.html
|
82
|
+
- doc/Henry/Task/CucumberTask.html
|
83
|
+
- doc/_index.html
|
84
|
+
- doc/class_list.html
|
85
|
+
- doc/css/common.css
|
86
|
+
- doc/css/full_list.css
|
87
|
+
- doc/css/style.css
|
88
|
+
- doc/file_list.html
|
89
|
+
- doc/frames.html
|
90
|
+
- doc/index.html
|
91
|
+
- doc/js/app.js
|
92
|
+
- doc/js/full_list.js
|
93
|
+
- doc/js/jquery.js
|
94
|
+
- doc/method_list.html
|
95
|
+
- doc/top-level-namespace.html
|
96
|
+
- henry-container.gemspec
|
97
|
+
- henry-context.yml.sample
|
98
|
+
- in.henry.sample
|
99
|
+
- lib/.yardoc/checksums
|
100
|
+
- lib/.yardoc/object_types
|
101
|
+
- lib/.yardoc/objects/root.dat
|
102
|
+
- lib/.yardoc/proxy_types
|
103
|
+
- lib/henry.rb
|
104
|
+
- lib/henry/.yardoc/checksums
|
105
|
+
- lib/henry/.yardoc/object_types
|
106
|
+
- lib/henry/.yardoc/objects/root.dat
|
107
|
+
- lib/henry/.yardoc/proxy_types
|
108
|
+
- lib/henry/container.rb
|
109
|
+
- lib/henry/container/version.rb
|
110
|
+
- lib/henry/task.rb
|
111
|
+
- lib/henry/task/cucumber_task.rb
|
112
|
+
homepage: http://henry.despegar.it
|
113
|
+
licenses: []
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ! '>='
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 1.8.24
|
133
|
+
signing_key:
|
134
|
+
specification_version: 3
|
135
|
+
summary: The Ruby Container for Henry
|
136
|
+
test_files: []
|
137
|
+
has_rdoc:
|