rdf_to_graphviz 0.0.0
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.
- checksums.yaml +7 -0
- data/lib/rdf_to_graphviz.rb +44 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a91c816f75869394cf9f8ded9f79c8285e450aae
|
4
|
+
data.tar.gz: 14fcefcec995f886247981124d905a296eb60fbc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90a68e54b5b88512b4a968098310e5475add2b0b1ce21d734beb3cbee28e18ab72f517f0ecb9eef79073ee8d13152101e463cabfe1ba8ce75e85393c716e1051
|
7
|
+
data.tar.gz: 4ec64cbd380fa54f79d0bf2c263683cdfeb60ab04446c3f5a60ddb5caa6e4011f8827b763406d6eb40f0b44abb1074af2615458085f8fe64c06fc097409ff8ca
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'linkeddata'
|
2
|
+
require 'sparql'
|
3
|
+
|
4
|
+
class RdfToGraphviz
|
5
|
+
|
6
|
+
def term_name(statement)
|
7
|
+
if statement.literal?
|
8
|
+
statement.to_s
|
9
|
+
elsif statement.node?
|
10
|
+
statement.to_s
|
11
|
+
else
|
12
|
+
statement.pname
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
def rdf_graph_to_dot(options = {})
|
18
|
+
txt_dot = ""
|
19
|
+
options[:rdf_graph] ||= @graph
|
20
|
+
options[:digraph] ||= true
|
21
|
+
if options[:digraph] == true
|
22
|
+
txt_dot << "\ndigraph digraph_1 {"
|
23
|
+
else
|
24
|
+
txt_dot << "\ngraph graph_1 {"
|
25
|
+
end
|
26
|
+
|
27
|
+
options[:rdf_graph].each_statement do |statement|
|
28
|
+
|
29
|
+
s = term_name(statement[0])
|
30
|
+
o = term_name(statement[2])
|
31
|
+
|
32
|
+
txt_dot << "\n\"#{s}\"[color=red, shape=doublecircle];"
|
33
|
+
if statement[2].literal?
|
34
|
+
txt_dot << "\n\"#{o}\"[shape=rectangle];"
|
35
|
+
else
|
36
|
+
txt_dot << "\n\"#{o}\"[color=blue, shape=circle];"
|
37
|
+
end
|
38
|
+
txt_dot << "\n\"#{s}\" -> \"#{o}\" [label=\"#{statement[1].pname}\", color=red];"
|
39
|
+
|
40
|
+
end
|
41
|
+
txt_dot << "}"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdf_to_graphviz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- WiDu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: wdulek@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/rdf_to_graphviz.rb
|
20
|
+
homepage: http://rubygems.org/gems/ruby_to_graphviz
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5.1
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: It's abble to generate simple dot graph from RDF::Graph
|
44
|
+
test_files: []
|