Module: Tapout

Defined in:
lib/tapout.rb,
lib/tapout/cli.rb,
lib/tapout/config.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/parsers/abstract.rb,
lib/tapout/reporters/abstract.rb,
lib/tapout/reporters/turn_reporter.rb,
lib/tapout/reporters/pretty_reporter.rb,
lib/tapout/reporters/runtime_reporter.rb,
lib/tapout/reporters/progress_reporter.rb,
lib/tapout/reporters/breakdown_reporter.rb

Defined Under Namespace

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

Constant Summary collapse

REVISION =

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

"4"

Class Method Summary collapse

Class Method Details

.cli(*argv) ⇒ Object

Command line interface.



7
8
9
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
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/tapout/cli.rb', line 7

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.config.trace = depth
    end

    opt.on('--lines', '-l LINES', 'number of surrounding source code lines') do |lines|
      self.config.lines = lines.to_i
    end

    opt.on('--minimal', '-m', 'show only errors, failures and pending tests') do |val|
      self.config.minimal = val
    end

    opt.on('--no-color', 'suppress ANSI color codes') do
      $ansi = false
    end

    opt.on('--require', '-r FEATURE', 'require feature') do |feature|
      require feature
    end

    #opt.on('--plugin', '-p NAME', 'Require plugin feature (tapout-<name>)') do |name|
    #  require "tapout-#{name}"
    #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

.configObject

Alias for ‘#configuration`.



14
15
16
# File 'lib/tapout/config.rb', line 14

def self.config
  configuration
end

.configurationObject

Access to configuration.



9
10
11
# File 'lib/tapout/config.rb', line 9

def self.configuration
  @config ||= Config.new
end

.configure(&block) ⇒ Object

Define configuration.



4
5
6
# File 'lib/tapout/config.rb', line 4

def self.configure(&block)
  configuration.update(&block)
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