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/turn_reporter.rb,
lib/tapout/reporters/pretty_reporter.rb,
lib/tapout/reporters/progress_reporter.rb,
lib/tapout/reporters/breakdown_reporter.rb

Defined Under Namespace

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

Constant Summary collapse

REVISION =

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

"3"

Class Method Summary collapse

Class Method Details

.cli(*argv) ⇒ Object

Command line interface.



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
75
76
77
78
79
80
81
82
# File 'lib/tapout.rb', line 18

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

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

    opt.separator("\nOPTIONS:")

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

    opt.on('--trace', '-t DEPTH', 'set backtrace depth') do |depth|
      self.trace = depth
    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("\nREPORTERS:\n        " + Reporters.index.keys.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

.const_missing(name) ⇒ Object

Any missing constant will be looked for in project metadata.



17
18
19
# File 'lib/tapout/version.rb', line 17

def self.const_missing(name)
  [name.to_s.downcase] || super(name)
end

.metadataHash

Project metadata.

Returns:

  • (Hash)

    metadata from .ruby file



8
9
10
11
12
13
# File 'lib/tapout/version.rb', line 8

def self.
  @metadata ||= (
    require 'yaml'
    YAML.load_file(File.join(File.dirname(__FILE__), '/../tapout.yml'))
  )
end

.traceObject



7
8
9
# File 'lib/tapout.rb', line 7

def self.trace
  @trace
end

.trace=(depth) ⇒ Object



12
13
14
# File 'lib/tapout.rb', line 12

def self.trace=(depth)
  @trace = depth.to_i
end