cuporter 0.2.4 → 0.2.5

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/Rakefile CHANGED
@@ -56,7 +56,7 @@ namespace :cuporter do
56
56
 
57
57
  spec = Gem::Specification.new do |s|
58
58
  s.name = 'cuporter'
59
- s.version = '0.2.4'
59
+ s.version = '0.2.5'
60
60
  s.rubyforge_project = s.name
61
61
 
62
62
  s.platform = Gem::Platform::RUBY
@@ -69,11 +69,12 @@ namespace :cuporter do
69
69
  s.email = 'twcamper@thoughtworks.com'
70
70
  s.homepage = 'http://github.com/twcamper/cuporter'
71
71
  s.required_ruby_version = '>= 1.8.7'
72
+ s.add_dependency('builder', '>= 2.1.2')
72
73
  s.default_executable = "cuporter"
73
74
  s.executables = [s.default_executable]
74
75
 
75
76
  s.files = %w(LICENSE README.textile Rakefile) +
76
- FileList["lib/**/*.{rb,css}", "spec/**/*.rb", "features/**/*.{feature,rb}", "bin/*"].to_a
77
+ FileList["lib/**/*.{rb,css}", "bin/*"].to_a
77
78
 
78
79
  s.require_path = "lib"
79
80
  end
@@ -2,10 +2,6 @@
2
2
  module Cuporter
3
3
  class ExampleSetNode < TagListNode
4
4
 
5
- def initialize(name, tags)
6
- super(name, tags)
7
- end
8
-
9
5
  def sort!
10
6
  # no op
11
7
  end
@@ -10,16 +10,17 @@ module Cuporter
10
10
  EXAMPLE_SET_LINE = /^\s*(Examples:[^#]*)$/
11
11
  EXAMPLE_LINE = /^\s*(\|.*\|)\s*$/
12
12
 
13
- def initialize
13
+ def initialize(file)
14
+ @file = file
14
15
  @current_tags = []
15
16
  end
16
17
 
17
- def self.parse(feature_content)
18
- self.new.parse(feature_content)
18
+ def self.parse(file)
19
+ self.new(file).parse
19
20
  end
20
21
 
21
- def parse(feature_content)
22
- lines = feature_content.split(/\n/)
22
+ def parse
23
+ lines = File.read(@file).split(/\n/)
23
24
 
24
25
  lines.each_with_index do |line, i|
25
26
  case line
@@ -28,6 +29,7 @@ module Cuporter
28
29
  @current_tags |= $1.strip.split(/\s+/)
29
30
  when FEATURE_LINE
30
31
  @feature = TagListNode.new($1, @current_tags)
32
+ @feature.file = @file.sub(/^.*features\//,"features/")
31
33
  @current_tags = []
32
34
  when SCENARIO_LINE
33
35
  # How do we know when we have read all the lines from a "Scenario Outline:"?
@@ -34,8 +34,8 @@ ul {
34
34
  .feature_name {
35
35
  margin-left: -2em;
36
36
  padding-left: 2em;
37
- padding-top: 0.1em;
38
- padding-bottom: 0.1em;
37
+ padding-top: 0.3em;
38
+ padding-bottom: 0.3em;
39
39
  font-weight: bold;
40
40
  background-color: #24A6C1;
41
41
  color: white;
@@ -68,4 +68,11 @@ ul {
68
68
  left: 4.5em;
69
69
  font-weight: bold;
70
70
  }
71
+ .file {
72
+ float: right;
73
+ padding-right: 0.5em;
74
+ font-weight: normal;
75
+ font-size: 1.1em;
76
+ color: black;
71
77
 
78
+ }
@@ -29,7 +29,10 @@ module Cuporter
29
29
 
30
30
  def write_node_name(node)
31
31
  builder.span("#{node.number}.", :class => :number) if node.number
32
- builder.div(node.name, :class => "#{node_class(node.name)}_name")
32
+ builder.div(:class => "#{node_class(node.name)}_name") do
33
+ builder.span(node.name)
34
+ builder.span(node.file, :class => :file) if node.file
35
+ end
33
36
  end
34
37
 
35
38
  def write_children(node)
data/lib/cuporter/node.rb CHANGED
@@ -3,8 +3,9 @@ module Cuporter
3
3
  class Node
4
4
  include Comparable
5
5
 
6
- attr_reader :name, :children
7
- attr_accessor :number
6
+ attr_reader :name
7
+ attr_accessor :children, :number, :file
8
+
8
9
 
9
10
  def initialize(name)
10
11
  @name = name.to_s.strip
@@ -67,20 +68,6 @@ module Cuporter
67
68
  end
68
69
  alias :== :eql?
69
70
 
70
- # Have my children adopt the other node's grandchildren.
71
- #
72
- # Copy children of other node's top-level, direct descendants to this
73
- # node's direct descendants of the same name.
74
- def merge(other)
75
- other.children.each do |other_child|
76
- direct_child = find_or_create_child(other_child.name)
77
- new_grandchild = Node.new(other.name)
78
- other_child.children.collect do |c|
79
- new_grandchild.add_child(c)
80
- end
81
- direct_child.add_child(new_grandchild)
82
- end
83
- end
84
71
 
85
72
  def total
86
73
  number_all_descendants unless @numberer
@@ -21,5 +21,20 @@ module Cuporter
21
21
  end
22
22
  end
23
23
 
24
+ # Have my children adopt the other node's grandchildren.
25
+ #
26
+ # Copy children of other node's top-level, direct descendants to this
27
+ # node's direct descendants of the same name.
28
+ def merge(other)
29
+ other.children.each do |other_child|
30
+ direct_child = find_or_create_child(other_child.name)
31
+ new_grandchild = Node.new(other.name)
32
+ new_grandchild.children = other_child.children
33
+ new_grandchild.file = other.file
34
+
35
+ direct_child.add_child(new_grandchild)
36
+ end
37
+ end
38
+
24
39
  end
25
40
  end
@@ -13,8 +13,8 @@ module Cuporter
13
13
  def scenarios_per_tag
14
14
  tags = TagListNode.new("report",[])
15
15
  files.each do |file|
16
- content = File.read(file)
17
- tags.merge(FeatureParser.parse(content)) unless content.empty?
16
+ feature = FeatureParser.parse(file)
17
+ tags.merge(feature) if feature
18
18
  end
19
19
  tags.sort_all_descendants!
20
20
  tags
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tim Camper
@@ -15,10 +15,25 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-08 00:00:00 -04:00
18
+ date: 2010-09-14 00:00:00 -04:00
19
19
  default_executable: cuporter
20
- dependencies: []
21
-
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: builder
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 2
34
+ version: 2.1.2
35
+ type: :runtime
36
+ version_requirements: *id001
22
37
  description: Scrapes Cucumber *.feature files to build report on tag usage
23
38
  email: twcamper@thoughtworks.com
24
39
  executables:
@@ -48,19 +63,6 @@ files:
48
63
  - lib/cuporter/tag_report.rb
49
64
  - lib/cuporter.rb
50
65
  - lib/cuporter/formatters/cuporter.css
51
- - spec/cuporter/node_spec.rb
52
- - spec/cuporter/sort_node_spec.rb
53
- - spec/cuporter/feature_parser_spec.rb
54
- - spec/cuporter/support/functional/cli.rb
55
- - spec/cuporter/node_numberer_spec.rb
56
- - spec/cuporter/example_set_node_spec.rb
57
- - spec/cuporter/functional/scenario_outlines_spec.rb
58
- - spec/cuporter/functional/single_feature_spec.rb
59
- - spec/cuporter/tag_list_node_spec.rb
60
- - spec/spec_helper.rb
61
- - features/pretty_print.feature
62
- - features/support/env.rb
63
- - features/step_definitions/cuporter_steps.rb
64
66
  - bin/cuporter
65
67
  has_rdoc: true
66
68
  homepage: http://github.com/twcamper/cuporter
@@ -1,7 +0,0 @@
1
- Feature: Pretty print report on 3 features
2
-
3
- @just_me
4
- Scenario: Everything in fixtures/self_test
5
- When I run cuporter --in fixtures/self_test
6
- Then the output should have the same contents as "features/reports/pretty_with_outlines_and_examples.txt"
7
-
@@ -1,8 +0,0 @@
1
- When /^I run cuporter (.*)$/ do |cuporter_opts|
2
- @output = `bin#{File::SEPARATOR}cuporter #{cuporter_opts}`
3
- end
4
-
5
-
6
- Then /^.* should have the same contents as "([^"]*)"$/ do |expected_file|
7
- @output.should == IO.read(File.expand_path(expected_file))
8
- end
@@ -1,2 +0,0 @@
1
- $LOAD_PATH << File.expand_path('../../../lib' , __FILE__)
2
- require 'cuporter'
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- module Cuporter
3
- describe ExampleSetNode do
4
- context 'empty' do
5
- it 'raises no error when numbering' do
6
- node = ExampleSetNode.new("Scenarios: stuff", [])
7
- expect do
8
- node.number_all_descendants
9
- end.to_not raise_error
10
- node.total.should == 0
11
- end
12
- end
13
-
14
- context 'with children' do
15
- it 'does not count first or "header" row' do
16
- node = ExampleSetNode.new("Scenarios: stuff", [])
17
- node.add_child(Node.new("|col1|col2|"))
18
- node.add_child(Node.new("|val1|val2|"))
19
-
20
- node.number_all_descendants
21
- node.children.first.number.should be_nil
22
- node.children.last.number.should == 1
23
- end
24
- end
25
- end
26
- end
@@ -1,78 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Cuporter
4
- describe FeatureParser do
5
- context "#tags" do
6
- context "one tag" do
7
- it "returns one tag" do
8
- feature = FeatureParser.parse("@wip\nFeature: foo")
9
- feature.tags.should == ["@wip"]
10
- end
11
- end
12
-
13
- context "two tags on one line" do
14
- it "returns two tags" do
15
- feature = FeatureParser.parse(" \n@smoke @wip\nFeature: foo")
16
- feature.tags.sort.should == %w[@smoke @wip].sort
17
- end
18
- end
19
- context "two tags on two lines" do
20
- it "returns two tags" do
21
- feature = FeatureParser.parse(" \n@smoke\n @wip\nFeature: foo")
22
- feature.tags.sort.should == %w[@smoke @wip].sort
23
- end
24
- end
25
- context "no tags" do
26
- it "returns no tags" do
27
- feature = FeatureParser.parse("\nFeature: foo")
28
- feature.tags.should == []
29
- end
30
- end
31
-
32
- end
33
-
34
- context "#name" do
35
- let(:name) {"Feature: consume a fairly typical feature name, and barf it back up"}
36
- context "sentence with comma" do
37
- it "returns the full name" do
38
- feature = FeatureParser.parse("\n#{name}\n Background: blah")
39
- feature.name.should == name
40
- end
41
- end
42
- context "name followed by comment" do
43
- it "returns only the full name" do
44
- feature = FeatureParser.parse("# Here is a feature comment\n# And another comment\n #{name} # comment text here\n Background: blah")
45
- feature.name.should == name
46
- end
47
- end
48
-
49
- end
50
-
51
- context "#parse" do
52
- context "table which is not an example set" do
53
- it "does not raise an error" do
54
- content = <<EOF
55
-
56
- Feature: table not examples
57
-
58
- Scenario: no examples under here
59
- Given foo
60
- When bar
61
- Then wow:
62
- | All |
63
- | Some |
64
- | Any |
65
- | Few |
66
- | Most |
67
- EOF
68
-
69
- expect do
70
- FeatureParser.parse(content)
71
- end.to_not raise_error
72
- end
73
- end
74
- end
75
-
76
- end
77
- end
78
-