cuporter 0.3.9 → 0.3.10
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 +88 -68
- data/Rakefile +2 -2
- data/bin/cuporter +67 -19
- data/config/cli/options.rb +26 -14
- data/config/configuration.rb +101 -54
- data/lib/cuporter/document.rb +1 -2
- data/lib/cuporter/document/html_document.rb +1 -1
- data/lib/cuporter/formatters/csv.rb +1 -5
- data/lib/cuporter/formatters/text.rb +7 -8
- metadata +5 -4
    
        data/README.textile
    CHANGED
    
    | @@ -25,9 +25,25 @@ h3. 4 Output Formats | |
| 25 25 | 
             
            # pretty-print text
         | 
| 26 26 | 
             
            # csv
         | 
| 27 27 |  | 
| 28 | 
            +
            Splitting the output among multiple formats is supported, so you could run a single report and write it 
         | 
| 29 | 
            +
            to an html file, a csv file, and show the xml or text on @stdout@ in the terminal.
         | 
| 30 | 
            +
             | 
| 28 31 | 
             
            h3. A bunch of configuration options
         | 
| 29 32 |  | 
| 30 | 
            -
            See the help output below | 
| 33 | 
            +
            See the help output below for all of the options, which can be supplied in to ways:
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            # Command Line
         | 
| 36 | 
            +
            # Yaml File
         | 
| 37 | 
            +
            ** use it to add to or override the program defaults
         | 
| 38 | 
            +
            ** *Batch mode:* run multiple reports at once simply by specifying an option set for each in @cuporter.yml@
         | 
| 39 | 
            +
            ** the file name itself is a configurable option
         | 
| 40 | 
            +
            ** See the samples.
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            h4. option override precedence
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            # Highest Precedence (overrides all): command line
         | 
| 45 | 
            +
            # Middle Precedence: yaml file
         | 
| 46 | 
            +
            # Lowest Precedence: @Cuporter::Config::OptionSet::DEFAULTS@
         | 
| 31 47 |  | 
| 32 48 | 
             
            ---------
         | 
| 33 49 |  | 
| @@ -113,73 +129,77 @@ h4. help | |
| 113 129 |  | 
| 114 130 | 
             
            <pre>
         | 
| 115 131 | 
             
              $ cuporter -h
         | 
| 116 | 
            -
             | 
| 117 | 
            -
            Usage: cuporter [options]
         | 
| 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 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 150 | 
            -
             | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 159 | 
            -
             | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 132 | 
            +
              
         | 
| 133 | 
            +
              Usage: cuporter [options]
         | 
| 134 | 
            +
              
         | 
| 135 | 
            +
                  -r, --report [tag|feature|tree]  View, or type of report.
         | 
| 136 | 
            +
                                                       Default: "tag"
         | 
| 137 | 
            +
              
         | 
| 138 | 
            +
                  -f, --format [xml|html|csv|text] Output format.
         | 
| 139 | 
            +
                                                       Default: text (it's pretty, though!)
         | 
| 140 | 
            +
                          
         | 
| 141 | 
            +
                  -i, --input-dir DIR              Root directory of *.feature files.
         | 
| 142 | 
            +
                                                       Default: "features"
         | 
| 143 | 
            +
              
         | 
| 144 | 
            +
                                                       Used to build the glob pattern '[--input-dir]/**/*.feature', which is really most likely
         | 
| 145 | 
            +
                                                       "features/**/*.features" and finds all feature files anywhere under "features" or
         | 
| 146 | 
            +
                                                       your custom root supplied with this option.
         | 
| 147 | 
            +
                                                       Overridden by "--file-input'.
         | 
| 148 | 
            +
                          
         | 
| 149 | 
            +
                  -I, --file-input FILE            Single *.feature file.  Full name with extension, like 'path/to/file.feature.'
         | 
| 150 | 
            +
                                                       Overrides "--input-dir" and used mostly for testing.
         | 
| 151 | 
            +
                          
         | 
| 152 | 
            +
                  -o, --output-file FILE           Output file path, like 'tmp/cucumber/tag_report.html'.
         | 
| 153 | 
            +
                          
         | 
| 154 | 
            +
                  -t, --tags TAG_EXPRESSION        Filter on tags for name report.
         | 
| 155 | 
            +
                                                       TAG_EXPRESSION rules:
         | 
| 156 | 
            +
                                                           1. $ cucumber --help
         | 
| 157 | 
            +
                                                           2. http://github.com/aslakhellesoy/cucumber/wiki/Tags
         | 
| 158 | 
            +
                          
         | 
| 159 | 
            +
                  -T, --title STRING               Override report default title, which is different for each view/report.
         | 
| 160 | 
            +
                                                       This affects the xml 'report' node title and the html head > title attributes.
         | 
| 161 | 
            +
                          
         | 
| 162 | 
            +
                      --config-file PATH           Specify any of these options in a yml file.
         | 
| 163 | 
            +
                                                         Order of precedence:
         | 
| 164 | 
            +
                                                            1 - command line
         | 
| 165 | 
            +
                                                            2 - yaml file
         | 
| 166 | 
            +
                                                            3 - these defaults
         | 
| 167 | 
            +
              
         | 
| 168 | 
            +
                                                         Default: 'cuporter.yml'
         | 
| 169 | 
            +
                          
         | 
| 170 | 
            +
                  -d, --dry-run                    Print the configuration without running any reports.
         | 
| 171 | 
            +
                          
         | 
| 172 | 
            +
                      --text-summary               Add a summary to the text format.
         | 
| 173 | 
            +
                          
         | 
| 174 | 
            +
              CSS and Javascript asset options:
         | 
| 175 | 
            +
              
         | 
| 176 | 
            +
                  -l, --link-assets                Do not inline CSS and js in <style/> and <script/> tags, but link to external files instead.
         | 
| 177 | 
            +
                                                         Default:  'false' for the tag and feature views, not optional for the
         | 
| 178 | 
            +
                                                                   tree view, which requires external gifs.
         | 
| 179 | 
            +
                          
         | 
| 180 | 
            +
                  -c, --copy-public-assets         If --output-file is supplied, and you're linking to external 
         | 
| 181 | 
            +
                                                         CSS and JavaScript assets, copy them from 'public/' to 'cuporter_public'
         | 
| 182 | 
            +
                                                         in the same dir as the output file.
         | 
| 183 | 
            +
                                                         Sets --use-copied-public-assets to 'true', and
         | 
| 184 | 
            +
                                                         the html report will link to these files by relative path.
         | 
| 185 | 
            +
              
         | 
| 186 | 
            +
                                                         Default: 'false'
         | 
| 187 | 
            +
                          
         | 
| 188 | 
            +
                  -u, --use-copied-public-assets   When running batches of reports, and the assets folder has already been
         | 
| 189 | 
            +
                                                         created by another call to cuporter with '--copy-public-assets'.
         | 
| 190 | 
            +
                                                         Set to 'true' automatically along with --copy-public-assets.
         | 
| 191 | 
            +
              
         | 
| 192 | 
            +
                                                         Default: 'false'
         | 
| 193 | 
            +
                          
         | 
| 194 | 
            +
              Reporting options: on by default but can be turned off:
         | 
| 195 | 
            +
              
         | 
| 196 | 
            +
                      --no-sort                    Do not sort tags, features, scenarios, or outlines
         | 
| 197 | 
            +
                      --no-number                  Do not get or show scenario or example numbers, (i.e., do not number the leaf nodes).
         | 
| 198 | 
            +
                      --no-total                   Do not get or show totals
         | 
| 199 | 
            +
                      --no-show-tags               Do not show cucumber tags at the feature, scenario, or outline level.
         | 
| 200 | 
            +
                      --no-show-files              Do not show feature file paths.
         | 
| 201 | 
            +
                      --no-leaves                  Show features only, with no scenarios or outlines.
         | 
| 202 | 
            +
              
         | 
| 183 203 | 
             
            </pre>
         | 
| 184 204 |  | 
| 185 205 | 
             
            h4. Examples
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -54,7 +54,7 @@ namespace :cuporter do | |
| 54 54 | 
             
              RDOC_OPTS = ["--all" , "--quiet" , "--line-numbers" , "--inline-source", 
         | 
| 55 55 | 
             
                "--main", "README.textile", 
         | 
| 56 56 | 
             
                "--title", "Cuporter: cucumber tag reporting"]
         | 
| 57 | 
            -
              XTRA_RDOC = %w{README.textile LICENSE }
         | 
| 57 | 
            +
              XTRA_RDOC = %w{bin/cuporter README.textile LICENSE }
         | 
| 58 58 |  | 
| 59 59 | 
             
              Rake::RDocTask.new do |rd|
         | 
| 60 60 | 
             
                rd.rdoc_dir = "doc/rdoc"
         | 
| @@ -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.10'
         | 
| 69 69 | 
             
                s.rubyforge_project = s.name
         | 
| 70 70 |  | 
| 71 71 | 
             
                s.platform = Gem::Platform::RUBY
         | 
    
        data/bin/cuporter
    CHANGED
    
    | @@ -5,28 +5,76 @@ $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__)) | |
| 5 5 | 
             
            require 'configuration'
         | 
| 6 6 | 
             
            require 'cuporter'
         | 
| 7 7 |  | 
| 8 | 
            +
            module Cuporter
         | 
| 8 9 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
               | 
| 14 | 
            -
             | 
| 15 | 
            -
               | 
| 16 | 
            -
             | 
| 17 | 
            -
               | 
| 18 | 
            -
             | 
| 19 | 
            -
               | 
| 20 | 
            -
             | 
| 10 | 
            +
              #=Default:
         | 
| 11 | 
            +
              # 
         | 
| 12 | 
            +
              # Single tag report of everything under "features/", formatted as
         | 
| 13 | 
            +
              # indented text, showing feature names, scenario names, tags, file names, as well as scenario totals and sequence numbers.
         | 
| 14 | 
            +
              #
         | 
| 15 | 
            +
              # Configuration:
         | 
| 16 | 
            +
              # 
         | 
| 17 | 
            +
              # Use the command line options and/or yaml file to turn off everything but
         | 
| 18 | 
            +
              # the feature names, and also to supply filtering tags (cucumber
         | 
| 19 | 
            +
              # syntax and logical rules).
         | 
| 20 | 
            +
              #
         | 
| 21 | 
            +
              #
         | 
| 22 | 
            +
              # Split output:
         | 
| 23 | 
            +
              # 
         | 
| 24 | 
            +
              # Note that a given report can be sent to multiple output targets.  For
         | 
| 25 | 
            +
              # example, html to a file and pretty text or xml to <tt>stdout</tt>.  Specify
         | 
| 26 | 
            +
              # multiple output files, and Cuporter will associate each of their names with the correct
         | 
| 27 | 
            +
              # format/output stream, but if you get the file extension wrong it will fall
         | 
| 28 | 
            +
              # back on <tt>stdout</tt>.  The possible extensions are <tt>.txt</tt>,
         | 
| 29 | 
            +
              # <tt>.xml</tt>, <tt>.html</tt>, and <tt>.csv</tt>.
         | 
| 30 | 
            +
              #
         | 
| 31 | 
            +
              #
         | 
| 32 | 
            +
              # Batch reporting:
         | 
| 33 | 
            +
              #
         | 
| 34 | 
            +
              # Use the yaml file to specify options for as many reports or views as you
         | 
| 35 | 
            +
              # like to produce at once.
         | 
| 36 | 
            +
              def self.run
         | 
| 37 | 
            +
                Cuporter.option_sets.each do |options|
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  if options.dry_run?
         | 
| 40 | 
            +
                    options.dump
         | 
| 41 | 
            +
                    puts
         | 
| 42 | 
            +
                    next
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                  report = Cuporter::ReportBase.create(options).build
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  options[:format].each do |format|
         | 
| 48 | 
            +
                    (options.output_file(format) || STDOUT).puts(
         | 
| 49 | 
            +
                      case format
         | 
| 50 | 
            +
                      when 'xml'
         | 
| 51 | 
            +
                        report.doc.to_xml(:indent => 2, :encoding => 'UTF-8')
         | 
| 52 | 
            +
                      when 'csv'
         | 
| 53 | 
            +
                        Cuporter::Formatters::NodeFormatters.total = options[:total]
         | 
| 54 | 
            +
                        report.doc.to_csv
         | 
| 55 | 
            +
                      when 'text', 'pretty'
         | 
| 56 | 
            +
                        Cuporter::Formatters::NodeFormatters.total = options[:total]
         | 
| 57 | 
            +
                        Cuporter::Formatters::NodeFormatters.text_summary = options[:text_summary]
         | 
| 58 | 
            +
                        report.doc.to_text
         | 
| 59 | 
            +
                      when 'html'
         | 
| 60 | 
            +
                        if options[:copy_public_assets]
         | 
| 61 | 
            +
                          Cuporter::Document::Assets.copy(options[:output_file].first)
         | 
| 62 | 
            +
                        end
         | 
| 63 | 
            +
                        html = Cuporter::Document.new_html(options[:report],
         | 
| 64 | 
            +
                                                           options[:link_assets], 
         | 
| 65 | 
            +
                                                           options[:use_copied_public_assets])
         | 
| 66 | 
            +
                        formatters = File.expand_path("../lib/cuporter/formatters", File.dirname(__FILE__))
         | 
| 67 | 
            +
                        xslt = Nokogiri::XSLT(File.read("#{formatters}/xml_to_html.xslt"))
         | 
| 68 | 
            +
                        html.add_report(xslt.transform(report.doc).at('.report'))
         | 
| 69 | 
            +
                        html.to_html
         | 
| 70 | 
            +
                      end
         | 
| 71 | 
            +
                    )
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                end
         | 
| 21 74 | 
             
              end
         | 
| 22 | 
            -
              html = Cuporter::Document.new_html(Cuporter.options[:report],
         | 
| 23 | 
            -
                                                 Cuporter.options[:link_assets], 
         | 
| 24 | 
            -
                                                 Cuporter.options[:use_copied_public_assets])
         | 
| 25 | 
            -
              formatters = File.expand_path("../lib/cuporter/formatters", File.dirname(__FILE__))
         | 
| 26 | 
            -
              xslt = Nokogiri::XSLT(File.read("#{formatters}/xml_to_html.xslt"))
         | 
| 27 | 
            -
              html.add_report(xslt.transform(report.doc).at('.report'))
         | 
| 28 | 
            -
              html.to_html
         | 
| 29 75 | 
             
            end
         | 
| 30 76 |  | 
| 77 | 
            +
            Cuporter.run
         | 
| 78 | 
            +
             | 
| 31 79 | 
             
            __END__
         | 
| 32 80 | 
             
            xsltproc --stringparam view feature lib/cuporter/formatters/xml_to_html.xslt new_feature.xml | ruby -e "f = STDIN.read; puts f.gsub(/\<\!--[\*\/]{2}--\>/, '')" | tee xslt_feature.html
         | 
    
        data/config/cli/options.rb
    CHANGED
    
    | @@ -37,7 +37,8 @@ module Cuporter | |
| 37 37 | 
             
                        opts.on("-f", "--format [xml|html|csv|text]", %Q{Output format.
         | 
| 38 38 | 
             
                                                     Default: text (it's pretty, though!)
         | 
| 39 39 | 
             
                        }) do |f|
         | 
| 40 | 
            -
                          @options[:format] =  | 
| 40 | 
            +
                          @options[:format] = [] unless @options[:format]
         | 
| 41 | 
            +
                          @options[:format] << f
         | 
| 41 42 | 
             
                        end
         | 
| 42 43 |  | 
| 43 44 | 
             
                        opts.on("-i", "--input-dir DIR", %Q{Root directory of *.feature files.
         | 
| @@ -59,15 +60,16 @@ module Cuporter | |
| 59 60 |  | 
| 60 61 | 
             
                        opts.on("-o", "--output-file FILE", %Q{Output file path, like 'tmp/cucumber/tag_report.html'.
         | 
| 61 62 | 
             
                        }) do |o|
         | 
| 62 | 
            -
                          @options[:output_file] =  | 
| 63 | 
            +
                          @options[:output_file] = [] unless @options[:output_file]
         | 
| 64 | 
            +
                          @options[:output_file] << o
         | 
| 63 65 | 
             
                        end
         | 
| 64 66 |  | 
| 65 | 
            -
                        @options[:tags] = []
         | 
| 66 67 | 
             
                        opts.on("-t", "--tags TAG_EXPRESSION", %Q{Filter on tags for name report.
         | 
| 67 68 | 
             
                                                     TAG_EXPRESSION rules:
         | 
| 68 69 | 
             
                                                         1. $ cucumber --help
         | 
| 69 70 | 
             
                                                         2. http://github.com/aslakhellesoy/cucumber/wiki/Tags
         | 
| 70 71 | 
             
                        }) do |t|
         | 
| 72 | 
            +
                          @options[:tags] = [] unless @options[:tags]
         | 
| 71 73 | 
             
                          @options[:tags] << t
         | 
| 72 74 | 
             
                        end
         | 
| 73 75 |  | 
| @@ -77,6 +79,27 @@ module Cuporter | |
| 77 79 | 
             
                          @options[:title] = title
         | 
| 78 80 | 
             
                        end
         | 
| 79 81 |  | 
| 82 | 
            +
                        opts.on("--config-file PATH", %Q{Specify any of these options in a yml file.
         | 
| 83 | 
            +
                                                       Order of precedence:
         | 
| 84 | 
            +
                                                          1 - command line
         | 
| 85 | 
            +
                                                          2 - yaml file
         | 
| 86 | 
            +
                                                          3 - these defaults
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                                                       Default: 'cuporter.yml'
         | 
| 89 | 
            +
                        }) do |path|
         | 
| 90 | 
            +
                          @options[:config_file] = path
         | 
| 91 | 
            +
                        end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                        opts.on("-d", "--dry-run", %Q{Print the configuration without running any reports.
         | 
| 94 | 
            +
                        }) do |d|
         | 
| 95 | 
            +
                          @options[:dry_run] = d
         | 
| 96 | 
            +
                        end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                        opts.on("--text-summary", %Q{Add a summary to the text format.
         | 
| 99 | 
            +
                        }) do |ts|
         | 
| 100 | 
            +
                          @options[:text_summary] = ts
         | 
| 101 | 
            +
                        end
         | 
| 102 | 
            +
             | 
| 80 103 | 
             
                        opts.separator "CSS and Javascript asset options:\n\n"
         | 
| 81 104 |  | 
| 82 105 | 
             
                        opts.on("-l", "--link-assets", %Q{Do not inline CSS and js in <style/> and <script/> tags, but link to external files instead.
         | 
| @@ -107,17 +130,6 @@ module Cuporter | |
| 107 130 | 
             
                          @options[:use_copied_public_assets] = u
         | 
| 108 131 | 
             
                        end
         | 
| 109 132 |  | 
| 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 133 | 
             
                        opts.separator "Reporting options: on by default but can be turned off:\n\n"
         | 
| 122 134 | 
             
                        opts.on("--no-sort", "Do not sort tags, features, scenarios, or outlines\n") do |n|
         | 
| 123 135 | 
             
                          @options[:sort] = n
         | 
    
        data/config/configuration.rb
    CHANGED
    
    | @@ -7,67 +7,110 @@ require 'cli/filter_args_builder' | |
| 7 7 | 
             
            module Cuporter
         | 
| 8 8 | 
             
              module Config
         | 
| 9 9 |  | 
| 10 | 
            -
                 | 
| 10 | 
            +
                class OptionSetCollection
         | 
| 11 11 |  | 
| 12 | 
            -
                   | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 12 | 
            +
                  def self.path
         | 
| 13 | 
            +
                    Cuporter::Config::CLI::Options[:config_file] || "cuporter.yml"
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def self.config_file
         | 
| 17 | 
            +
                    return [] unless File.exists?(path)
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                    require 'yaml'
         | 
| 20 | 
            +
                    yaml = YAML.load_file(path)
         | 
| 21 | 
            +
                    if yaml["option_sets"]
         | 
| 22 | 
            +
                      yaml["option_sets"].map do |option_set|
         | 
| 23 | 
            +
                        cast(option_set["options"])
         | 
| 24 | 
            +
                      end
         | 
| 25 | 
            +
                    else
         | 
| 26 | 
            +
                      yaml["defaults"].empty? ? [] : [cast(yaml["defaults"])]
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  def self.cast(option_set)
         | 
| 31 | 
            +
                    pairs = {}
         | 
| 32 | 
            +
                    option_set.each do |key, value|
         | 
| 33 | 
            +
                      pairs[key.to_sym] = case key
         | 
| 34 | 
            +
                                          when /^(tags|output_file|format)$/i
         | 
| 35 | 
            +
                                            value.is_a?(Array) ? value : [value]
         | 
| 36 | 
            +
                                          else
         | 
| 37 | 
            +
                                            value
         | 
| 38 | 
            +
                                          end
         | 
| 39 | 
            +
                    end
         | 
| 40 | 
            +
             
         | 
| 41 | 
            +
                    return pairs
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                class OptionSet
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  DEFAULTS = { :report                   => "tag",
         | 
| 48 | 
            +
                               :format                   => ["text"],
         | 
| 49 | 
            +
                               :input_dir                => "features",
         | 
| 50 | 
            +
                               :output_file              => [],
         | 
| 51 | 
            +
                               :tags                     => [],
         | 
| 52 | 
            +
                               :link_assets              => false,
         | 
| 53 | 
            +
                               :copy_public_assets       => false,
         | 
| 17 54 | 
             
                               :use_copied_public_assets => false,
         | 
| 18 | 
            -
                               : | 
| 19 | 
            -
                               : | 
| 20 | 
            -
                               : | 
| 21 | 
            -
                               : | 
| 22 | 
            -
                               : | 
| 23 | 
            -
                               : | 
| 55 | 
            +
                               :dry_run                  => false,
         | 
| 56 | 
            +
                               :sort                     => true,
         | 
| 57 | 
            +
                               :number                   => true,
         | 
| 58 | 
            +
                               :total                    => true,
         | 
| 59 | 
            +
                               :show_tags                => true,
         | 
| 60 | 
            +
                               :show_files               => true,
         | 
| 61 | 
            +
                               :leaves                   => true
         | 
| 24 62 | 
             
                  }
         | 
| 25 63 |  | 
| 26 | 
            -
                   | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 64 | 
            +
                  attr_reader :options
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  def initialize(file_config = {})
         | 
| 67 | 
            +
                    # CLI options replace any found in the file
         | 
| 68 | 
            +
                    cli_options_over_file_options = file_config.merge(Cuporter::Config::CLI::Options.options)
         | 
| 30 69 |  | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 70 | 
            +
                    # defaults will be used for anything not so far specified in the file
         | 
| 71 | 
            +
                    # or CLI
         | 
| 72 | 
            +
                    @options = post_process(DEFAULTS.merge(cli_options_over_file_options))
         | 
| 73 | 
            +
                  end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                  def [](key)
         | 
| 76 | 
            +
                    @options[key]
         | 
| 77 | 
            +
                  end
         | 
| 33 78 |  | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
                       | 
| 79 | 
            +
                  def output_file(format)
         | 
| 80 | 
            +
                    if (file = @options[:output_file].find {|f| f =~ ext_for(format) })
         | 
| 81 | 
            +
                      File.open(file, "w")
         | 
| 37 82 | 
             
                    end
         | 
| 38 | 
            -
                    @options
         | 
| 39 83 | 
             
                  end
         | 
| 40 84 |  | 
| 41 | 
            -
                  def  | 
| 85 | 
            +
                  def dump
         | 
| 86 | 
            +
                    col_1_max = @options.keys.max_by {|i| i.to_s.length }.to_s.size
         | 
| 87 | 
            +
                    @options.each do |key, value|
         | 
| 88 | 
            +
                      puts ":#{key.to_s.ljust(col_1_max, ' ')} => #{value.inspect}"
         | 
| 89 | 
            +
                    end
         | 
| 90 | 
            +
                  end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  def dry_run?
         | 
| 93 | 
            +
                    @options[:dry_run]
         | 
| 94 | 
            +
                  end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  private
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                  def post_process(options)
         | 
| 42 99 | 
             
                    options[:input_file_pattern] = options.delete(:input_file) || "#{options.delete(:input_dir)}/**/*.feature"
         | 
| 43 100 | 
             
                    options[:root_dir] = options[:input_file_pattern].split(File::SEPARATOR).first
         | 
| 44 101 | 
             
                    options[:filter_args] = Cuporter::Config::CLI::FilterArgsBuilder.new(options.delete(:tags)).args
         | 
| 45 | 
            -
                     | 
| 46 | 
            -
                      options[:output_file] = full_path( | 
| 47 | 
            -
                    else
         | 
| 48 | 
            -
                      options[:copy_public_assets] = false
         | 
| 49 | 
            -
                      options[:use_copied_public_assets] = false
         | 
| 102 | 
            +
                    options[:output_file].each_with_index do |file_path, i|
         | 
| 103 | 
            +
                      options[:output_file][i] = full_path(file_path.dup)
         | 
| 50 104 | 
             
                    end
         | 
| 51 | 
            -
                    options
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                  def self.config_file(path)
         | 
| 55 | 
            -
                    return {} unless File.exists?(path)
         | 
| 56 105 |  | 
| 57 | 
            -
                     | 
| 58 | 
            -
             | 
| 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
         | 
| 106 | 
            +
                    unless options[:output_file].find {|f| f =~ /\.html$/ }
         | 
| 107 | 
            +
                      options[:copy_public_assets] = options[:use_copied_public_assets] = false
         | 
| 66 108 | 
             
                    end
         | 
| 67 | 
            -
             | 
| 109 | 
            +
             | 
| 110 | 
            +
                    options
         | 
| 68 111 | 
             
                  end
         | 
| 69 112 |  | 
| 70 | 
            -
                  def  | 
| 113 | 
            +
                  def full_path(path)
         | 
| 71 114 | 
             
                    expanded_path = File.expand_path(path)
         | 
| 72 115 | 
             
                    path_nodes = expanded_path.split(File::SEPARATOR)
         | 
| 73 116 | 
             
                    file = path_nodes.pop
         | 
| @@ -75,20 +118,24 @@ module Cuporter | |
| 75 118 | 
             
                    expanded_path
         | 
| 76 119 | 
             
                  end
         | 
| 77 120 |  | 
| 121 | 
            +
                  def ext_for(format)
         | 
| 122 | 
            +
                    case format
         | 
| 123 | 
            +
                    when 'text', 'pretty'
         | 
| 124 | 
            +
                      /\.txt$/
         | 
| 125 | 
            +
                    else
         | 
| 126 | 
            +
                      /\.#{format}$/
         | 
| 127 | 
            +
                    end
         | 
| 128 | 
            +
                  end
         | 
| 78 129 | 
             
                end
         | 
| 79 130 | 
             
              end
         | 
| 80 131 |  | 
| 81 | 
            -
              def self. | 
| 82 | 
            -
                Config:: | 
| 132 | 
            +
              def self.option_sets
         | 
| 133 | 
            +
                if (yaml_hashes = Config::OptionSetCollection.config_file).any?
         | 
| 134 | 
            +
                  yaml_hashes.map {|set| Config::OptionSet.new(set) }
         | 
| 135 | 
            +
                else
         | 
| 136 | 
            +
                  [Config::OptionSet.new]
         | 
| 137 | 
            +
                end
         | 
| 83 138 | 
             
              end
         | 
| 84 139 |  | 
| 85 | 
            -
              def self.options
         | 
| 86 | 
            -
                Config::Options.options
         | 
| 87 | 
            -
              end
         | 
| 88 140 |  | 
| 89 | 
            -
              def self.output_file
         | 
| 90 | 
            -
                if options[:output_file]
         | 
| 91 | 
            -
                  File.open(options[:output_file], "w")
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
              end
         | 
| 94 141 | 
             
            end
         | 
    
        data/lib/cuporter/document.rb
    CHANGED
    
    | @@ -11,8 +11,7 @@ module Cuporter | |
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                def self.new_html(view, link_assets, use_copied_public_assets)
         | 
| 14 | 
            -
                   | 
| 15 | 
            -
                  doc =  Nokogiri::XML::Document.new
         | 
| 14 | 
            +
                  doc =  Cuporter::Document::Html.new
         | 
| 16 15 | 
             
                  doc.view = view
         | 
| 17 16 | 
             
                  doc.link_assets = link_assets
         | 
| 18 17 | 
             
                  doc.assets_src = Assets::PUBLIC_SOURCE_PATH
         | 
| @@ -13,11 +13,7 @@ module Cuporter | |
| 13 13 | 
             
                  end
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def total_column_spacer
         | 
| 16 | 
            -
                    @@total_column_spacer ||=  | 
| 17 | 
            -
                  end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  def total_column
         | 
| 20 | 
            -
                    @@total_column ||= total_column_spacer
         | 
| 16 | 
            +
                    @@total_column_spacer ||= NodeFormatters.total ? tab_stop : ""
         | 
| 21 17 | 
             
                  end
         | 
| 22 18 |  | 
| 23 19 | 
             
                  def total(node)
         | 
| @@ -14,8 +14,12 @@ module Cuporter | |
| 14 14 | 
             
                end
         | 
| 15 15 |  | 
| 16 16 | 
             
                module NodeFormatters
         | 
| 17 | 
            +
                  class << self
         | 
| 18 | 
            +
                    attr_accessor :total, :text_summary
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 17 21 | 
             
                  def report(l, node)
         | 
| 18 | 
            -
                    return l unless  | 
| 22 | 
            +
                    return l unless NodeFormatters.text_summary
         | 
| 19 23 | 
             
                    l += total(node)
         | 
| 20 24 | 
             
                    l += cuke_name(node['cuke_name'])
         | 
| 21 25 | 
             
                    l += title(node['title'])
         | 
| @@ -89,7 +93,6 @@ module Cuporter | |
| 89 93 | 
             
                module Text
         | 
| 90 94 | 
             
                  extend Util
         | 
| 91 95 | 
             
                  extend NodeFormatters
         | 
| 92 | 
            -
                  
         | 
| 93 96 |  | 
| 94 97 | 
             
                  SPACER  = " "
         | 
| 95 98 | 
             
                  def tab_stop
         | 
| @@ -97,16 +100,12 @@ module Cuporter | |
| 97 100 | 
             
                  end
         | 
| 98 101 |  | 
| 99 102 | 
             
                  def total_column_spacer
         | 
| 100 | 
            -
                    @@total_column_spacer ||=  | 
| 101 | 
            -
                  end
         | 
| 102 | 
            -
             | 
| 103 | 
            -
                  def total_column
         | 
| 104 | 
            -
                    @@total_column ||= Cuporter.options[:total] ? tab_stop * 2: ""
         | 
| 103 | 
            +
                    @@total_column_spacer ||= NodeFormatters.total ? tab_stop : ""
         | 
| 105 104 | 
             
                  end
         | 
| 106 105 |  | 
| 107 106 | 
             
                  def total(node)
         | 
| 108 107 | 
             
                    format_number(node, 'total') do |indent_length, value|
         | 
| 109 | 
            -
                      "[#{value}]".ljust( | 
| 108 | 
            +
                      "[#{value}]".ljust(indent_length, SPACER)
         | 
| 110 109 | 
             
                    end
         | 
| 111 110 | 
             
                  end
         | 
| 112 111 |  | 
    
        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: 7
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 3
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.3. | 
| 9 | 
            +
              - 10
         | 
| 10 | 
            +
              version: 0.3.10
         | 
| 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-06- | 
| 18 | 
            +
            date: 2011-06-28 00:00:00 -04:00
         | 
| 19 19 | 
             
            default_executable: cuporter
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -41,6 +41,7 @@ executables: | |
| 41 41 | 
             
            extensions: []
         | 
| 42 42 |  | 
| 43 43 | 
             
            extra_rdoc_files: 
         | 
| 44 | 
            +
            - bin/cuporter
         | 
| 44 45 | 
             
            - README.textile
         | 
| 45 46 | 
             
            - LICENSE
         | 
| 46 47 | 
             
            files: 
         |