flavored_gherkin 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2984005e874db23498bb3a6ef00dd9a44d551182
4
+ data.tar.gz: 2a5dc7a2f413282fe14a24ce1174fbe7f2db1bba
5
+ SHA512:
6
+ metadata.gz: a394260d7c3ff161c4b4e593104bd3c5637c866f20eaaac56caf99bc13c6ca578a43a416eb85641c06455de651e4b6c49590e3bcaebb92fab59af688fafb4911
7
+ data.tar.gz: 88a4a62c3592fde1b8d28d8897c1af4acb8377112514199ba6ba977065362875c988a47ab35a95d0029d07fcb151598b90b366f2114fe0b06279f7b64d07299e
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Rajat Thareja
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,111 @@
1
+ # Flavored Gherkin
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/flavored_gherkin.svg)](https://badge.fury.io/rb/flavored_gherkin)
4
+ [![Build status](https://travis-ci.org/rajatthareja/FlavoredGherkin.svg?branch=master)](https://travis-ci.org/rajatthareja/FlavoredGherkin)
5
+ [![Windows Build status](https://ci.appveyor.com/api/projects/status/agvyur7bg5ul1444/branch/master?svg=true)](https://ci.appveyor.com/project/rajatthareja/flavoredgherkin)
6
+
7
+
8
+ Ruby gem to convert gherkin feature files into html flavour.
9
+
10
+ **[View Sample](http://flavoredgherkin.rajatthareja.com/sample/Flavored_Gherkin_Sample.html)**
11
+
12
+ More flavours coming soon!
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+
18
+ gem install flavored_gherkin
19
+
20
+ ```
21
+
22
+ ## Information
23
+
24
+ * RDoc documentation [available on RubyDoc.info](http://www.rubydoc.info/gems/flavored_gherkin)
25
+ * Source code [available on GitHub](http://github.com/rajatthareja/FlavoredGherkin)
26
+
27
+ ## Usage
28
+
29
+ ### Options:
30
+
31
+ | Option | Type | Default | Values |
32
+ |---------------------------|-------------|----------------------------|-------------------------------|
33
+ | title | [String] | 'Flavored Gherkin' | Flavored Gherkin Title |
34
+ | feature_path / input_path | [String] | Present Working Directory | Feature Files Path |
35
+ | output_path | [String] | Present Working Directory | Flavored Gherkin Output Path |
36
+
37
+ ### Code Examples:
38
+
39
+ ```ruby
40
+
41
+ require 'report_builder'
42
+
43
+ # Example 1:
44
+
45
+ FlavoredGherkin.configure do |config|
46
+ config.title = 'My Features'
47
+ config.feature_path = 'myFolder/features'
48
+ config.output_path = 'myFolder/my_features'
49
+ end
50
+
51
+ FlavoredGherkin.build
52
+
53
+ # Example 2:
54
+
55
+ options = {
56
+ title: 'My Features',
57
+ feature_path: 'myFolder/features',
58
+ output_path: 'myFolder/my_features'
59
+ }
60
+
61
+ FlavoredGherkin.build options
62
+
63
+ # Example 3:
64
+
65
+ FlavoredGherkin.set 'title', 'My Features'
66
+ FlavoredGherkin.set 'feature_path', 'myFolder/features'
67
+ FlavoredGherkin.set 'output_path', 'myFolder/my_features'
68
+
69
+ FlavoredGherkin.build
70
+
71
+ # Example 4:
72
+
73
+ FlavoredGherkin.title = 'My Features'
74
+ FlavoredGherkin.feature_path = 'myFolder/features'
75
+ FlavoredGherkin.output_path = 'myFolder/my_features'
76
+
77
+ FlavoredGherkin.build
78
+
79
+ ```
80
+
81
+ ### CLI Options:
82
+
83
+ | Option | Values | Explanation |
84
+ |----------------------------|---------------|--------------------------------|
85
+ | -t, --source | TITLE | Flavored Gherkin Title |
86
+ | -f, --features / -i, --in | FEATURE_PATH | Feature Files Path |
87
+ | -o, --out | OUTPUT_PATH | Flavored Gherkin Output Path |
88
+
89
+ ### CLI Example:
90
+
91
+ ```bash
92
+
93
+ flavored_gherkin
94
+
95
+ flavored_gherkin -f 'myFolder/features'
96
+
97
+ flavored_gherkin -t 'My Features' -f 'myFolder/features' -o 'myFolder/my_features'
98
+
99
+ ```
100
+
101
+ ## Contributing
102
+
103
+ We're open to any contribution. It has to be tested properly though.
104
+
105
+ ## Collaborators
106
+
107
+ * [Rajat Thareja](http://rajatthareja.com)
108
+
109
+ ## License
110
+
111
+ Copyright (c) 2017 [MIT LICENSE](LICENSE)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require_relative '../lib/flavored_gherkin'
5
+
6
+ options = {}
7
+
8
+ opt_parser = OptionParser.new do |opts|
9
+ opts.banner = "Usage: \n flavored_gherkin [options]"
10
+ opts.separator 'Flavored Gherkin options:'
11
+
12
+ opts.on('-F', '--flavour FLAVOUR', String, 'Flavored Gherkin Flavour') do |flavour|
13
+ options[:flavour] = flavour
14
+ end
15
+
16
+ opts.on('-f', '--features FEATURE_PATH', String, 'Feature Files Path') do |feature_path|
17
+ options[:feature_path] = feature_path
18
+ end
19
+
20
+ opts.on('-i', '--in INPUT_PATH', String, 'Feature Files Path') do |input_path|
21
+ options[:input_path] = input_path
22
+ end
23
+
24
+ opts.on('-o', '--out OUTPUT_PATH', String, 'Flavored Gherkin Output Path') do |output_path|
25
+ options[:output_path] = output_path
26
+ end
27
+
28
+ opts.on('-t', '--title TITLE', String, 'Flavored Gherkin Title') do |title|
29
+ options[:title] = title
30
+ end
31
+
32
+ opts.separator 'Common options:'
33
+
34
+ opts.on_tail('-h', '--help', 'Show help') do
35
+ puts opts
36
+ exit
37
+ end
38
+
39
+ opts.on_tail('-v','--version', 'Show version') do
40
+ puts 'FlavoredGherkin v' + Gem.loaded_specs['flavored_gherkin'].version.to_s rescue puts "Something want wrong. \nUse 'gem list flavored_gherkin'"
41
+ exit
42
+ end
43
+ end
44
+
45
+ opt_parser.parse!(ARGV)
46
+
47
+ FlavoredGherkin.build options
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'flavored_gherkin'
3
+ s.version = '0.1'
4
+ s.bindir = 'bin'
5
+ s.summary = 'Ruby gem to convert gherkin feature files into html flavour.'
6
+ s.description = ''
7
+ s.authors = ['Rajat Thareja']
8
+ s.email = 'rajat.thareja.1990@gmail.com'
9
+ s.homepage = 'http://flavoredgherkin.rajatthareja.com'
10
+ s.license = 'MIT'
11
+ s.required_ruby_version = '>= 1.9.1'
12
+
13
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(sample/|css/|js/|pkg/|testing/|coverage/|CNAME|.gitignore|appveyor.yml|.travis.yml|_config.yml|Gemfile|Rakefile|fg.ico)}) }
14
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ s.test_files = s.files.grep(%r{^(testing)/})
16
+
17
+ s.add_runtime_dependency 'gherkin', '>= 4.0.0'
18
+
19
+ s.add_development_dependency 'rake', '< 13.0'
20
+ s.add_development_dependency 'rspec', '< 4.0'
21
+ end
@@ -0,0 +1,185 @@
1
+ require 'pathname'
2
+ require_relative 'flavored_gherkin/html_flavour'
3
+
4
+ ##
5
+ # Flavored Gherkin
6
+ #
7
+ module FlavoredGherkin
8
+ ##
9
+ # Configure Flavored Gherkin
10
+ #
11
+ # Example:
12
+ #
13
+ # FlavoredGherkin.configure do |config|
14
+ # config.title = 'My Features'
15
+ # config.feature_path = 'myFolder/features'
16
+ # config.output_path = 'myFolder/my_features'
17
+ # end
18
+ #
19
+ def self.configure
20
+ options = OpenStruct.new
21
+ yield options if block_given?
22
+ @options ||= {}
23
+ @options.merge! options.marshal_dump
24
+ end
25
+
26
+ ##
27
+ # Set Flavored Gherkin Options
28
+ #
29
+ # @param [String] option
30
+ # @param [String] value
31
+ #
32
+ # Example:
33
+ #
34
+ # FlavoredGherkin.set('title', 'My Features')
35
+ #
36
+ def self.set(option, value)
37
+ @options ||= {}
38
+ @options[option.to_sym] = value
39
+ end
40
+
41
+ ##
42
+ # Set Flavored Gherkin Flavour
43
+ #
44
+ # @param [String] flavour Flavored Gherkin Flavour
45
+ #
46
+ # Example:
47
+ #
48
+ # FlavoredGherkin.flavour = 'HtmlFlavour'
49
+ #
50
+ def self.flavour=(flavour)
51
+ @options ||= {}
52
+ @options[:flavour] = flavour
53
+ end
54
+
55
+ ##
56
+ # Set Flavored Gherkin Title
57
+ #
58
+ # @param [String] title Flavored Gherkin Title
59
+ #
60
+ # Example:
61
+ #
62
+ # FlavoredGherkin.title = 'My Features'
63
+ #
64
+ def self.title=(title)
65
+ @options ||= {}
66
+ @options[:title] = title
67
+ end
68
+
69
+ ##
70
+ # Set Feature Files Path
71
+ #
72
+ # @param [String] feature_path feature files path
73
+ #
74
+ # Example:
75
+ #
76
+ # FlavoredGherkin.feature_path = 'muFolder/features'
77
+ #
78
+ def self.feature_path=(feature_path)
79
+ @options ||= {}
80
+ @options[:feature_path] = feature_path
81
+ end
82
+
83
+ ##
84
+ # Set Feature Files Path
85
+ #
86
+ # @param [String] input_path feature files path
87
+ #
88
+ # Example:
89
+ #
90
+ # FlavoredGherkin.input_path = 'muFolder/features'
91
+ #
92
+ def self.input_path=(input_path)
93
+ @options ||= {}
94
+ @options[:input_path] = input_path
95
+ end
96
+
97
+ ##
98
+ # Set Flavored Gherkin Output Path
99
+ #
100
+ # @param [String] output_path Flavored Gherkin Output Path
101
+ #
102
+ # Example:
103
+ #
104
+ # FlavoredGherkin.output_path = 'myFolder/my_features'
105
+ #
106
+ def self.output_path=(output_path)
107
+ @options ||= {}
108
+ @options[:output_path] = output_path
109
+ end
110
+
111
+ ##
112
+ # Build Flavored Gherkin
113
+ #
114
+ # Examples:
115
+ #
116
+ # FlavoredGherkin.build
117
+ #
118
+ # FlavoredGherkin.build 'muFolder/features'
119
+ #
120
+ # FlavoredGherkin.build feature_path: 'muFolder/features', title: 'My Features'
121
+ #
122
+ def self.build(options = {})
123
+ @options ||= {}
124
+ if options.is_a? String
125
+ @options[:input_path] = options
126
+ elsif options.is_a? Hash
127
+ @options.merge! options
128
+ end
129
+ const_get(flavour).new.build title, feature_files, output_path
130
+ end
131
+
132
+ ##
133
+ # Returns Favour of Flavored Gherkin
134
+ #
135
+ # @return [String] Favour
136
+ #
137
+ def self.flavour
138
+ @options ||= {}
139
+ ['HtmlFlavour'].include?(@options[:flavour]) ? @options[:flavour] : 'HtmlFlavour'
140
+ end
141
+
142
+ ##
143
+ # Returns Title of Flavored Gherkin
144
+ #
145
+ # @return [String] Title
146
+ #
147
+ def self.title
148
+ @options ||= {}
149
+ @options[:title] || (@options[:feature_path] || @options[:input_path] || 'Gherkin/Flavored').split('/').reverse[0..5].join(' ').gsub('.', '')
150
+ end
151
+
152
+ ##
153
+ # Returns List of Feature Files
154
+ #
155
+ # @return [Array] List of Feature Files
156
+ #
157
+ def self.feature_files
158
+ @options ||= {}
159
+ feature_path = @options[:feature_path] || @options[:input_path] || Dir.pwd
160
+ if Pathname.new(feature_path).directory?
161
+ Dir.glob("#{feature_path}/**/*.feature")
162
+ elsif Pathname.new(feature_path).file?
163
+ [feature_path]
164
+ else
165
+ []
166
+ end
167
+ end
168
+
169
+ ##
170
+ # Returns Flavored Gherkin Output Path
171
+ #
172
+ # @return [String] Output Path with file name without extension
173
+ #
174
+ def self.output_path
175
+ @options ||= {}
176
+ output_path = @options[:output_path] ||= Dir.pwd + '/'
177
+ if output_path =~ /.*[\/\\]$/
178
+ unless Pathname(output_path).exist?
179
+ FileUtils.mkpath output_path
180
+ end
181
+ output_path += title.strip.gsub(' ', '_')
182
+ end
183
+ output_path
184
+ end
185
+ end
@@ -0,0 +1,21 @@
1
+ require 'gherkin/parser'
2
+
3
+ module FlavoredGherkin
4
+ ##
5
+ # Base for Flavored Gherkin Flavours
6
+ #
7
+ class Flavour
8
+ def get_gherkins(feature_files)
9
+ parser = Gherkin::Parser.new
10
+ feature_files.map do |file|
11
+ begin
12
+ gherkin = parser.parse(File.read(file))
13
+ gherkin[:file] = file
14
+ gherkin
15
+ rescue
16
+ puts "Skipping:: Invalid gherkin feature file #{file}"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ require 'erb'
2
+ require_relative 'flavour'
3
+
4
+ module FlavoredGherkin
5
+ ##
6
+ # Html Flavored Gherkin
7
+ #
8
+ class HtmlFlavour < Flavour
9
+ ##
10
+ # Build Html Flavored Gherkin
11
+ #
12
+ def build(title, feature_files, output_path)
13
+ gherkins = get_gherkins feature_files
14
+ raise "Error:: No valid gherkin feature file found #{feature_files}" if gherkins.empty?
15
+ File.open("#{output_path}.html", 'w') do |file|
16
+ file.write get('html_flavour').result(binding).gsub(' ', '').gsub("\n\n", '')
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def get(template)
23
+ @erb ||= {}
24
+ @erb[template] ||= ERB.new(File.read(File.dirname(__FILE__) + '/../../template/' + template + '.erb'), nil, nil, '_' + template)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ <b><%= scenario[:keyword] %></b>
2
+ <ul class="steps">
3
+ <% scenario[:steps].each do |step| %>
4
+ <li class="step"><%= get('step').result(binding) %></li>
5
+ <% end %>
6
+ </ul>
@@ -0,0 +1,32 @@
1
+ <div class="collapsible-header waves-effect waves-light brown lighten-1 white-text">
2
+ <i class="material-icons">featured_play_list</i>
3
+ <b><%= feature[:keyword] %></b>&nbsp;<%= feature[:name] %>
4
+ </div>
5
+ <div class="collapsible-body brown lighten-5">
6
+
7
+ <% feature[:tags].each do |tag| %>
8
+ <div class="chip brown lighten-4"><i class="material-icons rotate-45">label</i><span class="f-tag tag-<%= tag[:name].gsub('@', '') %>"><%= tag[:name] %></span></div>
9
+ <% end %>
10
+
11
+ <% if feature[:description] %>
12
+ <pre><%= feature[:description] %></pre>
13
+ <% end %>
14
+
15
+ <p><%= gherkin[:file] %></p>
16
+
17
+ <ul class="collection scenarios">
18
+ <% feature[:children].each_with_index do |scenario, s| %>
19
+ <% if scenario[:type] == :Background%>
20
+ <li class="collection-item brown lighten-4 background"><%= get('background').result(binding) %></li>
21
+ <% else %>
22
+ <% sid = "#{fid}s#{s}"%>
23
+ <li class="collection-item brown lighten-1 <%= scenario[:type] == :ScenarioOutline ? 'scenario-outline' : 'scenario'%>">
24
+ <i class="material-icons white-text">ac_unit</i>&nbsp;
25
+ <a class="modal-trigger waves-effect waves-light white-text" href="#<%= sid %>">
26
+ <b><%= scenario[:keyword] %></b> <%= scenario[:name] %>
27
+ </a>
28
+ </li>
29
+ <% end %>
30
+ <% end %>
31
+ </ul>
32
+ </div>
@@ -0,0 +1,37 @@
1
+ <footer class="page-footer brown lighten-4">
2
+ <div class="footer-copyright brown lighten-1">
3
+ <div class="container">
4
+ <span id="flavours">
5
+ <span class="brown flavour chip selected"></span>
6
+ <% %w(red pink purple deep-purple indigo blue cyan teal green orange deep-orange blue-grey).each do |flavour| %>
7
+ <span class="<%= flavour %> flavour chip z-depth-5"></span>
8
+ <% end %>
9
+ </span>
10
+ <a class="white-text text-lighten-4 right" href="http://flavoredgherkin.rajatthareja.com">Generated by Flavored Gherkin</a>
11
+ </div>
12
+ </div>
13
+ </footer>
14
+
15
+ <% gherkins.each_with_index do |gherkin, f| %>
16
+ <% feature = gherkin[:feature] %>
17
+ <% feature[:children].each_with_index do |scenario, s| %>
18
+ <% next if scenario[:type] == :Background%>
19
+ <% sid = "f#{f}s#{s}" %>
20
+ <%= get('scenario').result(binding) %>
21
+ <% end %>
22
+ <% end %>
23
+
24
+ <script type="text/javascript">
25
+ $(document).ready(function () {
26
+ <% gherkins.each_with_index do |gherkin, f| %>
27
+ <% feature = gherkin[:feature] %>
28
+ <% feature[:children].each_with_index do |scenario, s| %>
29
+ <% next if scenario[:type] == :Background%>
30
+ <% sid = "f#{f}s#{s}" %>
31
+ $('#<%= sid %>').modal();
32
+ <% end %>
33
+ <% end %>
34
+ });
35
+ </script>
36
+
37
+ <script type="text/javascript" src="https://cdn.rawgit.com/rajatthareja/FlavoredGherkin/4e2eb7d0c725b45eac6647de07d01403287771f7/js/flavored.gherkin.min.js"></script>
data/template/head.erb ADDED
@@ -0,0 +1,12 @@
1
+ <head>
2
+ <meta charset="utf-8">
3
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
4
+
5
+ <title><%= title %></title>
6
+
7
+ <link rel="icon" href="http://flavoredgherkin.rajatthareja.com/fg.ico">
8
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
9
+ <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css" media="screen,projection"/>
11
+ <link href="https://cdn.rawgit.com/rajatthareja/FlavoredGherkin/4e2eb7d0c725b45eac6647de07d01403287771f7/css/flavored.gherkin.min.css" rel="stylesheet">
12
+ </head>
@@ -0,0 +1,41 @@
1
+ <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
2
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/js/materialize.min.js"></script>
3
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.min.js"></script>
4
+ <script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
5
+
6
+ <header class="brown lighten-5">
7
+ <div class="row brown lighten-1">
8
+ <div class="col m9 hide-on-small-only">
9
+ <h5 id="title" class="truncate white-text tooltipped" data-tooltip="<%= title %>">
10
+ <div id="loading-flavour" class="preloader-wrapper small active">
11
+ <div class="spinner-layer spinner-blue-only">
12
+ <div class="circle-clipper left">
13
+ <div class="circle"></div>
14
+ </div>
15
+ <div class="gap-patch">
16
+ <div class="circle"></div>
17
+ </div>
18
+ <div class="circle-clipper right">
19
+ <div class="circle"></div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <%= title %>
24
+ </h5>
25
+ </div>
26
+
27
+ <div class="col m3 s12 brown lighten-1">
28
+ <ul class="tabs brown lighten-1">
29
+ <li class="tab col s4">
30
+ <a class="btn brown lighten-3 active blue-text waves-effect waves-light tooltipped" data-tooltip="Overview" href="#overview"><i class="material-icons">public</i></a>
31
+ </li>
32
+ <li class="tab col s4">
33
+ <a class="btn brown lighten-3 white-text waves-effect waves-light tooltipped" data-tooltip="Features" href="#features"><i class="material-icons">view_headline</i></a>
34
+ </li>
35
+ <li class="tab col s4">
36
+ <a class="btn brown lighten-3 white-text waves-effect waves-light tooltipped" data-tooltip="Summary" href="#summary"><i class="material-icons">view_comfy</i></a>
37
+ </li>
38
+ </ul>
39
+ </div>
40
+ </div>
41
+ </header>
@@ -0,0 +1,43 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <%= get('head').result(binding) %>
4
+ <body>
5
+ <%= get('header').result(binding) %>
6
+ <main>
7
+ <div class="row">
8
+ <div class="col s12 m3">
9
+ <table id="featuresCount" class="bordered">
10
+ <tbody></tbody>
11
+ </table>
12
+ </div>
13
+
14
+ <div class="col s12 m3 offset-m6">
15
+ <table id="scenariosCount" class="bordered">
16
+ <tbody></tbody>
17
+ </table>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="row">
22
+ <div id="overview" class="col s12">
23
+ <%= get('overview').result(binding) %>
24
+ </div>
25
+
26
+ <div id="features" class="col s12">
27
+ <ul class="collapsible popout features" data-collapsible="expandable">
28
+ <% gherkins.each_with_index do |gherkin, f| %>
29
+ <% fid = "f#{f}" %>
30
+ <% feature = gherkin[:feature] %>
31
+ <li class="feature"><%= get('feature').result(binding) %></li>
32
+ <% end %>
33
+ </ul>
34
+ </div>
35
+
36
+ <div id="summary" class="col s12">
37
+ <%= get('summary').result(binding) %>
38
+ </div>
39
+ </div>
40
+ </main>
41
+ <%= get('footer').result(binding) %>
42
+ </body>
43
+ </html>
@@ -0,0 +1,5 @@
1
+ <div class="row">
2
+ <div class="col s12">
3
+ <canvas id="scenariosTagsChart"></canvas>
4
+ </div>
5
+ </div>
@@ -0,0 +1,44 @@
1
+ <div id="<%= sid %>" class="modal modal-fixed-footer">
2
+
3
+ <div class="modal-content">
4
+ <% scenario[:tags].each do |tag| %>
5
+ <div class="chip brown lighten-4"><i class="material-icons rotate-45">label</i><span class="s-tag tag-<%= tag[:name].gsub('@', '') %>"><%= tag[:name] %></span></div>
6
+ <% end %>
7
+
8
+ <h5><%= scenario[:name]%></h5>
9
+
10
+ <p><%= gherkin[:file] + ':' + scenario[:location][:line].to_s %></p>
11
+
12
+ <ul class="collection steps">
13
+ <% scenario[:steps].each do |step| %>
14
+ <li class="collection-item brown lighten-4 step"><%= get('step').result(binding) %></li>
15
+ <% end %>
16
+ </ul>
17
+ <% if scenario[:examples] %>
18
+ <% scenario[:examples].each do |example| %>
19
+ <% col_size = 11/example[:tableHeader][:cells].size %>
20
+ <h5><%= example[:keyword] %></h5>
21
+ <div class="examples">
22
+ <div class="row">
23
+ <div class="col s1"></div>
24
+ <% example[:tableHeader][:cells].each do |cell| %>
25
+ <div class="col s<%= col_size %>"><b>| <%= cell[:value] %></b></div>
26
+ <% end %>
27
+ </div>
28
+ <% example[:tableBody].each do |row| %>
29
+ <div class="row example">
30
+ <div class="col s1"></div>
31
+ <% row[:cells].each do |cell| %>
32
+ <div class="col s<%= col_size %>"><b>| </b> <%= cell[:value] %></div>
33
+ <% end %>
34
+ </div>
35
+ <% end %>
36
+ </div>
37
+ <% end %>
38
+ <% end %>
39
+ </div>
40
+
41
+ <div class="modal-footer">
42
+ <span class="modal-action modal-close waves-effect waves-green btn-flat"><i class="material-icons">close</i></span>
43
+ </div>
44
+ </div>
data/template/step.erb ADDED
@@ -0,0 +1,11 @@
1
+ <b><%= step[:keyword] %></b> <%= ERB::Util.html_escape(step[:text]).gsub('&lt;', '<b>').gsub('&gt;', '</b>')%>
2
+ <% if step[:argument]%>
3
+ <% step[:argument][:rows].each do |row| %>
4
+ <div class="row">
5
+ <% col_size = 12/row[:cells].size%>
6
+ <% row[:cells].each do |cell| %>
7
+ <div class="col s<%= col_size %>"><b>| </b><%= cell[:value] %></div>
8
+ <% end %>
9
+ </div>
10
+ <% end %>
11
+ <% end %>
@@ -0,0 +1,36 @@
1
+ <table id="summaryTable" class="bordered" width="100%">
2
+ <thead class="brown lighten-1 white-text">
3
+ <tr>
4
+ <th>Feature</th>
5
+ <th>Scenario</th>
6
+ <th class="hide">Tags</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <% gherkins.each_with_index do |gherkin, f| %>
11
+ <% feature = gherkin[:feature] %>
12
+ <% feature[:children].each_with_index do |scenario, s| %>
13
+
14
+ <% next if scenario[:type] == :Background%>
15
+
16
+ <% sid = "f#{f}s#{s}" %>
17
+ <tr class="brown lighten-4">
18
+
19
+ <td>
20
+ <%= feature[:name] %>
21
+ </td>
22
+
23
+ <td class="hoverable">
24
+ <a class="modal-trigger black-text" href="#<%= sid %>"><%= scenario[:name] %></a>
25
+ </td>
26
+
27
+ <td class="hide">
28
+ <% scenario[:tags].each do |tag| %>
29
+ <%= tag[:name] + '. ' %>
30
+ <% end %>
31
+ </td>
32
+ </tr>
33
+ <% end %>
34
+ <% end %>
35
+ </tbody>
36
+ </table>
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flavored_gherkin
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Rajat Thareja
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gherkin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "<"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "<"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.0'
55
+ description: ''
56
+ email: rajat.thareja.1990@gmail.com
57
+ executables:
58
+ - flavored_gherkin
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE
63
+ - README.md
64
+ - bin/flavored_gherkin
65
+ - flavored_gherkin.gemspec
66
+ - lib/flavored_gherkin.rb
67
+ - lib/flavored_gherkin/flavour.rb
68
+ - lib/flavored_gherkin/html_flavour.rb
69
+ - template/background.erb
70
+ - template/feature.erb
71
+ - template/footer.erb
72
+ - template/head.erb
73
+ - template/header.erb
74
+ - template/html_flavour.erb
75
+ - template/overview.erb
76
+ - template/scenario.erb
77
+ - template/step.erb
78
+ - template/summary.erb
79
+ homepage: http://flavoredgherkin.rajatthareja.com
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 1.9.1
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.6.14
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Ruby gem to convert gherkin feature files into html flavour.
103
+ test_files: []