Module: TapOut

Defined in:
lib/tapout.rb,
lib/tapout/version.rb,
lib/tapout/parsers/json.rb,
lib/tapout/parsers/perl.rb,
lib/tapout/parsers/yaml.rb,
lib/tapout/adapters/perl.rb,
lib/tapout/reporters/abstract.rb,
lib/tapout/reporters/breakdown.rb,
lib/tapout/reporters/progressbar.rb

Defined Under Namespace

Modules: Reporters Classes: Curmudgeon, JsonParser, PerlAdapter, PerlParser, YamlParser

Constant Summary collapse

FORMATS =

Usable formats.

%w{breakdown dotprogress html outline progressbar tap}
VERSION =

Current version of TAPOUT project.

"0.2.3"
REVISION =

The current revision of the TAP-Y/J format.

"2"

Class Method Summary collapse

Class Method Details

.cli(*argv) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/tapout.rb', line 10

def self.cli(*argv)
  options = {}
  type    = :modern

  parser = OptionParser.new do |opt|
    opt.banner = "tapout [options] [format]"

    opt.separator("\nOPTIONS:")

    #opt.on('--format', '-f FORMAT', 'Report format') do |fmt|
    #  options[:format] = fmt
    #end

    #opt.on('-t', '--tap', 'Consume legacy TAP input') do |fmt|
    #  type = :legacy
    #end

    opt.on('--no-color', 'Supress ANSI color codes') do
      $ansi = false  # TODO: Is this correct?
    end

    opt.on('--debug', 'Run with $DEBUG flag on') do |fmt|
      $DEBUG = true
    end

    opt.separator("\nFORMATS:\n        " + FORMATS.join("\n        "))
  end

  parser.parse!(argv)

  options[:format] = argv.first

  # TODO: would be nice if it could automatically determine which
  #c = $stdin.getc
  #    $stdin.pos = 0
  #type = :legacy if c =~ /\d/
  #type = :modern if c == '-'

  stdin = Curmudgeon.new($stdin)

  case stdin.line1
  when /^\d/
    type = :perl
  when /^\-/
    type = :yaml
  when /^\{/
    type = :json
  else
    raise "Not a recognized TAP stream!"
  end

  case type
  when :perl
    stream_parser = PerlParser.new(options)
    exit_code     = stream_parser.consume(stdin)
  when :yaml
    stream_parser = YamlParser.new(options)
    exit_code     = stream_parser.consume(stdin)
  when :json
    stream_parser = JsonParser.new(options)
    exit_code     = stream_parser.consume(stdin)
  end

  exit(exit_code || 0)
end