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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdf_to_graphviz.rb +36 -14
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e153763d8ffb47a7292915cca57d46a320c52a8a
4
- data.tar.gz: 4de8d1e305374b82789226e6784a402c907bfeef
3
+ metadata.gz: 801d792d71bc697bd14095d435b2a1d956de949d
4
+ data.tar.gz: 7a5929bea84a35658da8c8919f2a55b857fecfde
5
5
  SHA512:
6
- metadata.gz: 047fa2f6c1aad66596007e3a4919883603f5814447e3dc04103f6effc4a6a4ee2c2f48b86f5e75808305624e56159c18fc9cb13c0f3547c58568703e3b216b02
7
- data.tar.gz: 309aa185510f6977bcafbf96e1f40722c59899fe3c52c1512c3f6c336fe4d0e5b1e6f840cc9f5e1d9288e47e0c7de6b16aa7ed9e302ff8d6cfcde479f78af900
6
+ metadata.gz: 5632a45520504376a7aa869659db7f430114a697063d8251f82da82da2da7297c4e9c2a7cb9dabb0d4cb018f215951015b1fbf51a174fb6872e7845576ff9c6c
7
+ data.tar.gz: 821ef84f100434a4a3fbd542a11f2d7088081eb02fa766b24b5125ec8a17c243394e7f1a0cb5c58fe7367367c9e147d28b048a26f5c0aa7e4606c32c66d5de28
@@ -18,22 +18,34 @@ class RdfToGraphviz
18
18
  end
19
19
 
20
20
  ##
21
- # +rdf_graph_to_dot(options = {})+ generate simple dot graph from RDF::Graph
22
- # @option options [RDF::Graph] :rdf_graph
23
- # @option options [TrueClass] :digraph - if true, graph has a direction - true is default
24
- # @option options [String] :subject_shape - default = doublecircle
25
- # @option options [String] :object_shape - default = circle
26
- # @option options [String] :literal_object_shape - default = rectangle
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] ||= true
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
- options[:rdf_graph].each_statement do |statement|
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=red, shape=#{options[:subject_shape]}];"
61
+ txt_dot << "\n\"#{s}\"[label=\"#{s}\", color=#{options[:subject_color]}, shape=#{options[:subject_shape]}];"
62
+
50
63
  if statement[2].literal?
51
- txt_dot << "\n\"#{o}\"[shape=#{options[:literal_object_shape]}];"
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=blue, shape=#{options[:object_shape]}];"
74
+ txt_dot << "\n\"#{o}\"[label=\"#{o}\", color=#{options[:object_color]}, shape=#{options[:object_shape]}];"
54
75
  end
55
- txt_dot << "\n\"#{s}\" -> \"#{o}\" [label=\"#{statement[1].pname}\", color=red];"
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.0.2
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: []