henry-container 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/{gems/henry-container-0.0.1.gem → henry-container-0.0.1.gem} +0 -0
  2. data/{gems/henry-container-0.0.2.gem → henry-container-0.0.2.gem} +0 -0
  3. data/{gems/henry-container-0.0.3.gem → henry-container-0.0.3.gem} +0 -0
  4. data/henry-container-0.0.4.gem +0 -0
  5. metadata +7 -49
  6. data/.gitignore +0 -2
  7. data/.rvmrc +0 -1
  8. data/.yardoc/checksums +0 -5
  9. data/.yardoc/object_types +0 -0
  10. data/.yardoc/objects/root.dat +0 -0
  11. data/.yardoc/proxy_types +0 -0
  12. data/Gemfile +0 -4
  13. data/Rakefile +0 -2
  14. data/bin/henry-ruby-container +0 -23
  15. data/doc/Henry/Container.html +0 -319
  16. data/doc/Henry/Task/CucumberTask.html +0 -287
  17. data/doc/Henry/Task.html +0 -551
  18. data/doc/Henry.html +0 -128
  19. data/doc/_index.html +0 -138
  20. data/doc/class_list.html +0 -53
  21. data/doc/css/common.css +0 -1
  22. data/doc/css/full_list.css +0 -57
  23. data/doc/css/style.css +0 -328
  24. data/doc/file_list.html +0 -52
  25. data/doc/frames.html +0 -28
  26. data/doc/index.html +0 -138
  27. data/doc/js/app.js +0 -214
  28. data/doc/js/full_list.js +0 -173
  29. data/doc/js/jquery.js +0 -4
  30. data/doc/method_list.html +0 -116
  31. data/doc/top-level-namespace.html +0 -112
  32. data/henry-container.gemspec +0 -24
  33. data/henry-context.yml.sample +0 -4
  34. data/in.henry.sample +0 -14
  35. data/lib/.yardoc/checksums +0 -0
  36. data/lib/.yardoc/object_types +0 -0
  37. data/lib/.yardoc/objects/root.dat +0 -0
  38. data/lib/.yardoc/proxy_types +0 -0
  39. data/lib/henry/.yardoc/checksums +0 -0
  40. data/lib/henry/.yardoc/object_types +0 -0
  41. data/lib/henry/.yardoc/objects/root.dat +0 -0
  42. data/lib/henry/.yardoc/proxy_types +0 -0
  43. data/lib/henry/container/version.rb +0 -11
  44. data/lib/henry/container.rb +0 -151
  45. data/lib/henry/task/cucumber_task.rb +0 -50
  46. data/lib/henry/task.rb +0 -31
  47. data/lib/henry.rb +0 -8
@@ -1,151 +0,0 @@
1
- require_relative 'container/version'
2
-
3
- require 'yaml'
4
- require 'ostruct'
5
- require 'json'
6
- require 'rake'
7
- require 'colorize'
8
-
9
- module Henry
10
-
11
- # Henry Container
12
- class Container
13
-
14
- # Nothing to be done here yet...
15
- def initialize(opts)
16
- @opts = opts
17
- end
18
-
19
- # Executes the loaded tasks and stores their results.
20
- def execute
21
- self.before_execution
22
-
23
- self.tasks_results = self.tasks.collect do |task|
24
- task.execute(self.task_params(task.name))
25
- end
26
-
27
- self.update_results
28
-
29
- self.dump_results
30
- end
31
-
32
- protected
33
-
34
- # Initial state the conteiner execution results.
35
- #
36
- # @return [Hash] the results template.
37
- RESULTS_TEMPLATE = {
38
- summary: {
39
- total: 0,
40
- tasks_results: [],
41
- breakdown_by_status_code: {
42
- 0 => 0,
43
- 1 => 0,
44
- 2 => 0
45
- },
46
- }
47
- }
48
-
49
- # Returns the input file path based on the given options.
50
- #
51
- # @return [String] the input file path.
52
- def input_file_path
53
- "#{@opts[:"in-dir"]}#{@opts[:in]}"
54
- end
55
-
56
- # Returns the output file path based on the given options.
57
- #
58
- # @return [String] the output file path.
59
- def output_file_path
60
- "#{@opts[:"out-dir"]}#{@opts[:out]}"
61
- end
62
-
63
- # Executes required validations before execution.
64
- def before_execution
65
- unless File.exists?(self.input_file_path)
66
- abort "#{"'#{self.input_file_path}' file does not exist.".red}\n #{'*'.red} If running isolated make sure to create it first.\n #{'*'.red} If running from Henry contact us at henry@despegar.it."
67
- end
68
-
69
- unless File.exists?('henry-context.yml')
70
- abort "'henry-context.yml' file does not exist. You need it in order to execute a Henry compatible test.".red
71
- end
72
-
73
- end
74
-
75
- # Loads and parses the @opts[:in] params.
76
- #
77
- # @return [{String => String}] the execution params.
78
- def params
79
- @params ||= JSON.parse(File.read(self.input_file_path))
80
- end
81
-
82
- # Returns the default params.
83
- # @note Custom task_params will overwrite the defaults.
84
- #
85
- # @return [Hash] the default params.
86
- def default_params
87
- @default_params ||= self.params['all']
88
- end
89
-
90
- # Returns the custom params for the given task.
91
- # @note default_params will be used for undefined keys.
92
- #
93
- # @param [String] task_name the target Task name.
94
- # @return [Hash] the Task custom params.
95
- def task_params(task_name)
96
- self.default_params.merge(self.params[task_name] || {})
97
- end
98
-
99
- # Load and parses the henry-context.yml params.
100
- #
101
- # @return [{String => String}] the execution context.
102
- def context
103
- @context ||= OpenStruct.new(YAML.load_file('henry-context.yml'))
104
- end
105
-
106
- # Returns the tasks to be executed based on the context.
107
- #
108
- # @return [<Task>] tasks to be executed.
109
- def tasks
110
- @tasks ||= self.context.tasks.collect { |task_data| Task.create(task_data["name"], task_data) }
111
- end
112
-
113
- # Returns the execution's current results.
114
- #
115
- # @return [Hash] the execution's current resutls.
116
- def results
117
- @results ||= RESULTS_TEMPLATE
118
- end
119
-
120
- # Returns the tasks_results node from the results hash.
121
- #
122
- # @return [Array]
123
- def tasks_results
124
- self.results[:summary][:tasks_results]
125
- end
126
-
127
- # Serts the tasks_results node of the results hash.
128
- #
129
- # @param [Array] results the tasks_results collection.
130
- def tasks_results=(results)
131
- self.results[:summary][:tasks_results] = results
132
- end
133
-
134
- # Updates the results attributes based on the task_results.
135
- def update_results
136
- self.tasks_results.each do |task_results|
137
- self.results[:summary][:total] += 1
138
-
139
- self.results[:summary][:breakdown_by_status_code][task_results[:code]] += 1
140
- end
141
- end
142
-
143
- # Writes into @opts[:out] the execution results.
144
- def dump_results
145
- File.open(self.output_file_path, 'w') { |f| f.write(results.to_json) }
146
- end
147
-
148
- end
149
-
150
- end
151
-
@@ -1,50 +0,0 @@
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_pid = Process.spawn('tail -f cucumber.out')
24
-
25
- Rake.application['cucumber'].invoke
26
-
27
- Process.kill(:SIGINT, tail_pid)
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 DELETED
@@ -1,31 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- require_relative 'henry/task'
2
- require_relative 'henry/container'
3
-
4
- # Henry
5
- module Henry
6
-
7
- end
8
-