Top Level Namespace
- Includes:
- YARD::Templates::Helpers::HtmlHelper
Defined Under Namespace
Modules: Cucumber, CucumberInTheYARD, YARD
Classes: StepDefinitionHandler, StepTransformHandler
Instance Method Summary
collapse
Instance Method Details
#all_directories_by_letter ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/templates/default/requirements/html/setup.rb', line 30
def all_directories_by_letter
hash = {}
objects = feature_directories
objects = run_verifier(objects)
objects.each {|o| (hash[o.value.to_s[0,1].upcase] ||= []) << o }
hash.values.each {|v| v.sort! {|a,b| b.value.to_s <=> a.value.to_s } }
hash
end
|
#all_features_by_letter ⇒ Object
10
11
12
13
14
|
# File 'lib/templates/default/tag/setup.rb', line 10
def all_features_by_letter
hash = {}
@tag.features.each {|o| (hash[o.value.to_s[0,1].upcase] ||= []) << o }
hash
end
|
#all_scenarios_by_letter ⇒ Object
16
17
18
19
20
|
# File 'lib/templates/default/tag/setup.rb', line 16
def all_scenarios_by_letter
hash = {}
@tag.scenarios.each {|o| (hash[o.value.to_s[0,1].upcase] ||= []) << o }
hash
end
|
11
12
13
14
15
16
17
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 11
def all_tags_by_letter
hash = {}
objects = tags
objects = run_verifier(objects)
objects.each {|o| (hash[o.value.to_s[1,1].upcase] ||= []) << o }
hash
end
|
#all_types_by_letter(type) ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/templates/default/featuredirectory/html/setup.rb', line 13
def all_types_by_letter(type)
hash = {}
objects = @directory.children.find_all {|child| child.is_a?(type) }
objects = run_verifier(objects)
objects.each {|o| (hash[o.value.to_s[0,1].upcase] ||= []) << o }
hash.values.each {|v| v.sort! {|a,b| b.value.to_s <=> a.value.to_s } }
hash
end
|
#background ⇒ Object
11
12
13
14
15
|
# File 'lib/templates/default/feature/setup.rb', line 11
def background
@scenario = @feature.background
@id = "background"
erb(:scenario)
end
|
#class_list(root = Registry.root) ⇒ Object
Remove CUCUMBER namespace from the class list
#feature_directories ⇒ Object
39
40
41
|
# File 'lib/templates/default/requirements/html/setup.rb', line 39
def feature_directories
@feature_directories ||= Registry.all(:featuredirectory)
end
|
27
28
29
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 27
def feature_tags_with_all_scenario_tags(feature)
feature.tags.collect {|t| t.value} + feature.scenarios.collect {|s| s.tags.collect {|t| t.value} }.flatten.uniq
end
|
#features ⇒ Object
23
24
25
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 23
def features
@features ||= Registry.all(:feature).sort {|x,y| x.value.to_s <=> y.value.to_s }
end
|
#generate_full_list(objects, friendly_name = nil) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/templates/default/fulldoc/html/setup.rb', line 32
def generate_full_list(objects,friendly_name=nil)
if !objects.empty?
@items = objects
@list_type = "#{objects.first.type.to_s}s"
@list_title = "#{friendly_name || objects.first.type.to_s.capitalize} List"
@list_class = "class"
asset("#{objects.first.type}_list.html",erb(:full_list))
else
log.warn "Full List: Failed to create a list because the objects array is empty."
end
end
|
#highlight_matches(step) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/templates/default/feature/setup.rb', line 36
def highlight_matches(step)
value = step.value.dup
if step.definition
matches = step.value.match(step.definition.regex)
if matches
matches[1..-1].reverse.each_with_index do |match,index|
next if match == nil
value[matches.begin((matches.size - 1) - index)..(matches.end((matches.size - 1) - index) - 1)] = "<span class='match'>#{h(match)}</span>"
end
end
end
value
end
|
#htmlify_with_newlines(text) ⇒ Object
53
54
55
|
# File 'lib/templates/default/feature/setup.rb', line 53
def htmlify_with_newlines(text)
text.split("\n").collect {|c| h(c) }.join("<br/>")
end
|
#init ⇒ Object
1
2
3
4
5
6
7
8
|
# File 'lib/templates/default/tag/setup.rb', line 1
def init
super
@tag = object
sections.push :tag
sections.push :feature unless @tag.features.empty?
sections.push :scenario unless @tag.scenarios.empty?
end
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/templates/default/steptransformers/setup.rb', line 35
def link_transformed_step(step)
value = step.value.dup
if step.definition
matches = step.value.match(step.definition.regex)
if matches
matches[1..-1].reverse.each_with_index do |match,index|
next if match == nil
transform = step.transforms.find {|transform| transform.regex.match(match) }
value[matches.begin((matches.size - 1) - index)..(matches.end((matches.size - 1) - index) - 1)] = transform ? "<a href='#{url_for(transform)}'>#{h(match)}</a>" : "<span class='match'>#{match}</span>"
end
end
end
value
end
|
#namespace ⇒ Object
7
8
9
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 7
def namespace
erb(:namespace)
end
|
#scenarios ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/templates/default/feature/setup.rb', line 17
def scenarios
scenarios = ""
if @feature.background
@scenario = @feature.background
@id = "background"
scenarios += erb(:scenario)
end
@feature.scenarios.each_with_index do |scenario,index|
@scenario = scenario
@id = "scenario#{index}"
scenarios += erb(:scenario)
end
scenarios
end
|
#serialize_feature_directories(namespaces) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/templates/default/fulldoc/html/setup.rb', line 54
def serialize_feature_directories(namespaces)
namespaces.each do |namespace|
Templates::Engine.with_serializer(namespace, options[:serializer]) do
options[:object] = namespace
T('layout').run(options)
end
serialize_feature_directories(namespace.children.find_all {|child| child.is_a?(YARD::CodeObjects::Cucumber::FeatureDirectory)})
end
end
|
#stepdefinitions ⇒ Object
7
8
9
10
11
12
|
# File 'lib/templates/default/steptransformers/setup.rb', line 7
def stepdefinitions
@item_title = "Step Definitions"
@item_type = "step definition"
@items = YARD::Registry.all(:stepdefinition)
erb(:header) + erb(:transformers)
end
|
#steps ⇒ Object
51
52
53
|
# File 'lib/templates/default/requirements/html/setup.rb', line 51
def steps
@steps ||= Registry.all(:step)
end
|
14
15
16
17
18
19
|
# File 'lib/templates/default/steptransformers/setup.rb', line 14
def steptransforms
@item_title = "Step Transforms"
@item_type = "step transform"
@items = YARD::Registry.all(:steptransform)
erb(:header) + erb(:transformers)
end
|
#tagify(tag) ⇒ Object
32
33
34
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 32
def tagify(tag)
%{<span class="tag" href="#{url_for tag}">#{tag.value}</span>}
end
|
19
20
21
|
# File 'lib/templates/default/featuretags/html/setup.rb', line 19
def tags
@tags ||= Registry.all(:tag)
end
|
#undefined_steps ⇒ Object
21
22
23
24
25
26
|
# File 'lib/templates/default/steptransformers/setup.rb', line 21
def undefined_steps
@item_title = "Undefined Steps"
@item_type = nil
@undefined_steps ||= Registry.all(:step).reject {|s| s.definition || s.scenario.outline? }
erb(:header) + erb(:undefined_steps)
end
|
#unique_steps(steps) ⇒ Object
29
30
31
32
33
|
# File 'lib/templates/default/steptransformers/setup.rb', line 29
def unique_steps(steps)
uniq_steps = {}
steps.each {|s| (uniq_steps[s.value.to_s] ||= []) << s }
uniq_steps
end
|