gherkin_format 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/bin/gherkin_format +10 -0
- data/features/template.markdown.feature +0 -1
- data/gherkin_format.gemspec +2 -2
- data/lib/jira.erb +61 -0
- data/lib/markdown.erb +9 -5
- data/lib/tags.erb +6 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a00c6a5ecb825a8885474b20f39c8da775b3f953
|
4
|
+
data.tar.gz: aa836409a9c1a37333b286d4e4e625a6426fcf76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48fa59409d904cf944ae7dc6bc89365e3617e7a902c9f56de39cb13216e125f0a4ac4c2ea4e6e52c63579bbe0cdb819105b4ad31c8ac08f36e84b3cddc35c33f
|
7
|
+
data.tar.gz: d22cfe16c3b6904c834536d955bf7792161ac4800e830e300d7069c37171638fdaa0b9b2e21fa7fb6f78bdb8bfa32da9884603b22fab2470fc2fac3f7526bc71
|
data/Rakefile
CHANGED
data/bin/gherkin_format
CHANGED
@@ -14,10 +14,20 @@ OptionParser.new do |opts|
|
|
14
14
|
opts.on('--template [TEMPLATE]', 'Renders into template') do |template|
|
15
15
|
options[:template] = template
|
16
16
|
end
|
17
|
+
opts.on('--json', 'Renders to Json') do |json|
|
18
|
+
options[:json] = json
|
19
|
+
end
|
17
20
|
end.parse!
|
18
21
|
|
19
22
|
formatter = GherkinFormat.new
|
20
23
|
|
24
|
+
if options.key? :json
|
25
|
+
fail 'Provide exactly one file' unless ARGV.length == 1
|
26
|
+
puts formatter.to_json(File.read(ARGV.first), ARGV.first)
|
27
|
+
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
21
31
|
if options.key? :template
|
22
32
|
formatter.render(options[:template], ARGV)
|
23
33
|
|
data/gherkin_format.gemspec
CHANGED
data/lib/jira.erb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
<%
|
2
|
+
def feature_name(feature)
|
3
|
+
"Feature #{feature['name']} (#{feature['uri']})"
|
4
|
+
end
|
5
|
+
|
6
|
+
def tags(element)
|
7
|
+
return '' unless element.key? 'tags'
|
8
|
+
"\n\nTags: #{element['tags'].map { |tag| tag['name'] } * ' '}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def table(element)
|
12
|
+
return '' unless element.key? 'rows'
|
13
|
+
"\n" + element['rows'].map{ |row| "| #{row['cells'].map { |value| escape(value) } * ' | '} |" } * "\n" + "\n\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def description(element)
|
17
|
+
return '' unless element.key? 'description'
|
18
|
+
return '' if element['description'].strip.length == 0
|
19
|
+
"\n\n{quote}\n" + element['description'] + "\n{quote}\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
def steps(scenario)
|
23
|
+
|
24
|
+
def docstring(step)
|
25
|
+
return '' unless step.key? 'doc_string'
|
26
|
+
"\n" + '"""' + "\n{code}\n" + escape(step['doc_string']['value']) + "\n{code}\n" + '"""'
|
27
|
+
end
|
28
|
+
|
29
|
+
return '' unless scenario.key? 'steps'
|
30
|
+
|
31
|
+
"\n" + scenario['steps'].map do |step|
|
32
|
+
['*', step['keyword'].strip, '* ', highlight(step['name']), docstring(step), table(step)].join
|
33
|
+
end * "\n"
|
34
|
+
end
|
35
|
+
|
36
|
+
def examples(element)
|
37
|
+
return '' unless element.key? 'examples'
|
38
|
+
"\n" + element['examples'].map do |example|
|
39
|
+
'h4. ' + example['keyword'] + ': ' + example['name'] + "\n" + table(example)
|
40
|
+
end * "\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
def scenarios(feature)
|
44
|
+
return '' unless feature.key? 'elements'
|
45
|
+
feature['elements'].map do |element|
|
46
|
+
"h3. #{element['keyword']}: #{element['name']}#{tags(element)}#{description(element)}\n#{steps(element)}\n#{examples(element)}"
|
47
|
+
end.join ''
|
48
|
+
end
|
49
|
+
|
50
|
+
def escape(value)
|
51
|
+
value.gsub('<', '\<').gsub('>', '\>').gsub('*', '\*').gsub('#', '\#').gsub('-', '\-').gsub('[', '\[').gsub(']', '\]').gsub('|', '\|').gsub('"', '\"')
|
52
|
+
end
|
53
|
+
|
54
|
+
def highlight(value)
|
55
|
+
value.gsub('«', '_«').gsub('»', '»_').gsub('\<', '_\<').gsub('\>', '\>_')
|
56
|
+
end
|
57
|
+
%>
|
58
|
+
<% for @feature in @features %>h2. <%= feature_name @feature %><%= tags @feature %>
|
59
|
+
<%= description @feature %>
|
60
|
+
<%= scenarios @feature %>
|
61
|
+
<% end %>
|
data/lib/markdown.erb
CHANGED
@@ -39,11 +39,15 @@ def examples(element)
|
|
39
39
|
'#### ' + example['keyword'] + ': ' + example['name'] + "\n" + table(example)
|
40
40
|
end * "\n"
|
41
41
|
end
|
42
|
+
|
43
|
+
def scenarios(feature)
|
44
|
+
return '' unless feature.key? 'elements'
|
45
|
+
feature['elements'].map do |element|
|
46
|
+
"\n### #{element['keyword']}: #{element['name']}#{tags(element)}#{description(element)}\n#{steps(element)}\n#{examples(element)}"
|
47
|
+
end.join ''
|
48
|
+
end
|
42
49
|
%>
|
43
50
|
<% for @feature in @features %>## <%= feature_name @feature %><%= tags @feature %>
|
44
51
|
<%= description @feature %>
|
45
|
-
|
46
|
-
|
47
|
-
<%= steps @element %>
|
48
|
-
<%= examples @element %>
|
49
|
-
<% end %><% end %>
|
52
|
+
<%= scenarios @feature %>
|
53
|
+
<% end %>
|
data/lib/tags.erb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin_format
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Rohe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gherkin
|
@@ -57,9 +57,11 @@ files:
|
|
57
57
|
- features/template.multi_markdown_without_highlighting.feature
|
58
58
|
- gherkin_format.gemspec
|
59
59
|
- lib/gherkin_format.rb
|
60
|
+
- lib/jira.erb
|
60
61
|
- lib/markdown.erb
|
61
62
|
- lib/multi_markdown.erb
|
62
63
|
- lib/multi_markdown_without_highlight.erb
|
64
|
+
- lib/tags.erb
|
63
65
|
homepage: http://github.com/funkwerk/gherkin_format/
|
64
66
|
licenses: []
|
65
67
|
metadata: {}
|