cuporter 0.3.7 → 0.3.9
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.
- data/README.textile +62 -50
- data/Rakefile +2 -2
- data/bin/cuporter +8 -2
- data/config/cli/filter_args_builder.rb +39 -0
- data/config/cli/options.rb +153 -0
- data/config/configuration.rb +94 -0
- data/lib/cuporter.rb +1 -2
- data/lib/cuporter/document.rb +3 -9
- data/lib/cuporter/document/assets.rb +25 -0
- data/lib/cuporter/document/html_document.rb +9 -5
- metadata +8 -6
- data/lib/cuporter/cli/filter_args_builder.rb +0 -37
- data/lib/cuporter/cli/options.rb +0 -162
data/README.textile
CHANGED
@@ -114,56 +114,71 @@ h4. help
|
|
114
114
|
<pre>
|
115
115
|
$ cuporter -h
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
117
|
+
Usage: cuporter [options]
|
118
|
+
|
119
|
+
-r, --report [tag|feature|tree] View, or type of report.
|
120
|
+
Default: "tag"
|
121
|
+
|
122
|
+
-f, --format [xml|html|csv|text] Output format.
|
123
|
+
Default: text (it's pretty, though!)
|
124
|
+
|
125
|
+
-i, --input-dir DIR Root directory of *.feature files.
|
126
|
+
Default: "features"
|
127
|
+
|
128
|
+
Used to build the glob pattern '[--input-dir]/**/*.feature', which is really most likely
|
129
|
+
"features/**/*.features" and finds all feature files anywhere under "features" or
|
130
|
+
your custom root supplied with this option.
|
131
|
+
Overridden by "--file-input'.
|
132
|
+
|
133
|
+
-I, --file-input FILE Single *.feature file. Full name with extension, like 'path/to/file.feature.'
|
134
|
+
Overrides "--input-dir" and used mostly for testing.
|
135
|
+
|
136
|
+
-o, --output-file FILE Output file path, like 'tmp/cucumber/tag_report.html'.
|
137
|
+
|
138
|
+
-t, --tags TAG_EXPRESSION Filter on tags for name report.
|
139
|
+
TAG_EXPRESSION rules:
|
140
|
+
1. $ cucumber --help
|
141
|
+
2. http://github.com/aslakhellesoy/cucumber/wiki/Tags
|
142
|
+
|
143
|
+
-T, --title STRING Override report default title, which is different for each view/report.
|
144
|
+
This affects the xml 'report' node title and the html head > title attributes.
|
145
|
+
|
145
146
|
CSS and Javascript asset options:
|
146
147
|
|
147
|
-
-
|
148
|
-
Only applies with '--link-assets', which is off by default.
|
149
|
-
Setting this will cause assets to be copied from 'public';
|
150
|
-
otherwise, the html will link to the files under 'cuporter/public' in
|
151
|
-
your gempath.
|
152
|
-
|
153
|
-
-l, --link-assets Do not inline CSS and js in <style/> and <script/> tags, but link to
|
154
|
-
external files instead.
|
148
|
+
-l, --link-assets Do not inline CSS and js in <style/> and <script/> tags, but link to external files instead.
|
155
149
|
Default: 'false' for the tag and feature views, not optional for the
|
156
150
|
tree view, which requires external gifs.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
151
|
+
|
152
|
+
-c, --copy-public-assets If --output-file is supplied, and you're linking to external
|
153
|
+
CSS and JavaScript assets, copy them from 'public/' to 'cuporter_public'
|
154
|
+
in the same dir as the output file.
|
155
|
+
Sets --use-copied-public-assets to 'true', and
|
156
|
+
the html report will link to these files by relative path.
|
157
|
+
|
158
|
+
Default: 'false'
|
159
|
+
|
160
|
+
-u, --use-copied-public-assets When running batches of reports, and the assets folder has already been
|
161
|
+
created by another call to cuporter with '--copy-public-assets'.
|
162
|
+
Set to 'true' automatically along with --copy-public-assets.
|
163
|
+
|
164
|
+
Default: 'false'
|
165
|
+
|
166
|
+
--config-file PATH Specify any of these options in a yml file.
|
167
|
+
Order of precedence:
|
168
|
+
1 - command line
|
169
|
+
2 - yaml file
|
170
|
+
3 - these defaults
|
171
|
+
|
172
|
+
Default: 'cuporter.yml'
|
173
|
+
|
174
|
+
Reporting options: on by default but can be turned off:
|
175
|
+
|
176
|
+
--no-sort Do not sort tags, features, scenarios, or outlines
|
177
|
+
--no-number Do not get or show scenario or example numbers, (i.e., do not number the leaf nodes).
|
178
|
+
--no-total Do not get or show totals
|
179
|
+
--no-show-tags Do not show cucumber tags at the feature, scenario, or outline level.
|
180
|
+
--no-show-files Do not show feature file paths.
|
181
|
+
--no-leaves Show features only, with no scenarios or outlines.
|
167
182
|
|
168
183
|
</pre>
|
169
184
|
|
@@ -191,7 +206,7 @@ h4. Examples
|
|
191
206
|
|
192
207
|
h3. Dependencies
|
193
208
|
|
194
|
-
# Nokogiri 1.4.
|
209
|
+
# Nokogiri 1.4.1 or above
|
195
210
|
** For all things Nodular: XML document building and XSL transformation into HTML
|
196
211
|
** Not tested on earlier versions yet but I'd guess you'll be fine with anything recent.
|
197
212
|
** @libxml2@ and @libxslt@ are required by this gem, which *should* handle them smoothly. However, @libxml@ and cousins
|
@@ -206,6 +221,3 @@ h3. Acknowledgements
|
|
206
221
|
|
207
222
|
* Acknowledgements remain due to the Cucumber HTML formatter, and to the human one, too!.
|
208
223
|
* Thanks to everyone involved in Nokogiri, jQuery and the Treeview plugin.
|
209
|
-
|
210
|
-
I used to _"Consider this a stop-gap until we get this functionality in a proper cucumber formatter"_, but now I'm not so sure. Megalomania?
|
211
|
-
|
data/Rakefile
CHANGED
@@ -65,7 +65,7 @@ namespace :cuporter do
|
|
65
65
|
|
66
66
|
spec = Gem::Specification.new do |s|
|
67
67
|
s.name = 'cuporter'
|
68
|
-
s.version = '0.3.
|
68
|
+
s.version = '0.3.9'
|
69
69
|
s.rubyforge_project = s.name
|
70
70
|
|
71
71
|
s.platform = Gem::Platform::RUBY
|
@@ -83,7 +83,7 @@ namespace :cuporter do
|
|
83
83
|
s.executables = [s.default_executable]
|
84
84
|
|
85
85
|
s.files = %w(LICENSE README.textile Rakefile) +
|
86
|
-
FileList["lib/**/*.{rb,xslt}", "bin/*", "public/**/*.{css,js,gif}"].to_a
|
86
|
+
FileList["config/**/*", "lib/**/*.{rb,xslt}", "bin/*", "public/**/*.{css,js,gif}"].to_a
|
87
87
|
|
88
88
|
s.require_path = "lib"
|
89
89
|
end
|
data/bin/cuporter
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../config', File.dirname(__FILE__))
|
3
4
|
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
5
|
+
require 'configuration'
|
4
6
|
require 'cuporter'
|
5
7
|
|
6
8
|
|
@@ -14,8 +16,12 @@ when 'csv'
|
|
14
16
|
when 'text', 'pretty'
|
15
17
|
report.doc.to_text
|
16
18
|
when 'html'
|
17
|
-
|
18
|
-
|
19
|
+
if Cuporter.options[:copy_public_assets]
|
20
|
+
Cuporter::Document::Assets.copy(Cuporter.options[:output_file])
|
21
|
+
end
|
22
|
+
html = Cuporter::Document.new_html(Cuporter.options[:report],
|
23
|
+
Cuporter.options[:link_assets],
|
24
|
+
Cuporter.options[:use_copied_public_assets])
|
19
25
|
formatters = File.expand_path("../lib/cuporter/formatters", File.dirname(__FILE__))
|
20
26
|
xslt = Nokogiri::XSLT(File.read("#{formatters}/xml_to_html.xslt"))
|
21
27
|
html.add_report(xslt.transform(report.doc).at('.report'))
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright 2011 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
+
|
3
|
+
module Cuporter
|
4
|
+
module Config
|
5
|
+
module CLI
|
6
|
+
class FilterArgsBuilder
|
7
|
+
def initialize(cli_tags = [])
|
8
|
+
@cli_tags = cli_tags
|
9
|
+
@all = []
|
10
|
+
@any = []
|
11
|
+
@none = []
|
12
|
+
@args = {}
|
13
|
+
filter_args
|
14
|
+
end
|
15
|
+
|
16
|
+
def filter_args
|
17
|
+
@cli_tags.each do |expression|
|
18
|
+
case expression
|
19
|
+
when /^~@/
|
20
|
+
@none << expression.sub(/~/,'')
|
21
|
+
when /,/
|
22
|
+
@any |= expression.split(',')
|
23
|
+
else
|
24
|
+
@all << expression
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def args
|
30
|
+
@args[:any] = @any unless @any.empty?
|
31
|
+
@args[:all] = @all unless @all.empty?
|
32
|
+
@args[:none] = @none unless @none.empty?
|
33
|
+
@args
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,153 @@
|
|
1
|
+
# Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
+
require 'optparse'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Cuporter
|
6
|
+
module Config
|
7
|
+
module CLI
|
8
|
+
|
9
|
+
class Options
|
10
|
+
|
11
|
+
def self.[](key)
|
12
|
+
self.options[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.options
|
16
|
+
parse unless @options
|
17
|
+
@options
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.args
|
21
|
+
@@args
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.parse
|
25
|
+
@@args = ARGV.dup
|
26
|
+
@options = {}
|
27
|
+
|
28
|
+
OptionParser.new(ARGV.dup) do |opts|
|
29
|
+
opts.banner = "Usage: cuporter [options]\n\n"
|
30
|
+
|
31
|
+
opts.on("-r", "--report [tag|feature|tree]", %Q{View, or type of report.
|
32
|
+
Default: "tag"
|
33
|
+
}) do |r|
|
34
|
+
@options[:report] = (r == 'name' ? 'feature' : r)
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-f", "--format [xml|html|csv|text]", %Q{Output format.
|
38
|
+
Default: text (it's pretty, though!)
|
39
|
+
}) do |f|
|
40
|
+
@options[:format] = f
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-i", "--input-dir DIR", %Q{Root directory of *.feature files.
|
44
|
+
Default: "features"
|
45
|
+
|
46
|
+
Used to build the glob pattern '[--input-dir]/**/*.feature', which is really most likely
|
47
|
+
"features/**/*.features" and finds all feature files anywhere under "features" or
|
48
|
+
your custom root supplied with this option.
|
49
|
+
Overridden by "--file-input'.
|
50
|
+
}) do |i|
|
51
|
+
@options[:input_dir] = i.sub(/#{File::SEPARATOR}$/,'')
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on("-I", "--file-input FILE", %Q{Single *.feature file. Full name with extension, like 'path/to/file.feature.'
|
55
|
+
Overrides "--input-dir" and used mostly for testing.
|
56
|
+
}) do |file|
|
57
|
+
@options[:input_file] = file
|
58
|
+
end
|
59
|
+
|
60
|
+
opts.on("-o", "--output-file FILE", %Q{Output file path, like 'tmp/cucumber/tag_report.html'.
|
61
|
+
}) do |o|
|
62
|
+
@options[:output_file] = o
|
63
|
+
end
|
64
|
+
|
65
|
+
@options[:tags] = []
|
66
|
+
opts.on("-t", "--tags TAG_EXPRESSION", %Q{Filter on tags for name report.
|
67
|
+
TAG_EXPRESSION rules:
|
68
|
+
1. $ cucumber --help
|
69
|
+
2. http://github.com/aslakhellesoy/cucumber/wiki/Tags
|
70
|
+
}) do |t|
|
71
|
+
@options[:tags] << t
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("-T", "--title STRING", %Q{Override report default title, which is different for each view/report.
|
75
|
+
This affects the xml 'report' node title and the html head > title attributes.
|
76
|
+
}) do |title|
|
77
|
+
@options[:title] = title
|
78
|
+
end
|
79
|
+
|
80
|
+
opts.separator "CSS and Javascript asset options:\n\n"
|
81
|
+
|
82
|
+
opts.on("-l", "--link-assets", %Q{Do not inline CSS and js in <style/> and <script/> tags, but link to external files instead.
|
83
|
+
Default: 'false' for the tag and feature views, not optional for the
|
84
|
+
tree view, which requires external gifs.
|
85
|
+
}) do |l|
|
86
|
+
@options[:link_assets] = l
|
87
|
+
end
|
88
|
+
|
89
|
+
opts.on("-c", "--copy-public-assets", %Q{If --output-file is supplied, and you're linking to external
|
90
|
+
CSS and JavaScript assets, copy them from 'public/' to 'cuporter_public'
|
91
|
+
in the same dir as the output file.
|
92
|
+
Sets --use-copied-public-assets to 'true', and
|
93
|
+
the html report will link to these files by relative path.
|
94
|
+
|
95
|
+
Default: 'false'
|
96
|
+
}) do |c|
|
97
|
+
@options[:copy_public_assets] = c
|
98
|
+
@options[:use_copied_public_assets] = c
|
99
|
+
end
|
100
|
+
|
101
|
+
opts.on("-u", "--use-copied-public-assets", %Q{When running batches of reports, and the assets folder has already been
|
102
|
+
created by another call to cuporter with '--copy-public-assets'.
|
103
|
+
Set to 'true' automatically along with --copy-public-assets.
|
104
|
+
|
105
|
+
Default: 'false'
|
106
|
+
}) do |u|
|
107
|
+
@options[:use_copied_public_assets] = u
|
108
|
+
end
|
109
|
+
|
110
|
+
opts.on("--config-file PATH", %Q{Specify any of these options in a yml file.
|
111
|
+
Order of precedence:
|
112
|
+
1 - command line
|
113
|
+
2 - yaml file
|
114
|
+
3 - these defaults
|
115
|
+
|
116
|
+
Default: 'cuporter.yml'
|
117
|
+
}) do |path|
|
118
|
+
@options[:config_file] = path
|
119
|
+
end
|
120
|
+
|
121
|
+
opts.separator "Reporting options: on by default but can be turned off:\n\n"
|
122
|
+
opts.on("--no-sort", "Do not sort tags, features, scenarios, or outlines\n") do |n|
|
123
|
+
@options[:sort] = n
|
124
|
+
end
|
125
|
+
|
126
|
+
opts.on("--no-number", "Do not get or show scenario or example numbers, (i.e., do not number the leaf nodes).\n") do |n|
|
127
|
+
@options[:number] = n
|
128
|
+
end
|
129
|
+
|
130
|
+
opts.on("--no-total", "Do not get or show totals\n") do |n|
|
131
|
+
@options[:total] = n
|
132
|
+
end
|
133
|
+
|
134
|
+
opts.on("--no-show-tags", "Do not show cucumber tags at the feature, scenario, or outline level.\n") do |show_tags|
|
135
|
+
@options[:show_tags] = show_tags
|
136
|
+
end
|
137
|
+
|
138
|
+
opts.on("--no-show-files", "Do not show feature file paths.\n") do |show_files|
|
139
|
+
@options[:show_files] = show_files
|
140
|
+
end
|
141
|
+
|
142
|
+
opts.on("--no-leaves", "Show features only, with no scenarios or outlines.\n\n\n") do |l|
|
143
|
+
@options[:leaves] = l
|
144
|
+
end
|
145
|
+
|
146
|
+
end.parse!
|
147
|
+
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Copyright 2011 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
+
$LOAD_PATH.unshift( File.expand_path("#{File.dirname(__FILE__)}"))
|
3
|
+
require 'fileutils'
|
4
|
+
require 'cli/options'
|
5
|
+
require 'cli/filter_args_builder'
|
6
|
+
|
7
|
+
module Cuporter
|
8
|
+
module Config
|
9
|
+
|
10
|
+
module Options
|
11
|
+
|
12
|
+
DEFAULTS = { :report => "tag",
|
13
|
+
:format => "text",
|
14
|
+
:input_dir => "features",
|
15
|
+
:tags => [],
|
16
|
+
:copy_public_assets => false,
|
17
|
+
:use_copied_public_assets => false,
|
18
|
+
:sort => true,
|
19
|
+
:number => true,
|
20
|
+
:total => true,
|
21
|
+
:show_tags => true,
|
22
|
+
:show_files => true,
|
23
|
+
:leaves => true
|
24
|
+
}
|
25
|
+
|
26
|
+
def self.options
|
27
|
+
unless @options
|
28
|
+
# empty hash if no file
|
29
|
+
file_config = config_file(Cuporter::Config::CLI::Options[:config_file] || "cuporter.yml")
|
30
|
+
|
31
|
+
# CLI options replace any found in the file
|
32
|
+
cli_options_over_file_options = file_config.merge(Cuporter::Config::CLI::Options.options)
|
33
|
+
|
34
|
+
# defaults will be used for anything not so far specified in the file
|
35
|
+
# or CLI
|
36
|
+
@options = post_process(DEFAULTS.merge(cli_options_over_file_options))
|
37
|
+
end
|
38
|
+
@options
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.post_process(options)
|
42
|
+
options[:input_file_pattern] = options.delete(:input_file) || "#{options.delete(:input_dir)}/**/*.feature"
|
43
|
+
options[:root_dir] = options[:input_file_pattern].split(File::SEPARATOR).first
|
44
|
+
options[:filter_args] = Cuporter::Config::CLI::FilterArgsBuilder.new(options.delete(:tags)).args
|
45
|
+
if options[:output_file]
|
46
|
+
options[:output_file] = full_path(options[:output_file].dup)
|
47
|
+
else
|
48
|
+
options[:copy_public_assets] = false
|
49
|
+
options[:use_copied_public_assets] = false
|
50
|
+
end
|
51
|
+
options
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.config_file(path)
|
55
|
+
return {} unless File.exists?(path)
|
56
|
+
|
57
|
+
require 'yaml'
|
58
|
+
pairs = {}
|
59
|
+
YAML.load_file(path).each do |key, value|
|
60
|
+
pairs[key.to_sym] = case value
|
61
|
+
when /^true$/i
|
62
|
+
true
|
63
|
+
when /^false$/i
|
64
|
+
false
|
65
|
+
end || value
|
66
|
+
end
|
67
|
+
pairs
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.full_path(path)
|
71
|
+
expanded_path = File.expand_path(path)
|
72
|
+
path_nodes = expanded_path.split(File::SEPARATOR)
|
73
|
+
file = path_nodes.pop
|
74
|
+
FileUtils.makedirs(path_nodes.join(File::SEPARATOR))
|
75
|
+
expanded_path
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.html?
|
82
|
+
Config::Options[:format] == 'html'
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.options
|
86
|
+
Config::Options.options
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.output_file
|
90
|
+
if options[:output_file]
|
91
|
+
File.open(options[:output_file], "w")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/lib/cuporter.rb
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
$LOAD_PATH.unshift( File.expand_path("#{File.dirname(__FILE__)}"))
|
3
3
|
$LOAD_PATH.unshift( File.expand_path("#{File.dirname(__FILE__)}/.."))
|
4
4
|
require 'cuporter/extensions/string'
|
5
|
-
require 'cuporter/cli/options'
|
6
|
-
require 'cuporter/cli/filter_args_builder'
|
7
5
|
require 'cuporter/node'
|
8
6
|
require 'cuporter/formatters/text'
|
9
7
|
require 'cuporter/formatters/csv'
|
@@ -12,6 +10,7 @@ require 'cuporter/feature_parser'
|
|
12
10
|
require 'cuporter/tag_nodes_parser'
|
13
11
|
require 'cuporter/node_parser'
|
14
12
|
require 'cuporter/document'
|
13
|
+
require 'cuporter/document/assets'
|
15
14
|
require 'cuporter/document/html_document'
|
16
15
|
require 'cuporter/report/report_base'
|
17
16
|
require 'cuporter/report/tag_report'
|
data/lib/cuporter/document.rb
CHANGED
@@ -10,20 +10,14 @@ module Cuporter
|
|
10
10
|
doc
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.new_html(view, link_assets,
|
13
|
+
def self.new_html(view, link_assets, use_copied_public_assets)
|
14
14
|
Nokogiri::XML::Document.send(:include, Cuporter::Document::Html)
|
15
15
|
doc = Nokogiri::XML::Document.new
|
16
16
|
doc.view = view
|
17
17
|
doc.link_assets = link_assets
|
18
|
-
|
18
|
+
doc.assets_src = Assets::PUBLIC_SOURCE_PATH
|
19
|
+
doc.assets_base_path = Assets.base_path(use_copied_public_assets)
|
19
20
|
|
20
|
-
# we count on the dirs being created by the option parser
|
21
|
-
if link_assets
|
22
|
-
FileUtils.cp_r("#{project_assets}/.", assets_dir)
|
23
|
-
doc.assets_dir = assets_dir
|
24
|
-
else
|
25
|
-
doc.assets_dir = project_assets
|
26
|
-
end
|
27
21
|
root = Nokogiri::XML::Node.new('html', doc)
|
28
22
|
root.create_internal_subset( 'html', "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")
|
29
23
|
doc << root
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright 2011 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
+
module Cuporter
|
3
|
+
module Document
|
4
|
+
module Assets
|
5
|
+
PUBLIC_SOURCE_PATH = File.expand_path( "public", File.dirname(__FILE__) + "../../../../")
|
6
|
+
RELATIVE_PUBLIC_ASSETS_PATH = "cuporter_public"
|
7
|
+
|
8
|
+
def self.copy(output_file_path)
|
9
|
+
assets_target = "#{File.dirname(output_file_path)}/#{RELATIVE_PUBLIC_ASSETS_PATH}"
|
10
|
+
FileUtils.rm_rf(assets_target) if File.exists?(assets_target)
|
11
|
+
FileUtils.mkdir(assets_target)
|
12
|
+
FileUtils.cp_r("#{PUBLIC_SOURCE_PATH}/.", assets_target)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.base_path(use_copied_public_assets)
|
16
|
+
# we count on the dirs being created by the option parser
|
17
|
+
if use_copied_public_assets
|
18
|
+
RELATIVE_PUBLIC_ASSETS_PATH
|
19
|
+
else
|
20
|
+
PUBLIC_SOURCE_PATH
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,7 +2,11 @@
|
|
2
2
|
module Cuporter
|
3
3
|
module Document
|
4
4
|
module Html
|
5
|
-
attr_accessor :view, :link_assets, :
|
5
|
+
attr_accessor :view, :link_assets, :assets_src, :assets_base_path
|
6
|
+
|
7
|
+
def assets_base_path
|
8
|
+
@assets_base_path ||= assets_target || assets_src
|
9
|
+
end
|
6
10
|
|
7
11
|
def add_report(node)
|
8
12
|
root << head(node['title'])
|
@@ -50,22 +54,22 @@ module Cuporter
|
|
50
54
|
|
51
55
|
def style_css(file)
|
52
56
|
style = new_node('style', 'type' => 'text/css')
|
53
|
-
style << file_contents("#{
|
57
|
+
style << file_contents("#{assets_src}/#{file}")
|
54
58
|
style
|
55
59
|
end
|
56
60
|
|
57
61
|
def script_js(file)
|
58
62
|
script = new_node('script', 'type' => 'text/javascript')
|
59
|
-
script << file_contents("#{
|
63
|
+
script << file_contents("#{assets_src}/#{file}")
|
60
64
|
script
|
61
65
|
end
|
62
66
|
|
63
67
|
def link_css(file)
|
64
|
-
new_node('link', 'type' => 'text/css', 'rel' => 'stylesheet', 'href' => "#{
|
68
|
+
new_node('link', 'type' => 'text/css', 'rel' => 'stylesheet', 'href' => "#{assets_base_path}/#{file}")
|
65
69
|
end
|
66
70
|
|
67
71
|
def link_js(file)
|
68
|
-
new_node('script', 'type' => 'text/javascript', 'src' => "#{
|
72
|
+
new_node('script', 'type' => 'text/javascript', 'src' => "#{assets_base_path}/#{file}")
|
69
73
|
end
|
70
74
|
|
71
75
|
def file_contents(file_name)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 9
|
10
|
+
version: 0.3.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Camper
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-14 00:00:00 -04:00
|
19
19
|
default_executable: cuporter
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,8 +47,10 @@ files:
|
|
47
47
|
- LICENSE
|
48
48
|
- README.textile
|
49
49
|
- Rakefile
|
50
|
-
-
|
51
|
-
-
|
50
|
+
- config/cli/filter_args_builder.rb
|
51
|
+
- config/cli/options.rb
|
52
|
+
- config/configuration.rb
|
53
|
+
- lib/cuporter/document/assets.rb
|
52
54
|
- lib/cuporter/document/html_document.rb
|
53
55
|
- lib/cuporter/document.rb
|
54
56
|
- lib/cuporter/extensions/nokogiri.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
module CLI
|
5
|
-
class FilterArgsBuilder
|
6
|
-
def initialize(cli_tags = [])
|
7
|
-
@cli_tags = cli_tags
|
8
|
-
@all = []
|
9
|
-
@any = []
|
10
|
-
@none = []
|
11
|
-
@args = {}
|
12
|
-
filter_args
|
13
|
-
end
|
14
|
-
|
15
|
-
def filter_args
|
16
|
-
@cli_tags.each do |expression|
|
17
|
-
case expression
|
18
|
-
when /^~@/
|
19
|
-
@none << expression.sub(/~/,'')
|
20
|
-
when /,/
|
21
|
-
@any |= expression.split(',')
|
22
|
-
else
|
23
|
-
@all << expression
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def args
|
29
|
-
@args[:any] = @any unless @any.empty?
|
30
|
-
@args[:all] = @all unless @all.empty?
|
31
|
-
@args[:none] = @none unless @none.empty?
|
32
|
-
@args
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/cuporter/cli/options.rb
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
# Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
-
require 'optparse'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
module Cuporter
|
6
|
-
module CLI
|
7
|
-
|
8
|
-
class Options
|
9
|
-
|
10
|
-
def self.[](key)
|
11
|
-
self.options[key]
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.options
|
15
|
-
unless @options
|
16
|
-
self.parse
|
17
|
-
@options[:input_file_pattern] = @options.delete(:input_file) || "#{@options.delete(:input_dir)}/**/*.feature"
|
18
|
-
@options[:root_dir] = @options[:input_file_pattern].split(File::SEPARATOR).first
|
19
|
-
@options[:filter_args] = Cuporter::CLI::FilterArgsBuilder.new(@options.delete(:tags)).args
|
20
|
-
end
|
21
|
-
@options
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.args
|
25
|
-
@@args
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
def self.full_path(path)
|
30
|
-
expanded_path = File.expand_path(path)
|
31
|
-
path_nodes = expanded_path.split(File::SEPARATOR)
|
32
|
-
file = path_nodes.pop
|
33
|
-
FileUtils.makedirs(path_nodes.join(File::SEPARATOR))
|
34
|
-
expanded_path
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.parse
|
38
|
-
@@args = ARGV.dup
|
39
|
-
@options = {}
|
40
|
-
OptionParser.new(ARGV.dup) do |opts|
|
41
|
-
opts.banner = "Usage: cuporter [options]\n\n"
|
42
|
-
|
43
|
-
@options[:report] = "tag"
|
44
|
-
opts.on("-r", "--report [tag|feature|tree]", %Q{View, or type of report.
|
45
|
-
Default: "tag"
|
46
|
-
}) do |r|
|
47
|
-
@options[:report] = (r == 'name' ? 'feature' : r)
|
48
|
-
end
|
49
|
-
|
50
|
-
@options[:format] = "text"
|
51
|
-
opts.on("-f", "--format [xml|html|csv|text]", %Q{Output format.
|
52
|
-
Default: text (it's pretty, though!)
|
53
|
-
}) do |f|
|
54
|
-
@options[:format] = f
|
55
|
-
end
|
56
|
-
|
57
|
-
@options[:input_dir] = "features"
|
58
|
-
opts.on("-i", "--input-dir DIR", %Q{Root directory of *.feature files.
|
59
|
-
Default: "features"
|
60
|
-
|
61
|
-
Used to build the glob pattern '[--input-dir]/**/*.feature', which is really most likely
|
62
|
-
"features/**/*.features" and finds all feature files anywhere under "features" or
|
63
|
-
your custom root supplied with this option.
|
64
|
-
Overridden by "--file-input'.
|
65
|
-
}) do |i|
|
66
|
-
@options[:input_dir] = i.sub(/#{File::SEPARATOR}$/,'')
|
67
|
-
end
|
68
|
-
|
69
|
-
opts.on("-I", "--file-input FILE", %Q{Single *.feature file. Full name with extension, like 'path/to/file.feature.'
|
70
|
-
Overrides "--input-dir" and used mostly for testing.
|
71
|
-
}) do |file|
|
72
|
-
@options[:input_file] = file
|
73
|
-
end
|
74
|
-
|
75
|
-
opts.on("-o", "--output-file FILE", %Q{Output file path, like 'tmp/cucumber/tag_report.html'.
|
76
|
-
}) do |o|
|
77
|
-
@options[:output_file] = full_path(o)
|
78
|
-
end
|
79
|
-
|
80
|
-
@options[:tags] = []
|
81
|
-
opts.on("-t", "--tags TAG_EXPRESSION", %Q{Filter on tags for name report.
|
82
|
-
TAG_EXPRESSION rules:
|
83
|
-
1. $ cucumber --help
|
84
|
-
2. http://github.com/aslakhellesoy/cucumber/wiki/Tags
|
85
|
-
}) do |t|
|
86
|
-
@options[:tags] << t
|
87
|
-
end
|
88
|
-
|
89
|
-
opts.on("-T", "--title STRING", %Q{Override report default title, which is different for each view/report.
|
90
|
-
This affects the xml 'report' node title and the html head > title attributes.
|
91
|
-
}) do |title|
|
92
|
-
@options[:title] = title
|
93
|
-
end
|
94
|
-
|
95
|
-
opts.separator "CSS and Javascript asset options:\n\n"
|
96
|
-
opts.on("-a", "--assets-dir PATH", %Q{Path to folder for CSS and Javascript assets.
|
97
|
-
Only applies with '--link-assets', which is off by default.
|
98
|
-
Setting this will cause assets to be copied from 'public';
|
99
|
-
otherwise, the html will link to the files under 'cuporter/public' in
|
100
|
-
your gempath.
|
101
|
-
}) do |a|
|
102
|
-
@options[:assets_dir] = a
|
103
|
-
end
|
104
|
-
|
105
|
-
opts.on("-l", "--link-assets", %Q{Do not inline CSS and js in <style/> and <script/> tags, but link to external files instead.
|
106
|
-
Default: 'false' for the tag and feature views, not optional for the
|
107
|
-
tree view, which requires external gifs.
|
108
|
-
}) do |l|
|
109
|
-
@options[:link_assets] = l
|
110
|
-
end
|
111
|
-
|
112
|
-
opts.separator "Reporting options: on by default but can be turned off:\n\n"
|
113
|
-
@options[:sort] = true
|
114
|
-
opts.on("--no-sort", "Do not sort tags, features, scenarios, or outlines\n") do |n|
|
115
|
-
@options[:sort] = n
|
116
|
-
end
|
117
|
-
|
118
|
-
@options[:number] = true
|
119
|
-
opts.on("--no-number", "Do not get or show scenario or example numbers, (i.e., do not number the leaf nodes).\n") do |n|
|
120
|
-
@options[:number] = n
|
121
|
-
end
|
122
|
-
|
123
|
-
@options[:total] = true
|
124
|
-
opts.on("--no-total", "Do not get or show totals\n") do |n|
|
125
|
-
@options[:total] = n
|
126
|
-
end
|
127
|
-
|
128
|
-
@options[:show_tags] = true
|
129
|
-
opts.on("--no-show-tags", "Do not show cucumber tags at the feature, scenario, or outline level.\n") do |show_tags|
|
130
|
-
@options[:show_tags] = show_tags
|
131
|
-
end
|
132
|
-
|
133
|
-
@options[:show_files] = true
|
134
|
-
opts.on("--no-show-files", "Do not show feature file paths.\n") do |show_files|
|
135
|
-
@options[:show_files] = show_files
|
136
|
-
end
|
137
|
-
|
138
|
-
@options[:leaves] = true
|
139
|
-
opts.on("--no-leaves", "Show features only, with no scenarios or outlines.\n\n\n") do |l|
|
140
|
-
@options[:leaves] = l
|
141
|
-
end
|
142
|
-
|
143
|
-
end.parse!
|
144
|
-
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
def self.html?
|
150
|
-
CLI::Options[:format] == 'html'
|
151
|
-
end
|
152
|
-
|
153
|
-
def self.options
|
154
|
-
CLI::Options.options
|
155
|
-
end
|
156
|
-
|
157
|
-
def self.output_file
|
158
|
-
if options[:output_file]
|
159
|
-
File.open(options[:output_file], "w")
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|