Class: RDoc::Gauntlet

Inherits:
Gauntlet
  • Object
show all
Defined in:
lib/gauntlet_rdoc.rb

Overview

Allows for testing of RDoc against every gem

Instance Method Summary collapse

Constructor Details

#initializeGauntlet

:nodoc:



12
13
14
15
16
17
# File 'lib/gauntlet_rdoc.rb', line 12

def initialize # :nodoc:
  super

  @args = nil
  @type = nil
end

Instance Method Details

#run(name) ⇒ Object

Runs an RDoc generator for gem name



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
# File 'lib/gauntlet_rdoc.rb', line 22

def run name
  return if self.data.key? name

  dir = File.expand_path "~/.gauntlet/data/#{@type}/#{name}"
  FileUtils.rm_rf dir if File.exist? dir

  yaml = File.read 'gemspec'
  begin
    spec = Gem::Specification.from_yaml yaml
  rescue Psych::SyntaxError
    puts "bad spec #{name}"
    self.data[name] = false
    return
  end

  args = @args.dup
  args << '--op' << dir
  args.concat spec.rdoc_options
  args << spec.require_paths
  args << spec.extra_rdoc_files
  args = args.flatten.map { |a| a.to_s }
  args.delete '--quiet'

  puts "#{name} - rdoc #{args.join ' '}"

  self.dirty = true
  r = RDoc::RDoc.new

  begin
    r.document args
    self.data[name] = true
    puts 'passed'
    FileUtils.rm_rf dir
  rescue Interrupt, StandardError, RDoc::Error, SystemStackError => e
    puts "failed - (#{e.class}) #{e.message}"
    self.data[name] = false
  end
rescue Gem::Exception
  puts "bad gem #{name}"
ensure
  puts
end

#run_the_gauntlet(type = 'rdoc', filter = nil) ⇒ Object

Runs the gauntlet with the given type (rdoc or ri) and filter for which gems to run



69
70
71
72
73
74
75
# File 'lib/gauntlet_rdoc.rb', line 69

def run_the_gauntlet type = 'rdoc', filter = nil
  @type = type || 'rdoc'
  @args = type == 'rdoc' ? [] : %w[--ri]
  @data_file = "#{DATADIR}/#{@type}-data.yml"

  super filter
end