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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d5b6cbca7cfc39b6a5ec76b76c0dc55f4694b0b
4
- data.tar.gz: e03d5ed13815d698a31c6653b1819dcfbd647dc7
3
+ metadata.gz: a00c6a5ecb825a8885474b20f39c8da775b3f953
4
+ data.tar.gz: aa836409a9c1a37333b286d4e4e625a6426fcf76
5
5
  SHA512:
6
- metadata.gz: 3c82de390a4747752e87bec0a06d58cdd57a090212bed9f3235c68860861c75771e423bad77e425a6c2dc46173b64e7d27224ac9d4939465d5ca52fb2d2c3515
7
- data.tar.gz: 88b5839bc83787d5a37e71f2801087582e687694fb20453db2a082c4cc07cf86ca5630c1485d9aaf2f49fdd6c3bc9106478879660b2dfe1a2d844c6c22db00bc
6
+ metadata.gz: 48fa59409d904cf944ae7dc6bc89365e3617e7a902c9f56de39cb13216e125f0a4ac4c2ea4e6e52c63579bbe0cdb819105b4ad31c8ac08f36e84b3cddc35c33f
7
+ data.tar.gz: d22cfe16c3b6904c834536d955bf7792161ac4800e830e300d7069c37171638fdaa0b9b2e21fa7fb6f78bdb8bfa32da9884603b22fab2470fc2fac3f7526bc71
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  desc 'Publishes the Gem'
14
14
  task :push do
15
- sh 'gem push gherkin_format-0.0.2-gem'
15
+ sh 'gem push gherkin_format-0.0.3.gem'
16
16
  end
17
17
 
18
18
  desc 'Checks ruby style'
@@ -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
 
@@ -63,7 +63,6 @@ Feature: Markdown Template
63
63
 
64
64
  Given something
65
65
 
66
-
67
66
  ### Scenario: Bar
68
67
 
69
68
  Given a foo
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_format'
3
- s.version = '0.0.2'
4
- s.date = '2015-06-02'
3
+ s.version = '0.0.3'
4
+ s.date = '2015-07-19'
5
5
  s.summary = 'Gherkin Format'
6
6
  s.description = 'Format Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
@@ -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 %>
@@ -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
- <% for @element in @feature['elements'] %>
46
- ### <%= @element['keyword'] %>: <%= @element['name'] %><%= tags @element %><%= description @element %>
47
- <%= steps @element %>
48
- <%= examples @element %>
49
- <% end %><% end %>
52
+ <%= scenarios @feature %>
53
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <%
2
+ def tags(element)
3
+ return '' unless element.key? 'tags'
4
+ element['tags'].map { |tag| tag['name'][1..-1] } * "\n"
5
+ end
6
+ %><% for @feature in @features %><%= tags @feature %><% end %>
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.2
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-06-02 00:00:00.000000000 Z
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: {}