cuke_sniffer 0.0.5 → 0.0.6

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.
Files changed (31) hide show
  1. data/bin/cuke_sniffer +85 -63
  2. data/lib/cuke_sniffer.rb +23 -16
  3. data/lib/cuke_sniffer/cli.rb +269 -523
  4. data/lib/cuke_sniffer/constants.rb +5 -2
  5. data/lib/cuke_sniffer/cuke_sniffer_helper.rb +165 -0
  6. data/lib/cuke_sniffer/dead_steps_helper.rb +54 -0
  7. data/lib/cuke_sniffer/feature.rb +13 -81
  8. data/lib/cuke_sniffer/feature_rules_evaluator.rb +56 -115
  9. data/lib/cuke_sniffer/formatter.rb +142 -0
  10. data/lib/cuke_sniffer/hook.rb +77 -160
  11. data/lib/cuke_sniffer/report/dead_steps.html.erb +36 -0
  12. data/lib/cuke_sniffer/report/features.html.erb +60 -0
  13. data/lib/cuke_sniffer/report/hooks.html.erb +49 -0
  14. data/lib/cuke_sniffer/report/improvement_list.html.erb +18 -0
  15. data/lib/cuke_sniffer/report/legend.html.erb +167 -0
  16. data/lib/cuke_sniffer/report/min_template.html.erb +125 -0
  17. data/lib/cuke_sniffer/report/rules.html.erb +9 -0
  18. data/lib/cuke_sniffer/report/standard_template.html.erb +137 -0
  19. data/lib/cuke_sniffer/report/step_definitions.html.erb +49 -0
  20. data/lib/cuke_sniffer/report/sub_rules.html.erb +24 -0
  21. data/lib/cuke_sniffer/report/summary.html.erb +71 -0
  22. data/lib/cuke_sniffer/rule.rb +28 -0
  23. data/lib/cuke_sniffer/rule_config.rb +241 -48
  24. data/lib/cuke_sniffer/rule_target.rb +62 -0
  25. data/lib/cuke_sniffer/rules_evaluator.rb +65 -70
  26. data/lib/cuke_sniffer/scenario.rb +102 -238
  27. data/lib/cuke_sniffer/step_definition.rb +163 -239
  28. data/lib/cuke_sniffer/summary_helper.rb +91 -0
  29. data/lib/cuke_sniffer/summary_node.rb +19 -0
  30. metadata +23 -5
  31. data/lib/cuke_sniffer/report/markup.rhtml +0 -353
@@ -0,0 +1,19 @@
1
+ require 'roxml'
2
+ module CukeSniffer
3
+
4
+ # Author:: Robert Cochran (mailto:cochrarj@miamioh.edu)
5
+ # Copyright:: Copyright (C) 2013 Robert Cochran
6
+ # License:: Distributes under the MIT License
7
+ # Single Summary Node object used for passing around results data and serializing out to xml
8
+ # Mixins: ROXML
9
+ class SummaryNode
10
+ include ROXML
11
+ xml_accessor :score
12
+ xml_accessor :count
13
+ xml_accessor :average
14
+ xml_accessor :good
15
+ xml_accessor :bad
16
+ xml_accessor :threshold
17
+ end # :nodoc:
18
+
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuke_sniffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-05-15 00:00:00.000000000 Z
14
+ date: 2013-08-17 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: roxml
@@ -36,20 +36,38 @@ executables:
36
36
  extensions: []
37
37
  extra_rdoc_files: []
38
38
  files:
39
+ - lib/cuke_sniffer/report/dead_steps.html.erb
40
+ - lib/cuke_sniffer/report/features.html.erb
41
+ - lib/cuke_sniffer/report/hooks.html.erb
42
+ - lib/cuke_sniffer/report/improvement_list.html.erb
43
+ - lib/cuke_sniffer/report/min_template.html.erb
44
+ - lib/cuke_sniffer/report/standard_template.html.erb
45
+ - lib/cuke_sniffer/report/rules.html.erb
46
+ - lib/cuke_sniffer/report/sub_rules.html.erb
47
+ - lib/cuke_sniffer/report/step_definitions.html.erb
48
+ - lib/cuke_sniffer/report/summary.html.erb
49
+ - lib/cuke_sniffer/report/legend.html.erb
39
50
  - lib/cuke_sniffer.rb
40
51
  - lib/cuke_sniffer/constants.rb
41
52
  - lib/cuke_sniffer/feature.rb
42
53
  - lib/cuke_sniffer/feature_rules_evaluator.rb
43
- - lib/cuke_sniffer/rules_evaluator.rb
54
+ - lib/cuke_sniffer/rule_target.rb
44
55
  - lib/cuke_sniffer/rule_config.rb
45
56
  - lib/cuke_sniffer/scenario.rb
46
57
  - lib/cuke_sniffer/step_definition.rb
47
- - lib/cuke_sniffer/report/markup.rhtml
58
+ - lib/cuke_sniffer/rule.rb
59
+ - lib/cuke_sniffer/formatter.rb
60
+ - lib/cuke_sniffer/summary_node.rb
61
+ - lib/cuke_sniffer/rules_evaluator.rb
62
+ - lib/cuke_sniffer/cuke_sniffer_helper.rb
63
+ - lib/cuke_sniffer/summary_helper.rb
64
+ - lib/cuke_sniffer/dead_steps_helper.rb
48
65
  - lib/cuke_sniffer/cli.rb
49
66
  - lib/cuke_sniffer/hook.rb
50
67
  - bin/cuke_sniffer
51
68
  homepage: https://github.com/r-cochran/cuke_sniffer
52
- licenses: []
69
+ licenses:
70
+ - MIT
53
71
  post_install_message:
54
72
  rdoc_options: []
55
73
  require_paths:
@@ -1,353 +0,0 @@
1
- <script>
2
- function toggleById(item, link) {
3
- updateDisplayStatus(document.getElementById(item));
4
- toggleText(link)
5
- }
6
- function updateDisplayStatus(object) {
7
- object.style.display = (object.style.display == "block") ? 'none' : "block";
8
- }
9
- function toggleText(link) {
10
- var char_result = link.innerHTML.indexOf("+") > -1 ? "-" : "+";
11
- link.innerHTML = link.innerHTML.replace(/(\+|\-)/, char_result)
12
- }
13
- </script>
14
- <style>
15
- .title {
16
- padding-left: 1%;
17
- width: 25%;
18
- background-color: green;
19
- color: white;
20
- border-top: 0;
21
- border-bottom: 0;
22
- font-weight: bold;
23
- font-size: 21pt;
24
- cursor: hand;
25
- }
26
-
27
- .shrink_section {
28
- border: 2px solid #90ee90;
29
- display: none;
30
- }
31
-
32
- .table_top {
33
- width: 20%;
34
- font-size: 14pt;
35
- padding: 0;
36
- }
37
-
38
- .divide_row {
39
- border-bottom: 1px solid black;
40
- }
41
-
42
- .red_number {
43
- width: 3%;
44
- color: red;
45
- text-indent: 1%;
46
- font-weight: bold;
47
- }
48
-
49
- .notes {
50
- text-indent: 1%;
51
- font-weight: bold;
52
- }
53
-
54
- .sub_section {
55
- display: none;
56
- margin-left: 1%;
57
- margin-right: 1%;
58
- border-top: 2px solid #add8e6;
59
- }
60
- </style>
61
-
62
-
63
- <div style="float: left; color: green; font-size: 20px; font-weight: bold; padding-bottom: 1px;">
64
- Cuke Sniffer
65
- </div>
66
- <br style="clear:both">
67
- <div style="border-top: 2px solid lightgreen; text-align: right;">
68
- <div style="float: right; background-color:green;border-right:2px solid #fff; color:white;padding:4px; padding-left:40px;font-size:11pt;font-weight:bold;padding-right:10px;">
69
- Score: <%= cuke_sniffer.summary[:total_score] %></div>
70
- </div>
71
- <br style="clear:both">
72
-
73
- <div class="title" onclick="toggleById('summary_data', this)">
74
- Summary -
75
- </div>
76
- <div class="shrink_section" style="display: block;" id="summary_data">
77
- <% data_symbols = [:features, :scenarios, :step_definitions, :hooks] %>
78
- <table style="width: 100%;" class="notes">
79
- <tr class="divide_row">
80
- <td class="table_top"></td>
81
- <td class="table_top">Features</td>
82
- <td class="table_top">Scenarios</td>
83
- <td class="table_top">Step Definitions</td>
84
- <td class="table_top">Hooks</td>
85
- </tr>
86
- <tr>
87
- <td>Total Score</td>
88
- <% data_symbols.each do |symbol| %>
89
- <td><%= cuke_sniffer.summary[symbol][:total_score] %></td>
90
- <% end %>
91
- </tr>
92
- <tr>
93
- <td>Count</td>
94
- <% data_symbols.each do |symbol| %>
95
- <td><%= cuke_sniffer.summary[symbol][:total].inspect %></td>
96
- <% end %>
97
- </tr>
98
- <tr/>
99
- <tr>
100
- <td>Lowest Score</td>
101
- <% data_symbols.each do |symbol| %>
102
- <td><%= cuke_sniffer.summary[symbol][:min] %></td>
103
- <% end %>
104
- </tr>
105
- <tr>
106
- <td>Highest Score</td>
107
- <% data_symbols.each do |symbol| %>
108
- <td><%= cuke_sniffer.summary[symbol][:max] %></td>
109
- <% end %>
110
- </tr>
111
- <tr>
112
- <td>Average Score</td>
113
- <% data_symbols.each do |symbol| %>
114
- <td><%= cuke_sniffer.summary[symbol][:average] %></td>
115
- <% end %>
116
- </tr>
117
- <tr/>
118
-
119
- <tr>
120
- <td>Threshold</td>
121
- <% data_symbols.each do |symbol| %>
122
- <td><%= cuke_sniffer.summary[symbol][:threshold] %></td>
123
- <% end %>
124
- </tr>
125
- <tr>
126
- <td>Good</td>
127
- <% data_symbols.each do |symbol| %>
128
- <td><%= ((cuke_sniffer.summary[symbol][:good].to_f/cuke_sniffer.summary[symbol][:total].to_f) * 100).round(2) %>
129
- %
130
- </td>
131
- <% end %>
132
- </tr>
133
- <tr>
134
- <td>Bad</td>
135
- <% data_symbols.each do |symbol| %>
136
- <td><%= ((cuke_sniffer.summary[symbol][:bad].to_f/cuke_sniffer.summary[symbol][:total].to_f) * 100).round(2) %>
137
- %
138
- </td>
139
- <% end %>
140
- </tr>
141
- </table>
142
- </div>
143
- <br style="clear:both">
144
-
145
- <div class="title" onclick="toggleById('improvement_list_data', this)">
146
- Improvement List +
147
- </div>
148
- <div class="shrink_section" id="improvement_list_data">
149
- <% if cuke_sniffer.summary[:improvement_list].empty? %>
150
- <div class="notes">No Improvements to make!</div>
151
- <% end %>
152
- <table style="width: 100%">
153
- <% cuke_sniffer.summary[:improvement_list].each do |improvement, count| %>
154
- <tr>
155
- <td class="red_number"><%= count %></td>
156
- <td class="notes"><%= improvement %></td>
157
- </tr>
158
- <% end %>
159
- </table>
160
- </div>
161
- <br style="clear:both">
162
-
163
- <div class="title" onclick="toggleById('dead_steps_data', this)">
164
- Dead Steps +
165
- </div>
166
- <div class="shrink_section" id="dead_steps_data">
167
- <% dead_steps = cuke_sniffer.get_dead_steps %>
168
- <% dead_steps.delete(:total) %>
169
- <% dead_step_count = dead_steps.values.flatten.count %>
170
- <% if dead_step_count == 0 %>
171
- <div class="notes">No dead steps found!</div>
172
- <% elsif dead_step_count == 1 %>
173
- <div class="notes" style="color: red"><%= dead_step_count %> Dead Step found.</div>
174
- <% else %>
175
- <div class="notes" style="color: red"><%= dead_step_count %> Dead Steps found.</div>
176
- <% end %>
177
-
178
- <table style="width: 100%">
179
- <% dead_steps.each_key do |file_name| %>
180
- <tr>
181
- <td>
182
- <div style="text-indent: 2%;font-weight: bold;"><%= file_name.gsub(cuke_sniffer.step_definitions_location, "") %>
183
- .rb
184
- </div>
185
- <table style="width: 100%; padding-left: 3%;">
186
- <% dead_steps[file_name].each do |regex| %>
187
- <tr>
188
- <td style="width: 3%"><%= regex.match(/(?<line>\d+):/)[:line] %></td>
189
- <td><%= regex.match(/:(?<regex>.*)/)[:regex] %></td>
190
- </tr>
191
- <% end %>
192
- </table>
193
- </td>
194
- </tr>
195
- <% end %>
196
- </table>
197
- </div>
198
- <br style="clear:both">
199
-
200
- <div class="title" onclick="toggleById('features_data', this)">
201
- Features +
202
- </div>
203
- <div class="shrink_section" id="features_data">
204
- <% if cuke_sniffer.features.count == 0 %>
205
- <div class="notes">No Feature/Scenario smells!</div>
206
- <% end %>
207
- <% index = 0 %>
208
- <% cuke_sniffer.features.each do |feature| %>
209
- <% next if feature.total_score <= 0 %>
210
- <div style="cursor: hand; padding-top: 3px" onclick="updateDisplayStatus(document.getElementById('feature_<%=index%>'))">
211
- <div class="red_number" style="float:left"><%= feature.total_score + feature.scenarios_score %></div>
212
- <div class="notes"><%= feature.name %></div>
213
- </div>
214
- <div id="feature_<%= index %>" class="sub_section">
215
- <div style="text-indent: 4%; float: left; width: 45%; border-right: 2px solid #add8e6; padding-bottom: 4px">
216
- <% if feature.rules_hash.empty? %>
217
- <pre style="margin: 0;"> </pre>
218
- <% end %>
219
- <% feature.rules_hash.each_key do |rule| %>
220
- <pre style="margin: 0;"><%= rule %></pre>
221
- <% end %>
222
- </div>
223
- <div style="text-indent: 1%; padding-bottom: 4px">
224
- <%= feature.location.gsub(cuke_sniffer.features_location, "") %>
225
- </div>
226
- <br style="clear:both">
227
-
228
- <div>
229
- <% unless feature.background.nil? or feature.background.score > 0 %>
230
- <div class="red_number" style="float:left; padding-left: 1%"><%= feature.background.score %></div>
231
- <div style="float: left; width: 45%;"><%= feature.background.type + ": " + feature.background.name %></div>
232
- <div style="margin-left:1%;float: left; border-left: 2px solid #90ee90; border-top: 2px solid #90ee90;text-indent: 1%;">
233
- <% feature.background.rules_hash.each_key do |rule| %>
234
- <pre style="margin: 0; text_indent: 3%;"><%= rule %></pre>
235
- <% end %>
236
- </div>
237
- <br style="clear:both">
238
- <% end %>
239
- </div>
240
- <div>
241
- <% feature.scenarios.each do |scenario| %>
242
- <% next if scenario.score <= 0 %>
243
- <div class="red_number" style="float:left; padding-left: 1%"><%= scenario.score %></div>
244
- <div style="float: left; width: 45%;"><%= scenario.type + ": " + scenario.name %></div>
245
- <div style="margin-left:1%;float: left; border-left: 2px solid #90ee90; border-top: 2px solid #90ee90; text-indent: 1%">
246
- <% scenario.rules_hash.each_key do |rule| %>
247
- <pre style="margin: 0; text_indent: 3%;"><%= rule %></pre>
248
- <% end %>
249
- </div>
250
- <br style="clear:both">
251
- <% end %>
252
- </div>
253
- </div>
254
- <% index += 1 %>
255
- <% end %>
256
- </div>
257
- <br style="clear:both">
258
-
259
- <div class="title" onclick="toggleById('step_definitions_data', this)">
260
- Step Definitions +
261
- </div>
262
- <div class="shrink_section" id="step_definitions_data">
263
- <% if cuke_sniffer.step_definitions.count == 0 %>
264
- <div class="notes">No Step Definition smells!</div>
265
- <% end %>
266
- <% index = 0 %>
267
- <% cuke_sniffer.step_definitions.each do |step_definition| %>
268
- <% next if step_definition.score <= 0 %>
269
- <div style="cursor: hand; padding-top: 3px" onclick="updateDisplayStatus(document.getElementById('step_definition_<%=index%>'))">
270
- <div class="red_number" style="float:left"><%= step_definition.score %></div>
271
- <% parameters = "" %>
272
- <% step_definition.parameters.each do |param| %>
273
- <% if param == step_definition.parameters.first %>
274
- <% parameters << "| " %>
275
- <% end %>
276
- <% parameters << param %>
277
-
278
- <% if param == step_definition.parameters.last %>
279
- <% parameters << " |" %>
280
- <% else %>
281
- <% parameters << ", " %>
282
- <% end %>
283
- <% end %>
284
- <div style="float: left" class="notes"><%= "/" + step_definition.regex.to_s.match(/\(\?\-mix\:(?<regex>.*)\)/)[:regex] + "/ do " + parameters %></div>
285
- <div style="float: right; padding-right:1%" class="notes"><%= step_definition.calls.keys.count %> Call(s)</div>
286
- </div>
287
- <div id="step_definition_<%= index %>" style="display:none;">
288
- <br style="clear:both">
289
-
290
- <div class="sub_section" style="display:block">
291
- <div style="text-indent: 4%; float: left; width: 45%; border-right: 2px solid #add8e6;">
292
- <% step_definition.rules_hash.each_key do |rule| %>
293
- <pre style="margin: 0;"><%= rule %></pre>
294
- <% end %>
295
- </div>
296
- <div style="text-indent: 1%">
297
- <p style="margin:0"><%= step_definition.location.gsub(cuke_sniffer.step_definitions_location, "") %></p>
298
- </div>
299
- </div>
300
- </div>
301
- <br style="clear:both">
302
- <% index += 1 %>
303
- <% end %>
304
- </div>
305
- <br style="clear:both">
306
-
307
- <div class="title" onclick="toggleById('hooks_data', this)">
308
- Hooks +
309
- </div>
310
- <div class="shrink_section" id="hooks_data">
311
- <% if cuke_sniffer.hooks.count == 0 %>
312
- <div class="notes">No Hook smells!</div>
313
- <% end %>
314
- <% index = 0 %>
315
- <% cuke_sniffer.hooks.each do |hook| %>
316
- <% next if hook.score <= 0 %>
317
- <div style="cursor: hand; padding-top: 3px" onclick="updateDisplayStatus(document.getElementById('hook_<%=index%>'))">
318
- <div class="red_number" style="float:left"><%= hook.score %></div>
319
- <% tags = "(" %>
320
- <% hook.tags.each do |tag| %>
321
- <% tags << tag %>
322
- <% tags << ", " unless tag == hook.tags.last %>
323
- <% end %>
324
- <% tags += ")" %>
325
- <% parameters = "| " %>
326
- <% hook.parameters.each do |parameter| %>
327
- <% parameters << parameter %>
328
- <% parameters << ", " unless parameter == hook.parameters.last %>
329
- <% end %>
330
- <% parameters += " |" %>
331
- <% name = hook.type %>
332
- <% name += tags unless tags == "()" %>
333
- <% name += " do " %>
334
- <% name += parameters unless parameters == "| |" %>
335
- <div class="notes"><%= name %></div>
336
- </div>
337
- <div id="hook_<%= index %>" style="display:none;">
338
- <div class="sub_section" style="display:block;">
339
- <div style="text-indent: 4%; float: left; width: 45%; border-right: 2px solid #add8e6;">
340
- <% hook.rules_hash.each_key do |rule| %>
341
- <pre style="margin: 0;"><%= rule %></pre>
342
- <% end %>
343
- </div>
344
- <div style="text-indent: 1%">
345
- <%= hook.location.gsub(cuke_sniffer.hooks_location, "") %>
346
- </div>
347
- <br style="clear:both">
348
- </div>
349
- </div>
350
- <% index += 1 %>
351
- <% end %>
352
- </div>
353
- <br style="clear:both">