rdf-rdfa 0.3.4.2 → 0.3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rdf/rdfa/reader.rb +6 -6
- data/lib/rdf/rdfa/writer.rb +29 -13
- data/lib/rdf/rdfa/writer/haml_templates.rb +3 -0
- metadata +111 -240
- data/.yardopts +0 -13
- data/CONTRIBUTORS +0 -1
- data/Gemfile +0 -19
- data/History.md +0 -98
- data/README.md +0 -311
- data/Rakefile +0 -64
- data/etc/basic.html +0 -15
- data/etc/foaf.html +0 -83
- data/etc/profile.html +0 -40
- data/etc/xhv.html +0 -459
- data/example-files/bb-test.rb +0 -14
- data/example-files/best-buy.html +0 -3203
- data/example-files/data-view.xhtml +0 -369
- data/example-files/erdf_profile.html +0 -116
- data/example-files/gk-foaf.html +0 -283
- data/example-files/payswarm.html +0 -449
- data/example-files/payswarm.n3 +0 -86
- data/example.rb +0 -23
- data/lib/rdf/.gitignore +0 -2
- data/pkg/.gitignore +0 -1
- data/rdf-rdfa.gemspec +0 -163
- data/script/console +0 -10
- data/script/intern_vocabulary +0 -99
- data/script/parse +0 -91
- data/script/tc +0 -115
- data/script/yard-to-rubyforge +0 -2
- data/spec/.gitignore +0 -1
- data/spec/literal_spec.rb +0 -244
- data/spec/matchers.rb +0 -108
- data/spec/profile_spec.rb +0 -68
- data/spec/reader_spec.rb +0 -572
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -46
- data/spec/test_helper.rb +0 -97
- data/spec/writer_spec.rb +0 -410
data/example-files/payswarm.n3
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
@base <http://recipes.payswarm.com/?p=10185> .
|
2
|
-
@prefix bibo: <http://purl.org/ontology/bibo/> .
|
3
|
-
@prefix cal: <http://www.w3.org/2002/12/cal/ical#> .
|
4
|
-
@prefix cc: <http://creativecommons.org/ns#> .
|
5
|
-
@prefix com: <http://purl.org/commerce#> .
|
6
|
-
@prefix dbp: <http://dbpedia.org/property/> .
|
7
|
-
@prefix dbp-owl: <http://dbpedia.org/ontology/> .
|
8
|
-
@prefix dbr: <http://dbpedia.org/resource/> .
|
9
|
-
@prefix dc: <http://purl.org/dc/terms/> .
|
10
|
-
@prefix dcterms: <http://purl.org/dc/terms/> .
|
11
|
-
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
12
|
-
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
13
|
-
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
|
14
|
-
@prefix gr: <http://purl.org/goodrelations/v1#> .
|
15
|
-
@prefix grddl: <http://www.w3.org/2003/g/data-view#> .
|
16
|
-
@prefix og: <http://ogp.me/ns#> .
|
17
|
-
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
18
|
-
@prefix ps: <http://purl.org/payswarm#> .
|
19
|
-
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
20
|
-
@prefix rdfa: <http://www.w3.org/ns/rdfa#> .
|
21
|
-
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
22
|
-
@prefix rif: <http://www.w3.org/2007/rif#> .
|
23
|
-
@prefix rss: <http://purl.org/rss/1.0/> .
|
24
|
-
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
|
25
|
-
@prefix sig: <http://purl.org/signature#> .
|
26
|
-
@prefix sioc: <http://rdfs.org/sioc/ns#> .
|
27
|
-
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
|
28
|
-
@prefix skosxl: <http://www.w3.org/2008/05/skos-xl#> .
|
29
|
-
@prefix v: <http://rdf.data-vocabulary.org/#> .
|
30
|
-
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
|
31
|
-
@prefix void: <http://rdfs.org/ns/void#> .
|
32
|
-
@prefix wdr: <http://www.w3.org/2007/05/powder#> .
|
33
|
-
@prefix wdrs: <http://www.w3.org/2007/05/powder-s#> .
|
34
|
-
@prefix xhv: <http://www.w3.org/1999/xhtml/vocab#> .
|
35
|
-
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
|
36
|
-
@prefix xmlns: <http://www.w3.org/2000/xmlns/> .
|
37
|
-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
38
|
-
|
39
|
-
<#listing> com:payee <#listing-payee>;
|
40
|
-
com:payeeRule [ com:destinationOwnerType ps:Authority;
|
41
|
-
com:maximumRate "11.45"@en-US;
|
42
|
-
com:rateContext com:Inclusive,
|
43
|
-
com:Tax,
|
44
|
-
com:TaxExempt;
|
45
|
-
com:rateType com:Percentage;
|
46
|
-
a com:PayeeRule];
|
47
|
-
ps:asset <#asset>;
|
48
|
-
ps:assetHash "025b9b9f1eea31a9431f0c181a22df8a8257fc49"@en-US;
|
49
|
-
ps:license <http://purl.org/payswarm/licenses/blogging>;
|
50
|
-
ps:licenseHash "b94ba441c42432e82b6e3a076f4c614f83cac6ef"@en-US;
|
51
|
-
ps:validFrom "2011-04-18T00:00:00+0000"^^xsd:dateTime;
|
52
|
-
ps:validUntil "2011-04-19T00:00:00+0000"^^xsd:dateTime;
|
53
|
-
sig:signature [ dc:created "2011-04-18T00:00:00Z"^^xsd:dateTime;
|
54
|
-
dc:creator <https://payswarm.com/i/devuser/keys/4>;
|
55
|
-
sig:signatureValue "MqF1r37JSev+2uUKdr1ZOWVfNbTx8YdBZUMW4hlgeQyIiYxfbHF+eYhU+NLFrclTjj3i7qnwREIIBP0O0BFk72JIBl3JcCDKpfbA7pqiFuaGvxr9+Ba7o0pYojo0A6Mc/+0UD5rjdJc+qAH9hnMOzKpjyeMxUcR1Z6w0XXKXc8A="@en-US;
|
56
|
-
a sig:JsonldSignature];
|
57
|
-
a gr:Offering,
|
58
|
-
ps:Listing .
|
59
|
-
<> xhv:alternate <https://recipes.payswarm.com/?feed=comments-rss2>,
|
60
|
-
<https://recipes.payswarm.com/?feed=rss2>,
|
61
|
-
<https://recipes.payswarm.com/?feed=rss2&p=10185>;
|
62
|
-
xhv:bookmark <https://recipes.payswarm.com/?p=10185>;
|
63
|
-
xhv:index <https://recipes.payswarm.com>;
|
64
|
-
xhv:next <https://recipes.payswarm.com/?p=10186>;
|
65
|
-
xhv:prev <https://recipes.payswarm.com/?p=10184>;
|
66
|
-
xhv:start <https://recipes.payswarm.com/?p=1>;
|
67
|
-
xhv:stylesheet <https://recipes.payswarm.com/wp-content/plugins/payswarm/payswarm.css?ver=3.1>,
|
68
|
-
<https://recipes.payswarm.com/wp-content/themes/twentyten/style.css> .
|
69
|
-
<#asset> dc:creator [ foaf:name "chef"@en-US];
|
70
|
-
dc:title "Soft Breadsticks"@en-US;
|
71
|
-
ps:assetProvider <https://dev.payswarm.com:19100/i/devuser>;
|
72
|
-
ps:authority <https://payswarm.dev:19100/client-config>;
|
73
|
-
ps:contentUrl <>;
|
74
|
-
sig:signature [ dc:created "2011-04-18T00:00:00Z"^^xsd:dateTime;
|
75
|
-
dc:creator <https://payswarm.com/i/devuser/keys/4>;
|
76
|
-
sig:signatureValue "GYQHOxTJeyfky4NkxTm/IEcVGKYq7omDXPwdX+CYlJD9ur6RX35jM/RS3SeB7teGlJs1KtAx+l4ZUsAZa4sINYkr9fKh0k0K7TCbXp2X5sJ4ZCE3AvxZfc4IQEMuiiq+C8LHJv6g6tVmdl25UIbfroEBd/Hv+ID995VgapsSmQo="@en-US;
|
77
|
-
a sig:JsonldSignature];
|
78
|
-
a ps:Asset,
|
79
|
-
ps:WebPage .
|
80
|
-
<#listing-payee> com:currency "USD"@en-US;
|
81
|
-
com:destination <https://dev.payswarm.com:19100/i/devuser/accounts/primary>;
|
82
|
-
com:payeePosition "0"^^xsd:integer;
|
83
|
-
com:rate "0.04597"@en-US;
|
84
|
-
com:rateType com:FlatAmount;
|
85
|
-
a com:Payee;
|
86
|
-
rdfs:comment "Payment for Soft Breadsticks by chef."@en-US .
|
data/example.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rdf/rdfa'
|
5
|
-
|
6
|
-
data = <<-EOF;
|
7
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
8
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
|
9
|
-
<html xmlns="http://www.w3.org/1999/xhtml" version="XHTML+RDFa 1.0"
|
10
|
-
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
11
|
-
<head>
|
12
|
-
<title>Test 0001</title>
|
13
|
-
</head>
|
14
|
-
<body>
|
15
|
-
<p>This photo was taken by <span class="author" about="photo1.jpg" property="dc:creator">Mark Birbeck</span>.</p>
|
16
|
-
</body>
|
17
|
-
</html>
|
18
|
-
EOF
|
19
|
-
|
20
|
-
reader = RDF::RDFa::Reader.new(data, :base_uri => 'http://rdfa.digitalbazaar.com/test-suite/test-cases/xhtml1/0001.xhtml')
|
21
|
-
reader.each_statement do |statement|
|
22
|
-
statement.inspect!
|
23
|
-
end
|
data/lib/rdf/.gitignore
DELETED
data/pkg/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
/*.gem
|
data/rdf-rdfa.gemspec
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{rdf-rdfa}
|
8
|
-
s.version = "0.3.4.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Gregg Kellogg"]
|
12
|
-
s.date = %q{2011-07-12}
|
13
|
-
s.description = %q{ RDF::RDFa is an RDFa reader/writer for Ruby using the RDF.rb library suite.
|
14
|
-
}
|
15
|
-
s.email = %q{gregg@kellogg-assoc.com}
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"AUTHORS",
|
18
|
-
"CONTRIBUTORS",
|
19
|
-
"History.md",
|
20
|
-
"README.md"
|
21
|
-
]
|
22
|
-
s.files = [
|
23
|
-
".yardopts",
|
24
|
-
"AUTHORS",
|
25
|
-
"CONTRIBUTORS",
|
26
|
-
"Gemfile",
|
27
|
-
"History.md",
|
28
|
-
"README",
|
29
|
-
"README.md",
|
30
|
-
"Rakefile",
|
31
|
-
"UNLICENSE",
|
32
|
-
"VERSION",
|
33
|
-
"etc/basic.html",
|
34
|
-
"etc/foaf.html",
|
35
|
-
"etc/profile.html",
|
36
|
-
"etc/xhv.html",
|
37
|
-
"example-files/bb-test.rb",
|
38
|
-
"example-files/best-buy.html",
|
39
|
-
"example-files/data-view.xhtml",
|
40
|
-
"example-files/erdf_profile.html",
|
41
|
-
"example-files/gk-foaf.html",
|
42
|
-
"example-files/payswarm.html",
|
43
|
-
"example-files/payswarm.n3",
|
44
|
-
"example.rb",
|
45
|
-
"lib/rdf/.gitignore",
|
46
|
-
"lib/rdf/rdfa.rb",
|
47
|
-
"lib/rdf/rdfa/format.rb",
|
48
|
-
"lib/rdf/rdfa/patches/graph_properties.rb",
|
49
|
-
"lib/rdf/rdfa/patches/literal_hacks.rb",
|
50
|
-
"lib/rdf/rdfa/patches/nokogiri_hacks.rb",
|
51
|
-
"lib/rdf/rdfa/patches/string_hacks.rb",
|
52
|
-
"lib/rdf/rdfa/profile.rb",
|
53
|
-
"lib/rdf/rdfa/profile/xhtml.rb",
|
54
|
-
"lib/rdf/rdfa/profile/xml.rb",
|
55
|
-
"lib/rdf/rdfa/reader.rb",
|
56
|
-
"lib/rdf/rdfa/version.rb",
|
57
|
-
"lib/rdf/rdfa/vocab.rb",
|
58
|
-
"lib/rdf/rdfa/writer.rb",
|
59
|
-
"lib/rdf/rdfa/writer/haml_templates.rb",
|
60
|
-
"pkg/.gitignore",
|
61
|
-
"rdf-rdfa.gemspec",
|
62
|
-
"script/console",
|
63
|
-
"script/intern_vocabulary",
|
64
|
-
"script/parse",
|
65
|
-
"script/tc",
|
66
|
-
"script/yard-to-rubyforge",
|
67
|
-
"spec/.gitignore",
|
68
|
-
"spec/literal_spec.rb",
|
69
|
-
"spec/matchers.rb",
|
70
|
-
"spec/profile_spec.rb",
|
71
|
-
"spec/reader_spec.rb",
|
72
|
-
"spec/spec.opts",
|
73
|
-
"spec/spec_helper.rb",
|
74
|
-
"spec/test_helper.rb",
|
75
|
-
"spec/writer_spec.rb"
|
76
|
-
]
|
77
|
-
s.homepage = %q{http://github.com/gkellogg/rdf-rdfa}
|
78
|
-
s.require_paths = ["lib"]
|
79
|
-
s.rubygems_version = %q{1.6.2}
|
80
|
-
s.summary = %q{RDFa reader/writer for RDF.rb.}
|
81
|
-
|
82
|
-
if s.respond_to? :specification_version then
|
83
|
-
s.specification_version = 3
|
84
|
-
|
85
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
86
|
-
s.add_runtime_dependency(%q<addressable>, ["= 2.2.4"])
|
87
|
-
s.add_runtime_dependency(%q<rdf>, [">= 0"])
|
88
|
-
s.add_runtime_dependency(%q<haml>, [">= 3.0.0"])
|
89
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 1.3.3"])
|
90
|
-
s.add_runtime_dependency(%q<facets>, [">= 2.9.1"])
|
91
|
-
s.add_development_dependency(%q<open-uri-cached>, [">= 0.0.3"])
|
92
|
-
s.add_development_dependency(%q<rdf-spec>, [">= 0"])
|
93
|
-
s.add_development_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
94
|
-
s.add_development_dependency(%q<rdf-n3>, [">= 0.3.1"])
|
95
|
-
s.add_development_dependency(%q<rspec>, [">= 2.1.0"])
|
96
|
-
s.add_development_dependency(%q<sxp>, [">= 0"])
|
97
|
-
s.add_development_dependency(%q<sparql-algebra>, [">= 0"])
|
98
|
-
s.add_development_dependency(%q<sparql-grammar>, [">= 0"])
|
99
|
-
s.add_development_dependency(%q<spira>, [">= 0.0.12"])
|
100
|
-
s.add_development_dependency(%q<yard>, [">= 0.6.4"])
|
101
|
-
s.add_runtime_dependency(%q<rdf>, [">= 0.3.3"])
|
102
|
-
s.add_runtime_dependency(%q<haml>, [">= 3.0.0"])
|
103
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 1.4.4"])
|
104
|
-
s.add_runtime_dependency(%q<facets>, [">= 2.9.1"])
|
105
|
-
s.add_development_dependency(%q<spira>, [">= 0.0.12"])
|
106
|
-
s.add_development_dependency(%q<rspec>, [">= 2.5.0"])
|
107
|
-
s.add_development_dependency(%q<rdf-spec>, [">= 0.3.3"])
|
108
|
-
s.add_development_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
109
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
110
|
-
else
|
111
|
-
s.add_dependency(%q<addressable>, ["= 2.2.4"])
|
112
|
-
s.add_dependency(%q<rdf>, [">= 0"])
|
113
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
114
|
-
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
115
|
-
s.add_dependency(%q<facets>, [">= 2.9.1"])
|
116
|
-
s.add_dependency(%q<open-uri-cached>, [">= 0.0.3"])
|
117
|
-
s.add_dependency(%q<rdf-spec>, [">= 0"])
|
118
|
-
s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
119
|
-
s.add_dependency(%q<rdf-n3>, [">= 0.3.1"])
|
120
|
-
s.add_dependency(%q<rspec>, [">= 2.1.0"])
|
121
|
-
s.add_dependency(%q<sxp>, [">= 0"])
|
122
|
-
s.add_dependency(%q<sparql-algebra>, [">= 0"])
|
123
|
-
s.add_dependency(%q<sparql-grammar>, [">= 0"])
|
124
|
-
s.add_dependency(%q<spira>, [">= 0.0.12"])
|
125
|
-
s.add_dependency(%q<yard>, [">= 0.6.4"])
|
126
|
-
s.add_dependency(%q<rdf>, [">= 0.3.3"])
|
127
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
128
|
-
s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
|
129
|
-
s.add_dependency(%q<facets>, [">= 2.9.1"])
|
130
|
-
s.add_dependency(%q<spira>, [">= 0.0.12"])
|
131
|
-
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
132
|
-
s.add_dependency(%q<rdf-spec>, [">= 0.3.3"])
|
133
|
-
s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
134
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
135
|
-
end
|
136
|
-
else
|
137
|
-
s.add_dependency(%q<addressable>, ["= 2.2.4"])
|
138
|
-
s.add_dependency(%q<rdf>, [">= 0"])
|
139
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
140
|
-
s.add_dependency(%q<nokogiri>, [">= 1.3.3"])
|
141
|
-
s.add_dependency(%q<facets>, [">= 2.9.1"])
|
142
|
-
s.add_dependency(%q<open-uri-cached>, [">= 0.0.3"])
|
143
|
-
s.add_dependency(%q<rdf-spec>, [">= 0"])
|
144
|
-
s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
145
|
-
s.add_dependency(%q<rdf-n3>, [">= 0.3.1"])
|
146
|
-
s.add_dependency(%q<rspec>, [">= 2.1.0"])
|
147
|
-
s.add_dependency(%q<sxp>, [">= 0"])
|
148
|
-
s.add_dependency(%q<sparql-algebra>, [">= 0"])
|
149
|
-
s.add_dependency(%q<sparql-grammar>, [">= 0"])
|
150
|
-
s.add_dependency(%q<spira>, [">= 0.0.12"])
|
151
|
-
s.add_dependency(%q<yard>, [">= 0.6.4"])
|
152
|
-
s.add_dependency(%q<rdf>, [">= 0.3.3"])
|
153
|
-
s.add_dependency(%q<haml>, [">= 3.0.0"])
|
154
|
-
s.add_dependency(%q<nokogiri>, [">= 1.4.4"])
|
155
|
-
s.add_dependency(%q<facets>, [">= 2.9.1"])
|
156
|
-
s.add_dependency(%q<spira>, [">= 0.0.12"])
|
157
|
-
s.add_dependency(%q<rspec>, [">= 2.5.0"])
|
158
|
-
s.add_dependency(%q<rdf-spec>, [">= 0.3.3"])
|
159
|
-
s.add_dependency(%q<rdf-isomorphic>, [">= 0.3.4"])
|
160
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
RDF = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "rdf", "lib"))
|
7
|
-
libs << " -I #{RDF}" if File.directory?(RDF)
|
8
|
-
libs << " -r #{File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib", "rdf", "rdfa.rb")}"
|
9
|
-
puts "Loading rdf-rdfa gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/intern_vocabulary
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Generate a Ruby version of an RDFa vocabulary to be directly accessible from RDF::RDFa::Profile
|
4
|
-
require 'rubygems'
|
5
|
-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
|
6
|
-
require 'linkeddata'
|
7
|
-
require 'getoptlong'
|
8
|
-
require 'open-uri'
|
9
|
-
|
10
|
-
def help
|
11
|
-
puts "Usage: #{$0} [options] file-or-uri ..."
|
12
|
-
puts "Options:"
|
13
|
-
puts " --dump: Dump raw output, otherwise serialize to Ruby"
|
14
|
-
puts " --debug: Display detailed debug output"
|
15
|
-
puts " --verbose: Verbose processing"
|
16
|
-
puts " --output: Write to file"
|
17
|
-
puts " --help,-?: This message"
|
18
|
-
exit(0)
|
19
|
-
end
|
20
|
-
|
21
|
-
dump = false
|
22
|
-
output = STDOUT
|
23
|
-
|
24
|
-
opts = GetoptLong.new(
|
25
|
-
["--debug", GetoptLong::NO_ARGUMENT],
|
26
|
-
["--dump", GetoptLong::NO_ARGUMENT],
|
27
|
-
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
|
28
|
-
["--verbose", GetoptLong::NO_ARGUMENT],
|
29
|
-
["--help", "-?", GetoptLong::NO_ARGUMENT]
|
30
|
-
)
|
31
|
-
opts.each do |opt, arg|
|
32
|
-
case opt
|
33
|
-
when '--verbose' then $verbose = true
|
34
|
-
when '--debug' then ::RDF::RDFa::debug = true
|
35
|
-
when '--dump' then dump = true
|
36
|
-
when '--output' then output = File.open(arg, "w")
|
37
|
-
when '--help' then help
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
help if ARGV.empty?
|
42
|
-
|
43
|
-
ARGV.each do |file|
|
44
|
-
uri = RDF::URI(file)
|
45
|
-
if RDF::RDFa::Profile.cache[uri]
|
46
|
-
STDERR.puts "Remove cached entry for #{uri} before attempting to parse"
|
47
|
-
exit(1)
|
48
|
-
end
|
49
|
-
|
50
|
-
profile = RDF::RDFa::Profile.find(uri)
|
51
|
-
if dump
|
52
|
-
puts profile.inspect
|
53
|
-
else
|
54
|
-
profile_short = uri.to_s.split("/").last.gsub(/[^\w]/, '_')
|
55
|
-
preceeding = ' '
|
56
|
-
output.puts <<START
|
57
|
-
# This file is automatically generated by #{__FILE__}
|
58
|
-
# RDFa vocabulary for #{file}
|
59
|
-
|
60
|
-
require 'facets/module'
|
61
|
-
|
62
|
-
class RDF::RDFa::Profile
|
63
|
-
def self.find_with_#{profile_short}(uri)
|
64
|
-
if uri.to_s == "#{file}"
|
65
|
-
@_#{profile_short}_prof ||= RDF::RDFa::Profile.new(RDF::URI("#{file}"), {
|
66
|
-
START
|
67
|
-
|
68
|
-
output.puts %{#{preceeding}:vocabulary => "#{profile.vocabulary},"} if profile.vocabulary
|
69
|
-
|
70
|
-
[:prefixes, :terms].each do |t|
|
71
|
-
hash = profile.send(t)
|
72
|
-
key_width = hash.keys.inject(0) {|width, k| k.inspect.length > width ? k.inspect.length : width}
|
73
|
-
unless hash.empty?
|
74
|
-
output.puts %(#{preceeding}:#{t} => {)
|
75
|
-
hash.keys.map(&:to_s).sort.each do |k|
|
76
|
-
v = hash[k.to_sym]
|
77
|
-
output.printf(%(#{preceeding} %*s => %s,\n), -key_width, k.to_sym.inspect, v.inspect)
|
78
|
-
end
|
79
|
-
output.puts %(#{preceeding}},)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
output.puts <<END
|
84
|
-
})
|
85
|
-
else
|
86
|
-
find_without_#{profile_short}(uri)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class << self
|
91
|
-
##
|
92
|
-
# Override find to return this profile, if matched
|
93
|
-
alias_method_chain :find, :#{profile_short}
|
94
|
-
end
|
95
|
-
end
|
96
|
-
END
|
97
|
-
|
98
|
-
end
|
99
|
-
end
|
data/script/parse
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", 'lib')))
|
4
|
-
require 'rdf/rdfa'
|
5
|
-
require 'rdf/n3' rescue nil
|
6
|
-
require 'rdf/rdfxml' rescue nil
|
7
|
-
require 'getoptlong'
|
8
|
-
require 'open-uri'
|
9
|
-
|
10
|
-
def run(input, options)
|
11
|
-
reader_class = RDF::Reader.for(options[:input_format].to_sym)
|
12
|
-
raise "Reader not found for #{$input_format}" unless reader_class
|
13
|
-
|
14
|
-
start = Time.new
|
15
|
-
num = 0
|
16
|
-
|
17
|
-
if options[:output_format] == :ntriples || options[:quiet]
|
18
|
-
reader_class.new(input, :base_uri => options[:base_uri], :strict => true).each do |statement|
|
19
|
-
num += 1
|
20
|
-
if options[:quiet]
|
21
|
-
#print "."
|
22
|
-
else
|
23
|
-
options[:output].puts statement.to_ntriples
|
24
|
-
end
|
25
|
-
end
|
26
|
-
elsif options[:output_format] == :inspect
|
27
|
-
reader_class.new(input, :base_uri => options[:base_uri], :strict => true).each do |statement|
|
28
|
-
num += 1
|
29
|
-
options[:output].puts statement.inspect
|
30
|
-
end
|
31
|
-
else
|
32
|
-
r = reader_class.new(input, options)
|
33
|
-
g = RDF::Graph.new << r
|
34
|
-
num = g.count
|
35
|
-
options[:output].puts g.dump(options[:output_format], options.merge(:prefixes => r.prefixes))
|
36
|
-
end
|
37
|
-
STDERR.puts
|
38
|
-
secs = Time.new - start
|
39
|
-
STDERR.puts "Parsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second."
|
40
|
-
rescue
|
41
|
-
fname = input.respond_to?(:path) ? input.path : "-stdin-"
|
42
|
-
STDERR.puts("Error in #{fname}")
|
43
|
-
raise
|
44
|
-
end
|
45
|
-
|
46
|
-
options = {
|
47
|
-
:verbose => false,
|
48
|
-
:validate => false,
|
49
|
-
:strict => true,
|
50
|
-
:output => STDOUT,
|
51
|
-
:output_format => :ntriples,
|
52
|
-
:input_format => :rdfa,
|
53
|
-
:base_uri => "http://example.com",
|
54
|
-
}
|
55
|
-
input = nil
|
56
|
-
|
57
|
-
opts = GetoptLong.new(
|
58
|
-
["--debug", GetoptLong::NO_ARGUMENT],
|
59
|
-
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
|
60
|
-
["--format", GetoptLong::REQUIRED_ARGUMENT],
|
61
|
-
["--input-format", GetoptLong::REQUIRED_ARGUMENT],
|
62
|
-
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
|
63
|
-
["--quiet", GetoptLong::NO_ARGUMENT],
|
64
|
-
["--template", GetoptLong::REQUIRED_ARGUMENT],
|
65
|
-
["--uri", GetoptLong::REQUIRED_ARGUMENT],
|
66
|
-
["--validate", GetoptLong::NO_ARGUMENT],
|
67
|
-
["--verbose", GetoptLong::NO_ARGUMENT]
|
68
|
-
)
|
69
|
-
opts.each do |opt, arg|
|
70
|
-
case opt
|
71
|
-
when '--debug' then ::RDF::RDFa::debug = true
|
72
|
-
when '--execute' then input = arg
|
73
|
-
when '--format' then options[:output_format] = arg.to_sym
|
74
|
-
when '--input-format' then options[:input_format] = arg.to_sym
|
75
|
-
when '--quiet' then options[:quiet] = true
|
76
|
-
when '--output' then options[:output] = File.open(arg, "w")
|
77
|
-
when '--template' then options[:haml] = arg.to_sym
|
78
|
-
when '--uri' then options[:base_uri] = arg
|
79
|
-
when '--verbose' then options[:verbose] = true
|
80
|
-
when '--validate' then options[:validate] = true
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
if ARGV.empty?
|
85
|
-
s = input ? input : $stdin.read
|
86
|
-
run(StringIO.new(s), options)
|
87
|
-
else
|
88
|
-
ARGV.each do |test_file|
|
89
|
-
run(Kernel.open(test_file), options)
|
90
|
-
end
|
91
|
-
end
|