kaya 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/CHANGELOG +52 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/NOTAS +19 -0
  7. data/README.md +279 -0
  8. data/Rakefile +1 -0
  9. data/bin/kaya +4 -0
  10. data/documentation/api.md +47 -0
  11. data/documentation/api_execution_data.md +47 -0
  12. data/documentation/configuration.md +13 -0
  13. data/documentation/custom_parameters.md +117 -0
  14. data/documentation/document_kaya.md +122 -0
  15. data/documentation/link.md +12 -0
  16. data/documentation/results.md +119 -0
  17. data/documentation/start.md +19 -0
  18. data/documentation/suites.md +60 -0
  19. data/documentation/test_suite_information.md +9 -0
  20. data/kaya.gemspec +42 -0
  21. data/lib/generators/task_rack.rb +160 -0
  22. data/lib/generators/templates/Gemfile.tt +2 -0
  23. data/lib/generators/templates/config.ru.tt +2 -0
  24. data/lib/generators/templates/kaya_conf.tt +49 -0
  25. data/lib/generators/templates/kaya_log.tt +0 -0
  26. data/lib/generators/templates/sidekiq_log.tt +0 -0
  27. data/lib/generators/templates/tasks.kaya.tt +10 -0
  28. data/lib/generators/templates/unicorn.rb.tt +21 -0
  29. data/lib/kaya/API/error.rb +17 -0
  30. data/lib/kaya/API/execution.rb +141 -0
  31. data/lib/kaya/API/result.rb +49 -0
  32. data/lib/kaya/API/results.rb +31 -0
  33. data/lib/kaya/API/suite.rb +42 -0
  34. data/lib/kaya/API/suites.rb +36 -0
  35. data/lib/kaya/background_jobs/sidekiq.rb +35 -0
  36. data/lib/kaya/background_jobs/workers/execution_checker.rb +20 -0
  37. data/lib/kaya/background_jobs/workers/garbage_cleaner.rb +31 -0
  38. data/lib/kaya/commands/bye.rb +12 -0
  39. data/lib/kaya/commands/help.rb +13 -0
  40. data/lib/kaya/commands/install.rb +27 -0
  41. data/lib/kaya/commands/reset.rb +39 -0
  42. data/lib/kaya/commands/reset_suites.rb +40 -0
  43. data/lib/kaya/commands/restart.rb +9 -0
  44. data/lib/kaya/commands/start.rb +104 -0
  45. data/lib/kaya/commands/stop.rb +53 -0
  46. data/lib/kaya/cuba.rb +287 -0
  47. data/lib/kaya/cucumber/features.rb +15 -0
  48. data/lib/kaya/cucumber/task.rb +64 -0
  49. data/lib/kaya/custom/execution_data.rb +50 -0
  50. data/lib/kaya/custom/params.rb +34 -0
  51. data/lib/kaya/database/mongo_connector.rb +285 -0
  52. data/lib/kaya/error/errors.rb +55 -0
  53. data/lib/kaya/execution.rb +57 -0
  54. data/lib/kaya/results/result.rb +493 -0
  55. data/lib/kaya/results/results.rb +47 -0
  56. data/lib/kaya/suites/custom/params.rb +151 -0
  57. data/lib/kaya/suites/suite.rb +177 -0
  58. data/lib/kaya/suites/suites.rb +130 -0
  59. data/lib/kaya/support/clean.rb +12 -0
  60. data/lib/kaya/support/configuration.rb +254 -0
  61. data/lib/kaya/support/console.rb +11 -0
  62. data/lib/kaya/support/documentation.rb +34 -0
  63. data/lib/kaya/support/error_handler_helper.rb +24 -0
  64. data/lib/kaya/support/files_cleanner.rb +136 -0
  65. data/lib/kaya/support/git.rb +161 -0
  66. data/lib/kaya/support/if_config.rb +14 -0
  67. data/lib/kaya/support/logo.rb +23 -0
  68. data/lib/kaya/support/logs.rb +37 -0
  69. data/lib/kaya/support/notification.rb +127 -0
  70. data/lib/kaya/support/processes.rb +96 -0
  71. data/lib/kaya/support/query_string.rb +22 -0
  72. data/lib/kaya/support/request.rb +32 -0
  73. data/lib/kaya/support/risk.rb +9 -0
  74. data/lib/kaya/support/time_helper.rb +11 -0
  75. data/lib/kaya/support/update.rb +65 -0
  76. data/lib/kaya/version.rb +3 -0
  77. data/lib/kaya/view/body.mote +60 -0
  78. data/lib/kaya/view/custom/params/select_list.mote +14 -0
  79. data/lib/kaya/view/custom/params/text.mote +9 -0
  80. data/lib/kaya/view/custom/params.mote +9 -0
  81. data/lib/kaya/view/error_handler.mote +40 -0
  82. data/lib/kaya/view/features/feature.mote +14 -0
  83. data/lib/kaya/view/features/features_list.mote +10 -0
  84. data/lib/kaya/view/features.mote +57 -0
  85. data/lib/kaya/view/footer.mote +10 -0
  86. data/lib/kaya/view/git_information.mote +21 -0
  87. data/lib/kaya/view/help/main.mote +21 -0
  88. data/lib/kaya/view/help/page.mote +2 -0
  89. data/lib/kaya/view/help/search_result.mote +29 -0
  90. data/lib/kaya/view/help.mote +72 -0
  91. data/lib/kaya/view/javascript.mote +96 -0
  92. data/lib/kaya/view/logs/log.mote +3 -0
  93. data/lib/kaya/view/modals.mote +31 -0
  94. data/lib/kaya/view/navigation_bar.mote +48 -0
  95. data/lib/kaya/view/not_found.mote +40 -0
  96. data/lib/kaya/view/parser.rb +79 -0
  97. data/lib/kaya/view/results/all.mote +59 -0
  98. data/lib/kaya/view/results/console.mote +106 -0
  99. data/lib/kaya/view/results/detailed_info.mote +112 -0
  100. data/lib/kaya/view/results/report.mote +1 -0
  101. data/lib/kaya/view/results/result.mote +23 -0
  102. data/lib/kaya/view/results/results.mote +52 -0
  103. data/lib/kaya/view/screenshot.mote +42 -0
  104. data/lib/kaya/view/sections.rb +25 -0
  105. data/lib/kaya/view/styles.mote +58 -0
  106. data/lib/kaya/view/suites/suite.mote +73 -0
  107. data/lib/kaya/view/suites/suites.mote +9 -0
  108. data/lib/kaya/view/view.rb +72 -0
  109. data/lib/kaya.rb +175 -0
  110. data/test/features/install.feature +18 -0
  111. data/test/features/support/env.rb +3 -0
  112. metadata +395 -0
@@ -0,0 +1,177 @@
1
+ module Kaya
2
+ module Suites
3
+ class Suite
4
+
5
+ attr_accessor :id,
6
+ :name,
7
+ :branch,
8
+ :status,
9
+ :command,
10
+ :custom,
11
+ :info,
12
+ :last_execution,
13
+ :last_result,
14
+ :active
15
+
16
+ # First, try to get suite info from mongo.
17
+ # If it does not exist creates a new one with default values
18
+ def initialize suite_data = nil
19
+ $K_LOG.debug "[#{suite_data["_id"]}:#{suite_data["name"]}] Creating suite object " if $K_LOG
20
+ if suite_data.is_a? Hash
21
+ @id = suite_data["_id"]
22
+ @name = suite_data["name"]
23
+ @branch = suite_data["branch"]
24
+ @status = suite_data["status"]
25
+ @command = suite_data["command"]
26
+ @custom = suite_data["custom"] || []
27
+ @info = suite_data["info"] || ""
28
+ @last_execution = suite_data["last_execution"]
29
+ @last_result = suite_data["last_result"]
30
+ @active = suite_data["active"]
31
+
32
+ else
33
+ $K_LOG.error "Creting suite object. Argument is not a hash" if $K_LOG
34
+ raise "Suite data not defined correctly. Expecting info about suite"
35
+ end
36
+ end
37
+
38
+
39
+ def api_response
40
+ response = suite_data_structure
41
+ response["results"]={
42
+ "size" => number_of_results,
43
+ "ids" => all_results_ids
44
+ }
45
+ response
46
+ end
47
+
48
+ def self.get suite_id
49
+ $K_LOG.debug "Getting suite data for [id:#{suite_id}]" if $K_LOG
50
+ suite_data = Kaya::Database::MongoConnector.suite_data_for suite_id
51
+ suite_data = suite_data.to_h if respond_to? :to_h
52
+ new(suite_data) if suite_data
53
+ end
54
+
55
+ def self.get_suite_with name
56
+ self.new(Kaya::Database::MongoConnector.suite_data_for_name(name))
57
+ end
58
+
59
+ def self.new_suite(suite_name)
60
+ $K_LOG.debug "Defining new suite [#{suite_name}]" if $K_LOG
61
+ suite_data = {
62
+ "_id" => Kaya::Database::MongoConnector.generate_id,
63
+ "name" => suite_name,
64
+ "branch" => Kaya::Support::Git.actual_branch,
65
+ "status" => "READY",
66
+ "active" => true
67
+ }
68
+ self.new(suite_data)
69
+
70
+ end
71
+
72
+ def suite_data_for suite_name
73
+ Kaya::Database::MongoConnector.suite_data_for(suite_name)
74
+ end
75
+
76
+ # Returns the structure of a suite data
77
+ # @return [Hash] data structure
78
+ def suite_data_structure
79
+ {
80
+ "_id" => id,
81
+ "name" => name,
82
+ "branch" => branch,
83
+ "status" => status,
84
+ "command" => command,
85
+ "custom" => custom,
86
+ "info" => info,
87
+ "last_execution" => last_execution,
88
+ "last_result" => last_result,
89
+ "active" => active
90
+ }
91
+ end
92
+
93
+ def has_custom_params?
94
+ !@custom.empty?
95
+ end
96
+
97
+ # Returns an array of those required custom params
98
+ # This is for start execution validations
99
+ # @return [Array]
100
+ def required_custom_params
101
+ custom.select{|param| param["required"]}.map{|param| param["name"]}
102
+ end
103
+
104
+ def has_info?
105
+ not @info.empty?
106
+ end
107
+
108
+ def activate!
109
+ @active= true
110
+ $K_LOG.debug "[#{@id}:#{@name}] Activated" if $K_LOG
111
+ self.save!
112
+ end
113
+
114
+ def deactivate!
115
+ @active = false
116
+ $K_LOG.debug "[#{@id}:#{@name}] Deactivated" if $K_LOG
117
+ self.save!
118
+ end
119
+
120
+ def is_ready?
121
+ status == "READY"
122
+ end
123
+
124
+ def is_running?
125
+ status == "RUNNING"
126
+ end
127
+
128
+ def set_ready!
129
+ @status = "READY"
130
+ $K_LOG.debug "[#{@id}:#{@name}] Marked as ready" if $K_LOG
131
+ self.save!
132
+ end
133
+
134
+ def set_running!
135
+ @status= "RUNNING"
136
+ $K_LOG.debug "[#{@id}:#{@name}] Marked as running" if $K_LOG
137
+ self.save!
138
+ end
139
+
140
+ def number_of_results
141
+ all_results.size
142
+ end
143
+
144
+ def all_results_ids
145
+ all_results.inject([]){|res, result| res << result["_id"]}
146
+ end
147
+
148
+ def all_results
149
+ Kaya::Database::MongoConnector.results_for(id)
150
+ end
151
+
152
+ def has_results?
153
+ number_of_results > 0
154
+ end
155
+
156
+ def save!
157
+ if Kaya::Database::MongoConnector.suite_data_for(id)
158
+ Kaya::Database::MongoConnector.update_suite(suite_data_structure)
159
+ else
160
+ Kaya::Database::MongoConnector.insert_suite(suite_data_structure)
161
+ end
162
+ $K_LOG.debug "[#{@id}:#{@name}] Suite saved" if $K_LOG
163
+ end
164
+
165
+ # If test suites ir running
166
+ def check_last_result!
167
+ if self.is_running? and (result = Results::Result.get(@last_result))
168
+ $K_LOG.debug "[#{@id}:#{@name}] Checking last result" if $K_LOG
169
+ self.set_ready! if (result.update_values! or result.finished?)
170
+ $K_LOG.debug "[#{@id}:#{@name}] Done" if $K_LOG
171
+ end
172
+ end
173
+
174
+ end
175
+
176
+ end
177
+ end
@@ -0,0 +1,130 @@
1
+ module Kaya
2
+ module Suites
3
+
4
+ def self.cucumber_yml
5
+ $K_LOG.debug "Getting cucumber.yml content" if $K_LOG
6
+ begin
7
+ # Try to open cucumber.yml file from root folder
8
+ content = YAML.load_file("#{Dir.pwd}/cucumber.yml")
9
+ rescue # Could not find the file
10
+ # Try to open from /config/
11
+ $K_LOG.warn "cucumber.yml file not found" if $K_LOG
12
+ begin
13
+ content = YAML.load_file("#{Dir.pwd}/config/cucumber.yml")
14
+ rescue # Could not find the file
15
+ $K_LOG.warn "cucumber.yml file not found" if $K_LOG
16
+ content ={}
17
+ end
18
+ end
19
+
20
+ begin
21
+ unless content.empty?
22
+
23
+ content.select do |suite_name, command|
24
+ command.include? "runnable=true"
25
+ end.map do |suite_name, command|
26
+
27
+ command.gsub!(' runnable=true','').gsub!(', ',',')
28
+
29
+ suite_info = command.scan(/info\=\[(.*)\]/).flatten.first
30
+
31
+ suite_info.gsub('<br>','\n') if suite_info.respond_to? :gsub
32
+
33
+ command.gsub!(/info\=\[(.*)\]/,"")
34
+
35
+ custom_params = command.scan(/custom\=\[(.*)\]/).flatten.first
36
+
37
+ custom = Kaya::Suites::Custom::Params.new(custom_params)
38
+
39
+ command.gsub!(/custom\=\[(.*)\]/,"")
40
+ $K_LOG.debug "{suite_name => #{suite_name}, command => #{command}, custom => #{custom.params}, info => #{suite_info}}" if $K_LOG
41
+
42
+ {"suite_name" => suite_name, "command" => command, "custom" => custom.params, "info" => suite_info}
43
+ end
44
+ else
45
+ []
46
+ end
47
+ rescue => e
48
+ $K_LOG.error "Suites: #{e}#{e.backtrace}" if $K_LOG
49
+ []
50
+ end
51
+ end
52
+
53
+ def self.update_suites
54
+ $K_LOG.debug "Updating suites" if $K_LOG
55
+ existing_suites_ids = self.suite_ids
56
+
57
+ self.cucumber_yml.each do |suite_data|
58
+ # If is there a suite for the given name suite_id will be setted
59
+ # and the id will be deleted from existing_suites_ids
60
+ existing_suites_ids.delete(suite_id = is_there_suite_with?(suite_data["suite_name"]))
61
+
62
+ if suite_id # Update
63
+ suite = Kaya::Suites::Suite.get(suite_id)
64
+ suite.name= suite_data["suite_name"]
65
+ else
66
+ suite = Kaya::Suites::Suite.new_suite(suite_data["suite_name"])
67
+ end
68
+
69
+ suite.command= suite_data["command"]
70
+ suite.custom = suite_data["custom"]
71
+ suite.info= suite_data["info"]
72
+
73
+ suite.activate! if suite_id
74
+ $K_LOG.debug "[#{suite.id}:#{suite.name}] Suite Updated" if $K_LOG
75
+ suite.save!
76
+ end
77
+
78
+ unless existing_suites_ids.empty?
79
+ existing_suites_ids.each do |suite_id|
80
+ suite = Kaya::Suites::Suite.get(suite_id)
81
+ suite.deactivate!
82
+ end
83
+ end
84
+ end
85
+
86
+ def self.is_there_suite_with? name
87
+ self.suite_id_for name
88
+ end
89
+
90
+ # Returns a list of suites id
91
+ # @param [Boolean] actives or not
92
+ # @return [Array] a list of suite ids
93
+ def self.suite_ids active=nil
94
+ $K_LOG.debug "Suites:Getting all suites ids" if $K_LOG
95
+ Kaya::Database::MongoConnector.suites(active).map do |suite_data|
96
+ suite_data["_id"]
97
+ end
98
+ end
99
+
100
+ # Returns the id for given suite name
101
+ # @param [String] suite name
102
+ # @return [Fixnum] suite id
103
+ def self.suite_id_for(suite_name, active=nil)
104
+ $K_LOG.debug "Suites:Getting suite id for #{suite_name}" if $K_LOG
105
+ Kaya::Database::MongoConnector.suite_id_for(suite_name, active)
106
+ end
107
+
108
+ # Returns the ids for running suites
109
+ # @return [Array] of suite ids
110
+ def self.all_running_suites
111
+ $K_LOG.debug "Suites: Getting all runnnig suites" if $K_LOG
112
+ Kaya::Database::MongoConnector.all_suites.select do |suite|
113
+ suite["status"] == "RUNNING"
114
+ end.map{|suite| suite["_id"]}
115
+ end
116
+
117
+ def self.reset_statuses
118
+ $K_LOG.debug "Resetting suites status" if $K_LOG
119
+ self.all_running_suites.each do |suite_id|
120
+ if suite = Kaya::Suites::Suite.get(suite_id)
121
+ if result = Kaya::Results::Result.get(suite.last_result)
122
+ result.update_values! # update_values! true means result got finished status
123
+ end
124
+ suite.set_ready!
125
+ end
126
+ end
127
+ end
128
+
129
+ end
130
+ end
@@ -0,0 +1,12 @@
1
+ module Kaya
2
+ module Support
3
+ module Clean
4
+ def self.start
5
+ Kaya::Suites.reset_statuses
6
+ Kaya::Results.reset_defuncts
7
+ Kaya::Support::FilesCleanner.delete_all_kaya_reports
8
+ Kaya::Support::FilesCleanner.delete_all_console_output_files
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,254 @@
1
+ module Kaya
2
+ module Support
3
+ class Configuration
4
+
5
+ attr_reader :input
6
+
7
+ def self.get
8
+ $K_LOG.debug "Creating configuration object" if $K_LOG
9
+ if File.exist?("#{Dir.pwd}/kaya_conf")
10
+ puts "Moving kaya_conf from #{Dir.pwd}/kaya_conf to #{self.path}".colorize(:green)
11
+ FileUtils.mv("#{Dir.pwd}/kaya_conf", self.path)
12
+ puts "Done.".colorize(:green)
13
+ end
14
+
15
+ if self.config_file_exists?
16
+ @@input = Kaya::Support::Update.kaya_conf
17
+ else
18
+ @@input = self.default_input
19
+ puts "Error loading kaya_conf. Using default values".colorize(:red)
20
+ end
21
+ end
22
+
23
+ def self.default_input
24
+ $K_LOG.debug "#{self.class}Setting default input (from template)" if $K_LOG
25
+ JSON.parse(IO.read(self.path_template))
26
+ end
27
+
28
+ def self.path
29
+ "#{Dir.pwd}/kaya/kaya_conf"
30
+ end
31
+
32
+ def self.path_template
33
+ File.expand_path("../../", __FILE__) + "/generators/templates/kaya_conf.tt"
34
+ end
35
+
36
+ def self.project_name
37
+ $K_LOG.debug "Project name: #{Dir.pwd.split("/").last}"
38
+ "#{Dir.pwd.split("/").last}"
39
+ end
40
+
41
+ def self.project_name= value
42
+ @@project_name = value
43
+ end
44
+
45
+ def self.project_name
46
+ @@project_name
47
+ end
48
+
49
+ def self.hostname
50
+ @@input['HOSTNAME'] || 'localhost'
51
+ end
52
+
53
+ # Returns the configured port. If it isn't a number, port 8080 will be returned by defualt
54
+ # @return [Fixnum] port number
55
+ def self.port
56
+ self.is_a_number?(@@input["APP_PORT"]) ? @@input["APP_PORT"] : 8080
57
+ end
58
+
59
+ def self.config_file_exists?
60
+ File.exist? self.path
61
+ end
62
+
63
+ def self.project_name
64
+ @@input['PROJECT_NAME'] || 'A project using Kaya'
65
+ end
66
+
67
+ def self.project_url
68
+ url = @@input['PROJECT_URL'] == "http://your.project.url" ? "" : @@input['PROJECT_URL']
69
+ url.empty? ? Kaya::Support::Git.remote_url : url
70
+ end
71
+
72
+ def self.db_type
73
+ @@input["DATABASE"]['TYPE'] || 'mongodb'
74
+ end
75
+
76
+ def self.db_host
77
+ @@input["DATABASE"]['HOST'] || 'localhost'
78
+ end
79
+
80
+ def self.db_port
81
+ @@input["DATABASE"]['PORT'] || 27017
82
+ end
83
+
84
+ def self.db_username
85
+ @@input["DATABASE"]["USERNAME"] || nil
86
+ end
87
+
88
+ def self.db_pass
89
+ @@input["DATABASE"]["PASSWORD"] || nil
90
+ end
91
+
92
+ def self.db_connection_data
93
+ {
94
+ :host => self.db_host,
95
+ :port => self.db_port,
96
+ :username => self.db_username,
97
+ :pass => self.db_pass
98
+ }
99
+ end
100
+
101
+ def self.notification?
102
+ self.notification_username and self.notification_password and self.use_gmail?
103
+ end
104
+
105
+ def self.notifications_to
106
+ self.recipients
107
+ end
108
+
109
+ def self.recipients
110
+ self.is_email_correct? ? @@input['NOTIFICATION']['RECIPIENTS'] : ''
111
+ end
112
+
113
+ def self.notification_username
114
+ @@input['NOTIFICATION']['USERNAME']
115
+ end
116
+
117
+ def self.notification_password
118
+ @@input['NOTIFICATION']['PASSWORD']
119
+ end
120
+
121
+ def self.refresh_time
122
+ self.is_a_number?(@@input['REFRESH_TIME']) ? @@input['REFRESH_TIME'] : 0
123
+ end
124
+
125
+ def self.refresh?
126
+ !self.refresh_time.zero?
127
+ end
128
+
129
+ def self.use_gmail?
130
+ self.is_boolean? @@input['USE_GMAIL'] ? @@input['USE_GMAIL'] : false
131
+ end
132
+
133
+ def self.is_email_correct?
134
+ begin
135
+ !@@input['NOTIFICATION']['RECIPIENTS'].scan(/\w+@[a-zA-Z]+?\.[a-zA-Z]{2,6}/).empty?
136
+ rescue
137
+ false
138
+ end
139
+ end
140
+
141
+ def self.attach_report?
142
+ value = @@input['NOTIFICATION']['ATTACH_REPORT']
143
+ self.is_boolean? value ? value : false
144
+ end
145
+
146
+
147
+
148
+ def self.is_a_number? value
149
+ !"#{value}".scan(/\d+/).empty?
150
+ end
151
+
152
+ def self.is_boolean? object
153
+ [TrueClass, FalseClass].include? object.class
154
+ end
155
+
156
+ def self.use_git?
157
+ self.validate_use_git_configuration_value
158
+ @@input['USE_GIT']
159
+ end
160
+
161
+ def self.validate_use_git_configuration_value
162
+ raise "You have to set USE_GIT config with true or false. Has #{@@input['USE_GIT']}" unless is_boolean? @@input['USE_GIT']
163
+ end
164
+
165
+ def self.formatted_datetime
166
+ @@input['FORMAT_DATETIME'] || "%d/%m/%Y %H:%M:%S"
167
+ end
168
+
169
+ def self.company
170
+ if @@input['FOOTER'].is_a? String
171
+ @@input['FOOTER']
172
+ else
173
+ ""
174
+ end
175
+ end
176
+
177
+ # After this period of time (in seconds) Kaya will show a stop execution button on result report and results list
178
+ def self.inactivity_timeout
179
+ self.is_a_number?(@@input["INACTIVITY_TIMEOUT"]) ? @@input["INACTIVITY_TIMEOUT"] : 60
180
+ end
181
+
182
+ # After this period of time (in seconds) Kaya will kill process execution automatically
183
+ def self.execution_time_to_live
184
+ self.is_a_number?(@@input["KILL_INACTIVE_EXECUTIONS_AFTER"]) ? @@input["KILL_INACTIVE_EXECUTIONS_AFTER"] : 3600
185
+ end
186
+
187
+ def self.kill_after_time?
188
+ self.execution_time_to_live > 0
189
+ end
190
+
191
+ def self.reset_execution_availability?
192
+ inactivity_timeout > 0
193
+ end
194
+
195
+ def self.auto_execution_id
196
+ if @@input.has_key? "AUTO_EXECUTION_ID"
197
+ if @@input["AUTO_EXECUTION_ID"]["datetime"]
198
+ Time.now.strftime(@@input["AUTO_EXECUTION_ID"]["format"])
199
+ else
200
+ @@input["AUTO_EXECUTION_ID"]["default"]
201
+ end
202
+ end
203
+ end
204
+
205
+ def self.headless?
206
+ if self.is_boolean? @@input["HEADLESS"]["active"]
207
+ "xvfb-run --auto-servernum --server-args='-screen 0, #{self.resolution}x#{self.size}' " if @@input["HEADLESS"]["active"]
208
+ end
209
+
210
+ # begin
211
+ # @@input["HEADLESS"]["active"] if self.is_boolean? @@input["HEADLESS"]["active"]
212
+ # rescue
213
+ # false
214
+ # end
215
+ end
216
+
217
+ # Returns value for screen resolution
218
+ # @return [String] resolution like 1024x768
219
+ def self.resolution
220
+ @@input["HEADLESS"]["resolution"]
221
+ end
222
+
223
+ # Returns value for screen size.
224
+ # This is used by xvfb configuration
225
+ # @return [String] value in inches
226
+ def self.size
227
+ @@input["HEADLESS"]["size"]
228
+ end
229
+
230
+ def self.pretty_configuration_values
231
+ output = self.configuration_values
232
+ JSON.pretty_generate(output).gsub("\"******\"", "******")
233
+ end
234
+
235
+ def self.configuration_values
236
+ output = Marshal.load(Marshal.dump(@@input))
237
+ output["DATABASE"]["USERNAME"] = "******"
238
+ output["DATABASE"]["PASSWORD"] = "******"
239
+ output["NOTIFICATION"]["USERNAME"] = "******"
240
+ output["NOTIFICATION"]["PASSWORD"] = "******"
241
+ output
242
+ end
243
+
244
+ def self.show_configuration_values
245
+ puts "
246
+
247
+ * Configuration values loaded at starting Kaya:
248
+
249
+ #{self.pretty_configuration_values}"
250
+ end
251
+
252
+ end
253
+ end
254
+ end
@@ -0,0 +1,11 @@
1
+ module Kaya
2
+ module Support
3
+ module Console
4
+
5
+ # Executes system command
6
+ def self.execute command
7
+ `#{command}`
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ module Kaya
2
+ module Support
3
+ class Documentation
4
+
5
+ @@main_folder = File.expand_path("../../../../", __FILE__) + "/"
6
+ @@docs_folder = @@main_folder + "documentation/"
7
+
8
+ @@folders_to_search = [@@main_folder, @@docs_folder]
9
+
10
+
11
+ def self.load_documentation
12
+ print "\nLoading documentation..."
13
+ Kaya::Database::MongoConnector.clean_documentation
14
+ @@folders_to_search.each { |folder| self.open_files folder }
15
+ print "OK"
16
+ end
17
+
18
+ def self.open_files folder
19
+ Dir.glob(folder + "*.md") do |md_file|
20
+ name = md_file.split("/").last.gsub('.md','')
21
+ text = File.read(md_file)
22
+ Kaya::Database::MongoConnector.insert_documentation self.generate_entry(name,text)
23
+ end
24
+ end
25
+
26
+ def self.generate_entry name, text
27
+ {
28
+ "title" => name,
29
+ "body" => text
30
+ }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ module Kaya
2
+ module Support
3
+ class ErrorHandlerHelper
4
+
5
+ def self.evaluate exception
6
+ case exception
7
+ when Mongo::ConnectionTimeoutError
8
+ ["Timeout Error","Could not connect to database"]
9
+ when Psych::SyntaxError
10
+ ["Parse Error","Cucumber.yml file is not configured correctly (#{exception.message})"]
11
+ when Kaya::Error::Suite
12
+ ["Suite Name Error",exception.message]
13
+ when Kaya::Error::CucumberYML
14
+ ["No Cucumber file", exception.message]
15
+ else
16
+ message = "#{exception.message}#{exception.backtrace}"
17
+ ["Unknown Error", message]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+