graph 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/lib/dep_analyzer.rb +53 -5
- data/lib/freebsd_analyzer.rb +2 -0
- data/lib/graph.rb +49 -7
- data/lib/homebrew_analyzer.rb +2 -0
- data/lib/macports_analyzer.rb +2 -0
- data/lib/rake_analyzer.rb +2 -0
- data/lib/rubygems/commands/graph_command.rb +3 -3
- data/lib/rubygems_analyzer.rb +2 -0
- data/lib/rubygems_plugin.rb +0 -1
- metadata +12 -12
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
data/lib/dep_analyzer.rb
CHANGED
@@ -2,12 +2,23 @@ require 'graph'
|
|
2
2
|
require 'set'
|
3
3
|
require 'tsort'
|
4
4
|
|
5
|
+
##
|
6
|
+
# A simple file caching mechanism with automatic timeout.
|
7
|
+
|
5
8
|
class Cache
|
9
|
+
|
10
|
+
##
|
11
|
+
# Create a cache at +cache+ path for a given +timeout+ (in hours).
|
12
|
+
|
6
13
|
def initialize(cache, timeout=24)
|
7
14
|
@cache = cache
|
8
15
|
@timeout = timeout
|
9
16
|
end
|
10
17
|
|
18
|
+
##
|
19
|
+
# Add a cached item to +id+. Value is returned either from the cache
|
20
|
+
# if it is new enough or by yielding.
|
21
|
+
|
11
22
|
def cache(id, timeout=@timeout)
|
12
23
|
Dir.mkdir @cache unless test ?d, @cache
|
13
24
|
path = File.join @cache, id
|
@@ -28,7 +39,11 @@ class Cache
|
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
31
|
-
class Set
|
42
|
+
class Set # :nodoc:
|
43
|
+
|
44
|
+
##
|
45
|
+
# A simple batch-add to Set. Bad API is bad. Thank god for open classes.
|
46
|
+
|
32
47
|
def push *v
|
33
48
|
v.each do |o|
|
34
49
|
add(o)
|
@@ -36,7 +51,7 @@ class Set
|
|
36
51
|
end
|
37
52
|
end
|
38
53
|
|
39
|
-
class Hash
|
54
|
+
class Hash # :nodoc:
|
40
55
|
include TSort
|
41
56
|
|
42
57
|
alias tsort_each_node each_key
|
@@ -45,6 +60,10 @@ class Hash
|
|
45
60
|
fetch(node).each(&block)
|
46
61
|
end
|
47
62
|
|
63
|
+
##
|
64
|
+
# Return the #inverse of a hash, allowing for multiple keys having
|
65
|
+
# the same values.
|
66
|
+
|
48
67
|
def minvert
|
49
68
|
r = Hash.new { |h,k| h[k] = [] }
|
50
69
|
invert.each do |keys, val|
|
@@ -58,6 +77,9 @@ class Hash
|
|
58
77
|
r
|
59
78
|
end
|
60
79
|
|
80
|
+
##
|
81
|
+
# Calculate the transitive closure of the hash.
|
82
|
+
|
61
83
|
def transitive
|
62
84
|
r = Hash.new { |h,k| h[k] = [] }
|
63
85
|
each do |k,v|
|
@@ -66,6 +88,9 @@ class Hash
|
|
66
88
|
r
|
67
89
|
end
|
68
90
|
|
91
|
+
##
|
92
|
+
# Calculates the (transitive) set of dependencies for a given key.
|
93
|
+
|
69
94
|
def t(k)
|
70
95
|
r = Set.new
|
71
96
|
self[k].each do |v|
|
@@ -75,30 +100,51 @@ class Hash
|
|
75
100
|
end
|
76
101
|
end
|
77
102
|
|
103
|
+
##
|
104
|
+
# Abstract class to analyze dependencies. Intended to be subclassed
|
105
|
+
# for a given dependency system (eg rubygems). Subclasses must
|
106
|
+
# implement #deps, #installed, and #outdated at the very least.
|
107
|
+
|
78
108
|
class DepAnalyzer < Cache
|
79
|
-
attr_accessor :g
|
109
|
+
attr_accessor :g # :nodoc:
|
80
110
|
|
81
|
-
def initialize
|
111
|
+
def initialize # :nodoc:
|
82
112
|
super ".#{self.class}.cache"
|
83
113
|
@g = Graph.new
|
84
114
|
end
|
85
115
|
|
116
|
+
##
|
117
|
+
# Allows your subclass to add extra fancy stuff to the graph when
|
118
|
+
# analysis is finished.
|
119
|
+
|
86
120
|
def decorate
|
87
121
|
# nothing to do by default
|
88
122
|
end
|
89
123
|
|
124
|
+
##
|
125
|
+
# Return the dependencies for a given port.
|
126
|
+
|
90
127
|
def deps port
|
91
128
|
raise NotImplementedError, "subclass responsibility"
|
92
129
|
end
|
93
130
|
|
131
|
+
##
|
132
|
+
# Return all installed items on the system.
|
133
|
+
|
94
134
|
def installed
|
95
135
|
raise NotImplementedError, "subclass responsibility"
|
96
136
|
end
|
97
137
|
|
138
|
+
##
|
139
|
+
# Return all outdated items currently installed.
|
140
|
+
|
98
141
|
def outdated
|
99
142
|
raise NotImplementedError, "subclass responsibility"
|
100
143
|
end
|
101
144
|
|
145
|
+
##
|
146
|
+
# Do the actual work.
|
147
|
+
|
102
148
|
def run(argv = ARGV)
|
103
149
|
setup
|
104
150
|
|
@@ -163,8 +209,10 @@ class DepAnalyzer < Cache
|
|
163
209
|
g
|
164
210
|
end
|
165
211
|
|
212
|
+
##
|
213
|
+
# Allows subclasses to do any preparation before the run.
|
214
|
+
|
166
215
|
def setup
|
167
216
|
# nothing to do by default
|
168
217
|
end
|
169
218
|
end
|
170
|
-
|
data/lib/freebsd_analyzer.rb
CHANGED
data/lib/graph.rb
CHANGED
@@ -7,7 +7,9 @@ require "enumerator"
|
|
7
7
|
# dot format.
|
8
8
|
|
9
9
|
class Graph
|
10
|
-
VERSION = "2.5.
|
10
|
+
VERSION = "2.5.2" # :nodoc:
|
11
|
+
|
12
|
+
# :stopdoc:
|
11
13
|
|
12
14
|
LIGHT_COLORS = %w(gray lightblue lightcyan lightgray lightpink
|
13
15
|
lightslategray lightsteelblue white)
|
@@ -79,6 +81,8 @@ class Graph
|
|
79
81
|
define_method(method_name) { arrowhead name }
|
80
82
|
end
|
81
83
|
|
84
|
+
# :startdoc:
|
85
|
+
|
82
86
|
##
|
83
87
|
# A parent graph, if any. Only used for subgraphs.
|
84
88
|
|
@@ -167,22 +171,31 @@ class Graph
|
|
167
171
|
nodes[name]
|
168
172
|
end
|
169
173
|
|
174
|
+
##
|
175
|
+
# Shortcut method for creating an arrowhead attribute.
|
176
|
+
|
170
177
|
def arrowhead shape
|
171
178
|
raise ArgumentError, "Bad arrow shape: #{shape}" unless shape =~ ARROW_RE
|
172
179
|
Attribute.new "arrowhead = #{shape}"
|
173
180
|
end
|
174
181
|
|
182
|
+
##
|
183
|
+
# Shortcut method for creating an arrowtail attribute.
|
184
|
+
|
175
185
|
def arrowtail shape
|
176
186
|
raise ArgumentError, "Bad arrow shape: #{shape}" unless shape =~ ARROW_RE
|
177
187
|
Attribute.new "arrowtail = #{shape}"
|
178
188
|
end
|
179
189
|
|
190
|
+
##
|
191
|
+
# Shortcut method for creating an arrowsize attribute.
|
192
|
+
|
180
193
|
def arrowsize size
|
181
194
|
Attribute.new "arrowsize = #{size}"
|
182
195
|
end
|
183
196
|
|
184
197
|
##
|
185
|
-
#
|
198
|
+
# Shortcut method to set the global node attributes to use boxes.
|
186
199
|
|
187
200
|
def boxes
|
188
201
|
node_attribs << shape("box")
|
@@ -203,6 +216,9 @@ class Graph
|
|
203
216
|
|
204
217
|
attr_accessor :scheme
|
205
218
|
|
219
|
+
##
|
220
|
+
# Shortcut method to create and set the graph to use a colorscheme.
|
221
|
+
|
206
222
|
def colorscheme name, n = nil
|
207
223
|
self.scheme = Attribute.new "colorscheme = #{name}#{n}"
|
208
224
|
max = COLOR_SCHEME_MAX[name.to_sym]
|
@@ -265,6 +281,9 @@ class Graph
|
|
265
281
|
Attribute.new "fontname = #{name.inspect}"
|
266
282
|
end
|
267
283
|
|
284
|
+
##
|
285
|
+
# Shortcut method to create a new fontsize Attribute instance.
|
286
|
+
|
268
287
|
def fontsize size
|
269
288
|
Attribute.new "fontsize = #{size}"
|
270
289
|
end
|
@@ -423,15 +442,25 @@ class Graph
|
|
423
442
|
end
|
424
443
|
end
|
425
444
|
|
445
|
+
##
|
446
|
+
# An attribute... that's compound. So much for self-documenting code. :(
|
447
|
+
|
426
448
|
class CompoundAttribute < Attribute
|
427
|
-
def initialize attr = []
|
449
|
+
def initialize attr = [] # :nodoc:
|
428
450
|
super
|
429
451
|
end
|
430
452
|
|
453
|
+
##
|
454
|
+
# Push an attribute into the list o' attributes.
|
455
|
+
|
431
456
|
def push attrib
|
432
457
|
attr.push attrib
|
433
458
|
end
|
434
459
|
|
460
|
+
##
|
461
|
+
# "Paint" a thingy with an attribute. Applies the attribute to the
|
462
|
+
# thingy. In this case, does it recursively.
|
463
|
+
|
435
464
|
def << thing
|
436
465
|
attr.each do |subattr|
|
437
466
|
subattr << thing # allows for recursive compound attributes
|
@@ -439,13 +468,18 @@ class Graph
|
|
439
468
|
self
|
440
469
|
end
|
441
470
|
|
442
|
-
def to_s
|
471
|
+
def to_s # :nodoc:
|
443
472
|
attr.join ", "
|
444
473
|
end
|
445
474
|
end
|
446
475
|
|
476
|
+
##
|
477
|
+
# You know... THINGY!
|
478
|
+
#
|
479
|
+
# Has a pointer back to its graph parent and attributes.
|
480
|
+
|
447
481
|
class Thingy < Struct.new :graph, :attributes
|
448
|
-
def initialize graph
|
482
|
+
def initialize graph # :nodoc:
|
449
483
|
super graph, []
|
450
484
|
end
|
451
485
|
|
@@ -476,7 +510,7 @@ class Graph
|
|
476
510
|
|
477
511
|
class Edge < Thingy
|
478
512
|
|
479
|
-
attr_accessor :from, :to
|
513
|
+
attr_accessor :from, :to # :nodoc:
|
480
514
|
|
481
515
|
##
|
482
516
|
# Create a new edge in +graph+ from +from+ to +to+.
|
@@ -505,7 +539,10 @@ class Graph
|
|
505
539
|
|
506
540
|
class Node < Thingy
|
507
541
|
|
508
|
-
attr_accessor :name
|
542
|
+
attr_accessor :name # :nodoc:
|
543
|
+
|
544
|
+
##
|
545
|
+
# Is this node connected to the graph?
|
509
546
|
|
510
547
|
def connected?
|
511
548
|
edges = graph.edges
|
@@ -513,6 +550,9 @@ class Graph
|
|
513
550
|
edges.include?(name) or edges.any? { |from, deps| deps.include? name }
|
514
551
|
end
|
515
552
|
|
553
|
+
##
|
554
|
+
# Is this node an orphan? (ie, not connected?)
|
555
|
+
|
516
556
|
def orphan?
|
517
557
|
not connected?
|
518
558
|
end
|
@@ -556,6 +596,7 @@ class Graph
|
|
556
596
|
end
|
557
597
|
end
|
558
598
|
|
599
|
+
class Object # :nodoc:
|
559
600
|
##
|
560
601
|
# Convenience method to create a new graph. Used for DSL-style:
|
561
602
|
#
|
@@ -566,3 +607,4 @@ end
|
|
566
607
|
def digraph name = nil, &block
|
567
608
|
Graph.new name, &block
|
568
609
|
end
|
610
|
+
end
|
data/lib/homebrew_analyzer.rb
CHANGED
data/lib/macports_analyzer.rb
CHANGED
data/lib/rake_analyzer.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'rubygems/command'
|
2
2
|
require 'rubygems_analyzer'
|
3
3
|
|
4
|
-
|
4
|
+
# :stopdoc:
|
5
|
+
|
6
|
+
class Gem::Commands::GraphCommand < Gem::Command # :nodoc: all
|
5
7
|
|
6
8
|
def initialize
|
7
9
|
super 'graph', 'Graph dependency relationships of installed gems'
|
@@ -13,6 +15,4 @@ class Gem::Commands::GraphCommand < Gem::Command
|
|
13
15
|
|
14
16
|
say "Graph saved to:\n\tRubygemsAnalyzer.png"
|
15
17
|
end
|
16
|
-
|
17
18
|
end
|
18
|
-
|
data/lib/rubygems_analyzer.rb
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 2.5.
|
9
|
+
- 2
|
10
|
+
version: 2.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Davis
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
FBHgymkyj/AOSqKRIpXPhjC6
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date:
|
39
|
+
date: 2013-02-07 00:00:00 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
@@ -46,11 +46,11 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
49
|
+
hash: 17
|
50
50
|
segments:
|
51
|
-
-
|
52
|
-
-
|
53
|
-
version: "
|
51
|
+
- 4
|
52
|
+
- 5
|
53
|
+
version: "4.5"
|
54
54
|
type: :development
|
55
55
|
version_requirements: *id001
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -76,11 +76,11 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
79
|
+
hash: 13
|
80
80
|
segments:
|
81
81
|
- 3
|
82
|
-
-
|
83
|
-
version: "3.
|
82
|
+
- 5
|
83
|
+
version: "3.5"
|
84
84
|
type: :development
|
85
85
|
version_requirements: *id003
|
86
86
|
description: |-
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
requirements: []
|
165
165
|
|
166
166
|
rubyforge_project: seattlerb
|
167
|
-
rubygems_version: 1.8.
|
167
|
+
rubygems_version: 1.8.25
|
168
168
|
signing_key:
|
169
169
|
specification_version: 3
|
170
170
|
summary: Graph is a type of hash that outputs in graphviz's dot format
|
metadata.gz.sig
CHANGED
Binary file
|