yowl 0.4.pre
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.
- data/CHANGES +15 -0
- data/INSTALL-MACOSX.md +107 -0
- data/README.md +92 -0
- data/Rakefile +76 -0
- data/bin/yowl +14 -0
- data/examples/introduction.html +5 -0
- data/lib/yowl/association.rb +66 -0
- data/lib/yowl/class.rb +296 -0
- data/lib/yowl/generator.rb +96 -0
- data/lib/yowl/import.rb +62 -0
- data/lib/yowl/individual.rb +398 -0
- data/lib/yowl/individual_association.rb +80 -0
- data/lib/yowl/ontology.rb +197 -0
- data/lib/yowl/options.rb +116 -0
- data/lib/yowl/optionsparser.rb +75 -0
- data/lib/yowl/person.rb +26 -0
- data/lib/yowl/property.rb +190 -0
- data/lib/yowl/repository.rb +100 -0
- data/lib/yowl/schema.rb +519 -0
- data/lib/yowl/template/css/jquery.ui.all.css +11 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/lib/yowl/template/css/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/yowl/template/css/smoothness/jquery-ui-1.8.23.custom.css +563 -0
- data/lib/yowl/template/css/yowl.css +414 -0
- data/lib/yowl/template/import-diagram.erb +29 -0
- data/lib/yowl/template/index.erb +56 -0
- data/lib/yowl/template/js/jquery-1.7.2.min.js +4 -0
- data/lib/yowl/template/js/jquery-ui-1.8.23.custom.min.js +125 -0
- data/lib/yowl/template/js/jquery.ui.accordion.js +611 -0
- data/lib/yowl/template/js/yowl.js +72 -0
- data/lib/yowl/template/ontology.erb +598 -0
- data/lib/yowl/template/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-icons_222222_256x240.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-icons_454545_256x240.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-icons_888888_256x240.png +0 -0
- data/lib/yowl/template/themes/base/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/yowl/template/themes/base/jquery.ui.accordion.css +19 -0
- data/lib/yowl/template/themes/base/jquery.ui.all.css +11 -0
- data/lib/yowl/template/themes/base/jquery.ui.autocomplete.css +53 -0
- data/lib/yowl/template/themes/base/jquery.ui.base.css +11 -0
- data/lib/yowl/template/themes/base/jquery.ui.button.css +38 -0
- data/lib/yowl/template/themes/base/jquery.ui.core.css +38 -0
- data/lib/yowl/template/themes/base/jquery.ui.datepicker.css +66 -0
- data/lib/yowl/template/themes/base/jquery.ui.dialog.css +21 -0
- data/lib/yowl/template/themes/base/jquery.ui.progressbar.css +11 -0
- data/lib/yowl/template/themes/base/jquery.ui.resizable.css +20 -0
- data/lib/yowl/template/themes/base/jquery.ui.selectable.css +10 -0
- data/lib/yowl/template/themes/base/jquery.ui.slider.css +24 -0
- data/lib/yowl/template/themes/base/jquery.ui.tabs.css +18 -0
- data/lib/yowl/template/themes/base/jquery.ui.theme.css +247 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/lib/yowl/template/themes/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/yowl/template/themes/smoothness/jquery-ui-1.8.23.custom.css +563 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.accordion.css +19 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.all.css +11 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.autocomplete.css +53 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.base.css +11 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.button.css +38 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.core.css +38 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.datepicker.css +66 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.dialog.css +21 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.progressbar.css +11 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.resizable.css +20 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.selectable.css +10 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.slider.css +24 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.tabs.css +18 -0
- data/lib/yowl/template/themes/smoothness/jquery.ui.theme.css +249 -0
- data/lib/yowl/util.rb +221 -0
- data/lib/yowl/version.rb +3 -0
- data/lib/yowl.rb +42 -0
- data/test/input/base-with-comments.ttl +163 -0
- data/test/input/base.ttl +221 -0
- data/test/input/empty.ttl +8 -0
- data/test/input/example.ttl +73 -0
- data/test/test_example_ttl.rb +62 -0
- data/test/test_yowl.rb +4 -0
- data/test/testcases.md +24 -0
- metadata +311 -0
data/CHANGES
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
0.4
|
|
3
|
+
|
|
4
|
+
- Rename to YOWL
|
|
5
|
+
|
|
6
|
+
0.3
|
|
7
|
+
|
|
8
|
+
- Now also finds dowl/introduction.html
|
|
9
|
+
- When rdfs:label is missing the short name is used
|
|
10
|
+
- Generates SVG graphics:
|
|
11
|
+
- a Class Diagram with all Classes found in a schema
|
|
12
|
+
- A Diagram per Class with its direct associations
|
|
13
|
+
- A Diagram per Individual with its direct associations
|
|
14
|
+
- At the index page: a Diagram with all Ontologies and their import relationships
|
|
15
|
+
|
data/INSTALL-MACOSX.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Installation on Mac OS X
|
|
2
|
+
|
|
3
|
+
Unfortunately, its not trivial to get YOWL to run on Mac OS X.
|
|
4
|
+
|
|
5
|
+
You can either use MacPorts or Brew to install some of the components that YOWL needs.
|
|
6
|
+
|
|
7
|
+
## MacPorts
|
|
8
|
+
|
|
9
|
+
You first have to download and install MacPorts: http://www.macports.org/install.php
|
|
10
|
+
|
|
11
|
+
Then use MacPorts to install GraphViz (which is used to generate the graphics) and wget:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
sudo port install graphviz wget
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## HomeBrew
|
|
18
|
+
|
|
19
|
+
As an alternative to MacPorts, you can install Brew and use that to install Graphviz,
|
|
20
|
+
for installation instructions of Brew look here: https://github.com/mxcl/homebrew/wiki/Installation
|
|
21
|
+
|
|
22
|
+
Once Brew is installed, install Graphviz and wget:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
sudo brew install graphviz wget
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Raptor 1
|
|
29
|
+
|
|
30
|
+
YOWL depends on the Ruby package "ruby-rdf" which in turn depends on a C library called "raptor".
|
|
31
|
+
Unfortunately, MacPorts recently dropped support for the older version of Raptor (version 1) that
|
|
32
|
+
is used by ruby-rdf, so MacPorts can only install version 2, which is not compatible with ruby-rdf,
|
|
33
|
+
so don't bother to install it.
|
|
34
|
+
Another well known package manager for Mac OS X, HomeBrew, also can only install version 2
|
|
35
|
+
of libraptor.
|
|
36
|
+
|
|
37
|
+
There are two solutions available at this point (unless you have a better idea):
|
|
38
|
+
|
|
39
|
+
### Building libraptor version 1 from source
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
mkdir -p ~/Work/build
|
|
43
|
+
cd ~/Work/build
|
|
44
|
+
wget http://download.librdf.org/source/raptor-1.4.21.tar.gz
|
|
45
|
+
tar xvf raptor-1.4.21.tar.gz
|
|
46
|
+
cd raptor-1.4.21
|
|
47
|
+
./configure "CPPFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include"
|
|
48
|
+
make
|
|
49
|
+
sudo make install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
As you can see in the configure line above, the build procedure assumes that you have Xcode installed, where it tries to find "curl/types.h".
|
|
53
|
+
If you have this file installed elsewhere then change that location on the configure line.
|
|
54
|
+
One way to find "curl/types.h" is:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
sudo locate types.h | grep curl
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
sudo find /usr /opt /sw /Applications -name 'types.h' | grep curl
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Installing libraptor version 1 with Fink
|
|
67
|
+
|
|
68
|
+
Besides MacPorts and HomeBrew, there's also Fink. Go to the Fink website, download
|
|
69
|
+
and install Fink and then type:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
sudo fink selfupdate
|
|
73
|
+
sudo fink install raptor-bin
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
This will fail on Mac OS X Mountain Lion (10.8.x or later) because the raptor package
|
|
77
|
+
as defined by Fink is dependent on an older version of curl, which does no longer have
|
|
78
|
+
the "curl/types.h" file, which is needed by raptor, unless you configure it a bit
|
|
79
|
+
differently:
|
|
80
|
+
|
|
81
|
+
Open the Fink package file for raptor:
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
sudo vi /sw/fink/10.7/stable/main/finkinfo/libs/libraptor1-shlibs.info
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Find the line that starts with "ConfigureParams:" and add the option --with-www=xml so
|
|
88
|
+
that it looks as follows:
|
|
89
|
+
```
|
|
90
|
+
ConfigureParams: --enable-dependency-tracking --disable-static --enable-gtk-doc --with-www=xml
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Then save the file and execute the following:
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
sudo fink rebuildpackage raptor-bin
|
|
97
|
+
sudo fink install raptor-bin
|
|
98
|
+
sudo ln -s /sw/lib/libraptor.1.dylib /usr/lib/libraptor.dylib
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Gems
|
|
102
|
+
|
|
103
|
+
YOWL depends on various "ruby gems" that can be installed as follows:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
sudo gem install ffi rdf rdf-raptor rdf-json rdf-trix sxp sparql ruby-graphviz
|
|
107
|
+
```
|
data/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# YOWL
|
|
2
|
+
|
|
3
|
+
Yet another OWL documentor. YOWL is a command line utility that can read a number of
|
|
4
|
+
RDFS/OWL files, called the repository, and generate a documentation website from it,
|
|
5
|
+
with visualisations like Class Diagrams (as SVG), Individuals Diagrams and Import Diagrams.
|
|
6
|
+
|
|
7
|
+
It also detects annotations from the following public ontologies:
|
|
8
|
+
|
|
9
|
+
- Dublin Core
|
|
10
|
+
- [Term-centric Semantic Web Vocabulary Annotations](http://www.w3.org/2003/06/sw-vocab-status/note)
|
|
11
|
+
- [VANN](http://vocab.org/vann/.html)
|
|
12
|
+
- SKOS
|
|
13
|
+
- FOAF
|
|
14
|
+
|
|
15
|
+
This is a fork of the original DOWL project at https://github.com/ldodds/dowl.
|
|
16
|
+
|
|
17
|
+
# INSTALLATION
|
|
18
|
+
|
|
19
|
+
## Installation on Mac OS X:
|
|
20
|
+
|
|
21
|
+
[Installation on Mac OS X](/jgeluk/yowl/blob/master/INSTALL-MACOSX.md)
|
|
22
|
+
|
|
23
|
+
## Installation on Ubuntu
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
apt-get install ruby rake gem
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## General
|
|
30
|
+
|
|
31
|
+
Install all libraries used by YOWL:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
[sudo] gem install ffi rdf rdf-raptor rdf-json rdf-trix sxp sparql ruby-graphviz
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This version of YOWL is not yet available as a "gem" itself so it needs to be downloaded from Github:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
mkdir ~/downloads
|
|
41
|
+
cd ~/downloads
|
|
42
|
+
wget http://github.com/jgeluk/yowl/tarball/master -O yowl.tar.gz
|
|
43
|
+
tar xvf yowl.tar.gz
|
|
44
|
+
#
|
|
45
|
+
# Remember the name of the root directory of the unpacked tarball
|
|
46
|
+
# which looks like jgeluk-yowl-5ba77f5
|
|
47
|
+
#
|
|
48
|
+
sudo rm -rf /opt/yowl
|
|
49
|
+
sudo mv ~/downloads/jgeluk-yowl-5ba77f5 /opt/yowl
|
|
50
|
+
cd /opt/yowl
|
|
51
|
+
sudo rake install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or get it with git:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
rm -rf /opt/yowl
|
|
58
|
+
cd /opt
|
|
59
|
+
git clone git@github.com:jgeluk/yowl.git
|
|
60
|
+
cd /opt/yowl
|
|
61
|
+
sudo rake install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
# Usage
|
|
65
|
+
|
|
66
|
+
Execute bin/yowl to see usage options:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
user@host:/opt/yowl# /opt/yowl/bin/yowl
|
|
70
|
+
Output will be generated in this directory: /opt/yowl
|
|
71
|
+
Usage: YOWL [<options>]
|
|
72
|
+
|
|
73
|
+
Specific options:
|
|
74
|
+
-i, --ontology FILES Read input FILES
|
|
75
|
+
-o, --output DIR Write HTML output to DIR
|
|
76
|
+
-t, --template DIR Use ERB templates in DIR
|
|
77
|
+
--no-vann Skip looking for vann:preferedNamespacePrefix
|
|
78
|
+
|
|
79
|
+
Common options:
|
|
80
|
+
-?, -h, --help Show this message
|
|
81
|
+
-V, --version Show version
|
|
82
|
+
-v, --verbose Show verbose logging
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For example, to generate a site for the PROV ontology,
|
|
86
|
+
download the prov owl file and run YOWL as follows:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
/opt/yowl/bin/yowl -i /root/downloads/prov/*.owl -o /var/www/prov
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'rubygems/package_task'
|
|
4
|
+
require 'rdoc/task'
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
require 'rake/clean'
|
|
7
|
+
|
|
8
|
+
NAME = "yowl"
|
|
9
|
+
VER = "0.4.pre"
|
|
10
|
+
|
|
11
|
+
RDOC_OPTS = ['--quiet', '--title', 'yowl reference', '--main', 'README.md']
|
|
12
|
+
|
|
13
|
+
PKG_FILES = %w(README.md INSTALL-MACOSX.md Rakefile CHANGES) +
|
|
14
|
+
Dir.glob("{bin,test,examples,lib}/**/*")
|
|
15
|
+
|
|
16
|
+
CLEAN.include ['*.gem', 'pkg']
|
|
17
|
+
|
|
18
|
+
SPEC = Gem::Specification.new do |s|
|
|
19
|
+
s.platform = Gem::Platform::RUBY
|
|
20
|
+
s.summary = 'OWL visualization and documentation generator'
|
|
21
|
+
s.description = <<-EOF
|
|
22
|
+
Yet another OWL documentor. YOWL is a command line utility that can read a number of RDFS/OWL files,
|
|
23
|
+
called the repository, and generate a documentation website from it, with visualisations like
|
|
24
|
+
Class Diagrams (as SVG), Individuals Diagrams and Import Diagrams.
|
|
25
|
+
EOF
|
|
26
|
+
s.name = NAME
|
|
27
|
+
s.version = VER
|
|
28
|
+
s.required_ruby_version = ">= 1.8.7"
|
|
29
|
+
s.has_rdoc = true
|
|
30
|
+
s.extra_rdoc_files = ["README.md", "INSTALL-MACOSX.md", "CHANGES"]
|
|
31
|
+
s.rdoc_options = RDOC_OPTS
|
|
32
|
+
s.authors = ['Leigh Dodds', 'Jacobus Geluk']
|
|
33
|
+
s.email = ['leigh.dodds@talis.com', 'jacobus.geluk@gmail.com']
|
|
34
|
+
s.homepage = 'http://github.com/jgeluk/yowl'
|
|
35
|
+
s.files = PKG_FILES
|
|
36
|
+
s.require_path = "lib"
|
|
37
|
+
s.bindir = "bin"
|
|
38
|
+
s.executables = ["yowl"]
|
|
39
|
+
s.test_file = "test/test_yowl.rb"
|
|
40
|
+
s.add_dependency("rdf-raptor", ">= 0.4.0")
|
|
41
|
+
s.add_dependency("ffi", ">= 1.1.5")
|
|
42
|
+
s.add_dependency("rdf", ">= 0.3.8")
|
|
43
|
+
s.add_dependency("rdf-raptor", ">= 0.4.2")
|
|
44
|
+
s.add_dependency("rdf-json", ">= 0.3.0")
|
|
45
|
+
s.add_dependency("rdf-trix", ">= 0.3.0")
|
|
46
|
+
s.add_dependency("sxp", ">= 0.0.14")
|
|
47
|
+
s.add_dependency("sparql", ">= 0.3.1")
|
|
48
|
+
s.add_dependency("ruby-graphviz", ">= 1.0.8")
|
|
49
|
+
s.rubyforge_project = 'nowarning'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Gem::PackageTask.new(SPEC) do |pkg|
|
|
53
|
+
pkg.need_tar = true
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
RDoc::Task.new do |rdoc|
|
|
57
|
+
rdoc.rdoc_dir = 'doc/rdoc'
|
|
58
|
+
rdoc.options += RDOC_OPTS
|
|
59
|
+
rdoc.rdoc_files.include("README.md", "INSTALL-MACOSX.md", "CHANGES", "lib/**/*.rb")
|
|
60
|
+
rdoc.main = "README.md"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Rake::TestTask.new do |test|
|
|
64
|
+
test.verbose = true
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc "Install from a locally built copy of the gem"
|
|
68
|
+
task :install do
|
|
69
|
+
sh %{rake package}
|
|
70
|
+
sh %{sudo gem install pkg/#{NAME}-#{VER}}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
desc "Uninstall the gem"
|
|
74
|
+
task :uninstall => [:clean] do
|
|
75
|
+
sh %{sudo gem uninstall #{NAME}}
|
|
76
|
+
end
|
data/bin/yowl
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'getoptlong'
|
|
5
|
+
require 'yowl'
|
|
6
|
+
require 'erb'
|
|
7
|
+
|
|
8
|
+
PROGRAM = File::basename $0
|
|
9
|
+
|
|
10
|
+
options = YOWL::OptionsParser.parse(ARGV)
|
|
11
|
+
if options
|
|
12
|
+
repository = YOWL::Repository.new(options)
|
|
13
|
+
YOWL::Generator.new(repository, options).run()
|
|
14
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
module YOWL
|
|
2
|
+
class Association < YOWL::LabelledDocObject
|
|
3
|
+
|
|
4
|
+
attr_reader :domainClass
|
|
5
|
+
attr_reader :rangeClass
|
|
6
|
+
attr_reader :property
|
|
7
|
+
attr_reader :key
|
|
8
|
+
def initialize(resource, schema, domainClass, rangeClass)
|
|
9
|
+
super(resource, schema)
|
|
10
|
+
@domainClass = domainClass
|
|
11
|
+
@rangeClass = rangeClass
|
|
12
|
+
|
|
13
|
+
@key = "#{@domainClass.uri},#{@rangeClass.uri},#{label}".hash
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def label
|
|
17
|
+
return short_name
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def hash
|
|
21
|
+
return key
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def eql?(other)
|
|
25
|
+
@key.eql? other.key
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
#
|
|
29
|
+
# Add the current Association as an edge to the given GraphViz graph,
|
|
30
|
+
# but check whether the Association refers to a Domain and Range class in
|
|
31
|
+
# the current schema and whether the Association has already been added
|
|
32
|
+
# to the graph (by checking the given edges collection).
|
|
33
|
+
#
|
|
34
|
+
def addAsGraphVizEdge(graph_, nodes_, edges_)
|
|
35
|
+
|
|
36
|
+
if not nodes_.has_key?(@domainClass.uri)
|
|
37
|
+
return nodes_, edges_
|
|
38
|
+
end
|
|
39
|
+
if not nodes_.has_key?(@rangeClass.uri)
|
|
40
|
+
return nodes_, edges_
|
|
41
|
+
end
|
|
42
|
+
if edges_.has_key?(@key)
|
|
43
|
+
return nodes_, edges_
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
domainClassNode = nodes_[@domainClass.uri]
|
|
47
|
+
rangeClassNode = nodes_[@rangeClass.uri]
|
|
48
|
+
|
|
49
|
+
edges_[@key] = Association.newGraphVizEdge(graph_, domainClassNode, rangeClassNode, label)
|
|
50
|
+
|
|
51
|
+
return nodes_, edges_
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def Association.newGraphVizEdge(graph_, domainNode_, rangeNode_, label_, constraint_ = true)
|
|
55
|
+
return graph_.add_edges(
|
|
56
|
+
domainNode_,
|
|
57
|
+
rangeNode_,
|
|
58
|
+
:label => label_,
|
|
59
|
+
:arrowhead => :open,
|
|
60
|
+
:arrowsize => 0.5,
|
|
61
|
+
:penwidth => 0.5,
|
|
62
|
+
:constraint => constraint_
|
|
63
|
+
)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
data/lib/yowl/class.rb
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
module YOWL
|
|
2
|
+
|
|
3
|
+
class Class < YOWL::LabelledDocObject
|
|
4
|
+
|
|
5
|
+
include Comparable
|
|
6
|
+
|
|
7
|
+
attr_reader :resource
|
|
8
|
+
attr_reader :subClasses
|
|
9
|
+
attr_reader :associations
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
def initialize(resource, schema)
|
|
13
|
+
super(resource, schema)
|
|
14
|
+
@super_classes = nil
|
|
15
|
+
@subClasses = nil
|
|
16
|
+
@associations = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
public
|
|
20
|
+
def Class.withUri(resource, schema)
|
|
21
|
+
if resource.anonymous?
|
|
22
|
+
warn "WARNING: Ignoring class with uri #{resource.to_s}"
|
|
23
|
+
return
|
|
24
|
+
end
|
|
25
|
+
klass = schema.classes[resource.to_s]
|
|
26
|
+
if klass
|
|
27
|
+
return klass
|
|
28
|
+
end
|
|
29
|
+
klass = Class.new(resource, schema)
|
|
30
|
+
schema.classes[resource.to_s] = klass
|
|
31
|
+
if schema.options.verbose
|
|
32
|
+
puts "Created class #{klass.short_name}"
|
|
33
|
+
end
|
|
34
|
+
return klass
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
public
|
|
38
|
+
def short_name()
|
|
39
|
+
sn = super()
|
|
40
|
+
if sn[0,7] == "http://" or sn[0,8] == "https://"
|
|
41
|
+
if sn.include?('#')
|
|
42
|
+
ns = sn.slice(/.*#/)
|
|
43
|
+
else
|
|
44
|
+
ns = sn.slice(/.*\//)
|
|
45
|
+
end
|
|
46
|
+
return sn[ns.length..-1]
|
|
47
|
+
end
|
|
48
|
+
return sn
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
public
|
|
52
|
+
def super_classes()
|
|
53
|
+
if not @super_classes.nil?
|
|
54
|
+
return @super_classes
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
@super_classes = []
|
|
58
|
+
|
|
59
|
+
@schema.model.query(
|
|
60
|
+
RDF::Query::Pattern.new(@resource, YOWL::Namespaces::RDFS.subClassOf)
|
|
61
|
+
) do |statement|
|
|
62
|
+
#
|
|
63
|
+
# Only look at statements like these:
|
|
64
|
+
#
|
|
65
|
+
# <rdfs:subClassOf rdf:resource="<uri>"/>
|
|
66
|
+
#
|
|
67
|
+
# And ignore statements like these:
|
|
68
|
+
#
|
|
69
|
+
# <rdfs:subClassOf>
|
|
70
|
+
# <owl:Restriction>
|
|
71
|
+
# <owl:onProperty rdf:resource="<uri>"/>
|
|
72
|
+
# <owl:allValuesFrom rdf:resource="<uri>"/>
|
|
73
|
+
# </owl:Restriction>
|
|
74
|
+
# </rdfs:subClassOf>
|
|
75
|
+
#
|
|
76
|
+
if statement.object.uri?
|
|
77
|
+
superClass = Class.withUri(statement.object, @schema)
|
|
78
|
+
if superClass
|
|
79
|
+
if superClass != self
|
|
80
|
+
@super_classes << superClass
|
|
81
|
+
end
|
|
82
|
+
else
|
|
83
|
+
warn "WARNING: Could not find super class #{statement.object.to_s}"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
return @super_classes
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
public
|
|
91
|
+
def hasSuperClasses?
|
|
92
|
+
return ! super_classes.empty?()
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
public
|
|
96
|
+
def hasSuperClassesInSchema?
|
|
97
|
+
super_classes.each() do |klass|
|
|
98
|
+
if @schema.classes.include?(klass.uri)
|
|
99
|
+
return true
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
return false
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
public
|
|
106
|
+
def subClasses()
|
|
107
|
+
if @subClasses
|
|
108
|
+
return @subClasses
|
|
109
|
+
end
|
|
110
|
+
@subClasses = Set.new
|
|
111
|
+
|
|
112
|
+
@schema.model.query(
|
|
113
|
+
RDF::Query::Pattern.new(nil, YOWL::Namespaces::RDFS.subClassOf, @resource)
|
|
114
|
+
) do |statement|
|
|
115
|
+
subClass = Class.withUri(statement.subject, @schema)
|
|
116
|
+
if subClass
|
|
117
|
+
if subClass != self
|
|
118
|
+
@subClasses << subClass
|
|
119
|
+
end
|
|
120
|
+
else
|
|
121
|
+
warn "WARNING: Could not find sub class of #{short_name} with uri #{statement.subject.to_s}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
#@subClasses.sort! { |x,y| x <=> y }
|
|
125
|
+
return @subClasses
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
public
|
|
129
|
+
def hasSubClasses?
|
|
130
|
+
return ! subClasses.empty?()
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
public
|
|
134
|
+
#
|
|
135
|
+
# Return a collection of Associations representing ObjectProperties
|
|
136
|
+
# where the current class is one of the Domain classes.
|
|
137
|
+
#
|
|
138
|
+
def associations()
|
|
139
|
+
if not @associations.nil?
|
|
140
|
+
return @associations
|
|
141
|
+
end
|
|
142
|
+
@associations = Set.new
|
|
143
|
+
|
|
144
|
+
if @schema.options.verbose
|
|
145
|
+
puts "Searching for associations of class #{short_name}"
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
query = RDF::Query.new({
|
|
149
|
+
:property => {
|
|
150
|
+
YOWL::Namespaces::RDFS.domain => @resource,
|
|
151
|
+
RDF.type => YOWL::Namespaces::OWL.ObjectProperty,
|
|
152
|
+
YOWL::Namespaces::RDFS.range => :range
|
|
153
|
+
}
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
solutions = query.execute(@schema.model)
|
|
157
|
+
if @schema.options.verbose
|
|
158
|
+
puts " - Found #{solutions.count} solutions"
|
|
159
|
+
end
|
|
160
|
+
solutions.distinct!
|
|
161
|
+
if @schema.options.verbose
|
|
162
|
+
puts " - Found #{solutions.count} distinct solutions"
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
solutions.each do |solution|
|
|
166
|
+
property = solution[:property]
|
|
167
|
+
range = solution[:range]
|
|
168
|
+
if @schema.options.verbose
|
|
169
|
+
puts " - Found Association from #{short_name} to #{@schema.prefixedUri(range)}: #{@schema.prefixedUri(property.to_s)}"
|
|
170
|
+
end
|
|
171
|
+
rangeClass = Class.withUri(range, @schema)
|
|
172
|
+
if @schema.options.verbose
|
|
173
|
+
puts " - Found this class for it: #{rangeClass}"
|
|
174
|
+
end
|
|
175
|
+
if rangeClass
|
|
176
|
+
@associations << Association.new(property, @schema, self, rangeClass)
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
if @schema.options.verbose
|
|
180
|
+
puts " - Returning #{@associations.size} associations for class #{short_name}"
|
|
181
|
+
end
|
|
182
|
+
return @associations
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
public
|
|
186
|
+
#
|
|
187
|
+
# Add the current class as a GraphViz node to the given collection of nodes
|
|
188
|
+
# and to the given graph. Return the collection of nodes.
|
|
189
|
+
#
|
|
190
|
+
def addAsGraphvizNode (graph_, nodes_, edges_)
|
|
191
|
+
name = short_name
|
|
192
|
+
if @schema.options.verbose
|
|
193
|
+
puts "- Processing class #{name}"
|
|
194
|
+
end
|
|
195
|
+
#
|
|
196
|
+
# No need to add a node twice
|
|
197
|
+
#
|
|
198
|
+
if nodes_.has_key? uri
|
|
199
|
+
return nodes_, edges_
|
|
200
|
+
end
|
|
201
|
+
node = graph_.add_nodes(escaped_uri)
|
|
202
|
+
node.URL = "#class_#{short_name}"
|
|
203
|
+
|
|
204
|
+
prefix = nil
|
|
205
|
+
if name.include?(':')
|
|
206
|
+
prefix = name.sub(/:\s*(.*)/, "")
|
|
207
|
+
name = name.sub(/(.*)\s*:/, "")
|
|
208
|
+
end
|
|
209
|
+
name = name.split(/(?=[A-Z])/).join(' ')
|
|
210
|
+
if prefix
|
|
211
|
+
#
|
|
212
|
+
# Can't get HTML labels to work
|
|
213
|
+
#
|
|
214
|
+
#name = "<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"><TR><TD>#{name}</TD></TR><TR><TD><I>(#{prefix})</I></TD></TR></TABLE>"
|
|
215
|
+
name = "#{name}\n(#{prefix})"
|
|
216
|
+
end
|
|
217
|
+
node.label = name
|
|
218
|
+
|
|
219
|
+
if hasComment?
|
|
220
|
+
node.tooltip = comment
|
|
221
|
+
else
|
|
222
|
+
if hasDefinition?
|
|
223
|
+
node.tooltip = definition
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
nodes_[uri] = node
|
|
227
|
+
return nodes_, edges_
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
public
|
|
231
|
+
#
|
|
232
|
+
# Generate a diagram for each class, the "per class diagram"
|
|
233
|
+
#
|
|
234
|
+
def perClassDiagramAsSvg
|
|
235
|
+
#if @schema.options.verbose
|
|
236
|
+
# puts "Generating SVG Per Class Diagram for #{short_name}"
|
|
237
|
+
#end
|
|
238
|
+
|
|
239
|
+
g = GraphvizUtility.setDefaults(GraphViz.new(:G, :type => :digraph))
|
|
240
|
+
g[:rankdir] = "LR"
|
|
241
|
+
g.node[:fixedsize] = false
|
|
242
|
+
|
|
243
|
+
nodes = Hash.new
|
|
244
|
+
edges = Hash.new
|
|
245
|
+
nodes, edges = addAsGraphvizNode(g, nodes, edges)
|
|
246
|
+
|
|
247
|
+
#
|
|
248
|
+
# Do the "outbound" associations first
|
|
249
|
+
#
|
|
250
|
+
associations.each do |association|
|
|
251
|
+
nodes, edges = association.rangeClass.addAsGraphvizNode(g, nodes, edges)
|
|
252
|
+
nodes, edges = association.addAsGraphVizEdge(g, nodes, edges)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
#
|
|
256
|
+
# Then do the "inbound" associations
|
|
257
|
+
#
|
|
258
|
+
@schema.classes.values.to_set.each do |klass|
|
|
259
|
+
klass.associations.each do |association|
|
|
260
|
+
if self == association.rangeClass
|
|
261
|
+
nodes, edges = association.rangeClass.addAsGraphvizNode(g, nodes, edges)
|
|
262
|
+
nodes, edges = association.addAsGraphVizEdge(g, nodes, edges)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
return GraphvizUtility.embeddableSvg(g)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
#
|
|
271
|
+
# Create the GraphVis Edge for all "is a" (rdf:type) associations from a node
|
|
272
|
+
# (representing a Class or Individual) to another node (always representing a Class)
|
|
273
|
+
#
|
|
274
|
+
def Class.newGraphVizEdge(graph_, domainNode_, rangeNode_, constraint_ = true)
|
|
275
|
+
options = {
|
|
276
|
+
:arrowhead => :empty,
|
|
277
|
+
:arrowsize => 0.5,
|
|
278
|
+
:dir => :back,
|
|
279
|
+
:label => "is a",
|
|
280
|
+
:labeldistance => 2,
|
|
281
|
+
:penwidth => 0.5,
|
|
282
|
+
:constraint => constraint_
|
|
283
|
+
}
|
|
284
|
+
if not constraint_
|
|
285
|
+
options[:style] = :dashed
|
|
286
|
+
end
|
|
287
|
+
return graph_.add_edges(
|
|
288
|
+
rangeNode_,
|
|
289
|
+
domainNode_,
|
|
290
|
+
options
|
|
291
|
+
)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
end
|