rubigraph 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.txt +61 -0
- data/Rakefile +13 -0
- data/lib/rubigraph.rb +185 -0
- data/test/test_rubigraph.rb +0 -0
- metadata +69 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= Rubigraph
|
2
|
+
|
3
|
+
http://rubyforge.org/projects/rubigraph
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
a Ruby wrap for Ubigraph (http://www.ubietylab.net/ubigraph).
|
8
|
+
|
9
|
+
see http://www.ubietylab.net/ubigraph/content/Docs/index.html to get complete description about API.
|
10
|
+
|
11
|
+
== FEATURES/PROBLEMS:
|
12
|
+
|
13
|
+
It provides a shortcut to plot, draw a graph (by calling XML-RPC internally).
|
14
|
+
|
15
|
+
== SYNOPSIS:
|
16
|
+
Make sure Ubigraph serverr is started before using this library.
|
17
|
+
|
18
|
+
require 'rubigraph'
|
19
|
+
Rubigraph.init
|
20
|
+
|
21
|
+
v1 = Vertex.new
|
22
|
+
v2 = Vertex.new
|
23
|
+
e12 = Edge.new(v1, v2)
|
24
|
+
|
25
|
+
v1.color = '#003366'
|
26
|
+
v2.shape = 'sphere'
|
27
|
+
e12.label = 'edge between 1 and 2'
|
28
|
+
|
29
|
+
== REQUIREMENTS:
|
30
|
+
|
31
|
+
Ubigraph (http://www.ubietylab.net/ubigraph),
|
32
|
+
tested under rev1450, rev1554
|
33
|
+
|
34
|
+
== INSTALL:
|
35
|
+
|
36
|
+
sudo gem install
|
37
|
+
|
38
|
+
== LICENSE:
|
39
|
+
|
40
|
+
The MIT License
|
41
|
+
|
42
|
+
Copyright (c) 2008 mootoh
|
43
|
+
|
44
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
45
|
+
a copy of this software and associated documentation files (the
|
46
|
+
'Software'), to deal in the Software without restriction, including
|
47
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
48
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
49
|
+
permit persons to whom the Software is furnished to do so, subject to
|
50
|
+
the following conditions:
|
51
|
+
|
52
|
+
The above copyright notice and this permission notice shall be
|
53
|
+
included in all copies or substantial portions of the Software.
|
54
|
+
|
55
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
56
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
57
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
58
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
59
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
60
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
61
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/rubigraph.rb'
|
6
|
+
|
7
|
+
Hoe.new('rubigraph', Rubigraph::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'rubigraph' # if different than lowercase project name
|
9
|
+
p.email = 'mootoh@gmail.com'
|
10
|
+
p.author = 'mootoh'
|
11
|
+
end
|
12
|
+
|
13
|
+
# vim: syntax=Ruby
|
data/lib/rubigraph.rb
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
#
|
5
|
+
# Ruby wrapper for Ubigraph.
|
6
|
+
#
|
7
|
+
# Call Rubigraph.init at first.
|
8
|
+
#
|
9
|
+
module Rubigraph
|
10
|
+
VERSION = '0.0.1'
|
11
|
+
|
12
|
+
class Vertex
|
13
|
+
attr_reader :id
|
14
|
+
|
15
|
+
def initialize(id = nil)
|
16
|
+
@id = id ?
|
17
|
+
Rubigraph.server.call('ubigraph.new_vertex_w_id', id) :
|
18
|
+
Rubigraph.server.call('ubigraph.new_vertex')
|
19
|
+
raise 'Rubigraph::Vertex.initialize: cannot create vertex' if @id == -1
|
20
|
+
end
|
21
|
+
|
22
|
+
def remove
|
23
|
+
if -1 == Rubigraph.server.call('ubigraph.remove_vertex', @id)
|
24
|
+
raise "Rubigraph::Vertex#remove: cannot remove vertex #{@id}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_attribute(att, value)
|
29
|
+
if -1 == Rubigraph.server.call('ubigraph.set_vertex_attribute', @id, att, value.to_s)
|
30
|
+
raise "Rubigraph::Vertex##{att}=: cannot change #{att} #{@id}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_attributes(attrs)
|
35
|
+
attrs.each do |k, v|
|
36
|
+
if -1 == Rubigraph.server.call('ubigraph.set_vertex_attribute', @id, k, v.to_s)
|
37
|
+
raise "Rubigraph::Vertex##{k}=: cannot change #{v} #{@id}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def color=(c)
|
43
|
+
set_attribute('color', c)
|
44
|
+
end
|
45
|
+
|
46
|
+
def colour=(c)
|
47
|
+
self.color=(c)
|
48
|
+
end
|
49
|
+
|
50
|
+
def shape=(s)
|
51
|
+
set_attribute('shape', s)
|
52
|
+
end
|
53
|
+
|
54
|
+
def shapedetail=(d)
|
55
|
+
set_attribute('shapedetail', d)
|
56
|
+
end
|
57
|
+
|
58
|
+
def label=(l)
|
59
|
+
set_attribute('label', l)
|
60
|
+
end
|
61
|
+
|
62
|
+
def labelpos=(p)
|
63
|
+
set_attribute('labelpos', p)
|
64
|
+
end
|
65
|
+
|
66
|
+
def size=(s)
|
67
|
+
set_attribute('size', s)
|
68
|
+
end
|
69
|
+
|
70
|
+
def fontcolor=(c)
|
71
|
+
set_attribute('fontcolor', c)
|
72
|
+
end
|
73
|
+
|
74
|
+
def fontfamily=(f)
|
75
|
+
# TODO: should assert 'Helvetica' | 'Times Roman'
|
76
|
+
set_attribute('fontfamily', f)
|
77
|
+
end
|
78
|
+
|
79
|
+
def fontsize=(s)
|
80
|
+
# TODO: should assert 10, 12, 18. 24
|
81
|
+
set_attribute('fontsize', s)
|
82
|
+
end
|
83
|
+
end # Vertex
|
84
|
+
|
85
|
+
# Edge between Vertexes
|
86
|
+
class Edge
|
87
|
+
# create an Edge.
|
88
|
+
# from, to should be Vertex.
|
89
|
+
def initialize(from, to, id = nil)
|
90
|
+
if id
|
91
|
+
@id = Rubigraph.server.call('ubigraph.new_edge_w_id', id, from.id, to.id)
|
92
|
+
else
|
93
|
+
@id = Rubigraph.server.call('ubigraph.new_edge', from.id, to.id)
|
94
|
+
end
|
95
|
+
raise 'Rubigraph::Edge.initialize: cannot create edge' if @id == -1
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove
|
99
|
+
if -1 == Rubigraph.server.call('ubigraph.remove_edge', @id)
|
100
|
+
raise "Rubigraph::Edge#remove: cannot remove edge #{@id}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def set_attribute(att, value)
|
105
|
+
if -1 == Rubigraph.server.call('ubigraph.set_edge_attribute', @id, att, value.to_s)
|
106
|
+
raise "Rubigraph::edge##{att}=: cannot change #{att} #{@id}"
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def set_attributes(attrs)
|
111
|
+
attrs.each do |k, v|
|
112
|
+
if -1 == Rubigraph.server.call('ubigraph.set_edge_attribute', @id, k, v.to_s)
|
113
|
+
raise "Rubigraph::edge##{k}=: cannot change #{v} #{@id}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def color=(c)
|
119
|
+
set_attribute('color', c)
|
120
|
+
end
|
121
|
+
|
122
|
+
def colour=(c)
|
123
|
+
self.color=(c)
|
124
|
+
end
|
125
|
+
|
126
|
+
def label=(l)
|
127
|
+
set_attribute('label', l)
|
128
|
+
end
|
129
|
+
|
130
|
+
def labelpos=(p)
|
131
|
+
set_attribute('labelpos', p)
|
132
|
+
end
|
133
|
+
|
134
|
+
def fontcolor=(c)
|
135
|
+
set_attribute('fontcolor', c)
|
136
|
+
end
|
137
|
+
|
138
|
+
def fontfamily=(f)
|
139
|
+
# TODO: should assert 'Helvetica' | 'Times Roman'
|
140
|
+
set_attribute('fontfamily', f)
|
141
|
+
end
|
142
|
+
|
143
|
+
def fontsize=(s)
|
144
|
+
# TODO: should assert 10, 12, 18. 24
|
145
|
+
set_attribute('fontsize', s)
|
146
|
+
end
|
147
|
+
|
148
|
+
def strength=(s)
|
149
|
+
set_attribute('strength', s)
|
150
|
+
end
|
151
|
+
|
152
|
+
def orientationweight=(o)
|
153
|
+
set_attribute('orientationweight', o)
|
154
|
+
end
|
155
|
+
|
156
|
+
def width=(w)
|
157
|
+
set_attribute('width', w)
|
158
|
+
end
|
159
|
+
|
160
|
+
def arrow=(a)
|
161
|
+
set_attribute('arrow', a)
|
162
|
+
end
|
163
|
+
|
164
|
+
def showstrain=(s)
|
165
|
+
set_attribute('showstrain', s)
|
166
|
+
end
|
167
|
+
|
168
|
+
end # Edge
|
169
|
+
|
170
|
+
|
171
|
+
# initialize XML-RPC client
|
172
|
+
def self.init(host='127.0.0.1', port='20738')
|
173
|
+
@server = XMLRPC::Client.new2("http://#{host}:#{port}/RPC2")
|
174
|
+
end
|
175
|
+
|
176
|
+
# clear all vertex, edges
|
177
|
+
def self.clear
|
178
|
+
@server.call('ubigraph.clear')
|
179
|
+
end
|
180
|
+
|
181
|
+
# for internal use.
|
182
|
+
def self.server
|
183
|
+
@server
|
184
|
+
end
|
185
|
+
end # Rubigraph
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubigraph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mootoh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-27 00:00:00 +09:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.3
|
23
|
+
version:
|
24
|
+
description: a Ruby wrap for Ubigraph (http://www.ubietylab.net/ubigraph). see http://www.ubietylab.net/ubigraph/content/Docs/index.html to get complete description about API.
|
25
|
+
email: mootoh@gmail.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- History.txt
|
32
|
+
- Manifest.txt
|
33
|
+
- README.txt
|
34
|
+
files:
|
35
|
+
- History.txt
|
36
|
+
- Manifest.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- lib/rubigraph.rb
|
40
|
+
- test/test_rubigraph.rb
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://rubyforge.org/projects/rubigraph
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options:
|
45
|
+
- --main
|
46
|
+
- README.txt
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project: rubigraph
|
64
|
+
rubygems_version: 1.1.1
|
65
|
+
signing_key:
|
66
|
+
specification_version: 2
|
67
|
+
summary: a Ruby wrap for Ubigraph (http://www.ubietylab.net/ubigraph)
|
68
|
+
test_files:
|
69
|
+
- test/test_rubigraph.rb
|