yard-cucumber 3.1.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.yardopts +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -17
- data/History.txt +13 -0
- data/README.md +10 -10
- data/example/scenario_outline.feature +8 -2
- data/example/step_definitions/example.step.rb +13 -0
- data/example/transform.feature +5 -0
- data/lib/cucumber/city_builder.rb +64 -15
- data/lib/templates/default/featuretags/html/namespace.erb +32 -4
- data/lib/templates/default/fulldoc/html/full_list_features.erb +1 -1
- data/lib/templates/default/fulldoc/html/full_list_tags.erb +1 -1
- data/lib/templates/default/fulldoc/html/js/cucumber.js +9 -0
- data/lib/templates/default/fulldoc/html/setup.rb +26 -4
- data/lib/templates/default/tag/html/alpha_table.erb +2 -1
- data/lib/yard-cucumber.rb +1 -0
- data/lib/yard-cucumber/version.rb +1 -1
- data/lib/yard/code_objects/cucumber/base.rb +1 -9
- data/lib/yard/code_objects/cucumber/feature.rb +7 -9
- data/lib/yard/code_objects/cucumber/namespace_object.rb +55 -49
- data/lib/yard/code_objects/cucumber/scenario.rb +6 -10
- data/lib/yard/code_objects/cucumber/scenario_outline.rb +16 -23
- data/lib/yard/code_objects/cucumber/step.rb +12 -9
- data/lib/yard/code_objects/cucumber/tag.rb +17 -13
- data/lib/yard/code_objects/step_definition.rb +3 -6
- data/lib/yard/code_objects/step_transform.rb +3 -6
- data/lib/yard/code_objects/step_transformer.rb +1 -4
- data/lib/yard/handlers/constant_transform_handler.rb +98 -0
- data/lib/yard/handlers/cucumber/feature_handler.rb +1 -1
- data/lib/yard/handlers/step_transform_handler.rb +22 -3
- data/yard-cucumber.gemspec +2 -2
- metadata +44 -26
@@ -0,0 +1,98 @@
|
|
1
|
+
# There might be a nicer way to decorate this class but with my limited knowledge could only get this handler
|
2
|
+
# to be applied after the default constant handler by inheriting from the default constant handler.
|
3
|
+
# This is required so that the value assigned from the transform is not overridden in the registry by the
|
4
|
+
# default handler
|
5
|
+
class YARD::Handlers::Ruby::ConstantTransformHandler < YARD::Handlers::Ruby::ConstantHandler
|
6
|
+
include YARD::Handlers::Ruby::StructHandlerMethods
|
7
|
+
handles :assign
|
8
|
+
|
9
|
+
namespace_only
|
10
|
+
|
11
|
+
process do
|
12
|
+
begin
|
13
|
+
if statement[1][0][0] == "Transform"
|
14
|
+
name = statement[0][0][0]
|
15
|
+
# Move the docstring to the transform statement
|
16
|
+
statement[1].docstring = statement.docstring
|
17
|
+
# Set the docstring on the constant to reference the transform that will be processed
|
18
|
+
statement.docstring = "Reference to {#{YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE}::#{name} transform}"
|
19
|
+
value = statement[1][1].source
|
20
|
+
value = substitute(value)
|
21
|
+
value = convert_captures(strip_anchors(value))
|
22
|
+
instance = register ConstantObject.new(namespace, name) {|o| o.source = statement; o.value = value }
|
23
|
+
# specify the owner so that the transform can use the registered constant's name
|
24
|
+
parse_block(statement[1], {:owner => instance})
|
25
|
+
elsif statement[1][0][0] == "ParameterType"
|
26
|
+
name = statement[0][0][0]
|
27
|
+
# Move the docstring to the transform statement
|
28
|
+
statement[1].docstring = statement.docstring
|
29
|
+
# Set the docstring on the constant to reference the transform that will be processed
|
30
|
+
statement.docstring = "Reference to {#{YARD::CodeObjects::Cucumber::CUCUMBER_STEPTRANSFORM_NAMESPACE}::#{name} transform}"
|
31
|
+
|
32
|
+
value = find(statement, :label, 'regexp:').parent.children[1].source
|
33
|
+
|
34
|
+
value = substitute(value)
|
35
|
+
value = convert_captures(strip_anchors(value))
|
36
|
+
instance = register ConstantObject.new(namespace, name) {|o| o.source = statement; o.value = value }
|
37
|
+
# specify the owner so that the transform can use the registered constant's name
|
38
|
+
parse_block(statement[1], {:owner => instance})
|
39
|
+
end
|
40
|
+
rescue
|
41
|
+
# This supresses any errors where any of the statement elements are out of bounds.
|
42
|
+
# In this case the or in cases where the object being assigned is not a Transform
|
43
|
+
# the default constant handler will already have performed the relevant action
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def find(node, node_type, value)
|
50
|
+
node.traverse { |child| return(child) if node_type == child.type && child.source == value }
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
# Cucumber's Transform object overrides the to_s function and strips
|
55
|
+
# the anchor tags ^$ and any captures so that id it is interpolated in a step definition
|
56
|
+
# the it can appear anywhere in the step without being effected by position or captures
|
57
|
+
def convert_captures(regexp_source)
|
58
|
+
regexp_source
|
59
|
+
.gsub(/(\()(?!\?[<:=!])/,'(?:')
|
60
|
+
.gsub(/(\(\?<)(?![=!])/,'(?:<')
|
61
|
+
end
|
62
|
+
|
63
|
+
def strip_anchors(regexp_source)
|
64
|
+
regexp_source.
|
65
|
+
gsub(/(^\(\/|\/\)$)/, '').
|
66
|
+
gsub(/(^\^|\$$)/, '')
|
67
|
+
end
|
68
|
+
|
69
|
+
# Support for interpolation in the Transform's Regex
|
70
|
+
def substitute(data)
|
71
|
+
until (nested = constants_from_value(data)).empty?
|
72
|
+
nested.each {|n| data.gsub!(value_regex(n),find_value_for_constant(n)) }
|
73
|
+
end
|
74
|
+
data
|
75
|
+
end
|
76
|
+
|
77
|
+
def constants_from_value(data)
|
78
|
+
escape_pattern = /#\{\s*(\w+)\s*\}/
|
79
|
+
data.scan(escape_pattern).flatten.collect { |value| value.strip }
|
80
|
+
end
|
81
|
+
|
82
|
+
# Return a regex of the value
|
83
|
+
def value_regex(value)
|
84
|
+
/#\{\s*#{value}\s*\}/
|
85
|
+
end
|
86
|
+
|
87
|
+
def find_value_for_constant(name)
|
88
|
+
constant = YARD::Registry.all(:constant).find{|c| c.name == name.to_sym }
|
89
|
+
log.warn "ConstantTransformHandler#find_value_for_constant : Could not find the CONSTANT [#{name}] using the string value." unless constant
|
90
|
+
constant ? strip_regex_from(constant.value) : name
|
91
|
+
end
|
92
|
+
|
93
|
+
# Step the regex starting / and ending / from the value
|
94
|
+
def strip_regex_from(value)
|
95
|
+
value.gsub(/^\/|\/$/,'')
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -105,7 +105,7 @@ module YARD
|
|
105
105
|
|
106
106
|
if stepdef_matches
|
107
107
|
step.definition = stepdef_object
|
108
|
-
stepdef_matches[
|
108
|
+
stepdef_matches[1..-1].each do |match|
|
109
109
|
@@step_transforms.each do |steptrans,steptransform_object|
|
110
110
|
if steptrans.match(match)
|
111
111
|
step.transforms << steptransform_object
|
@@ -1,18 +1,26 @@
|
|
1
1
|
|
2
2
|
class YARD::Handlers::Ruby::StepTransformHandler < YARD::Handlers::Ruby::Base
|
3
3
|
handles method_call(:Transform)
|
4
|
+
handles method_call(:ParameterType)
|
4
5
|
|
5
6
|
process do
|
6
7
|
|
8
|
+
nextStatement = nil
|
7
9
|
instance = YARD::CodeObjects::StepTransformObject.new(step_transform_namespace,step_transformer_name) do |o|
|
8
10
|
o.source = statement.source
|
9
11
|
o.comments = statement.comments
|
10
12
|
o.keyword = statement[0].source
|
11
|
-
o.
|
13
|
+
if (o.keyword == 'Transform')
|
14
|
+
o.value = statement[1].source.gsub(/(^\(?\/|\/\)?$)/, '').gsub(/(^\^|\$$)/, '')
|
15
|
+
nextStatement = statement[2]
|
16
|
+
elsif (o.keyword == 'ParameterType')
|
17
|
+
o.value = find(statement, :label, 'regexp:').parent.children[1].source.gsub(/(^\(?\/|\/\)?$)/, '').gsub(/(^\^|\$$)/, '')
|
18
|
+
nextStatement = find(statement, :label, 'transformer:').parent.children[1]
|
19
|
+
end
|
12
20
|
end
|
13
21
|
|
14
22
|
obj = register instance
|
15
|
-
parse_block(
|
23
|
+
parse_block(nextStatement,:owner => obj)
|
16
24
|
|
17
25
|
end
|
18
26
|
|
@@ -21,11 +29,22 @@ class YARD::Handlers::Ruby::StepTransformHandler < YARD::Handlers::Ruby::Base
|
|
21
29
|
end
|
22
30
|
|
23
31
|
def step_transformer_name
|
24
|
-
|
32
|
+
# If the owner is a constant then we get the name of the constant so that the reference from the constant will work
|
33
|
+
if (owner.is_a?(YARD::CodeObjects::ConstantObject))
|
34
|
+
owner.name
|
35
|
+
else
|
36
|
+
"step_transform#{self.class.generate_unique_id}"
|
37
|
+
end
|
25
38
|
end
|
26
39
|
|
27
40
|
def self.generate_unique_id
|
28
41
|
@step_transformer_count = @step_transformer_count.to_i + 1
|
29
42
|
end
|
30
43
|
|
44
|
+
private
|
45
|
+
|
46
|
+
def find(node, node_type, value)
|
47
|
+
node.traverse { |child| return(child) if node_type == child.type && child.source == value }
|
48
|
+
self
|
49
|
+
end
|
31
50
|
end
|
data/yard-cucumber.gemspec
CHANGED
@@ -56,8 +56,8 @@ Gem::Specification.new do |s|
|
|
56
56
|
|
57
57
|
s.add_development_dependency 'rake', '~> 10'
|
58
58
|
|
59
|
-
s.add_dependency 'gherkin', '
|
60
|
-
s.add_dependency 'cucumber', '
|
59
|
+
s.add_dependency 'gherkin', '>= 4.0', '< 6.0'
|
60
|
+
s.add_dependency 'cucumber', '>= 2.0', '< 4.0'
|
61
61
|
s.add_dependency 'yard', '~> 0.8', '>= 0.8.1'
|
62
62
|
|
63
63
|
s.rubygems_version = "1.3.7"
|
metadata
CHANGED
@@ -1,75 +1,87 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franklin Webber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: gherkin
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.0'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '6.0'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- -
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '4.0'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '6.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: cucumber
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.0'
|
54
|
+
- - "<"
|
46
55
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
56
|
+
version: '4.0'
|
48
57
|
type: :runtime
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
52
|
-
- -
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.0'
|
64
|
+
- - "<"
|
53
65
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
66
|
+
version: '4.0'
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: yard
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
|
-
- - ~>
|
71
|
+
- - "~>"
|
60
72
|
- !ruby/object:Gem::Version
|
61
73
|
version: '0.8'
|
62
|
-
- -
|
74
|
+
- - ">="
|
63
75
|
- !ruby/object:Gem::Version
|
64
76
|
version: 0.8.1
|
65
77
|
type: :runtime
|
66
78
|
prerelease: false
|
67
79
|
version_requirements: !ruby/object:Gem::Requirement
|
68
80
|
requirements:
|
69
|
-
- - ~>
|
81
|
+
- - "~>"
|
70
82
|
- !ruby/object:Gem::Version
|
71
83
|
version: '0.8'
|
72
|
-
- -
|
84
|
+
- - ">="
|
73
85
|
- !ruby/object:Gem::Version
|
74
86
|
version: 0.8.1
|
75
87
|
description: "\n YARD-Cucumber is a YARD extension that processes Cucumber Features,
|
@@ -84,10 +96,11 @@ extra_rdoc_files:
|
|
84
96
|
- README.md
|
85
97
|
- History.txt
|
86
98
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .rspec
|
89
|
-
- .ruby-gemset
|
90
|
-
- .ruby-version
|
99
|
+
- ".gitignore"
|
100
|
+
- ".rspec"
|
101
|
+
- ".ruby-gemset"
|
102
|
+
- ".ruby-version"
|
103
|
+
- ".yardopts"
|
91
104
|
- Gemfile
|
92
105
|
- Gemfile.lock
|
93
106
|
- History.txt
|
@@ -163,6 +176,7 @@ files:
|
|
163
176
|
- lib/yard/code_objects/step_definition.rb
|
164
177
|
- lib/yard/code_objects/step_transform.rb
|
165
178
|
- lib/yard/code_objects/step_transformer.rb
|
179
|
+
- lib/yard/handlers/constant_transform_handler.rb
|
166
180
|
- lib/yard/handlers/cucumber/base.rb
|
167
181
|
- lib/yard/handlers/cucumber/feature_handler.rb
|
168
182
|
- lib/yard/handlers/legacy/step_definition_handler.rb
|
@@ -180,27 +194,31 @@ licenses:
|
|
180
194
|
- MIT
|
181
195
|
metadata: {}
|
182
196
|
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
183
|
-
(::) (::) (::)\n\n Thank you for installing yard-cucumber
|
184
|
-
\ Changes:\n \n *
|
185
|
-
|
186
|
-
|
197
|
+
(::) (::) (::)\n\n Thank you for installing yard-cucumber 4.0.0 / 2018-02-25.\n\n
|
198
|
+
\ Changes:\n \n * @wellavelino: Adjusts the indentation of several project classes\n
|
199
|
+
\ (https://github.com/burtlo/yard-cucumber/pull/89)\n * @elhuang: Adding example
|
200
|
+
tags and scenarios counts\n (https://github.com/burtlo/yard-cucumber/pull/87)\n
|
201
|
+
\ * @weh: Update README.md\n (https://github.com/burtlo/yard-cucumber/pull/84)\n
|
202
|
+
\ * @weh: Fix Gem Load Error\n (https://github.com/burtlo/yard-cucumber/pull/83)\n
|
203
|
+
\ * @Stephen-Kaye: Transforms with CONSTANTS\n (https://github.com/burtlo/yard-cucumber/pull/79)\n
|
204
|
+
\ \n\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n\n"
|
187
205
|
rdoc_options:
|
188
|
-
- --charset=UTF-8
|
206
|
+
- "--charset=UTF-8"
|
189
207
|
require_paths:
|
190
208
|
- lib
|
191
209
|
required_ruby_version: !ruby/object:Gem::Requirement
|
192
210
|
requirements:
|
193
|
-
- -
|
211
|
+
- - ">="
|
194
212
|
- !ruby/object:Gem::Version
|
195
213
|
version: '0'
|
196
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
215
|
requirements:
|
198
|
-
- -
|
216
|
+
- - ">="
|
199
217
|
- !ruby/object:Gem::Version
|
200
218
|
version: '0'
|
201
219
|
requirements: []
|
202
220
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
221
|
+
rubygems_version: 2.7.6
|
204
222
|
signing_key:
|
205
223
|
specification_version: 4
|
206
224
|
summary: Cucumber Features in YARD
|