rdf_to_graphviz 0.0.0.2 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rdf_to_graphviz.rb +36 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 801d792d71bc697bd14095d435b2a1d956de949d
|
4
|
+
data.tar.gz: 7a5929bea84a35658da8c8919f2a55b857fecfde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5632a45520504376a7aa869659db7f430114a697063d8251f82da82da2da7297c4e9c2a7cb9dabb0d4cb018f215951015b1fbf51a174fb6872e7845576ff9c6c
|
7
|
+
data.tar.gz: 821ef84f100434a4a3fbd542a11f2d7088081eb02fa766b24b5125ec8a17c243394e7f1a0cb5c58fe7367367c9e147d28b048a26f5c0aa7e4606c32c66d5de28
|
data/lib/rdf_to_graphviz.rb
CHANGED
@@ -18,22 +18,34 @@ class RdfToGraphviz
|
|
18
18
|
end
|
19
19
|
|
20
20
|
##
|
21
|
-
#
|
22
|
-
# @
|
23
|
-
# @
|
24
|
-
# @option options [
|
25
|
-
# @option options [String] :
|
26
|
-
# @option options [String] :
|
21
|
+
# rdf_graph_to_dot(rdf_graph, options = {}) generate simple dot graph from RDF::Graph
|
22
|
+
# @param [RDF::Graph] rdf_graph
|
23
|
+
# @param [Hash{Symbol => Object}] options
|
24
|
+
# @option options [TrueClass] :digraph - default = true - if true, graph has a direction
|
25
|
+
# @option options [String] :subject_shape - default = doublecircle
|
26
|
+
# @option options [String] :object_shape - default = circle
|
27
|
+
# @option options [String] :literal_object_shape - default = rectangle
|
28
|
+
# @option options [String] :subject_color - default = red
|
29
|
+
# @option options [String] :object_color - default = blue
|
30
|
+
# @option options [String] :predicate_color - default = black
|
31
|
+
# @option options [TrueClass] :is_literal_object_uniq - default = true
|
27
32
|
# @return [String] - contain representation of RDF::Graph in Graphviz dot
|
28
33
|
#
|
29
|
-
def rdf_graph_to_dot(options = {})
|
34
|
+
def rdf_graph_to_dot(rdf_graph, options = {})
|
30
35
|
txt_dot = ""
|
31
36
|
|
32
|
-
options[:rdf_graph] ||= @graph
|
33
|
-
options[:digraph]
|
37
|
+
#options[:rdf_graph] ||= @graph
|
38
|
+
options[:digraph] = true if options[:digraph].nil?
|
34
39
|
options[:subject_shape] ||= "doublecircle"
|
35
40
|
options[:object_shape] ||= "circle"
|
36
41
|
options[:literal_object_shape] ||= "rectangle"
|
42
|
+
options[:subject_color] ||= "red"
|
43
|
+
options[:object_color] ||= "blue"
|
44
|
+
options[:predicate_color] ||= "black"
|
45
|
+
options[:is_literal_object_uniq] = true if options[:is_literal_object_uniq].nil?
|
46
|
+
|
47
|
+
|
48
|
+
n=0
|
37
49
|
|
38
50
|
if options[:digraph] == true
|
39
51
|
txt_dot << "\ndigraph digraph_1 {"
|
@@ -41,18 +53,28 @@ class RdfToGraphviz
|
|
41
53
|
txt_dot << "\ngraph graph_1 {"
|
42
54
|
end
|
43
55
|
|
44
|
-
|
56
|
+
rdf_graph.each_statement do |statement|
|
45
57
|
|
46
58
|
s = term_name(statement[0])
|
47
59
|
o = term_name(statement[2])
|
48
60
|
|
49
|
-
txt_dot << "\n\"#{s}\"[color
|
61
|
+
txt_dot << "\n\"#{s}\"[label=\"#{s}\", color=#{options[:subject_color]}, shape=#{options[:subject_shape]}];"
|
62
|
+
|
50
63
|
if statement[2].literal?
|
51
|
-
|
64
|
+
if options[:is_literal_object_uniq] == true
|
65
|
+
txt_dot << "\n\"#{o}\"[label=\"#{o}\", shape=#{options[:literal_object_shape]}];"
|
66
|
+
else
|
67
|
+
|
68
|
+
txt_dot << "\n#{"\"o"+n.to_s}\"[label=\"#{o}\", shape=#{options[:literal_object_shape]}];"
|
69
|
+
|
70
|
+
o = "o"+n.to_s
|
71
|
+
n += 1
|
72
|
+
end
|
52
73
|
else
|
53
|
-
txt_dot << "\n\"#{o}\"[color
|
74
|
+
txt_dot << "\n\"#{o}\"[label=\"#{o}\", color=#{options[:object_color]}, shape=#{options[:object_shape]}];"
|
54
75
|
end
|
55
|
-
|
76
|
+
|
77
|
+
txt_dot << "\n\"#{s}\" -> \"#{o}\" [label=\"#{statement[1].pname}\", color=#{options[:predicate_color]}];"
|
56
78
|
|
57
79
|
end
|
58
80
|
txt_dot << "}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdf_to_graphviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WiDu
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: "Gem translate RDF::Graph to Graphviz Dot format.\n\tRequire: linkeddata
|
42
|
-
& sparql gems"
|
42
|
+
& sparql gems. It's not compatible with 0.0.0.2!"
|
43
43
|
email: wdulek@gmail.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|