cuporter 0.3.10 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +86 -70
- data/Rakefile +6 -5
- data/bin/cuporter +2 -0
- data/config/batch_mode.example.yml +47 -0
- data/config/cli/options.rb +19 -3
- data/config/configuration.rb +23 -126
- data/config/cuporter.example.yml +8 -0
- data/config/option_set.rb +79 -0
- data/config/yaml_file/option_set_collection.rb +42 -0
- data/lib/cuporter.rb +1 -3
- data/lib/cuporter/feature_parser.rb +6 -70
- data/lib/cuporter/feature_parser/language.rb +41 -0
- data/lib/cuporter/feature_parser/node_parser.rb +64 -0
- data/lib/cuporter/feature_parser/old_gherkin_yaml/i18n.rb +9 -0
- data/lib/cuporter/feature_parser/parser_base.rb +84 -0
- data/lib/cuporter/feature_parser/tag_nodes_parser.rb +96 -0
- data/lib/cuporter/logging.rb +32 -0
- data/lib/cuporter/node.rb +6 -6
- data/lib/cuporter/report/tag_report.rb +1 -1
- metadata +31 -9
- data/lib/cuporter/node_parser.rb +0 -62
- data/lib/cuporter/tag_nodes_parser.rb +0 -94
@@ -0,0 +1,32 @@
|
|
1
|
+
module Cuporter
|
2
|
+
|
3
|
+
def self.log_error(exception_obj, *messages)
|
4
|
+
ex = "\n\t#{exception_obj.class}: #{exception_obj.message}"
|
5
|
+
ex += "\n\t#{exception_obj.backtrace.join("\n\t")}"
|
6
|
+
Logging.error_logger.warn(messages.join(' ') + ex)
|
7
|
+
end
|
8
|
+
|
9
|
+
module Logging
|
10
|
+
attr_accessor :output_home
|
11
|
+
|
12
|
+
def error_logger
|
13
|
+
@error_logger ||= begin
|
14
|
+
require "logger"
|
15
|
+
logger = ::Logger.new(error_log_file)
|
16
|
+
logger.level = ::Logger::WARN
|
17
|
+
logger.formatter = proc { |severity, datetime, progname, msg|
|
18
|
+
"#{severity} #{datetime.strftime('%b-%d-%y %H:%M:%S')} #{msg}\n\n"
|
19
|
+
}
|
20
|
+
logger
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def error_log_file
|
25
|
+
File.open(File.join(output_home, 'cuporter_errors.log'), 'a')
|
26
|
+
end
|
27
|
+
|
28
|
+
extend(Cuporter::Logging)
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/lib/cuporter/node.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Copyright 2011 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
2
|
+
require 'cuporter/node/sorting'
|
3
|
+
require 'cuporter/node/totalling'
|
4
|
+
require 'cuporter/node/numbering'
|
5
|
+
require 'cuporter/node/node_base'
|
6
|
+
require 'cuporter/node/tagged_node'
|
7
7
|
|
8
8
|
require 'rubygems'
|
9
9
|
require 'nokogiri'
|
10
|
-
require '
|
10
|
+
require 'cuporter/node/types'
|
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: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 12
|
10
|
+
version: 0.3.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tim Camper
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable: cuporter
|
18
|
+
date: 2011-07-04 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: nokogiri
|
@@ -34,6 +33,22 @@ dependencies:
|
|
34
33
|
version: 1.4.1
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: gherkin
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 23
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
version: 1.0.0
|
50
|
+
type: :runtime
|
51
|
+
version_requirements: *id002
|
37
52
|
description: Scrapes Cucumber *.feature files to build reports on tag usage and test inventory
|
38
53
|
email: twcamper@thoughtworks.com
|
39
54
|
executables:
|
@@ -48,18 +63,28 @@ files:
|
|
48
63
|
- LICENSE
|
49
64
|
- README.textile
|
50
65
|
- Rakefile
|
66
|
+
- config/batch_mode.example.yml
|
51
67
|
- config/cli/filter_args_builder.rb
|
52
68
|
- config/cli/options.rb
|
53
69
|
- config/configuration.rb
|
70
|
+
- config/cuporter.example.yml
|
71
|
+
- config/option_set.rb
|
72
|
+
- config/yaml_file/option_set_collection.rb
|
54
73
|
- lib/cuporter/document/assets.rb
|
55
74
|
- lib/cuporter/document/html_document.rb
|
56
75
|
- lib/cuporter/document.rb
|
57
76
|
- lib/cuporter/extensions/nokogiri.rb
|
58
77
|
- lib/cuporter/extensions/string.rb
|
78
|
+
- lib/cuporter/feature_parser/language.rb
|
79
|
+
- lib/cuporter/feature_parser/node_parser.rb
|
80
|
+
- lib/cuporter/feature_parser/old_gherkin_yaml/i18n.rb
|
81
|
+
- lib/cuporter/feature_parser/parser_base.rb
|
82
|
+
- lib/cuporter/feature_parser/tag_nodes_parser.rb
|
59
83
|
- lib/cuporter/feature_parser.rb
|
60
84
|
- lib/cuporter/filter.rb
|
61
85
|
- lib/cuporter/formatters/csv.rb
|
62
86
|
- lib/cuporter/formatters/text.rb
|
87
|
+
- lib/cuporter/logging.rb
|
63
88
|
- lib/cuporter/node/node_base.rb
|
64
89
|
- lib/cuporter/node/numbering.rb
|
65
90
|
- lib/cuporter/node/sorting.rb
|
@@ -67,12 +92,10 @@ files:
|
|
67
92
|
- lib/cuporter/node/totalling.rb
|
68
93
|
- lib/cuporter/node/types.rb
|
69
94
|
- lib/cuporter/node.rb
|
70
|
-
- lib/cuporter/node_parser.rb
|
71
95
|
- lib/cuporter/report/feature_report.rb
|
72
96
|
- lib/cuporter/report/report_base.rb
|
73
97
|
- lib/cuporter/report/tag_report.rb
|
74
98
|
- lib/cuporter/report/tree_report.rb
|
75
|
-
- lib/cuporter/tag_nodes_parser.rb
|
76
99
|
- lib/cuporter.rb
|
77
100
|
- lib/cuporter/formatters/xml_to_html.xslt
|
78
101
|
- bin/cuporter
|
@@ -101,7 +124,6 @@ files:
|
|
101
124
|
- public/jquery.treeview/images/treeview-gray.gif
|
102
125
|
- public/jquery.treeview/images/treeview-red-line.gif
|
103
126
|
- public/jquery.treeview/images/treeview-red.gif
|
104
|
-
has_rdoc: true
|
105
127
|
homepage: http://github.com/twcamper/cuporter
|
106
128
|
licenses: []
|
107
129
|
|
@@ -140,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
162
|
requirements: []
|
141
163
|
|
142
164
|
rubyforge_project: cuporter
|
143
|
-
rubygems_version: 1.
|
165
|
+
rubygems_version: 1.8.5
|
144
166
|
signing_key:
|
145
167
|
specification_version: 3
|
146
168
|
summary: Scrapes Cucumber *.feature files to build reports on tag usage and test inventory
|
data/lib/cuporter/node_parser.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
class NodeParser < FeatureParser
|
5
|
-
|
6
|
-
# ++sub_expression++ is the paren group in the regex, dereferenced with $1 in the caller
|
7
|
-
def new_feature_node(sub_expression, file)
|
8
|
-
f = Node.new_node(:Feature, @doc, :cuke_name => sub_expression, :tags => @current_tags, :file_path => file)
|
9
|
-
f.filter = @filter
|
10
|
-
f
|
11
|
-
end
|
12
|
-
|
13
|
-
def handle_scenario_line(sub_expression)
|
14
|
-
if @filter.pass?(@current_tags | @feature.tags)
|
15
|
-
@feature.add_child(Node.new_node(:Scenario, @doc, :cuke_name => sub_expression, :tags => @current_tags))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def new_scenario_outline_node(sub_expression)
|
20
|
-
so = Node.new_node(:ScenarioOutline, @doc, :cuke_name => sub_expression, :tags => @current_tags)
|
21
|
-
so.filter = @filter
|
22
|
-
so
|
23
|
-
end
|
24
|
-
|
25
|
-
def handle_example_set_line
|
26
|
-
if @filter.pass?(@feature.tags | @scenario_outline.tags | @example_set.tags)
|
27
|
-
@scenario_outline.add_child @example_set
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def new_example_set_node(sub_expression)
|
32
|
-
es = Node.new_node(:Examples, @doc, :cuke_name => sub_expression, :tags => @current_tags)
|
33
|
-
es.filter = @filter
|
34
|
-
es
|
35
|
-
end
|
36
|
-
|
37
|
-
def new_example_line(sub_expression)
|
38
|
-
example_type = :ExampleHeader
|
39
|
-
# if the example set has a child already, then it must be the header
|
40
|
-
example_type = :Example if @example_set.has_children?
|
41
|
-
@example_set.add_child(Node.new_node(example_type, @doc, :cuke_name => sub_expression))
|
42
|
-
end
|
43
|
-
|
44
|
-
def close_scenario_outline
|
45
|
-
if @scenario_outline
|
46
|
-
if @example_set
|
47
|
-
handle_example_set_line
|
48
|
-
@example_set = nil
|
49
|
-
end
|
50
|
-
@feature.add_child(@scenario_outline) if @scenario_outline.has_children?
|
51
|
-
@scenario_outline = nil
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def initialize(file, doc, filter)
|
56
|
-
super(file)
|
57
|
-
@filter = filter
|
58
|
-
@doc = doc
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# Copyright 2010 ThoughtWorks, Inc. Licensed under the MIT License
|
2
|
-
|
3
|
-
module Cuporter
|
4
|
-
class TagNodesParser < FeatureParser
|
5
|
-
|
6
|
-
# ++sub_expression++ is the paren group in the regex, dereferenced with $1 in the caller
|
7
|
-
def new_feature_node(sub_expression, file)
|
8
|
-
{:cuke_name => sub_expression, :tags => @current_tags, :file_path => file}
|
9
|
-
end
|
10
|
-
|
11
|
-
def handle_scenario_line(sub_expression)
|
12
|
-
if @filter.pass?(@feature[:tags] | @current_tags)
|
13
|
-
s = {:cuke_name => sub_expression, :tags => @current_tags}
|
14
|
-
|
15
|
-
(@feature[:tags] | s[:tags]).each do |tag|
|
16
|
-
next unless @filter.pass?([tag])
|
17
|
-
add_scenario(tag, @feature, s)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def new_scenario_outline_node(sub_expression)
|
23
|
-
{:cuke_name => sub_expression, :tags => @current_tags}
|
24
|
-
end
|
25
|
-
|
26
|
-
def handle_example_set_line
|
27
|
-
end
|
28
|
-
|
29
|
-
def new_example_set_node(sub_expression)
|
30
|
-
{:cuke_name => sub_expression.to_s.strip, :tags => @current_tags}
|
31
|
-
end
|
32
|
-
|
33
|
-
def new_example_line(sub_expression)
|
34
|
-
context_tags = (@feature[:tags] | @scenario_outline[:tags] | @example_set[:tags])
|
35
|
-
if @filter.pass?(context_tags)
|
36
|
-
e = {:cuke_name => sub_expression}
|
37
|
-
|
38
|
-
context_tags.each do |tag|
|
39
|
-
next unless @filter.pass?([tag])
|
40
|
-
add_example(tag, @feature, @scenario_outline, @example_set, e)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def close_scenario_outline
|
46
|
-
if @scenario_outline
|
47
|
-
if @example_set
|
48
|
-
@example_set = nil
|
49
|
-
end
|
50
|
-
@scenario_outline = nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
def add_scenario(tag, feature, scenario)
|
54
|
-
unless ( t = @report.tag_node(tag))
|
55
|
-
t = @report.add_child(Node.new_node(:tag, @doc, 'cuke_name' => tag))
|
56
|
-
end
|
57
|
-
unless ( f = t.feature_node(feature) )
|
58
|
-
f = t.add_child(Node.new_node(:Feature, @doc, feature))
|
59
|
-
end
|
60
|
-
f.add_child(Node.new_node(:Scenario, @doc, scenario))
|
61
|
-
end
|
62
|
-
|
63
|
-
def add_example(tag, feature, scenario_outline, example_set, example)
|
64
|
-
unless ( t = @report.tag_node(tag))
|
65
|
-
t = @report.add_child(Node.new_node(:Tag, @doc, 'cuke_name' => tag))
|
66
|
-
end
|
67
|
-
unless ( f = t.feature_node(feature) )
|
68
|
-
f = t.add_child(Node.new_node(:Feature, @doc, feature))
|
69
|
-
end
|
70
|
-
unless ( so = f.scenario_outline_node(scenario_outline) )
|
71
|
-
so = f.add_child(Node.new_node(:ScenarioOutline, @doc, scenario_outline))
|
72
|
-
end
|
73
|
-
|
74
|
-
# The first Example is an ExampleHeader, which does not get counted or
|
75
|
-
# numbered. If the ExampleSet is new, it has no children, and therefore
|
76
|
-
# this is the first and should be an ExampleHeader.
|
77
|
-
example_type = :Example
|
78
|
-
unless ( es = so.example_set_node(example_set) )
|
79
|
-
es = so.add_child(Node.new_node(:Examples, @doc, example_set))
|
80
|
-
example_type = :ExampleHeader
|
81
|
-
end
|
82
|
-
es.add_child(Node.new_node(example_type, @doc, example))
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
def initialize(file, report, filter)
|
87
|
-
super(file)
|
88
|
-
@filter = filter
|
89
|
-
@report = report
|
90
|
-
@doc = report.document
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|