rdf_to_graphviz 0.0.0.1 → 0.0.0.2

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 +17 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5e0c2a779a3177de81e59aaa7be3aaf3e942159
4
- data.tar.gz: b58846649ea1ce6d93d45276def1caa6d4cf78d7
3
+ metadata.gz: e153763d8ffb47a7292915cca57d46a320c52a8a
4
+ data.tar.gz: 4de8d1e305374b82789226e6784a402c907bfeef
5
5
  SHA512:
6
- metadata.gz: 11b66dad890e9dcffadd58e68d2cce39c9af06519ec8ff51808d4ea9d6bedb9ceea8201a0ea6c8004a757323a2e12753b1803cea6f5f6edb94f42a887ba56881
7
- data.tar.gz: 20134685d5839c6c25435cfb5ed1ec3e75beaaa5938de9bdc6697cb88f97e2247a0966afa163a370b652daa3cd8d839528dbda26fc2b86cf4c5030113531351c
6
+ metadata.gz: 047fa2f6c1aad66596007e3a4919883603f5814447e3dc04103f6effc4a6a4ee2c2f48b86f5e75808305624e56159c18fc9cb13c0f3547c58568703e3b216b02
7
+ data.tar.gz: 309aa185510f6977bcafbf96e1f40722c59899fe3c52c1512c3f6c336fe4d0e5b1e6f840cc9f5e1d9288e47e0c7de6b16aa7ed9e302ff8d6cfcde479f78af900
@@ -17,20 +17,24 @@ class RdfToGraphviz
17
17
 
18
18
  end
19
19
 
20
- # =Example:
21
- # +require 'ruby-graphviz'+
22
- # require 'rdf_to_graphviz'
23
-
24
- # konwerter = RdfToGraphviz.new
25
- # queryable = RDF::Graph.load("http://ruby-rdf.github.com/rdf/etc/doap.nt")
26
- # str = konwerter.rdf_graph_to_dot({:rdf_graph => queryable})
27
- # puts str
28
- # GraphViz.parse_string(str).output( :png => "res_graph1.png" )
29
-
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
27
+ # @return [String] - contain representation of RDF::Graph in Graphviz dot
28
+ #
30
29
  def rdf_graph_to_dot(options = {})
31
30
  txt_dot = ""
31
+
32
32
  options[:rdf_graph] ||= @graph
33
33
  options[:digraph] ||= true
34
+ options[:subject_shape] ||= "doublecircle"
35
+ options[:object_shape] ||= "circle"
36
+ options[:literal_object_shape] ||= "rectangle"
37
+
34
38
  if options[:digraph] == true
35
39
  txt_dot << "\ndigraph digraph_1 {"
36
40
  else
@@ -42,11 +46,11 @@ class RdfToGraphviz
42
46
  s = term_name(statement[0])
43
47
  o = term_name(statement[2])
44
48
 
45
- txt_dot << "\n\"#{s}\"[color=red, shape=doublecircle];"
49
+ txt_dot << "\n\"#{s}\"[color=red, shape=#{options[:subject_shape]}];"
46
50
  if statement[2].literal?
47
- txt_dot << "\n\"#{o}\"[shape=rectangle];"
51
+ txt_dot << "\n\"#{o}\"[shape=#{options[:literal_object_shape]}];"
48
52
  else
49
- txt_dot << "\n\"#{o}\"[color=blue, shape=circle];"
53
+ txt_dot << "\n\"#{o}\"[color=blue, shape=#{options[:object_shape]}];"
50
54
  end
51
55
  txt_dot << "\n\"#{s}\" -> \"#{o}\" [label=\"#{statement[1].pname}\", color=red];"
52
56
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf_to_graphviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.1
4
+ version: 0.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - WiDu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: linkeddata