Module: Silhouette

Defined in:
lib/silhouette/finder.rb,
lib/silhouette/coverage.rb,
lib/silhouette/emitters.rb,
lib/silhouette/converter.rb,
lib/silhouette/processor.rb

Defined Under Namespace

Classes: ASCIIConverter, ASCIIConverterLong, BinaryEmitter, CallNode, CallTree, CoverageProcessor, DefaultProfiler, Emitter, EntryPointProfiler, InvalidFormat, MethodFinder, Options, Processor, ProfileNode, SourceFile

Class Method Summary collapse

Class Method Details

.emittersObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/silhouette/emitters.rb', line 4

def self.emitters
    out = []
    constants.each do |name|
        con = const_get(name)
        if Class === con and con.superclass == Emitter
            out << con
        end
    end
    out
end

.find_emitter(file) ⇒ Object

Raises:



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
# File 'lib/silhouette/emitters.rb', line 15

def self.find_emitter(file)
  
  if !File.exists? file
    bz = "#{file}.bz2"
    file = bz if File.exists?(bz)
  end
  
  if !File.exists? file
    gz = "#{file}.gz"
    file = gz if File.exists?(gz)
  end

  if file == "-"
    io = STDIN
  
  elsif /.bz2$/.match(file)
    io = IO.popen("bzip2 -dc '#{file}'")
  elsif /.gz$/.match(file)
    io = IO.popen("gzip -dc '#{file}'")
  else
    raise "Unknown file" unless File.exists?(io)
    io = File.open(file)
  end

  emitters.each do |em|
    begin
      return em.new(io)
    rescue InvalidFormat
    end
  end

  raise InvalidFormat, "Unable to find valid emitter"
end