rdf_context 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,12 @@
1
+ === 0.4.5
2
+ * Order includes to remove platform dependencies on load requirements.
3
+ * Fix XML Comparison matcher
4
+ * Add --store option to bin/rdf_context. Let Parser#detect_format intuit file type.
5
+ * Add Graph#contents as alias to store
6
+ * Add ConjunctiveGraph#triples to return all triples from store, not just default context
7
+ * Add Graph#nsbinding to retreive Store#nsbinding
8
+ * Fix numerious SQLite3Store and AbstractSQLStore bugs. Add round-trip tests to Graph spec.
9
+
1
10
  === 0.4.4
2
11
  * Namespace usage cleanup
3
12
  * When serializing graph to RDF/XML, create namespaces as necessary.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
@@ -4,13 +4,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../lib/rdf_context")
4
4
  require 'getoptlong'
5
5
  class Parse
6
6
  include RdfContext
7
- def parse(file, base_uri)
7
+ def parse(file, base_uri, store = nil)
8
8
  puts "Parse: #{file}" if $quiet
9
- parser = case file
10
- when /\.(nt|n3)$/ then N3Parser.new
11
- when /\.x?html/ then RdfaParser.new
12
- else RdfXmlParser.new
13
- end
9
+ graph_opts = {:identifier => base_uri}
10
+ graph_opts[:store] = store if store
11
+ parser = Parser.new(:graph => Graph.new(graph_opts))
14
12
  parser.parse(File.read(file), base_uri, :strict => true)
15
13
  output = case $format
16
14
  when "xml"
@@ -34,12 +32,13 @@ end
34
32
 
35
33
  $verbose = false
36
34
  base_uri = "http://example.com"
37
-
35
+ store = :list_store
38
36
  opts = GetoptLong.new(
39
37
  ["--verbose", GetoptLong::NO_ARGUMENT],
40
38
  ["--quiet", GetoptLong::NO_ARGUMENT],
41
39
  ["--debug", GetoptLong::NO_ARGUMENT],
42
40
  ["--format", GetoptLong::REQUIRED_ARGUMENT],
41
+ ["--store", GetoptLong::REQUIRED_ARGUMENT],
43
42
  ["--uri", GetoptLong::REQUIRED_ARGUMENT]
44
43
  )
45
44
  opts.each do |opt, arg|
@@ -49,11 +48,21 @@ opts.each do |opt, arg|
49
48
  when '--debug' then $DEBUG = true
50
49
  when '--format' then $format = arg
51
50
  when '--uri' then base_uri = arg
51
+ when '--store'
52
+ case arg
53
+ when /list/
54
+ store = :list_store
55
+ when /memory/
56
+ store = :memory_store
57
+ else
58
+ puts "Creating SQLite3 database '#{arg}'" unless File.exists?(arg)
59
+ store = RdfContext::SQLite3Store.new(RdfContext::URIRef.new("http://kellogg-assoc.com/rdf_context"), :path => arg)
60
+ end
52
61
  end
53
62
  end
54
63
 
55
64
  x = Parse.new
56
65
  ARGV.each do |test_file|
57
- x.parse(test_file, base_uri)
66
+ x.parse(test_file, base_uri, store)
58
67
  end
59
68
 
data/cmx.db ADDED
Binary file
data/ep.nt ADDED
@@ -0,0 +1,194 @@
1
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Release> .
2
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#grid> "urn:GRid:A1-a0587-aaaaaaaaaa-b"@en-us .
3
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creationDate> "2008-05-28T16:53:42Z"@en-us .
4
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#MasterRelease> .
5
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://purl.org/dc/elements/1.1/title> "ep"@en-us .
6
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#parentalWarning> "unspecified"@en-us .
7
+ <http://localhost:3000/stylesheets/mobile.xslt> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#XSLT> .
8
+ <http://localhost:3000/stylesheets/mobile.xslt> <http://purl.org/dc/elements/1.1/title> "Mobile Stylesheet"@en-us .
9
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#xslt> <http://localhost:3000/stylesheets/mobile.xslt> .
10
+ <http://localhost:3000/stylesheets/settop.xslt> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#XSLT> .
11
+ <http://localhost:3000/stylesheets/settop.xslt> <http://purl.org/dc/elements/1.1/title> "Set-top Stylesheet"@en-us .
12
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#xslt> <http://localhost:3000/stylesheets/settop.xslt> .
13
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#XSLT> .
14
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop> <http://purl.org/dc/elements/1.1/title> "Mobile Stylesheet"@en-us .
15
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop> <http://cmx.org/spec/terms#parentalWarning> "unspecified"@en-us .
16
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop.xslt> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Encoding> .
17
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop.xslt> <http://cmx.org/spec/terms#format> "application/xslt+xml"@en-us .
18
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop.xslt> <http://purl.org/dc/elements/1.1/title> "Mobile Stylesheet"@en-us .
19
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop.xslt> <http://cmx.org/spec/terms#payloadHash> "e06f397e1340b9fa4793412d818e4ebf"@en-us .
20
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop> <http://cmx.org/spec/terms#encoding> <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop.xslt> .
21
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#xslt> <http://localhost:3000/releases/Matchbox%20Twenty-ep/stylesheets/desktop> .
22
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
23
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#displayArtist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
24
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
25
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#keyName> "Matchbox Twenty"@en-us .
26
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#issued> "2008-05-28T15:15:00Z"@en-us .
27
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://purl.org/dc/elements/1.1/title> "Matchbox Twenty"@en-us .
28
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#expires> "2008-05-28T15:15:00Z"@en-us .
29
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#member> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
30
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#member> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> .
31
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#member> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> .
32
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> <http://cmx.org/spec/terms#member> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> .
33
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
34
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
35
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> <http://cmx.org/spec/terms#keyName> "Thomas"@en-us .
36
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> <http://purl.org/dc/elements/1.1/title> "Rob Thomas"@en-us .
37
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> <http://cmx.org/spec/terms#namesBeforeKeyName> "Rob"@en-us .
38
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
39
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
40
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> <http://cmx.org/spec/terms#keyName> "Yale"@en-us .
41
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> <http://purl.org/dc/elements/1.1/title> "Brian Yale"@en-us .
42
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> <http://cmx.org/spec/terms#namesBeforeKeyName> "Brian"@en-us .
43
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Brian%20Yale> .
44
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
45
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> <http://cmx.org/spec/terms#keyName> "Cook"@en-us .
46
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> <http://purl.org/dc/elements/1.1/title> "Kyle Cook"@en-us .
47
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> <http://cmx.org/spec/terms#namesBeforeKeyName> "Kyle"@en-us .
48
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Kyle%20Cook> .
49
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
50
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> <http://cmx.org/spec/terms#keyName> "Doucette"@en-us .
51
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> <http://purl.org/dc/elements/1.1/title> "Paul Doucette"@en-us .
52
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> <http://cmx.org/spec/terms#namesBeforeKeyName> "Paul"@en-us .
53
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Paul%20Doucette> .
54
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
55
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> <http://cmx.org/spec/terms#keyName> "Jagger"@en-us .
56
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> <http://purl.org/dc/elements/1.1/title> "Mick Jagger"@en-us .
57
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> <http://cmx.org/spec/terms#namesBeforeKeyName> "Mick"@en-us .
58
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> .
59
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Serletic> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
60
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Serletic> <http://cmx.org/spec/terms#keyName> "Serletic"@en-us .
61
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Serletic> <http://purl.org/dc/elements/1.1/title> "Matt Serletic"@en-us .
62
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Serletic> <http://cmx.org/spec/terms#namesBeforeKeyName> "Matt"@en-us .
63
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Serletic> .
64
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Steve%20Lilywhite> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
65
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Steve%20Lilywhite> <http://cmx.org/spec/terms#keyName> "Lilywhite"@en-us .
66
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Steve%20Lilywhite> <http://purl.org/dc/elements/1.1/title> "Steve Lilywhite"@en-us .
67
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Steve%20Lilywhite> <http://cmx.org/spec/terms#namesBeforeKeyName> "Steve"@en-us .
68
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Steve%20Lilywhite> .
69
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Atlantic> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
70
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Atlantic> <http://cmx.org/spec/terms#keyName> "Atlantic"@en-us .
71
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Atlantic> <http://purl.org/dc/elements/1.1/title> "Atlantic"@en-us .
72
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Atlantic> .
73
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Ryan%20MacMillan> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
74
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Ryan%20MacMillan> <http://cmx.org/spec/terms#keyName> "MacMillan"@en-us .
75
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Ryan%20MacMillan> <http://purl.org/dc/elements/1.1/title> "Ryan MacMillan"@en-us .
76
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Ryan%20MacMillan> <http://cmx.org/spec/terms#namesBeforeKeyName> "Ryan"@en-us .
77
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Ryan%20MacMillan> .
78
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Beck> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Contributor> .
79
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Beck> <http://cmx.org/spec/terms#keyName> "Beck"@en-us .
80
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Beck> <http://purl.org/dc/elements/1.1/title> "Matt Beck"@en-us .
81
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Beck> <http://cmx.org/spec/terms#namesBeforeKeyName> "Matt"@en-us .
82
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#releaseContributor> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matt%20Beck> .
83
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
84
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:02Z"@en-us .
85
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#rights> "2002 Bidnis, Inc./EMI Blackwood Music, Inc. (BMI), Jagged Music (ASCAP)"@en-us .
86
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000363-1"@en-us .
87
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://purl.org/dc/elements/1.1/title> "Disease"@en-us .
88
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
89
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Mick%20Jagger> .
90
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
91
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:02Z"@en-us .
92
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://purl.org/dc/elements/1.1/title> "Disease"@en-us .
93
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
94
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://cmx.org/spec/terms#mainArtist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
95
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/Disease> .
96
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease> .
97
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
98
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:10Z"@en-us .
99
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://purl.org/dc/elements/1.1/title> "Disease (Acoustic)"@en-us .
100
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
101
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
102
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/Disease%20%28Acoustic%29> .
103
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Disease%20%28Acoustic%29> .
104
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Disease> .
105
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
106
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:03Z"@en-us .
107
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#rights> "2000 EMI Blackwood Music, Inc./Bidnis, Inc. (BMI)"@en-us .
108
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000371-1"@en-us .
109
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://purl.org/dc/elements/1.1/title> "If You're Gone"@en-us .
110
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
111
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
112
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:03Z"@en-us .
113
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://purl.org/dc/elements/1.1/title> "If You're Gone"@en-us .
114
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
115
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://cmx.org/spec/terms#mainArtist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
116
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/If%20You%27re%20Gone> .
117
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone> .
118
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
119
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:11Z"@en-us .
120
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://purl.org/dc/elements/1.1/title> "If You're Gone (Live)"@en-us .
121
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
122
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
123
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/If%20You%27re%20Gone%20%28Live%29> .
124
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/If%20You%27re%20Gone%20%28Live%29> .
125
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/If%20You%27re%20Gone> .
126
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
127
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:06Z"@en-us .
128
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#rights> "1996 EMI Blackwood Music, Inc. (BMI)"@en-us .
129
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000391-1"@en-us .
130
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://purl.org/dc/elements/1.1/title> "Push"@en-us .
131
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
132
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
133
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:06Z"@en-us .
134
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://purl.org/dc/elements/1.1/title> "Push"@en-us .
135
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
136
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://cmx.org/spec/terms#mainArtist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
137
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/Push> .
138
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push> .
139
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
140
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:11Z"@en-us .
141
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://purl.org/dc/elements/1.1/title> "Push (Live)"@en-us .
142
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
143
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
144
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/Push%20%28Live%29> .
145
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Push%20%28Live%29> .
146
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Push> .
147
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
148
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#issued> "2008-05-27T18:59:00Z"@en-us .
149
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#creationDate> "2008-05-27T18:59:00Z"@en-us .
150
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000442-1"@en-us .
151
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://purl.org/dc/elements/1.1/title> "All I Need"@en-us .
152
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#expires> "2008-05-27T18:59:00Z"@en-us .
153
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
154
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
155
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#issued> "2008-05-27T18:57:00Z"@en-us .
156
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:12:00Z"@en-us .
157
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://purl.org/dc/elements/1.1/title> "All I Need"@en-us .
158
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#expires> "2008-05-27T18:57:00Z"@en-us .
159
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
160
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
161
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/All%20I%20Need> .
162
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need> .
163
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
164
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:11Z"@en-us .
165
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://purl.org/dc/elements/1.1/title> "All I Need (Live)"@en-us .
166
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
167
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
168
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/All%20I%20Need%20%28Live%29> .
169
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/All%20I%20Need%20%28Live%29> .
170
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/All%20I%20Need> .
171
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
172
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://cmx.org/spec/terms#creationDate> "2008-05-28T16:53:42Z"@en-us .
173
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000589-1"@en-us .
174
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://purl.org/dc/elements/1.1/title> "Suffer Me"@en-us .
175
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://cmx.org/spec/terms#composerLyricist> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Rob%20Thomas> .
176
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
177
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://cmx.org/spec/terms#creationDate> "2008-05-27T00:13:09Z"@en-us .
178
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://purl.org/dc/elements/1.1/title> "Suffer Me"@en-us .
179
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://cmx.org/spec/terms#genre> "Alternative Rock"@en-us .
180
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://cmx.org/spec/terms#performer> <http://localhost:3000/releases/Matchbox%20Twenty-ep/contributors/Matchbox%20Twenty> .
181
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/audio/Suffer%20Me> .
182
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/Suffer%20Me> .
183
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/Suffer%20Me> .
184
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Creation> .
185
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> <http://cmx.org/spec/terms#creationDate> "2008-06-16T05:13:19Z"@en-us .
186
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> <http://cmx.org/spec/terms#iswc> "urn:ISWC:T-000000612-1"@en-us .
187
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> <http://purl.org/dc/elements/1.1/title> "075678370120"@en-us .
188
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/075678370120> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#Production> .
189
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/075678370120> <http://cmx.org/spec/terms#creationDate> "2008-06-16T05:13:20Z"@en-us .
190
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/075678370120> <http://purl.org/dc/elements/1.1/title> "075678370120"@en-us .
191
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/075678370120> <http://cmx.org/spec/terms#embodiment> <http://localhost:3000/releases/Matchbox%20Twenty-ep/image/075678370120> .
192
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> <http://cmx.org/spec/terms#realization> <http://localhost:3000/releases/Matchbox%20Twenty-ep/productions/075678370120> .
193
+ <http://localhost:3000/releases/Matchbox%20Twenty-ep> <http://cmx.org/spec/terms#creation> <http://localhost:3000/releases/Matchbox%20Twenty-ep/creations/075678370120> .
194
+ _:bn1262559423262d <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://cmx.org/spec/terms#photoAlbum> .
@@ -15,7 +15,7 @@ rescue LoadError
15
15
  require 'treetop'
16
16
  end
17
17
 
18
- Dir.glob(File.join(File.dirname(__FILE__), 'rdf_context/**.rb')).each { |f| require f }
18
+ Dir.glob(File.join(File.dirname(__FILE__), 'rdf_context/**.rb')).sort.each { |f| require f }
19
19
 
20
20
  # Include Storage types, but be tollerant of failure to load as dependencies might not be available
21
21
  Dir.glob(File.join(File.dirname(__FILE__), "rdf_context/store/**.rb")).each do |f|
@@ -1,7 +1,7 @@
1
1
  module RdfContext
2
2
  # The BNode class creates RDF blank nodes.
3
3
  class BNode
4
- attr_reader :identifier
4
+ attr_accessor :identifier
5
5
 
6
6
  # Create a new BNode, optionally accept a identifier for the BNode.
7
7
  # Otherwise, generated sequentially.
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), "graph.rb")
1
+ require File.join(File.dirname(__FILE__), "graph")
2
2
 
3
3
  module RdfContext
4
4
  # ConjunctiveGraph - The top level container for all named Graphs sharing a _Store_
@@ -28,6 +28,20 @@ module RdfContext
28
28
  @@default_context = Graph.new(:identifier => @store.identifier, :store => @store)
29
29
  end
30
30
 
31
+ # Contexts contained within the store
32
+ def contexts
33
+ @store.contexts
34
+ end
35
+
36
+ # Triples across all contexts in store, optionally matching subject, predicate, or object.
37
+ # Delegates to Store#triples.
38
+ #
39
+ # @param [Triple, nil] triple:: Triple to match, may be a patern triple or nil
40
+ # @return [Array]:: List of matched triples
41
+ def triples(triple = Triple.new(nil, nil, nil), &block) # :yields: triple, context
42
+ @store.triples(triple, nil, &block) || []
43
+ end
44
+
31
45
  # Parse source into a new context.
32
46
  #
33
47
  # Create a new context (Graph) and parse into that.
@@ -1,3 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'namespace')
2
+ require File.join(File.dirname(__FILE__), 'triple')
1
3
  require File.join(File.dirname(__FILE__), 'store', 'list_store')
2
4
  require File.join(File.dirname(__FILE__), 'store', 'memory_store')
3
5
 
@@ -26,7 +28,7 @@ module RdfContext
26
28
  # For more on named graphs, see: http://en.wikipedia.org/wiki/RDFLib
27
29
  #
28
30
  # @param [Hash] options:: Options
29
- # <em>options[:store]</em>:: storage, defaults to a new ListStore instance
31
+ # <em>options[:store]</em>:: storage, defaults to a new ListStore instance. May be symbol :list_store or :memory_store
30
32
  # <em>options[:identifier]</em>:: Identifier for this graph, Literal, BNode or URIRef
31
33
  def initialize(options = {})
32
34
  @nsbinding = {}
@@ -39,7 +41,7 @@ module RdfContext
39
41
  else ListStore.new
40
42
  end
41
43
 
42
- @identifier = options[:identifier] || BNode.new
44
+ @identifier = Triple.coerce_subject(options[:identifier]) || BNode.new
43
45
  end
44
46
 
45
47
  def inspect
@@ -129,7 +131,7 @@ module RdfContext
129
131
  tmp_ns = tmp_ns.succ
130
132
  end
131
133
  end
132
-
134
+
133
135
  xml.instruct!
134
136
  xml.rdf(:RDF, rdf_attrs) do
135
137
  # Add statements for each subject
@@ -137,11 +139,12 @@ module RdfContext
137
139
  xml.rdf(:Description, (s.is_a?(BNode) ? "rdf:nodeID" : "rdf:about") => s) do
138
140
  triples(Triple.new(s, nil, nil)) do |triple, context|
139
141
  xml_args = triple.object.xml_args
142
+ qname = triple.predicate.to_qname(uri_bindings)
140
143
  if triple.object.is_a?(Literal) && triple.object.xmlliteral?
141
144
  replace_text["__replace_with_#{triple.object.object_id}__"] = xml_args[0]
142
145
  xml_args[0] = "__replace_with_#{triple.object.object_id}__"
143
146
  end
144
- xml.tag!(triple.predicate.to_qname(uri_bindings), *xml_args)
147
+ xml.tag!(qname, *xml_args)
145
148
  end
146
149
  end
147
150
  end
@@ -168,6 +171,9 @@ module RdfContext
168
171
  @store.bind(namespace)
169
172
  end
170
173
 
174
+ # List of namespace bindings, as a hash
175
+ def nsbinding; @store.nsbinding; end
176
+
171
177
  # Namespace for prefix
172
178
  def namespace(prefix); @store.namespace(prefix); end
173
179
 
@@ -325,20 +331,20 @@ module RdfContext
325
331
  end
326
332
 
327
333
  alias_method :==, :eql?
328
- end
329
334
 
330
- # Parse source into Graph.
331
- #
332
- # Merges results into a common Graph
333
- #
334
- # @param [IO, String] stream:: the RDF IO stream, string, Nokogiri::HTML::Document or Nokogiri::XML::Document
335
- # @param [String] uri:: the URI of the document
336
- # @param [Hash] options:: Options from
337
- # <em>options[:debug]</em>:: Array to place debug messages
338
- # <em>options[:type]</em>:: One of _rdfxml_, _html_, or _n3_
339
- # <em>options[:strict]</em>:: Raise Error if true, continue with lax parsing, otherwise
340
- # @return [Graph]:: Returns the graph containing parsed triples
341
- def parse(stream, uri, options = {}, &block) # :yields: triple
342
- Parser.parse(stream, uri, options.merge(:graph => self), &block)
335
+ # Parse source into Graph.
336
+ #
337
+ # Merges results into a common Graph
338
+ #
339
+ # @param [IO, String] stream:: the RDF IO stream, string, Nokogiri::HTML::Document or Nokogiri::XML::Document
340
+ # @param [String] uri:: the URI of the document
341
+ # @param [Hash] options:: Options from
342
+ # <em>options[:debug]</em>:: Array to place debug messages
343
+ # <em>options[:type]</em>:: One of _rdfxml_, _html_, or _n3_
344
+ # <em>options[:strict]</em>:: Raise Error if true, continue with lax parsing, otherwise
345
+ # @return [Graph]:: Returns the graph containing parsed triples
346
+ def parse(stream, uri, options = {}, &block) # :yields: triple
347
+ Parser.parse(stream, uri, options.merge(:graph => self), &block)
348
+ end
343
349
  end
344
350
  end
@@ -1,3 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'graph')
2
+
1
3
  module RdfContext
2
4
  # Generic RdfContext Parser class
3
5
  class Parser
@@ -48,6 +50,13 @@ module RdfContext
48
50
  # @raise [Error]:: Raises RdfError if _strict_
49
51
  def parse(stream, uri = nil, options = {}, &block) # :yields: triple
50
52
  if self.class == Parser
53
+
54
+ options[:strict] ||= @strict if @strict
55
+ options[:graph] ||= @graph if @graph
56
+ options[:debug] ||= @debug if @debug
57
+ # Intuit type, if not provided
58
+ options[:type] ||= detect_format(stream, uri)
59
+
51
60
  # Create a delegate of a specific parser class
52
61
  @delegate ||= case options[:type].to_s
53
62
  when "n3", "ntriples", "turtle" then N3Parser.new(options)
@@ -68,6 +77,10 @@ module RdfContext
68
77
  end
69
78
  end
70
79
 
80
+
81
+ def graph; @delegate ? @delegate.graph : (@graph || Graph.new); end
82
+ def debug; @delegate ? @delegate.debug : @debug; end
83
+
71
84
  # Return N3 Parser instance
72
85
  def self.n3_parser(options = {}); N3Parser.new(options); end
73
86
  # Return RDF/XML Parser instance
@@ -75,6 +88,30 @@ module RdfContext
75
88
  # Return Rdfa Parser instance
76
89
  def self.rdfa_parser(options = {}); RdfaParser.new(options); end
77
90
 
91
+ # Heuristically detect the format of the uri
92
+ def detect_format(stream, uri = nil)
93
+ format = case uri.to_s
94
+ when /\.(rdf|xml)$/ then :rdfxml
95
+ when /\.(html|xhtml)$/ then :rdfa
96
+ when /\.(nt|n3|txt)$/ then :n3
97
+ else
98
+ # Got to look into the file to see
99
+ if stream.is_a?(IO)
100
+ stream.rewind
101
+ string = stream.read(1000)
102
+ stream.rewind
103
+ else
104
+ string = stream.to_s
105
+ end
106
+ case string
107
+ when /<\w+:RDF/ then :rdfxml
108
+ when /<RDF/ then :rdfxml
109
+ when /<html/i then :rdfa
110
+ else :n3
111
+ end
112
+ end
113
+ end
114
+
78
115
  protected
79
116
  # Figure out the document path, if it is a Nokogiri::XML::Element or Attribute
80
117
  def node_path(node)
@@ -113,6 +150,7 @@ module RdfContext
113
150
  triple
114
151
  rescue RdfException => e
115
152
  add_debug(node, "add_triple raised #{e.class}: #{e.message}")
153
+ puts e.backtrace if $DEBUG
116
154
  raise if @strict
117
155
  end
118
156
  end
@@ -65,7 +65,7 @@ module RdfContext
65
65
  @doc = case stream
66
66
  when Nokogiri::HTML::Document then stream
67
67
  when Nokogiri::XML::Document then stream
68
- else Nokogiri::XML.parse(stream, uri)
68
+ else Nokogiri::XML.parse(stream, uri.to_s)
69
69
  end
70
70
 
71
71
  raise ParserException, "Empty document" if @doc.nil? && @strict
@@ -113,12 +113,12 @@ module RdfContext
113
113
 
114
114
  @doc = case stream
115
115
  when Nokogiri::XML::Document then stream
116
- else Nokogiri::XML.parse(stream, uri)
116
+ else Nokogiri::XML.parse(stream, uri.to_s)
117
117
  end
118
118
 
119
119
  @id_mapping = Hash.new
120
120
 
121
- raise ParserException, "Empty document" if @doc.nil? && @strict
121
+ raise ParserException, "Empty document" if @doc.nil? || @doc.root.nil?
122
122
  @callback = block
123
123
 
124
124
  root = @doc.root
@@ -458,7 +458,6 @@ module RdfContext
458
458
  QUOTED_PARTITION
459
459
  ]
460
460
  ]
461
- q=unionSELECT(selects, :distinct => true, :select_type => CONTEXT_SELECT)
462
461
  else
463
462
  selects = [
464
463
  [
@@ -488,18 +487,19 @@ module RdfContext
488
487
  ]
489
488
  end
490
489
 
491
- results = []
492
490
  q=unionSELECT(selects, :distinct => true, :select_type => CONTEXT_SELECT)
493
- executeSQL(_normalizeSQLCmd(q), parameters) do |row|
491
+ executeSQL(_normalizeSQLCmd(q), parameters).map do |row|
494
492
  id, termComb = row
495
493
 
496
494
  termCombString = REVERSE_TERM_COMBINATIONS[termComb.to_i]
497
495
  subjTerm, predTerm, objTerm, ctxTerm = termCombString.chars.to_a
498
496
 
499
497
  graphKlass, idKlass = constructGraph(ctxTerm)
500
- results << graphKlass.new(:store => self, :identifier => idKlass.new(id))
498
+ [graphKlass, idKlass.new(id)]
499
+ end.uniq.map do |gi|
500
+ graphKlass, id = gi
501
+ graphKlass.new(:store => self, :identifier => id)
501
502
  end
502
- results
503
503
  end
504
504
 
505
505
  # Namespace persistence interface implementation
@@ -508,34 +508,54 @@ module RdfContext
508
508
  def bind(namespace)
509
509
  executeSQL("INSERT INTO #{namespace_binds} VALUES (?, ?)", namespace.prefix, namespace.uri)
510
510
  # May throw exception, should be handled in driver-specific class
511
-
511
+
512
+ @namespaceCache ||= {}
513
+ @namespaceUriCache ||= {}
514
+ @nsbinding = nil
515
+ @namespaceCache[namespace.prefix] = namespace
516
+ @namespaceUriCache[namespace.uri.to_s] = namespace.prefix
512
517
  namespace
513
518
  end
514
519
 
515
520
  # Namespace for prefix
516
521
  def namespace(prefix)
517
- executeSQL("SELECT uri FROM #{namespace_binds} WHERE prefix=?", prefix) do |row|
518
- return Namespace.new(row[0], prefix)
522
+ @namespaceCache ||= {}
523
+ @namespaceUriCache ||= {}
524
+ unless @namespaceCache.has_key?(prefix)
525
+ @namespaceCache[prefix] = nil
526
+ executeSQL("SELECT uri FROM #{namespace_binds} WHERE prefix=?", prefix) do |row|
527
+ @namespaceCache[prefix] = Namespace.new(row[0], prefix)
528
+ @namespaceUriCache[row[0].to_s] = prefix
529
+ end
519
530
  end
520
- nil
531
+ @namespaceCache[prefix]
521
532
  end
522
533
 
523
534
  # Prefix for namespace
524
535
  def prefix(namespace)
525
536
  uri = namespace.is_a?(Namespace) ? namespace.uri.to_s : namespace
526
- executeSQL("SELECT prefix FROM #{namespace_binds} WHERE uri=?", uri) do |row|
527
- return row[0]
537
+
538
+ @namespaceCache ||= {}
539
+ @namespaceUriCache ||= {}
540
+ unless @namespaceUriCache.has_key?(uri.to_s)
541
+ @namespaceUriCache[uri.to_s] = nil
542
+ executeSQL("SELECT prefix FROM #{namespace_binds} WHERE uri=?", uri) do |row|
543
+ @namespaceUriCache[uri.to_s] = row[0]
544
+ end
528
545
  end
529
- nil
546
+ @namespaceUriCache[uri.to_s]
530
547
  end
531
548
 
532
549
  # List of namespace bindings, as a hash
533
550
  def nsbinding
534
- namespaces = {}
535
- executeSQL("SELECT prefix, uri FROM #{namespace_binds}") do |row|
536
- namespaces[row[0]] = Namespace.new(row[1], row[0])
551
+ unless @nsbinding.is_a?(Hash)
552
+ @nsbinding = {}
553
+ executeSQL("SELECT prefix, uri FROM #{namespace_binds}") do |row|
554
+ @nsbinding[row[0]] = Namespace.new(row[1], row[0])
555
+ end
556
+ @nsbinding
537
557
  end
538
- namespaces
558
+ @nsbinding
539
559
  end
540
560
 
541
561
  # Transactional interfaces
@@ -572,11 +592,6 @@ module RdfContext
572
592
  @db.execute(qStr, *params, &block)
573
593
  end
574
594
 
575
- # Escape backslashes and single quotes
576
- def escapeQuotes(qstr)
577
- qstr.nil? ? "" : qstr.gsub("\\","\\\\").gsub("'", "\\'")
578
- end
579
-
580
595
  # Normalize a SQL command before executing it. Commence unicode black magic
581
596
  def _normalizeSQLCmd(cmd)
582
597
  cmd # XXX
@@ -587,7 +602,7 @@ module RdfContext
587
602
  def normalizeTerm(term)
588
603
  case term
589
604
  when Graph then normalizeTerm(term.identifier)
590
- when Literal then escapeQuotes(term.to_n3)
605
+ when Literal then term.to_s.rdf_escape
591
606
  when URIRef then term.to_s.rdf_escape
592
607
  when BNode then term.to_s
593
608
  else term
@@ -737,7 +752,7 @@ module RdfContext
737
752
  end
738
753
 
739
754
  def buildLitLanguageClause(obj,tableName)
740
- ["#{tableName}.objDatatype='#{obj.lang}'"] if obj.is_a?(Literal) && obj.lang
755
+ ["#{tableName}.objLanguage='#{obj.lang}'"] if obj.is_a?(Literal) && obj.lang
741
756
  end
742
757
 
743
758
  # Stubs for Clause Functions that are overridden by specific implementations (MySQL vs SQLite for instance)
@@ -837,7 +852,11 @@ module RdfContext
837
852
  # when "F"
838
853
  # @otherCache[[termType, termString]] ||= QuotedGraph(:identifier => URIRef(termString), :store => self)
839
854
  when "B"
840
- @bnodeCache[termString] ||= BNode.new(termString)
855
+ @bnodeCache[termString] ||= begin
856
+ bn = BNode.new
857
+ bn.identifier = termString
858
+ bn
859
+ end
841
860
  when "U"
842
861
  @uriCache[termString] || URIRef.new(termString)
843
862
  # when "V"
@@ -90,11 +90,6 @@ module RdfContext
90
90
 
91
91
  protected
92
92
 
93
- # Escape backslashes and single quotes
94
- def escapeQuotes(qstr)
95
- qstr.nil? ? "" : qstr.gsub("\\","\\\\").gsub("'", "\\'").gsub('"', '""')
96
- end
97
-
98
93
  # Where clase utility functions
99
94
  def buildSubjClause(subject, tableName)
100
95
  # case subject
@@ -167,15 +162,18 @@ module RdfContext
167
162
  #@statement_cache[qStr] ||= @db.prepare(qStr)
168
163
  @statement_cache[qStr] ||= qStr
169
164
 
170
- puts "executeSQL: '#{qStr}', #{params.join(", ")}" if $DEBUG
165
+ puts "executeSQL: '#{qStr}', '#{params.join("', '")}'" if $DEBUG
171
166
  if block_given?
172
167
  @db.execute(@statement_cache[qStr], *params) do |row|
173
168
  puts "executeSQL res: #{row.inspect}" if $DEBUG
174
169
  yield(row)
175
170
  end
176
171
  else
172
+ puts "executeSQL no block given" if $DEBUG
177
173
  @db.execute(@statement_cache[qStr], *params)
178
174
  end
175
+ rescue SQLite3::SQLException => e
176
+ puts "SQL Exception (ignored): #{e.message}" if $DEBUG
179
177
  end
180
178
 
181
179
  CREATE_ASSERTED_STATEMENTS_TABLE = %(
@@ -1,3 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), 'bnode')
2
+ require File.join(File.dirname(__FILE__), 'literal')
1
3
  require File.join(File.dirname(__FILE__), 'uriref')
2
4
 
3
5
  module RdfContext
@@ -1,3 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), 'bnode')
2
+ require File.join(File.dirname(__FILE__), 'literal')
3
+ require File.join(File.dirname(__FILE__), 'uriref')
4
+
1
5
  module RdfContext
2
6
  # An RDF Triple, or statement.
3
7
  #
@@ -88,8 +92,8 @@ module RdfContext
88
92
  subject
89
93
  when nil
90
94
  subject
91
- when /^\w+:\/\/\S+/ # does it smell like a URI?
92
- URIRef.new subject
95
+ when /^\w+:\/\/\S+/, /^file:\S+/ # does it smell like a URI?
96
+ URIRef.new(subject)
93
97
  else
94
98
  raise InvalidSubject, "Subject is not of a known class (#{subject.class}: #{subject.inspect})"
95
99
  end
@@ -292,13 +292,11 @@ HERE
292
292
  end
293
293
 
294
294
  it "should output RDF/XML" do
295
- rdfxml = <<HERE
295
+ rdfxml = <<-HERE
296
296
  <?xml version="1.0" encoding="UTF-8"?>
297
297
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#">
298
298
  <rdf:Description rdf:about="http://example.org/john">
299
299
  <foaf:knows rdf:resource="http://example.org/jane"/>
300
- </rdf:Description>
301
- <rdf:Description rdf:about="http://example.org/john">
302
300
  <foaf:knows rdf:resource="http://example.org/rick"/>
303
301
  </rdf:Description>
304
302
  <rdf:Description rdf:about="http://example.org/jane">
@@ -126,20 +126,21 @@ module Matchers
126
126
  def matches?(actual)
127
127
  @actual = actual
128
128
 
129
- a = "<foo>#{@actual}</foo>" unless @actual.index("<") == 0
130
- e = "<foo>#{@expected}</foo>" unless @actual.index("<") == 0
129
+ a = @actual.index("<") == 0 ? @actual : "<foo>#{@actual}</foo>"
130
+ e = @expected.index("<") == 0 ? @expected : "<foo>#{@expected}</foo>"
131
131
  a_hash = ActiveSupport::XmlMini.parse(a)
132
132
  e_hash = ActiveSupport::XmlMini.parse(e)
133
133
  a_hash == e_hash
134
134
  rescue
135
+ puts $!
135
136
  @fault = $!.message
136
137
  false
137
138
  end
138
139
 
139
140
  def failure_message_for_should
140
141
  "#{@info + "\n" unless @info.empty?}" +
141
- "#{@fault + "\n" unless @fault.nil?}" +
142
- "Expected:\n#{@expected}\n" +
142
+ "Fault: #{@fault + "\n" if @fault}" +
143
+ "Expected:#{@expected}\n" +
143
144
  "Actual:#{@actual}"
144
145
  end
145
146
  end
@@ -25,5 +25,29 @@ describe "RDF Parser" do
25
25
  graph[0].object.to_s.should == "Gregg Kellogg"
26
26
  end
27
27
 
28
+ describe "File detection" do
29
+ subject { Parser.new }
30
+ {
31
+ "File with .rdf extension" => [nil, "foo.rdf", :rdfxml],
32
+ "File with .xml extension" => [nil, "foo.xml", :rdfxml],
33
+ "File with .html extension" => [nil, "foo.html", :rdfa],
34
+ "File with .xhtml extension" => [nil, "foo.xhtml", :rdfa],
35
+ "File with .nt extension" => [nil, "foo.nt", :n3],
36
+ "File with .n3 extension" => [nil, "foo.n3", :n3],
37
+ "File with .txt extension" => [nil, "foo.txt", :n3],
38
+ "File with rdf:RDF content" => ["<rdf:RDF", "foo", :rdfxml],
39
+ "File with foo:RDF content" => ["<foo:RDF", "foo", :rdfxml],
40
+ "File with RDF content" => ["<RDF", "foo", :rdfxml],
41
+ "File with HTML content" => ["<HTML", "foo", :rdfa],
42
+ "File with html content" => ["<html", "foo", :rdfa],
43
+ "File with hTmL content" => ["<hTmL", "foo", :rdfa],
44
+ "File with nt content" => ["<http::/foo> _:bar \"1\" .", "foo", :n3],
45
+ }.each_pair do |what, args|
46
+ it "should detect format of #{what}" do
47
+ type = args.pop
48
+ subject.detect_format(*args).should == type
49
+ end
50
+ end
51
+ end
28
52
  end
29
53
 
@@ -36,7 +36,7 @@ module RdfaHelper
36
36
  next if statement.subject.is_a?(BNode)
37
37
  #next unless statement.subject.uri.to_s.match(/0001/)
38
38
  unless self.about
39
- self.about = URI.parse(statement.subject.uri.to_s)
39
+ self.about = Addressable::URI.parse(statement.subject.uri.to_s)
40
40
  self.name = statement.subject.short_name
41
41
  end
42
42
 
@@ -162,6 +162,34 @@ shared_examples_for "Store" do
162
162
  end
163
163
  end
164
164
 
165
+ describe "triple round-trip" do
166
+ {
167
+ "UUU" => Triple.new(RDF_NS.a, RDF_NS.b, RDF_NS.c),
168
+ "UUB" => Triple.new(RDF_NS.a, RDF_NS.b, BNode.new),
169
+ "UUBn" => Triple.new(RDF_NS.a, RDF_NS.b, BNode.new("foo")),
170
+ "BUU" => Triple.new(BNode.new, RDF_NS.b, RDF_NS.c),
171
+ "BUB" => Triple.new(BNode.new, RDF_NS.b, BNode.new),
172
+ "untyped" => Triple.new(RDF_NS.a, RDF_NS.b, "Gregg"),
173
+ "int" => Triple.new(RDF_NS.a, RDF_NS.b, 1),
174
+ "float" => Triple.new(RDF_NS.a, RDF_NS.b, 1.1),
175
+ "xml" => Triple.new(RDF_NS.a, RDF_NS.b,
176
+ Literal.typed("foo <sup <sup xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">bar</sup> baz!", "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral")),
177
+ "Dürst" => Triple.new(RDF_NS.a, RDF_NS.b, Literal.untyped("Dürst")),
178
+ "lang" => Triple.new(RDF_NS.a, RDF_NS.b, Literal.untyped("Gregg", "de-ch")),
179
+ "backslash:\\" => Triple.new(RDF_NS.a, RDF_NS.b, "backslash:\\"),
180
+ "dquote:\"" => Triple.new(RDF_NS.a, RDF_NS.b, "dquote:\""),
181
+ "newline:\n" => Triple.new(RDF_NS.a, RDF_NS.b, "newline:\n"),
182
+ "return:\r" => Triple.new(RDF_NS.a, RDF_NS.b, "return:\r"),
183
+ "tab:\t" => Triple.new(RDF_NS.a, RDF_NS.b, "tab:\t"),
184
+ }.each_pair do |desc, triple|
185
+ it "should retrieve #{desc}" do
186
+ subject.add(triple, nil)
187
+ subject.triples(triple, nil).should include(triple)
188
+ #subject.triples(Triple.new(nil, nil, nil), nil).should include(triple)
189
+ end
190
+ end
191
+ end
192
+
165
193
  it "should remove a triple" do
166
194
  subject.add(Triple.new(@ex.john, RDF_TYPE, @foaf.Person), nil)
167
195
  subject.size.should == 1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf_context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-03 00:00:00 -08:00
12
+ date: 2010-01-08 00:00:00 -08:00
13
13
  default_executable: rdf_context
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -101,6 +101,8 @@ files:
101
101
  - Rakefile
102
102
  - VERSION
103
103
  - bin/rdf_context
104
+ - cmx.db
105
+ - ep.nt
104
106
  - lib/rdf_context.rb
105
107
  - lib/rdf_context/bnode.rb
106
108
  - lib/rdf_context/conjunctive_graph.rb