Class: DepAnalyzer
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Cache
#cache
Constructor Details
Returns a new instance of DepAnalyzer.
81
82
83
84
|
# File 'lib/dep_analyzer.rb', line 81
def initialize
super ".#{self.class}.cache"
@g = Graph.new
end
|
Instance Attribute Details
#g ⇒ Object
Returns the value of attribute g.
79
80
81
|
# File 'lib/dep_analyzer.rb', line 79
def g
@g
end
|
Instance Method Details
#decorate ⇒ Object
86
87
88
|
# File 'lib/dep_analyzer.rb', line 86
def decorate
end
|
#deps(port) ⇒ Object
90
91
92
|
# File 'lib/dep_analyzer.rb', line 90
def deps port
raise NotImplementedError, "subclass responsibility"
end
|
#installed ⇒ Object
94
95
96
|
# File 'lib/dep_analyzer.rb', line 94
def installed
raise NotImplementedError, "subclass responsibility"
end
|
#outdated ⇒ Object
98
99
100
|
# File 'lib/dep_analyzer.rb', line 98
def outdated
raise NotImplementedError, "subclass responsibility"
end
|
#run(argv = ARGV) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/dep_analyzer.rb', line 102
def run(argv = ARGV)
setup
ports = {}
installed.each do |port|
ports[port] = nil
end
old = {}
outdated.each do |port|
old[port] = nil
end
all_ports = ports.keys
ports.each_key do |port|
deps = self.deps(port)
deps -= (deps - all_ports)
deps.each do |dep|
g[port] << dep
end
ports[port] = deps
end
blue = g.color "blue"
purple = g.color "purple4"
red = g.color "red"
indies = ports.keys - ports.minvert.keys
indies.each do |k|
blue << g[k]
end
old.each do |k,v|
if indies.include? k then
purple << g[k]
else
red << g[k]
end
end
decorate
puts "Looks like you can nuke:\n\t#{indies.sort.join("\n\t")}"
unless argv.empty? then
argv.each do |pkg|
hits = ports.transitive[pkg]
sorted = ports.tsort.reverse
topo = [pkg] + sorted.select { |o| hits.include? o }
prune = ports.dup
topo.each do |k|
prune.delete(k)
end
topo -= prune.values.flatten.uniq
puts topo.join(' ')
end
end
g
end
|
#setup ⇒ Object
166
167
168
|
# File 'lib/dep_analyzer.rb', line 166
def setup
end
|