graph 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,16 @@
1
+ === 2.1.0 / 2011-05-26
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * If bin/graph isn't given a type, list them and exit.
6
+ * Updated RubygemsAnalyzer to work with new API.
7
+ * `graph` command no longer defaults to any analyzer.
8
+
9
+ * 2 bug fixes:
10
+
11
+ * Escape newlines in labels. (rohitn)
12
+ * Refactored all saving code to bin/graph for clarity.
13
+
1
14
  === 2.0.1 / 2011-02-18
2
15
 
3
16
  * 2 minor enhancements:
data/bin/graph CHANGED
@@ -3,12 +3,24 @@
3
3
  $o ||= false
4
4
  $d ||= false
5
5
 
6
- type = (ARGV.shift || "macports")
6
+ type = ARGV.shift
7
+ unless type then
8
+ require "rubygems"
9
+
10
+ hits = Gem.find_files("*_analyzer.rb").map { |s|
11
+ File.basename s, "_analyzer.rb"
12
+ } - %w(dep)
13
+
14
+ abort "#{File.basename $0}: Need a type: #{hits.join(", ")}"
15
+ end
7
16
 
8
17
  require "#{type}_analyzer"
9
18
 
10
- klass = Object.const_get "#{type.capitalize}Analyzer"
19
+ name = "#{type.capitalize}Analyzer"
20
+ klass = Object.const_get name
11
21
  analyzer = klass.new
12
- analyzer.run
22
+ graph = analyzer.run
23
+
24
+ graph.save name, $d ? nil : "png"
13
25
 
14
- system "open #{type.capitalize}Analyzer.#{$d ? "dot" : "png"}" if $o
26
+ system "open #{name}.#{$d ? "dot" : "png"}" if $o
@@ -160,7 +160,7 @@ class DepAnalyzer < Cache
160
160
  end
161
161
  end
162
162
 
163
- g.save "#{self.class}", "png"
163
+ g
164
164
  end
165
165
 
166
166
  def setup
@@ -7,7 +7,7 @@ require "enumerator"
7
7
  # dot format.
8
8
 
9
9
  class Graph
10
- VERSION = "2.0.1" # :nodoc:
10
+ VERSION = "2.1.0" # :nodoc:
11
11
 
12
12
  LIGHT_COLORS = %w(gray lightblue lightcyan lightgray lightpink
13
13
  lightslategray lightsteelblue white)
@@ -197,7 +197,7 @@ class Graph
197
197
  # Shortcut method to set the graph's label. Usually used with subgraphs.
198
198
 
199
199
  def label name
200
- graph_attribs << "label = \"#{name}\""
200
+ graph_attribs << "label = \"#{name.gsub(/\n/, '\n')}\""
201
201
  end
202
202
 
203
203
  ##
@@ -349,7 +349,7 @@ class Graph
349
349
 
350
350
  def label name
351
351
  attributes.reject! { |s| s =~ /^label =/ }
352
- attributes << "label = \"#{name}\""
352
+ attributes << "label = \"#{name.gsub(/\n/, '\n')}\""
353
353
  self
354
354
  end
355
355
 
@@ -1,3 +1,4 @@
1
+ require "rubygems"
1
2
  require 'dep_analyzer'
2
3
 
3
4
  class RakeAnalyzer < DepAnalyzer
@@ -8,8 +9,9 @@ class RakeAnalyzer < DepAnalyzer
8
9
 
9
10
  current = nil
10
11
  rake = Gem.bin_path('rake', 'rake') rescue 'rake'
12
+ path = $:.join File::PATH_SEPARATOR
11
13
 
12
- `#{Gem.ruby} -I#{$:.join File::PATH_SEPARATOR} -S #{rake} -P -s`.each_line do |line|
14
+ `#{Gem.ruby} -I#{path} -S #{rake} -P -s`.each_line do |line|
13
15
  case line
14
16
  when /^rake (.+)/
15
17
  name = $1
@@ -23,8 +25,6 @@ class RakeAnalyzer < DepAnalyzer
23
25
  warn "unparsed: #{line.chomp}"
24
26
  end
25
27
  end
26
-
27
- save "RakeAnalyzer", "png"
28
28
  end
29
29
  end
30
30
  end
@@ -8,7 +8,8 @@ class Gem::Commands::GraphCommand < Gem::Command
8
8
  end
9
9
 
10
10
  def execute
11
- RubygemsAnalyzer.new.run options[:args]
11
+ g = RubygemsAnalyzer.new.run options[:args]
12
+ g.save "RubygemsAnalyzer", "png"
12
13
 
13
14
  say "Graph saved to:\n\tRubygemsAnalyzer.png"
14
15
  end
@@ -12,17 +12,18 @@ class RubygemsAnalyzer < DepAnalyzer
12
12
  def installed
13
13
  # don't cache so it updates every delete
14
14
  puts "scanning installed rubygems"
15
- Gem.source_index.gems.values.map { |gem| gem.name }.sort
15
+ Gem::Specification.map(&:name).sort
16
16
  end
17
17
 
18
18
  def outdated
19
19
  # don't cache so it updates every delete
20
20
  puts "scanning outdated rubygems"
21
- Gem.source_index.outdated.sort
21
+ Gem::Specification.outdated.sort
22
22
  end
23
23
 
24
- def deps gem
25
- Gem.source_index.find_name(gem).first.dependencies.map { |dep| dep.name }
24
+ def deps gem_name
25
+ gem = Gem::Specification.find_by_name gem_name
26
+ gem.dependencies
26
27
  end
27
28
 
28
29
  def decorate
@@ -31,7 +32,7 @@ class RubygemsAnalyzer < DepAnalyzer
31
32
  installed = self.installed
32
33
 
33
34
  installed.each do |gem|
34
- deps = Gem.source_index.find_name(gem).first.dependencies
35
+ deps = self.deps gem
35
36
 
36
37
  deps.each do |dep|
37
38
  next if dep.type == :runtime
@@ -82,6 +82,12 @@ class TestGraph < MiniTest::Unit::TestCase
82
82
  assert_graph graph, 'label = "blah"', '"a" -> "b"'
83
83
  end
84
84
 
85
+ def test_label_newline
86
+ graph.label "blah\nblah"
87
+
88
+ assert_graph graph, 'label = "blah\\nblah"', '"a" -> "b"'
89
+ end
90
+
85
91
  def test_left_shift
86
92
  subgraph = Graph.new "blah"
87
93
 
@@ -283,6 +289,12 @@ class TestNode < MiniTest::Unit::TestCase
283
289
  assert_equal ["label = \"blah\""], n.attributes
284
290
  end
285
291
 
292
+ def test_label_newline
293
+ n.label "blah\nblah"
294
+
295
+ assert_equal ["label = \"blah\\nblah\""], n.attributes
296
+ end
297
+
286
298
  def test_to_s
287
299
  assert_equal '"n"', n.to_s
288
300
  end
@@ -309,6 +321,12 @@ class TestEdge < MiniTest::Unit::TestCase
309
321
  assert_equal ["label = \"blah\""], e.attributes
310
322
  end
311
323
 
324
+ def test_label_newline
325
+ e.label "blah\nblah"
326
+
327
+ assert_equal ["label = \"blah\\nblah\""], e.attributes
328
+ end
329
+
312
330
  def test_to_s
313
331
  assert_equal '"a" -> "b"', e.to_s
314
332
  end
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: 13
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 0
9
8
  - 1
10
- version: 2.0.1
9
+ - 0
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Davis
@@ -36,8 +36,7 @@ cert_chain:
36
36
  FBHgymkyj/AOSqKRIpXPhjC6
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2011-02-18 00:00:00 -08:00
40
- default_executable:
39
+ date: 2011-05-27 00:00:00 Z
41
40
  dependencies:
42
41
  - !ruby/object:Gem::Dependency
43
42
  name: minitest
@@ -50,9 +49,9 @@ dependencies:
50
49
  hash: 11
51
50
  segments:
52
51
  - 2
52
+ - 1
53
53
  - 0
54
- - 2
55
- version: 2.0.2
54
+ version: 2.1.0
56
55
  type: :development
57
56
  version_requirements: *id001
58
57
  - !ruby/object:Gem::Dependency
@@ -63,12 +62,12 @@ dependencies:
63
62
  requirements:
64
63
  - - ">="
65
64
  - !ruby/object:Gem::Version
66
- hash: 41
65
+ hash: 35
67
66
  segments:
68
67
  - 2
69
68
  - 9
70
- - 1
71
- version: 2.9.1
69
+ - 4
70
+ version: 2.9.4
72
71
  type: :development
73
72
  version_requirements: *id002
74
73
  description: |-
@@ -121,7 +120,6 @@ files:
121
120
  - lib/rubygems_plugin.rb
122
121
  - test/test_graph.rb
123
122
  - .gemtest
124
- has_rdoc: true
125
123
  homepage: http://rubyforge.org/projects/seattlerb
126
124
  licenses: []
127
125
 
@@ -152,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
150
  requirements: []
153
151
 
154
152
  rubyforge_project: seattlerb
155
- rubygems_version: 1.4.2
153
+ rubygems_version: 1.8.3
156
154
  signing_key:
157
155
  specification_version: 3
158
156
  summary: Graph is a type of hash that outputs in graphviz's dot format
metadata.gz.sig CHANGED
Binary file