kaya 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1c3119c8bbaa8212c7affae2b171fc8e32e01f3
4
- data.tar.gz: 55b705e678b261d38f7ea741180b5b01e01274a3
3
+ metadata.gz: 45359e9ff9bad0618df21686ea9caddc36cda396
4
+ data.tar.gz: edf1cc2eb78c5329fd8c7d5ee1ee969362152940
5
5
  SHA512:
6
- metadata.gz: c37613be82d5a81612a4a267a686cf6067991320916742dbc53c490753b4c70cd69ee2c8cfa816ee55cd8b247bad2e3bee107ef2fc65ffefde79b0eb5e2f808c
7
- data.tar.gz: deb237fe0d85e804eaf970c65773605845363e1db8602aed621197e462a5bd9302d86a0bf1d31199c553ffba7f2fda562f6e8a3f250a0173040e6a91d663f7bc
6
+ metadata.gz: b99f3101952241a2f6dffc3d9d32f63f4a31a92a4338d0dcbb55fddb2c5f1e618473bcf04e23f8c9181cec88396247c4b8157c8163322ce54b715a7160fdee80
7
+ data.tar.gz: fd96a85d144aba666260257ff6246bf14167f4df18caae840edd03033e8b2a49a54c4e8b82d75dd6057f5b93fd35965399c360d07e6d1861ba1a4f9f61d15567
data/README.md CHANGED
@@ -81,92 +81,69 @@ Reference about configuration
81
81
 
82
82
  kaya/kaya_conf file reference:
83
83
 
84
- {
85
-
86
- "USE_GIT" : true,
87
-
88
- "HOSTNAME" : "your-host-name",
89
-
90
- "APP_PORT" : 8080,
91
-
92
- "DATABASE" : {
93
-
84
+ {
85
+ "USE_GIT" : true,
86
+ "HOSTNAME" : "your-host-name",
87
+ "APP_PORT" : 8080,
88
+ "DATABASE" : {
94
89
  "TYPE" : "mongodb",
95
90
  "HOST" :"localhost",
96
91
  "PORT" : 27017,
97
92
  "USERNAME" : null,
98
93
  "PASSWORD" : null},
99
-
100
- "PROJECT_NAME" : "Awesome Project",
101
-
102
- "PROJECT_URL" : "http://your.project.url",
103
-
104
- "INACTIVITY_TIMEOUT" : 60,
105
-
106
- "KILL_INACTIVE_EXECUTIONS_AFTER" : 300,
107
-
108
- "FORMAT_DATETIME" : "%d/%m/%Y %H:%M:%S",
109
-
110
- "REFRESH_TIME" : 10,
111
-
112
- "NOTIFICATION" : {
94
+ "PROJECT_NAME" : "Awesome Project",
95
+ "PROJECT_URL" : "http://your.project.url",
96
+ "INACTIVITY_TIMEOUT" : 60,
97
+ "KILL_INACTIVE_EXECUTIONS_AFTER" : 300,
98
+ "FORMAT_DATETIME" : "%d/%m/%Y %H:%M:%S",
99
+ "REFRESH_TIME" : 10,
100
+ "NOTIFICATION" : {
113
101
  "USE_GMAIL" : false,
114
102
  "USERNAME" : null,
115
103
  "PASSWORD" : null,
116
104
  "RECIPIENTS" : "your@email.com",
117
105
  "ATTACH_REPORT" : false
118
- },
119
-
120
- "FOOTER" : "Tests by a great and funny team",
121
-
122
- "AUTO_EXECUTION_ID" : {
106
+ },
107
+ "FOOTER" : "Tests by a great and funny team",
108
+ "AUTO_EXECUTION_ID" : {
123
109
  "datetime" : true,
124
110
  "format" : "%d%^b%y-%H%M",
125
111
  "default" : null
126
- },
127
-
128
- "HEADLESS" : {
112
+ },
113
+ "HEADLESS" : {
129
114
  "active" : false,
130
115
  "resolution" : "1024x768",
131
116
  "size":"24"}
132
- }
133
-
134
-
135
-
136
-
117
+ }
137
118
 
138
119
  This file is where you can configure:
139
120
 
140
- "USE_GIT": (Boolean) set as true if you are using git
141
-
142
- "MONGO_HOST" : (String) The host where mongodb is running
143
-
144
- "APP_PORT" : (Fixnum/Int) The http port that Kaya will be listening
145
-
146
- "PROJECT_NAME" : (String) The name of your Cucumber project
121
+ "USE_GIT": (Boolean) set as true if you are using git
147
122
 
148
- "PROJECT_URL" : (String) The url of your project (basically the url of the repository)
123
+ "MONGO_HOST" : (String) The host where mongodb is running
149
124
 
150
- "INACTIVITY_TIMEOUT" : (Fixnum/Int) The time in seconds to consider an execution as inactive. This will show you the option to reset an inactive execution
125
+ "APP_PORT" : (Fixnum/Int) The http port that Kaya will be listening
151
126
 
152
- "KILL_INACTIVE_EXECUTIONS_AFTER" : (Fixnum/Int) The time in seconds to wait for killing automatically those inactive executions
127
+ "PROJECT_NAME" : (String) The name of your Cucumber project
153
128
 
154
- "FORMAT_DATETIME" : "%d/%m/%Y %H:%M:%S"
129
+ "PROJECT_URL" : (String) The url of your project (basically the url of the repository)
155
130
 
156
- "REFRESH_TIME" : (Fixnum/Int) The time in seconds to refresh result window in console view
131
+ "INACTIVITY_TIMEOUT" : (Fixnum/Int) The time in seconds to consider an execution as inactive. This will show you the option to reset an inactive execution
157
132
 
158
- "NOTIFICATION" : (Boolean) This is a flag to use notifications through gmail service. You should have a gmail account to use it.
133
+ "KILL_INACTIVE_EXECUTIONS_AFTER" : (Fixnum/Int) The time in seconds to wait for killing automatically those inactive executions
159
134
 
160
- "FOOTER" : (String) A text you want to see at the footer like "Tests by a great team (team_name@domain.com"
135
+ "FORMAT_DATETIME" : "%d/%m/%Y %H:%M:%S"
161
136
 
162
- "AUTO_EXECUTION_ID" : (JSON) If you want to use a simple execution id given by the actual time you can set the value of "datetime" to true (Boolean), with this option you can use a strftime format and it will put the execution id automatically.
163
- If you set "datetime" to false (Boolean) you can use "default" value. Setting "datetime" as false and "default" as null you will have to (if you need it) set the execution id manually each time you run a suite.
164
-
165
- "HEADLESS" (JSON) : Set active as true to use headless mode
137
+ "REFRESH_TIME" : (Fixnum/Int) The time in seconds to refresh result window in console view
166
138
 
139
+ "NOTIFICATION" : (Boolean) This is a flag to use notifications through gmail service. You should have a gmail account to use it.
167
140
 
141
+ "FOOTER" : (String) A text you want to see at the footer like "Tests by a great team (team_name@domain.com"
168
142
 
143
+ "AUTO_EXECUTION_ID" : (JSON) If you want to use a simple execution id given by the actual time you can set the value of "datetime" to true (Boolean), with this option you can use a strftime format and it will put the execution id automatically.
144
+ If you set "datetime" to false (Boolean) you can use "default" value. Setting "datetime" as false and "default" as null you will have to (if you need it) set the execution id manually each time you run a suite.
169
145
 
146
+ "HEADLESS" (JSON) : Set active as true to use headless mode
170
147
 
171
148
 
172
149
  Available Commands
@@ -197,8 +174,6 @@ Available Commands
197
174
  $ kaya restart
198
175
 
199
176
 
200
-
201
-
202
177
  Get (what you need!)
203
178
  ---------------------
204
179
 
@@ -217,8 +192,6 @@ Get (what you need!)
217
192
  - /kaya/help
218
193
 
219
194
 
220
-
221
-
222
195
  Tip
223
196
  ---------------------
224
197
 
@@ -256,16 +229,9 @@ Returns the result for a given result id
256
229
 
257
230
  kaya/api/results/<result_id>
258
231
 
232
+ Returns the data you've added to result from execution
259
233
 
260
-
261
-
262
-
263
- Kaya
264
- ---------------------
265
-
266
- [listen](https://www.youtube.com/watch?v=Zgww4QtntnQ "Kaya")
267
-
268
- [listen](https://www.youtube.com/watch?v=4t7ghwxuUVo "Kaya")
234
+ kaya/api/results/<result_id>/data
269
235
 
270
236
 
271
237
 
data/kaya.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["roman.g.rodriguez@gmail.com"]
11
11
  spec.summary = %q{Exposes Cucumber suites in a web service to make them run}
12
12
  spec.description = %q{You can run your cucumber suites easily, save and see the execution results}
13
- spec.homepage = "http://qqq.akjsdh"
13
+ spec.homepage = "https://github.com/romgrod/kaya"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.0.0"
16
16
 
data/lib/kaya/cuba.rb CHANGED
@@ -112,7 +112,6 @@ Cuba.define do
112
112
 
113
113
  on "#{HOSTNAME}/kaya/suites" do
114
114
  query_string = Kaya::Support::QueryString.new req
115
- (Kaya::Support::Git.reset_hard and Kaya::Support::Git.pull) if Kaya::Support::Configuration.use_git?
116
115
  Kaya::Suites.update_suites
117
116
  template = Mote.parse(File.read("#{Kaya::View.path}/body.mote"),self, [:section, :query_string, :suite_name, :log_name])
118
117
  res.write template.call(section:"Test Suites", query_string:query_string, suite_name:nil, log_name:nil)
@@ -7,33 +7,57 @@ module Kaya
7
7
  include Mongo
8
8
 
9
9
  def initialize(opts={host: "localhost", port: 27017, username: nil, pass: nil})
10
+ set_db_name
11
+ set_client(opts)
12
+ set_db
13
+ authenticate(opts)
14
+ set_suite_collection
15
+ set_results_collection
16
+ set_commits_collection
17
+ set_documentation_collection
18
+ end
10
19
 
20
+ def set_db_name
11
21
  project_name = Dir.pwd.split("/").last
12
22
  @@db_name = "#{project_name}_kaya"
23
+ end
13
24
 
25
+ def set_client opts
14
26
  @@client = MongoClient.new(opts[:host], opts[:port])
27
+ end
15
28
 
29
+ def set_db
30
+ @@db = @@client.db(@@db_name)
31
+ end
16
32
 
17
- @@db = @@client.db(@@db_name)
33
+ def authenticate opts
18
34
  @@auth = @@db.authenticate(opts[:username], opts[:pass]) if opts[:username] and opts[:pass]
35
+ end
19
36
 
37
+ def set_suite_collection
20
38
  @@suites = @@db.collection("suites")
21
39
  @@suites.ensure_index({"last_result" => 1})
40
+ end
22
41
 
42
+ def set_commits_collection
43
+ @@commits = @@db.collection("commits")
44
+ end
45
+
46
+ def set_results_collection
23
47
  @@results = @@db.collection("results")
24
48
  @@results.ensure_index({"_id" => 1})
25
49
  @@results.ensure_index({"started_at" => 1, "_id" => 1})
50
+ end
26
51
 
52
+ def set_documentation_collection
27
53
  @@documentation = @@db.collection("documentation")
28
54
  end
29
55
 
30
- def self.connected?
31
- begin
32
- @@db and true
33
- rescue
34
- false
35
- end
36
- end
56
+
57
+ ##########################
58
+ # DOCUMENTATION
59
+ #
60
+ #
37
61
 
38
62
  # Removes all documents of documentation from the DB
39
63
  def self.clean_documentation
@@ -67,6 +91,20 @@ module Kaya
67
91
  @@documentation.find({:$or => [{ "title" => /#{title}/ },{ "title" => /#{title.upcase}/ },{ "body" => /#{title}/ }]}).to_a
68
92
  end
69
93
 
94
+
95
+ ###########################
96
+ # COMMONS
97
+ #
98
+ #
99
+
100
+ def self.connected?
101
+ begin
102
+ @@db and true
103
+ rescue
104
+ false
105
+ end
106
+ end
107
+
70
108
  def self.generate_id
71
109
  Time.now.to_f.to_s.gsub( ".","")[0..12].to_i
72
110
  end
@@ -88,58 +126,80 @@ module Kaya
88
126
  MongoClient.new().db(@@db_name)
89
127
  end
90
128
 
91
- # Update suites collection with suites that comes from cucumber.yml file
92
- # All given suites will be active. Others will be deactivated
93
- # @param [Hash] cucumber_yml_suites
94
- def self.update_suites cucumber_yml_suites
95
129
 
96
- existing_suites = self.suites
130
+ ##################################
131
+ # COMMITS
132
+ #
133
+ #
97
134
 
98
- existing_suites_name_list = existing_suites.map{|suite| suite["name"]}
99
135
 
100
- cucumber_yml_suites.each_with_index do |cucumber_suite, index|
136
+ # Saves commit information
137
+ # @param [Hash] commit_info = {"_id" => Fixnum, "commit_id" => String, "info" => String}
138
+ def self.insert_commit commit_info
139
+ @@commits.insert({"_id" => self.generate_id, "log" => commit_info})
140
+ end
101
141
 
102
- suite_data = existing_suites.select{|suite| suite["name"]==cucumber_suite["name"]}.first
142
+ # Returns last saved commit info
143
+ # @return [Hash] if exist
144
+ def self.last_commit
145
+ data = @@commits.find({}).to_a.first
146
+ data["log"] if data
147
+ end
103
148
 
104
- # if exist, so update it, else creates a new one
105
- if suite_data
106
- #Delete it from list and update it
107
- existing_suites.delete(suite_data)
108
- suite_data["command"] = cucumber_suite["command"]
109
- suite_data["custom"] = cucumber_suite["custom"]
110
- suite_data["active"] = true
111
- suite_data["index"] = index
149
+ ##################################
150
+ # SUITES
151
+ #
152
+ #
112
153
 
113
- # Updates register with new data
114
- self.update_suite(suite_data)
115
- print "UPDATED: #{suite_data['_id']}\n\n"
116
- else
117
- # Creates a new one
118
- suite_data = self.suite_data_structure
119
- suite_data["name"] = cucumber_suite["name"]
120
- suite_data["command"] = cucumber_suite["command"]
121
- suite_data["custom"] = cucumber_suite["custom"]
122
- suite_data["branch"] = Kaya::Support::Git.actual_branch
154
+ # # Update suites collection with suites that comes from cucumber.yml file
155
+ # # All given suites will be active. Others will be deactivated
156
+ # # @param [Hash] cucumber_yml_suites
157
+ # def self.update_suites cucumber_yml_suites
123
158
 
124
- # Saves register with new data
125
- id = self.insert_suite(suite_data)
159
+ # existing_suites = self.suites
126
160
 
127
- print "INSERTED: #{id}\n\n"
161
+ # existing_suites_name_list = existing_suites.map{|suite| suite["name"]}
128
162
 
129
- end
163
+ # cucumber_yml_suites.each_with_index do |cucumber_suite, index|
130
164
 
165
+ # suite_data = existing_suites.select{|suite| suite["name"]==cucumber_suite["name"]}.first
131
166
 
132
- end
167
+ # # if exist, so update it, else creates a new one
168
+ # if suite_data
169
+ # #Delete it from list and update it
170
+ # existing_suites.delete(suite_data)
171
+ # suite_data["command"] = cucumber_suite["command"]
172
+ # suite_data["custom"] = cucumber_suite["custom"]
173
+ # suite_data["active"] = true
174
+ # suite_data["index"] = index
133
175
 
134
- # If at least one existing suite isn't con cucumber yml file, so deactivate them
135
- unless existing_suites.empty?
136
- existing_suites.each do |suite|
176
+ # # Updates register with new data
177
+ # self.update_suite(suite_data)
178
+ # print "UPDATED: #{suite_data['_id']}\n\n"
179
+ # else
180
+ # # Creates a new one
181
+ # suite_data = self.suite_data_structure
182
+ # suite_data["name"] = cucumber_suite["name"]
183
+ # suite_data["command"] = cucumber_suite["command"]
184
+ # suite_data["custom"] = cucumber_suite["custom"]
185
+ # suite_data["branch"] = Kaya::Support::Git.actual_branch
137
186
 
138
- print "DEACTIVATED: #{suite['_id']}\n\n"
139
- deactivate_suite(suite["_id"])
140
- end
141
- end
142
- end
187
+ # # Saves register with new data
188
+ # id = self.insert_suite(suite_data)
189
+
190
+ # print "INSERTED: #{id}\n\n"
191
+ # end
192
+ # end
193
+
194
+ # # If at least one existing suite isn't con cucumber yml file, so deactivate them
195
+ # unless existing_suites.empty?
196
+ # existing_suites.each do |suite|
197
+
198
+ # print "DEACTIVATED: #{suite['_id']}\n\n"
199
+ # deactivate_suite(suite["_id"])
200
+ # end
201
+ # end
202
+ # end
143
203
 
144
204
 
145
205
  # Inserts a suite in suites collection
@@ -148,7 +208,6 @@ module Kaya
148
208
  @@suites.insert(suite_data)
149
209
  end
150
210
 
151
-
152
211
  # Update record for a given suite
153
212
  # @param [Hash] suite_data
154
213
  def self.update_suite suite_data
@@ -192,8 +251,10 @@ module Kaya
192
251
 
193
252
 
194
253
 
195
-
196
- # RESULTS COLLECTION METHODS
254
+ ######################################3
255
+ # RESULTS
256
+ #
257
+ #
197
258
 
198
259
  # Creates a result data andc
199
260
  # returns de id for that register
@@ -51,6 +51,24 @@ module Kaya
51
51
  end
52
52
 
53
53
  def self.update_suites
54
+
55
+ if Kaya::Support::Configuration.use_git?
56
+ last_saved_commit = Kaya::Database::MongoConnector.last_commit
57
+ last_repo_commit = Kaya::Support::Git.last_commit
58
+ if last_saved_commit.nil? or (last_saved_commit != last_repo_commit)
59
+ Kaya::Support::Git.reset_hard
60
+ Kaya::Support::Git.pull
61
+ self.update!
62
+ Kaya::Database::MongoConnector.insert_commit(last_repo_commit)
63
+ else
64
+ $K_LOG.debug "No git changes!"
65
+ end
66
+ else
67
+ self.update!
68
+ end
69
+ end
70
+
71
+ def self.update!
54
72
  $K_LOG.debug "Updating suites" if $K_LOG
55
73
  existing_suites_ids = self.suite_ids
56
74
 
@@ -136,6 +136,56 @@ module Kaya
136
136
  "Commit: #{self.commits.first}"
137
137
  end
138
138
 
139
+ def self.last_commit
140
+ self.commits.first
141
+ end
142
+
143
+ # # Returns information about commit
144
+ # # @return [Hash]
145
+ # # {
146
+ # # "_id":Fixnum,
147
+ # # "commit_id":Fixnum,
148
+ # # "author":String,
149
+ # # "date":String,
150
+ # # "message":String
151
+ # # }
152
+ # def self.last_commit_info
153
+ # commits = self.log
154
+ # last_commit_raw = commits.split("\n\ncommit ").first.split("\n")
155
+ # {
156
+ # "_id" => self.generate_id,
157
+ # "commit_id" => self.extract_id(last_commit_raw),
158
+ # "author" => self.extract_author(last_commit_raw),
159
+ # "date" => self.extract_date(last_commit_raw),
160
+ # "message" => self.extract_message(last_commit_raw)
161
+ # }
162
+ # end
163
+
164
+ # def self.last_commit_id
165
+ # self.last_commit_info["commit_id"]
166
+ # end
167
+
168
+ # # returns commit id
169
+ # # @return [String] commit
170
+ # def self.extract_id commit_info
171
+ # commit_id = commit_info.select{|line| line.start_with? "commit "}.first
172
+ # commit_id.split(" ").last
173
+ # end
174
+
175
+ # def self.extract_author commit_info
176
+ # author = commit_info.select{|line| line.start_with? "Author: " }
177
+ # author.first.split("Author: ").last
178
+ # end
179
+
180
+ # def self.extract_date commit_info
181
+ # date = commit_info.select{|line| line.start_with? "Date: "}.first
182
+ # date.split(" ").last
183
+ # end
184
+
185
+ # def self.extract_message commit_info
186
+ # info = commit_info.last
187
+ # end
188
+
139
189
  def self.is_there_commit_id_diff? obtained_commit
140
190
  obtained_commit != self.last_commit_id
141
191
  end
data/lib/kaya/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaya
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -25,11 +25,16 @@
25
25
  end
26
26
  end
27
27
 
28
+
28
29
  results_size_text = if (key or status)
29
30
  "#{results_list.size} result#{'s' if results_list.size>1} found"
30
31
  else
31
- "Showing #{results_list.size} results."
32
+ total_of_results = results_list.size
33
+ results_list = results_list[0..19] if total_of_results > 20
34
+ "Showing #{results_list.size} results of #{total_of_results}."
32
35
  end
36
+
37
+
33
38
  ?>
34
39
 
35
40
  <div class='well'>
@@ -1,5 +1,5 @@
1
1
  % suites_list = Kaya::API::Suites.list({})
2
- % $K_LOG.error "results.mote suite_name=#{suite_name}" if $K_LOG
2
+ % $K_LOG.debug "Results for suite name #{suite_name}" if $K_LOG and suite_name
3
3
  % unless suites_list["suites"].empty?
4
4
  % suites_list["suites"].select!{|suite| suite["name"]==suite_name} if suite_name
5
5
  % suites_list["suites"].each do |suite|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-19 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -351,7 +351,7 @@ files:
351
351
  - lib/kaya/view/view.rb
352
352
  - test/features/install.feature
353
353
  - test/features/support/env.rb
354
- homepage: http://qqq.akjsdh
354
+ homepage: https://github.com/romgrod/kaya
355
355
  licenses:
356
356
  - MIT
357
357
  metadata: {}