Class: RakeAnalyzer

Inherits:
DepAnalyzer show all
Defined in:
lib/rake_analyzer.rb

Overview

:stopdoc:

Instance Attribute Summary

Attributes inherited from DepAnalyzer

#g

Instance Method Summary collapse

Methods inherited from DepAnalyzer

#decorate, #deps, #initialize, #installed, #outdated, #setup

Methods inherited from Cache

#cache, #initialize

Constructor Details

This class inherits a constructor from DepAnalyzer

Instance Method Details

#runObject



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

def run
  digraph do
    rotate
    boxes

    current = nil
    rake = Gem.bin_path('rake', 'rake') rescue 'rake'
    path = $:.join File::PATH_SEPARATOR

    content =
      if $stdin.tty? then
        `#{Gem.ruby} -I#{path} -S #{rake} -P -s`
      else
        $stdin.read
      end

    content.each_line do |line|
      case line
      when /^rake (.+)/
        name = $1
        current = name
        node current if current
      when /^\s+(.+)/
        dep = $1
        next if current =~ /pkg/ and File.file? dep
        edge current, dep if current
      else
        warn "unparsed: #{line.chomp}"
      end
    end
  end
end