yard-gherkin-turnip 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +3 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.yardopts +1 -0
  7. data/Gemfile +6 -0
  8. data/Gemfile.lock +48 -0
  9. data/History.txt +293 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +182 -0
  12. data/Rakefile +24 -0
  13. data/example/README.md +8 -0
  14. data/example/child_feature/README.md +21 -0
  15. data/example/child_feature/child.feature +11 -0
  16. data/example/child_feature/grandchild_feature/grandchild.feature +12 -0
  17. data/example/empty.feature +2 -0
  18. data/example/placeholder.feature +34 -0
  19. data/example/scenario.feature +63 -0
  20. data/example/scenario_outline.feature +100 -0
  21. data/example/scenario_outline_multi.feature +15 -0
  22. data/example/step_definitions/customer.step.rb +16 -0
  23. data/example/step_definitions/duck.step.rb +6 -0
  24. data/example/step_definitions/placeholder.step.rb +70 -0
  25. data/example/step_definitions/text.step.rb +11 -0
  26. data/example/tags.feature +18 -0
  27. data/lib/cucumber/city_builder.rb +412 -0
  28. data/lib/docserver/default/fulldoc/html/js/cucumber.js +88 -0
  29. data/lib/docserver/default/layout/html/headers.erb +13 -0
  30. data/lib/docserver/doc_server/full_list/html/full_list.erb +39 -0
  31. data/lib/docserver/doc_server/full_list/html/setup.rb +18 -0
  32. data/lib/templates/default/feature/html/feature.erb +39 -0
  33. data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
  34. data/lib/templates/default/feature/html/outline.erb +59 -0
  35. data/lib/templates/default/feature/html/pystring.erb +3 -0
  36. data/lib/templates/default/feature/html/scenario.erb +55 -0
  37. data/lib/templates/default/feature/html/setup.rb +54 -0
  38. data/lib/templates/default/feature/html/steps.erb +39 -0
  39. data/lib/templates/default/feature/html/table.erb +20 -0
  40. data/lib/templates/default/featuredirectory/html/alpha_table.erb +30 -0
  41. data/lib/templates/default/featuredirectory/html/directory.erb +32 -0
  42. data/lib/templates/default/featuredirectory/html/setup.rb +41 -0
  43. data/lib/templates/default/featuretags/html/namespace.erb +159 -0
  44. data/lib/templates/default/featuretags/html/setup.rb +34 -0
  45. data/lib/templates/default/fulldoc/html/css/cucumber.css +226 -0
  46. data/lib/templates/default/fulldoc/html/directories.erb +27 -0
  47. data/lib/templates/default/fulldoc/html/full_list_featuredirectories.erb +11 -0
  48. data/lib/templates/default/fulldoc/html/full_list_features.erb +37 -0
  49. data/lib/templates/default/fulldoc/html/full_list_stepdefinitions.erb +20 -0
  50. data/lib/templates/default/fulldoc/html/full_list_steps.erb +20 -0
  51. data/lib/templates/default/fulldoc/html/full_list_tags.erb +16 -0
  52. data/lib/templates/default/fulldoc/html/js/cucumber.js +331 -0
  53. data/lib/templates/default/fulldoc/html/setup.rb +208 -0
  54. data/lib/templates/default/layout/html/setup.rb +131 -0
  55. data/lib/templates/default/requirements/html/alpha_table.erb +26 -0
  56. data/lib/templates/default/requirements/html/requirements.erb +50 -0
  57. data/lib/templates/default/requirements/html/setup.rb +51 -0
  58. data/lib/templates/default/steptransformers/html/header.erb +12 -0
  59. data/lib/templates/default/steptransformers/html/index.erb +10 -0
  60. data/lib/templates/default/steptransformers/html/placeholders.erb +79 -0
  61. data/lib/templates/default/steptransformers/html/setup.rb +107 -0
  62. data/lib/templates/default/steptransformers/html/step_definitions.erb +79 -0
  63. data/lib/templates/default/steptransformers/html/undefined_steps.erb +26 -0
  64. data/lib/templates/default/tag/html/alpha_table.erb +33 -0
  65. data/lib/templates/default/tag/html/setup.rb +27 -0
  66. data/lib/templates/default/tag/html/tag.erb +35 -0
  67. data/lib/yard-gherkin-turnip.rb +42 -0
  68. data/lib/yard-gherkin-turnip/version.rb +3 -0
  69. data/lib/yard/code_objects/cucumber/base.rb +24 -0
  70. data/lib/yard/code_objects/cucumber/feature.rb +16 -0
  71. data/lib/yard/code_objects/cucumber/namespace_object.rb +55 -0
  72. data/lib/yard/code_objects/cucumber/scenario.rb +22 -0
  73. data/lib/yard/code_objects/cucumber/scenario_outline.rb +68 -0
  74. data/lib/yard/code_objects/cucumber/step.rb +46 -0
  75. data/lib/yard/code_objects/cucumber/tag.rb +31 -0
  76. data/lib/yard/code_objects/placeholder.rb +45 -0
  77. data/lib/yard/code_objects/step_definition.rb +46 -0
  78. data/lib/yard/code_objects/step_transformer.rb +32 -0
  79. data/lib/yard/handlers/cucumber/base.rb +21 -0
  80. data/lib/yard/handlers/cucumber/feature_handler.rb +96 -0
  81. data/lib/yard/handlers/placeholder_handler.rb +28 -0
  82. data/lib/yard/handlers/placeholder_match_handler.rb +17 -0
  83. data/lib/yard/handlers/step_definition_handler.rb +55 -0
  84. data/lib/yard/parser/cucumber/feature.rb +72 -0
  85. data/lib/yard/server/adapter.rb +43 -0
  86. data/lib/yard/server/commands/list_command.rb +31 -0
  87. data/lib/yard/server/router.rb +31 -0
  88. data/lib/yard/templates/helpers/base_helper.rb +26 -0
  89. data/yard-gherkin-turnip.gemspec +67 -0
  90. metadata +216 -0
@@ -0,0 +1,27 @@
1
+ <% @row = @row == 'even' ? 'odd' : 'even' %>
2
+ <% if @directory.children %>
3
+ <ul>
4
+ <% @directory.children.sort {|x,y| x.value.to_s <=> y.value.to_s }.each_with_index do |child,index| %>
5
+ <% if child.is_a?(YARD::CodeObjects::Cucumber::Feature) %>
6
+ <li class="<%= @row %>">
7
+ <div class="item" style="padding-left: <%= @padding %>px">
8
+ <%= linkify child, child.value %>
9
+ <small><%= child.location %></small>
10
+ </div>
11
+ </li>
12
+ <% @row = @row == 'even' ? 'odd' : 'even' %>
13
+ <% end %>
14
+
15
+ <% if child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory) %>
16
+ <li class="<%= @row %>">
17
+ <div class="item" style="padding-left: <%= @padding %>px">
18
+ <%= "<a class='toggle'></a>" unless child.features.empty? && child.subdirectories.empty? %>
19
+ <%= linkify child, child.value.to_s.capitalize %>
20
+ <small><%= child.location %></small>
21
+ </div>
22
+ <%= directory_node child, @padding + 15, @row %>
23
+ </li>
24
+ <% end %>
25
+ <% end %>
26
+ </ul>
27
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <% n = 'odd' %>
2
+ <% @items.each do |directory| %>
3
+ <li class="<%= n %>">
4
+ <div class="item" style="padding-left: 30px">
5
+ <%= "<a class='toggle'></a>" unless directory.features.empty? && directory.subdirectories.empty? %>
6
+ <%= linkify directory, directory.value %>
7
+ <small><%= directory.location %></small>
8
+ </div>
9
+ <%= directory_node directory, 45, n %>
10
+ </li>
11
+ <% end %>
@@ -0,0 +1,37 @@
1
+ <% n = 'odd' %>
2
+ <li class="<%= n %>">
3
+ <div class="item" style="padding-left: 30px">
4
+ <%= all_features_link %>
5
+ </div>
6
+ </li>
7
+ <% n = n == 'odd' ? 'even' : 'odd' %>
8
+ <% @items.each do |feature| %>
9
+ <li class="<%= n %>">
10
+ <div class="item" style="padding-left: 30px">
11
+ <%= "<a class='toggle'></a>" unless feature.scenarios.empty? %>
12
+ <%= linkify feature, feature.value %>
13
+ <small style="display: inline;"><%= feature.total_scenarios %></small>
14
+ </div>
15
+
16
+ <% n = n == 'odd' ? 'even' : 'odd' %>
17
+ <% if feature.scenarios %>
18
+ <ul>
19
+ <% feature.scenarios.each_with_index do |scenario,index| %>
20
+ <li class="<%= n %>">
21
+ <div class="item" style="padding-left: 45px">
22
+ <span class='object_link'>
23
+ <a href="<%= url_for(scenario.feature,"scenario_#{index}") %>"
24
+ title="<%= h scenario.value %>">
25
+ <%= h scenario.value %>
26
+ </a>
27
+ </span>
28
+ <small><%= scenario.location %></small>
29
+ </div>
30
+ </li>
31
+ <% n = n == 'odd' ? 'even' : 'odd' %>
32
+ <% end %>
33
+ </ul>
34
+ <% end %>
35
+
36
+ </li>
37
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <li>
2
+ <div class="item" style="padding-left: 30px">
3
+ <%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "All Step Definitions" %>
4
+ </div>
5
+ </li>
6
+ <% n = 'odd' %>
7
+ <% @items.each do |stepdef| %>
8
+ <li class="<%= n %>">
9
+ <div class="item" style="padding-left: 30px">
10
+ <span class='object_link'>
11
+ <span class="pre"><%= stepdef.keyword %></span>
12
+ <a href="<%= url_for stepdef %>" title="<%= h stepdef.value %>">
13
+ <span class="name"><%= h stepdef.literal_value %></span>
14
+ </a>&nbsp;&nbsp;
15
+ </span>
16
+ <small><%= h(stepdef.location) %></small>
17
+ </div>
18
+ </li>
19
+ <% n = n == 'even' ? 'odd' : 'even' %>
20
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <li class='odd'>
2
+ <div class="item" style="padding-left: 30px">
3
+ <%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE, "All Defined Steps" %>
4
+ </div>
5
+ </li>
6
+ <% n = 'even' %>
7
+ <% @items.each do |step| %>
8
+ <li class="<%= n %>">
9
+ <div class="item" style="padding-left: 30px">
10
+ <span class='object_link'>
11
+ <a href="<%= url_for step.scenario.feature %>" title="<%= h step.value %>">
12
+ <span class="pre"><%= step.keyword %></span>
13
+ <span class="name"><%= h(step.value) %></span>
14
+ </a>
15
+ </span>
16
+ <span class="">(<%= h(step.file) %>)<span>
17
+ </div>
18
+ </li>
19
+ <% n = n == 'even' ? 'odd' : 'even' %>
20
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <li>
2
+ <div class="item" style="padding-left: 30px;">
3
+ <%= linkify YARD::CodeObjects::Cucumber::CUCUMBER_TAG_NAMESPACE, "All Tags" %>
4
+ </div
5
+ </li>
6
+
7
+ <% n = 'odd' %>
8
+ <% @items.each do |tag| %>
9
+ <li class="<%= n %>">
10
+ <div class="item" style="padding-left: 30px;">
11
+ <%= linkify tag, tag.value %>
12
+ <small style="display: inline;"><%= tag.total_scenarios %></small>
13
+ </div>
14
+ </li>
15
+ <% n = n == 'odd' ? 'even' : 'odd' %>
16
+ <% end %>
@@ -0,0 +1,331 @@
1
+ function cucumberKeyboardShortcuts() {
2
+ if (window.top.frames.main) return;
3
+ $(document).keypress(function(evt) {
4
+ if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
5
+ if (typeof evt.target !== "undefined" &&
6
+ (evt.target.nodeName == "INPUT" ||
7
+ evt.target.nodeName == "TEXTAREA")) return;
8
+ switch (evt.charCode) {
9
+ case 68: case 100: $('#stepdefinition_list_link').click(); break; // 'd'
10
+ case 82: case 114: $('#feature_list_link').click(); break; // 'r'
11
+ case 83: case 115: $('#step_list_link').click(); break; // 's'
12
+ case 84: case 116: $('#tag_list_link').click(); break; // 't'
13
+ }
14
+ });
15
+ }
16
+
17
+ $(cucumberKeyboardShortcuts);
18
+
19
+ $(function() {
20
+
21
+ //
22
+ // Feature Page - Scenarios
23
+ //
24
+ $('.scenario div.title').click(function(eventObject) {
25
+ if (typeof eventObject.currentTarget !== "undefined") {
26
+ toggleScenario( $($(eventObject.currentTarget).parent()) );
27
+ }
28
+ });
29
+
30
+ //
31
+ // Developer View
32
+ // Click + Developer View = toggle the expansion of all tags, location, and comments
33
+ //
34
+ $('#view').click(function(eventObject) {
35
+
36
+ if (typeof eventObject.currentTarget !== "undefined") {
37
+ var view = eventObject.currentTarget;
38
+
39
+ if (view.innerHTML === '[More Detail]') {
40
+ $('.developer').show(500);
41
+ view.innerHTML = '[Less Detail]';
42
+ } else {
43
+ $('.developer').hide(500);
44
+ // Already hidden elements with .developer sub-elements were not getting message
45
+ $('.developer').each(function() {
46
+ $(this).css('display','none');
47
+ });
48
+ view.innerHTML = '[More Detail]';
49
+ }
50
+ }
51
+ });
52
+
53
+ //
54
+ // Expand/Collapse All
55
+ //
56
+ $('#expand').click(function(eventObject) {
57
+
58
+ if (typeof eventObject.currentTarget !== "undefined") {
59
+ if (eventObject.currentTarget.innerHTML === '[Expand All]') {
60
+ eventObject.currentTarget.innerHTML = '[Collapse All]';
61
+ $('div.scenario > div.details:hidden').each(function() {
62
+ toggleScenario( $($(this).parent()) );
63
+ });
64
+ } else {
65
+ eventObject.currentTarget.innerHTML = '[Expand All]';
66
+ $('div.scenario > div.details:visible').each(function() {
67
+ toggleScenario( $($(this).parent()) );
68
+ });
69
+ }
70
+ }
71
+ });
72
+
73
+ //
74
+ // Expand/Collapse All
75
+ //
76
+ $('#stepdefinition,#pplaceholder').click(function(eventObject) {
77
+
78
+ if (typeof eventObject.currentTarget !== "undefined") {
79
+ if (eventObject.currentTarget.innerHTML === '[Expand All]') {
80
+ eventObject.currentTarget.innerHTML = '[Collapse All]';
81
+ $('div.' + eventObject.currentTarget.id + ' > div.details:hidden').each(function() {
82
+ $(this).show(200);
83
+ });
84
+ $('div.' + eventObject.currentTarget.id + ' a.stepdef').text("[Collapse]")
85
+ } else {
86
+ eventObject.currentTarget.innerHTML = '[Expand All]';
87
+ $('div.' + eventObject.currentTarget.id + ' > div.details:visible').each(function() {
88
+ $(this).hide(200);
89
+ });
90
+ console.log(eventObject.currentTarget.id);
91
+ $('div.' + eventObject.currentTarget.id + ' a.stepdef').text('[Expand]');
92
+ }
93
+ }
94
+ });
95
+
96
+ $('.stepdef').click(function(eventObject) {
97
+ if (typeof eventObject.currentTarget !== "undefined") {
98
+ if (eventObject.currentTarget.innerHTML === '[Expand]') {
99
+ eventObject.currentTarget.innerHTML = '[Collapse]';
100
+ $(eventObject.target).parent().parent().parent().find("div.details:hidden").each(function() {
101
+ $(this).show(200);
102
+ });
103
+ } else {
104
+ eventObject.currentTarget.innerHTML = '[Expand]';
105
+ $(eventObject.target).parent().parent().parent().find("div.details:visible").each(function() {
106
+ $(this).hide(200);
107
+ });
108
+ }
109
+ }
110
+ });
111
+
112
+
113
+ //
114
+ // Scenario Outlines - Toggle Examples
115
+ //
116
+ $('.outline table tr').click(function(eventObject) {
117
+
118
+ if (typeof eventObject.currentTarget !== "undefined") {
119
+ var exampleRow = $(eventObject.currentTarget);
120
+
121
+ if (eventObject.currentTarget.className.match(/example\d+-\d+/) == null) {
122
+ return false;
123
+ }
124
+
125
+ var exampleClass = eventObject.currentTarget.className.match(/example\d+-\d+/)[0];
126
+ var example = exampleRow.closest('div.details').find('.' + exampleClass);
127
+
128
+ var currentExample = null;
129
+
130
+ $('.outline table tr').each(function() {
131
+ $(this).removeClass('selected');
132
+ });
133
+
134
+ if ( example[0].style.display == 'none' ) {
135
+ currentExample = example[0];
136
+ exampleRow.addClass('selected');
137
+ } else {
138
+ currentExample = exampleRow.closest('div.details').find('.steps')[0];
139
+ }
140
+
141
+ // hide everything
142
+ exampleRow.closest('div.details').find('.steps').each(function() {
143
+ $(this).hide();
144
+ });
145
+
146
+ // show the selected
147
+ $(currentExample).show();
148
+ }
149
+ });
150
+
151
+
152
+ });
153
+
154
+
155
+ function toggleScenario(scenario) {
156
+
157
+ var state = scenario.find(".attributes input[name='collapsed']")[0];
158
+
159
+ if (state.value === 'true') {
160
+ scenario.find("div.details").each(function() {
161
+ $(this).show(500);
162
+ });
163
+ state.value = "false";
164
+ scenario.find('a.toggle').each(function() {
165
+ this.innerHTML = ' - ';
166
+ });
167
+
168
+ } else {
169
+ scenario.find("div.details").each(function() {
170
+ $(this).hide(500);
171
+ });
172
+ state.value = "true";
173
+ scenario.find('a.toggle').each(function() {
174
+ this.innerHTML = ' + ';
175
+ });
176
+ }
177
+ }
178
+
179
+
180
+ function updateTagFiltering(tagString) {
181
+ var formulaTags = determineTagsUsedInFormula(tagString);
182
+ displayExampleCommandLine(formulaTags);
183
+ displayQualifyingFeaturesAndScenarios(formulaTags);
184
+ fixSectionRowAlternations();
185
+ }
186
+
187
+ function clearTagFiltering() {
188
+ updateTagFiltering("");
189
+ }
190
+
191
+ function determineTagsUsedInFormula(tagString) {
192
+
193
+ tagString = tagString.replace(/^(\s+)|(\s+)$/,'').replace(/\s{2,}/,' ');
194
+
195
+ var tagGroup = tagString.match(/(?:~)?@\w+(,(?:~)?@\w+)*/g);
196
+
197
+ var returnTags = [];
198
+
199
+ if (tagGroup) {
200
+ tagGroup.forEach(function(tag, index, array) {
201
+ console.log("Tag Group: " + tag);
202
+ var validTags = removeInvalidTags(tag)
203
+ if (validTags != "") {
204
+ returnTags.push(validTags);
205
+ }
206
+ });
207
+ }
208
+
209
+ return returnTags;
210
+ }
211
+
212
+ function removeInvalidTags(tagGroup) {
213
+ tagGroup.split(",").forEach(function(tag, index, array) {
214
+
215
+ baseTag = tag.match(/^~(.+)/) ? tag.match(/^~(.+)/)[1] : tag;
216
+
217
+ //console.log("Validating Tag: " + tag)
218
+ if (tag_list.indexOf(baseTag) === -1) {
219
+ //console.log("Removing Tag: " + tag);
220
+ tagGroup = tagGroup.replace(new RegExp(',?' + tag + ',?'),"")
221
+ }
222
+ });
223
+
224
+ return tagGroup;
225
+ }
226
+
227
+
228
+ function displayExampleCommandLine(tags) {
229
+ $("#command_example")[0].innerHTML = "cucumber ";
230
+
231
+ if (tags.length > 0) {
232
+ $("#command_example")[0].innerHTML += "--tags " + tags.join(" --tags ");
233
+ }
234
+ }
235
+
236
+ function fixSectionRowAlternations() {
237
+ $(".feature:visible,.scenario:visible").each(function(index){
238
+ $(this).removeClass("odd even").addClass( ((index + 1) % 2 == 0 ? "even" : "odd") );
239
+ });
240
+ }
241
+
242
+ function displayQualifyingFeaturesAndScenarios(tags) {
243
+
244
+ if (tags.length > 0) {
245
+
246
+ $(".feature,.scenario").each(function(feature){
247
+ $(this).hide();
248
+ });
249
+
250
+ var tagSelectors = generateCssSelectorFromTags(tags);
251
+
252
+ tagSelectors.forEach(function(selector,selectorIndex,selectorArray) {
253
+ var tags = selector;
254
+
255
+ $(".feature." + tags).each(function(index) {
256
+ $(this).show();
257
+ });
258
+ $(".scenario." + tags).each(function(index) {
259
+ $(this).show();
260
+ $(this).parent().prev().show();
261
+ });
262
+
263
+ });
264
+
265
+ if ( $(".feature:visible,.scenario:visible").length == 0 ) {
266
+ $("#features div.undefined").show();
267
+ } else {
268
+ $("#features div.undefined").hide();
269
+ }
270
+
271
+
272
+ } else {
273
+ $(".feature:hidden,.scenario:hidden").each(function(feature){
274
+ $(this).show();
275
+ });
276
+ }
277
+
278
+ }
279
+
280
+ function updateScenarioCount() {
281
+ var count = 0;
282
+ $(".scenario:visible").each(function(index) {
283
+ count += parseInt($(this).attr("count"))
284
+ });
285
+ count_header = " (" + count + ")";
286
+ document.getElementById("scenario_count").innerHTML = count_header;
287
+ }
288
+
289
+ function generateCssSelectorFromTags(tagGroups) {
290
+
291
+ var tagSelectors = [ "" ];
292
+
293
+ tagGroups.forEach(function(tagGroup,index,array) {
294
+ var newTagSelectors = [];
295
+
296
+ tagSelectors.forEach(function(selector,selectorIndex,selectorArray) {
297
+ tagGroup.split(",").forEach(function(tag,tagIndex,tagArray) {
298
+
299
+ if ( tag.match(/^~@.+$/) ) {
300
+ tag = tag.match(/^~(@.+)$/)[1]
301
+ //console.log("selector: " + (selector + " :not(" + tag + ")").trim());
302
+ newTagSelectors.push((selector + ":not(." + tag.replace(/@/g,"\\@") +")").trim());
303
+ } else {
304
+ //console.log("selector: " + (selector + " " + tag).trim());
305
+ newTagSelectors.push((selector + "." + tag.replace(/@/g,"\\@")).trim());
306
+ }
307
+ });
308
+
309
+ });
310
+
311
+ tagSelectors = newTagSelectors;
312
+
313
+ });
314
+
315
+
316
+ return tagSelectors;
317
+ }
318
+
319
+
320
+ function createStepDefinitionLinks() {
321
+ $('.toggleSteps').toggle(function() {
322
+ $(this).parent().next().slideDown(100);
323
+ $(this).text("Hide " + $(this).attr('alt'));
324
+ },
325
+ function() {
326
+ $(this).parent().next().slideUp(100);
327
+ $(this).text("View " + $(this).attr('alt'));
328
+ });
329
+ }
330
+
331
+ $(createStepDefinitionLinks);