GraphvizR 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,7 @@
1
+ == 0.3.1 / 2007-02-19
2
+
3
+ * fixed a bug
4
+
1
5
  == 0.3.0 / 2007-02-17
2
6
 
3
7
  * rdot view template for rails
@@ -5,17 +5,14 @@ Rakefile
5
5
  bin/graphviz_r
6
6
  lib/graphviz_r.rb
7
7
  test/test_graphviz_r.rb
8
- vendor/plugins/rdot
9
- vendor/plugins/rdot/config
8
+ vendor/plugins/rdot/README
9
+ vendor/plugins/rdot/Rakefile
10
10
  vendor/plugins/rdot/config/database.yml
11
- vendor/plugins/rdot/lib
11
+ vendor/plugins/rdot/init.rb
12
+ vendor/plugins/rdot/install.rb
12
13
  vendor/plugins/rdot/lib/rdot.rb
13
14
  vendor/plugins/rdot/lib/rdot_template.rb
14
- vendor/plugins/rdot/tasks
15
15
  vendor/plugins/rdot/tasks/rdot_tasks.rake
16
+ vendor/plugins/rdot/test/log/.deleteme
16
17
  vendor/plugins/rdot/test/rdot_test.rb
17
- vendor/plugins/rdot/test/log
18
- vendor/plugins/rdot/README
19
- vendor/plugins/rdot/Rakefile
20
- vendor/plugins/rdot/init.rb
21
- vendor/plugins/rdot/install.rb
18
+ vendor/plugins/rdot/test/test_helper.rb
data/README.txt CHANGED
@@ -1,14 +1,19 @@
1
1
  = GraphvizR
2
- by ANDO Yasushi
3
- http://blog.technohippy.net
2
+ by ANDO Yasushi
3
+ http://blog.technohippy.net/pages/products/graphviz_r/en
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- Generate Graphviz dot file.
7
+ Graphviz wrapper for Ruby. This can be used as a common library, a rails plugin and a command line tool.
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
- * Generate Graphviz dot file
11
+ GraphvizR is graphviz adapter for Ruby, and it can:
12
+ * generate a graphviz dot file,
13
+ * generate an image file by means of utilizing graphviz,
14
+ * interprete rdot file and generate an image file,
15
+ * and, generate a graph image file in rails application as a rails plugin.
16
+
12
17
 
13
18
  == SYNOPSYS:
14
19
 
@@ -39,26 +44,49 @@ replies the dot code:
39
44
 
40
45
  To know more detail, please see test/test_graphviz_r.rb
41
46
 
42
- === In Your Rails Controller:
43
-
44
- render :rdot do
45
- graph [:size => '1.5, 2.5']
46
- node [:shape => :record]
47
- node1 [:label => "<p_left> left|<p_center>center|<p_right> right"]
48
- node2 [:label => "left|center|right"]
49
- node1 >> node2
50
- node1(:p_left) >> node2
51
- node2 >> node1(:p_center)
52
- (node2 >> node1(:p_right)) [:label => 'record']
47
+ === On Rails :
48
+
49
+ *use _render :rdot_ in controller*
50
+
51
+ def show_graph
52
+ render :rdot do
53
+ graph [:size => '1.5, 2.5']
54
+ node [:shape => :record]
55
+ node1 [:label => "<p_left> left|<p_center>center|<p_right> right"]
56
+ node2 [:label => "left|center|right"]
57
+ node1 >> node2
58
+ node1(:p_left) >> node2
59
+ node2 >> node1(:p_center)
60
+ (node2 >> node1(:p_right)) [:label => 'record']
61
+ end
53
62
  end
54
63
 
64
+ *use rdot view template*
65
+
66
+ class RdotGenController < ApplicationController
67
+ def index
68
+ @label1 = "<p_left> left|<p_center>center|<p_right> right"
69
+ @label2 = "left|center|right"
70
+ end
71
+ end
72
+
73
+ # view/rdot_gen/index.rdot
74
+ graph [:size => '1.5, 2.5']
75
+ node [:shape => :record]
76
+ node1 [:label => @label1]
77
+ node2 [:label => @label2]
78
+ node1 >> node2
79
+ node1(:p_left) >> node2
80
+ node2 >> node1(:p_center)
81
+ (node2 >> node1(:p_right)) [:label => 'record']
82
+
55
83
  == DEPENDENCIES:
56
84
 
57
85
  * Graphviz (http://www.graphviz.org/)
58
86
 
59
87
  == TODO:
60
88
 
61
- * rails plugin
89
+ * cover all specification for graphviz
62
90
 
63
91
  == INSTALL:
64
92
 
data/Rakefile CHANGED
@@ -6,9 +6,11 @@ require './lib/graphviz_r.rb'
6
6
 
7
7
  Hoe.new('GraphvizR', GraphvizR::VERSION) do |p|
8
8
  p.rubyforge_name = 'graphviz_r'
9
- # p.summary = 'FIX'
10
- # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
11
- # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
9
+ p.summary = 'Graphviz wrapper for Ruby and Rails'
10
+ p.description = p.paragraphs_of('README.txt', 2..-5).join("\n\n")
11
+ p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[2..-1]
12
+ p.email = 'andyjpn@gmail.com'
13
+ p.author = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1].sub(/\s*by /, '')
12
14
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
13
15
  end
14
16
 
@@ -1,5 +1,5 @@
1
1
  class GraphvizR
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  INDENT_UNIT = ' '
4
4
 
5
5
  class Attributes
@@ -285,6 +285,17 @@ digraph sample {
285
285
  alpha -> gamma [label = "label1"];
286
286
  beta -> delta [label = "label2"];
287
287
  delta -> size;
288
+ }
289
+ end_of_string
290
+ end
291
+
292
+ def test_access_as_hash
293
+ gvr = GraphvizR.new 'sample'
294
+ (gvr['alpha'] >> gvr['beta']) [:label => "label1"]
295
+
296
+ assert_equal <<-end_of_string, gvr.data(:dot)
297
+ digraph sample {
298
+ "alpha" -> "beta" [label = "label1"];
288
299
  }
289
300
  end_of_string
290
301
  end
@@ -15,6 +15,7 @@ class ActionController::Base
15
15
  def render_rdot(options=nil, &block)
16
16
  options ||= {}
17
17
  format = options[:format] || 'png'
18
+ options[:disposition] = 'attachment' unless options[:disposition] == 'inline'
18
19
  content_type =
19
20
  case format
20
21
  when 'svg'
@@ -31,7 +32,7 @@ class ActionController::Base
31
32
  copy_instance_variables block, gvr
32
33
  gvr.instance_eval &block
33
34
  end
34
- send_data gvr.data(format), :type => content_type #,disposition => 'inline'
35
+ send_data gvr.data(format), :type => content_type ,:disposition => options[:disposition]
35
36
  end
36
37
 
37
38
  private
@@ -40,8 +41,6 @@ private
40
41
  block_instance_variables = eval 'instance_variables', from_block.binding
41
42
  block_instance_variables.each do |name|
42
43
  to_obj.instance_variable_set name.to_sym, eval(name, from_block.binding)
43
- #to_obj.class.__send__ :attr_accessor, name[1..-1]
44
- #to_obj.send "#{name[1..-1]}=", eval(name, from_block.binding)
45
44
  end
46
45
  end
47
46
  end
@@ -0,0 +1,52 @@
1
+ RAILS_ENV = 'test'
2
+
3
+ def __DIR__; File.dirname(__FILE__); end
4
+
5
+ def require_gem_or_lib(component)
6
+ begin
7
+ require_gem component
8
+ rescue LoadError
9
+ $:.unshift(__DIR__ + '/../../../rails/' + component.split('/')[0].gsub('_', '') + '/lib')
10
+ require component
11
+ end
12
+ end
13
+
14
+ require 'test/unit'
15
+ $:.unshift(__DIR__ + '/../lib')
16
+ begin
17
+ require 'rubygems'
18
+ rescue LoadError
19
+ $:.unshift(__DIR__ + '/../../../rails/activesupport/lib')
20
+ $:.unshift(__DIR__ + '/../../../rails/activerecord/lib')
21
+ $:.unshift(__DIR__ + '/../../../rails/actionpack/lib')
22
+ end
23
+
24
+ #require_gem_or_lib 'activesupport'
25
+ #require_gem_or_lib 'active_record'
26
+ #require_gem_or_lib 'action_controller'
27
+ #require_gem_or_lib 'action_controller/test_process'
28
+ require '/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support'
29
+ require '/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record'
30
+ require '/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller'
31
+ require '/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_process'
32
+
33
+
34
+ config_file =
35
+ if File.exist?(__DIR__ + '/../../../../config/database.yml')
36
+ __DIR__ + '/../../../../config/database.yml'
37
+ else
38
+ __DIR__ + '/../config/database.yml'
39
+ end
40
+
41
+ ActiveRecord::Base.establish_connection(YAML.load(ERB.new(File.read(config_file)).result)[RAILS_ENV])
42
+
43
+ ActionController::Routing::Routes.reload rescue nil
44
+ class ActionController::Base; def rescue_action(e) raise e end; end
45
+
46
+ logfile = __DIR__ + '/log/rdot.log'
47
+ File.unlink(logfile) if File.exists?(logfile)
48
+ logger = Logger.new(logfile)
49
+ logger.level = Logger::DEBUG
50
+ ActionController::Base.logger = logger
51
+
52
+ require __DIR__ + '/../init'
metadata CHANGED
@@ -3,15 +3,42 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: GraphvizR
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.3.0
7
- date: 2007-02-16 00:00:00 +09:00
8
- summary: The author was too lazy to write a summary
6
+ version: 0.3.1
7
+ date: 2007-02-19 00:00:00 +09:00
8
+ summary: Graphviz wrapper for Ruby and Rails
9
9
  require_paths:
10
10
  - lib
11
- email: ryand-ruby@zenspider.com
12
- homepage: http://www.zenspider.com/ZSS/Products/GraphvizR/
11
+ email: andyjpn@gmail.com
12
+ homepage: http://blog.technohippy.net/pages/products/graphviz_r/en
13
13
  rubyforge_project: graphviz_r
14
- description: The author was too lazy to write a description
14
+ description: "Graphviz wrapper for Ruby. This can be used as a common library, a rails plugin
15
+ and a command line tool. == FEATURES/PROBLEMS: GraphvizR is graphviz adapter
16
+ for Ruby, and it can: * generate a graphviz dot file, * generate an image file
17
+ by means of utilizing graphviz, * interprete rdot file and generate an image
18
+ file, * and, generate a graph image file in rails application as a rails plugin.
19
+ == SYNOPSYS: === Command Line: bin/graphviz_r sample/record.rdot === In Your
20
+ Code: This ruby code: gvr = GraphvizR.new 'sample' gvr.graph [:label =>
21
+ 'example', :size => '1.5, 2.5'] gvr.beta [:shape => :box]
22
+ gvr.alpha >> gvr.beta (gvr.beta >> gvr.delta) [:label => 'label1'] gvr.delta >>
23
+ gvr.gamma gvr.to_dot replies the dot code: digraph sample { graph [label =
24
+ \"example\", size = \"1.5, 2.5\"]; beta [shape = box]; alpha -> beta; beta ->
25
+ delta [label = \"label1\"]; delta -> gamma; } To know more detail, please see
26
+ test/test_graphviz_r.rb === On Rails : *use _render :rdot_ in controller* def
27
+ show_graph render :rdot do graph [:size => '1.5, 2.5'] node [:shape => :record]
28
+ node1 [:label => \"<p_left> left|<p_center>center|<p_right> right\"] node2
29
+ [:label => \"left|center|right\"] node1 >> node2 node1(:p_left) >> node2 node2
30
+ >> node1(:p_center) (node2 >> node1(:p_right)) [:label => 'record'] end end
31
+ *use rdot view template* class RdotGenController < ApplicationController def
32
+ index @label1 = \"<p_left> left|<p_center>center|<p_right> right\" @label2 =
33
+ \"left|center|right\" end end # view/rdot_gen/index.rdot graph [:size => '1.5,
34
+ 2.5'] node [:shape => :record] node1 [:label => @label1] node2 [:label =>
35
+ @label2] node1 >> node2 node1(:p_left) >> node2 node2 >> node1(:p_center) (node2
36
+ >> node1(:p_right)) [:label => 'record'] == DEPENDENCIES: * Graphviz
37
+ (http://www.graphviz.org/) == TODO: * cover all specification for graphviz ==
38
+ INSTALL: * sudo gem install graphviz_r * if you want to use this in ruby on
39
+ rails * script/plugin install
40
+ http://technohippy.net/svn/repos/graphviz_r/trunk/vendor/plugins/rdot ==
41
+ LICENSE: (The MIT License)"
15
42
  autorequire:
16
43
  default_executable:
17
44
  bindir: bin
@@ -28,7 +55,7 @@ signing_key:
28
55
  cert_chain:
29
56
  post_install_message:
30
57
  authors:
31
- - Ryan Davis
58
+ - ANDO Yasushi
32
59
  files:
33
60
  - History.txt
34
61
  - Manifest.txt
@@ -37,20 +64,17 @@ files:
37
64
  - bin/graphviz_r
38
65
  - lib/graphviz_r.rb
39
66
  - test/test_graphviz_r.rb
40
- - vendor/plugins/rdot
41
- - vendor/plugins/rdot/config
67
+ - vendor/plugins/rdot/README
68
+ - vendor/plugins/rdot/Rakefile
42
69
  - vendor/plugins/rdot/config/database.yml
43
- - vendor/plugins/rdot/lib
70
+ - vendor/plugins/rdot/init.rb
71
+ - vendor/plugins/rdot/install.rb
44
72
  - vendor/plugins/rdot/lib/rdot.rb
45
73
  - vendor/plugins/rdot/lib/rdot_template.rb
46
- - vendor/plugins/rdot/tasks
47
74
  - vendor/plugins/rdot/tasks/rdot_tasks.rake
75
+ - vendor/plugins/rdot/test/log/.deleteme
48
76
  - vendor/plugins/rdot/test/rdot_test.rb
49
- - vendor/plugins/rdot/test/log
50
- - vendor/plugins/rdot/README
51
- - vendor/plugins/rdot/Rakefile
52
- - vendor/plugins/rdot/init.rb
53
- - vendor/plugins/rdot/install.rb
77
+ - vendor/plugins/rdot/test/test_helper.rb
54
78
  test_files:
55
79
  - test/test_graphviz_r.rb
56
80
  rdoc_options: []