sparql 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -19,10 +19,10 @@ This is a [Ruby][] implementation of [SPARQL][] for [RDF.rb][].
19
19
 
20
20
  ## Description
21
21
 
22
- The {SPARQL} gem implements [SPARQL 1.0 Query] and provides [Rack][] and [Sinatra][]
22
+ The {SPARQL} gem implements [SPARQL 1.0][] and provides [Rack][] and [Sinatra][]
23
23
  middleware to provide results using [HTTP Content Negotiation][conneg].
24
24
 
25
- * {SPARQL::Grammar} implements a [SPARQL 1.0 Query] parser generating [SPARQL S-Expressions (SSE)][SSE].
25
+ * {SPARQL::Grammar} implements a [SPARQL 1.0][] parser generating [SPARQL S-Expressions (SSE)][SSE].
26
26
  * {SPARQL::Algebra} executes SSE against Any `RDF::Graph` or `RDF::Repository`, including
27
27
  compliant [RDF.rb][] repository adaptors such as [RDF::DO][] and [RDF::Mongo][].
28
28
  * {Rack::SPARQL} and {Sinatra::SPARQL} provide middleware components to format results
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -9,7 +9,7 @@ module Rack; module SPARQL
9
9
  # format to serialize any result with a body being `RDF::Enumerable`.
10
10
  #
11
11
  # Override content negotiation by setting the :format option to
12
- # {#initialize}.
12
+ # {Rack::SPARQL#initialize}.
13
13
  #
14
14
  # This endpoint also serves the fuction of Rack::LinkedData, as it will serialize
15
15
  # SPARQL results, which may be RDF Graphs
@@ -4,7 +4,7 @@ require 'json'
4
4
  # Extensions for Ruby's `Object` class.
5
5
  class Object
6
6
  ##
7
- # Returns the SXP binary representation of this object, defaults to `self'.
7
+ # Returns the SXP binary representation of this object, defaults to `self`.
8
8
  #
9
9
  # @return [String]
10
10
  def to_sxp_bin
@@ -28,7 +28,7 @@ end
28
28
  # Extensions for Ruby's `Object` class.
29
29
  class Array
30
30
  ##
31
- # Returns the SXP representation of this object, defaults to `self'.
31
+ # Returns the SXP representation of this object, defaults to `self`.
32
32
  #
33
33
  # @return [String]
34
34
  def to_sxp_bin
@@ -10,13 +10,14 @@ module SPARQL; module Algebra
10
10
  # The SPARQL GraphPattern `dataset` operator.
11
11
  #
12
12
  # Instintiated with two operands, the first being an array of data source URIs,
13
- # either bare, indicating a default dataset, or expressed as an array [:named, <uri>],
13
+ # either bare, indicating a default dataset, or expressed as an array `\[:named, \<uri\>\]`,
14
14
  # indicating that it represents a named data source.
15
15
  #
16
16
  # @example
17
- # (prefix ((: <http://example/>))
18
- # (dataset (<data-g1.ttl> (named <data-g2.ttl>))
19
- # (bgp (triple ?s ?p ?o))))
17
+ #
18
+ # (prefix ((: <http://example/>))
19
+ # (dataset (<data-g1.ttl> (named <data-g2.ttl>))
20
+ # (bgp (triple ?s ?p ?o))))
20
21
  #
21
22
  # @see http://www.w3.org/TR/rdf-sparql-query/#specifyingDataset
22
23
  class Dataset < Binary
@@ -30,22 +30,27 @@ module SPARQL
30
30
  # sxp = sse.to_sxp
31
31
  #
32
32
  # The following examples illustrate SPARQL transformations:
33
- #
33
+ #
34
34
  # SPARQL:
35
+ #
35
36
  # SELECT * WHERE { ?a ?b ?c }
36
37
  #
37
38
  # SSE:
39
+ #
38
40
  # RDF::Query.new {
39
41
  # pattern [RDF::Query::Variable.new("a"), RDF::Query::Variable.new("b"), RDF::Query::Variable.new("c")]
40
42
  # }
41
43
  #
42
44
  # SXP:
45
+ #
43
46
  # (bgp (triple ?a ?b ?c))
44
47
  #
45
48
  # SPARQL:
49
+ #
46
50
  # SELECT * FROM <a> WHERE { ?a ?b ?c }
47
51
  #
48
52
  # SSE:
53
+ #
49
54
  # SPARQL::Algebra::Operator::Dataset.new(
50
55
  # [RDF::URI("a")],
51
56
  # RDF::Query.new {
@@ -54,12 +59,15 @@ module SPARQL
54
59
  # )
55
60
  #
56
61
  # SXP:
62
+ #
57
63
  # (dataset (<a>) (bgp (triple ?a ?b ?c)))
58
64
  #
59
65
  # SPARQL:
66
+ #
60
67
  # SELECT * FROM NAMED <a> WHERE { ?a ?b ?c }
61
68
  #
62
69
  # SSE:
70
+ #
63
71
  # SPARQL::Algebra::Operator::Dataset.new(
64
72
  # [[:named, RDF::URI("a")]],
65
73
  # RDF::Query.new {
@@ -68,12 +76,15 @@ module SPARQL
68
76
  # )
69
77
  #
70
78
  # SXP:
79
+ #
71
80
  # (dataset ((named <a>)) (bgp (triple ?a ?b ?c)))
72
81
  #
73
82
  # SPARQL:
83
+ #
74
84
  # SELECT DISTINCT * WHERE {?a ?b ?c}
75
85
  #
76
86
  # SSE:
87
+ #
77
88
  # SPARQL::Algebra::Operator::Distinct.new(
78
89
  # RDF::Query.new {
79
90
  # pattern [RDF::Query::Variable.new("a"), RDF::Query::Variable.new("b"), RDF::Query::Variable.new("c")]
@@ -81,12 +92,15 @@ module SPARQL
81
92
  # )
82
93
  #
83
94
  # SXP:
95
+ #
84
96
  # (distinct (bgp (triple ?a ?b ?c)))
85
97
  #
86
98
  # SPARQL:
99
+ #
87
100
  # SELECT ?a ?b WHERE {?a ?b ?c}
88
101
  #
89
102
  # SSE:
103
+ #
90
104
  # SPARQL::Algebra::Operator::Project.new(
91
105
  # [RDF::Query::Variable.new("a"), RDF::Query::Variable.new("b")],
92
106
  # RDF::Query.new {
@@ -95,12 +109,15 @@ module SPARQL
95
109
  # )
96
110
  #
97
111
  # SXP:
112
+ #
98
113
  # (project (?a ?b) (bgp (triple ?a ?b ?c)))
99
114
  #
100
115
  # SPARQL:
116
+ #
101
117
  # CONSTRUCT {?a ?b ?c} WHERE {?a ?b ?c FILTER (?a)}
102
118
  #
103
119
  # SSE:
120
+ #
104
121
  # SPARQL::Algebra::Operator::Construct.new(
105
122
  # [RDF::Query::Pattern.new(RDF::Query::Variable.new("a"), RDF::Query::Variable.new("b"), RDF::Query::Variable.new("c"))],
106
123
  # SPARQL::Algebra::Operator::Filter.new(
@@ -112,12 +129,15 @@ module SPARQL
112
129
  # )
113
130
  #
114
131
  # SXP:
132
+ #
115
133
  # (construct ((triple ?a ?b ?c)) (filter ?a (bgp (triple ?a ?b ?c))))
116
134
  #
117
135
  # SPARQL:
136
+ #
118
137
  # SELECT * WHERE {<a> <b> <c> OPTIONAL {<d> <e> <f>}}
119
138
  #
120
139
  # SSE:
140
+ #
121
141
  # SPARQL::Algebra::Operator::LeftJoin.new(
122
142
  # RDF::Query.new {
123
143
  # pattern [RDF::URI("a"), RDF::URI("b"), RDF::URI("c")]
@@ -128,12 +148,15 @@ module SPARQL
128
148
  # )
129
149
  #
130
150
  # SXP:
151
+ #
131
152
  # (leftjoin (bgp (triple <a> <b> <c>)) (bgp (triple <d> <e> <f>)))
132
153
  #
133
154
  # SPARQL:
155
+ #
134
156
  # SELECT * WHERE {<a> <b> <c> {<d> <e> <f>}}
135
157
  #
136
158
  # SSE:
159
+ #
137
160
  # SPARQL::Algebra::Operator::Join.new(
138
161
  # RDF::Query.new {
139
162
  # pattern [RDF::URI("a"), RDF::URI("b"), RDF::URI("c")]
@@ -144,9 +167,11 @@ module SPARQL
144
167
  # )
145
168
  #
146
169
  # SXP:
170
+ #
147
171
  # (join (bgp (triple <a> <b> <c>)) (bgp (triple <d> <e> <f>)))
148
172
  #
149
173
  # SPARQL:
174
+ #
150
175
  # PREFIX : <http://example/>
151
176
  #
152
177
  # SELECT *
@@ -157,6 +182,7 @@ module SPARQL
157
182
  # }
158
183
  #
159
184
  # SSE:
185
+ #
160
186
  # SPARQL::Algebra::Operator::Prefix.new(
161
187
  # [[:":", RDF::URI("http://example/")]],
162
188
  # SPARQL::Algebra::Operator::Union.new(
@@ -170,6 +196,7 @@ module SPARQL
170
196
  # )
171
197
  #
172
198
  # SXP:
199
+ #
173
200
  # (prefix ((: <http://example/>))
174
201
  # (union
175
202
  # (bgp (triple ?s ?p ?o))
@@ -5,8 +5,8 @@ module SPARQL; module Grammar
5
5
  ##
6
6
  # A lexical analyzer for the SPARQL 1.0 grammar.
7
7
  #
8
- # Note that productions [80]-[85] have been incorporated directly into
9
- # [77], [78], [79].
8
+ # Note that productions \[80\]-\[85\] have been incorporated directly into
9
+ # \[77\], \[78\], \[79\].
10
10
  #
11
11
  # @example Tokenizing a SPARQL query string
12
12
  # query = "SELECT * WHERE { ?s ?p ?o }"
@@ -105,38 +105,38 @@ module SPARQL; module Grammar
105
105
  OPERATOR = /a|\|\||&&|!=|<=|>=|[!=<>+\-*\/]/
106
106
  COMMENT = /#.*/
107
107
 
108
- PN_CHARS_BASE = /[A-Z]|[a-z]|#{U_CHARS1}/ # [95]
109
- PN_CHARS_U = /_|#{PN_CHARS_BASE}/ # [96]
108
+ PN_CHARS_BASE = /[A-Z]|[a-z]|#{U_CHARS1}/ # \[95\]
109
+ PN_CHARS_U = /_|#{PN_CHARS_BASE}/ # \[96\]
110
110
  VARNAME = /(?:[0-9]|#{PN_CHARS_U})
111
- (?:[0-9]|#{PN_CHARS_U}|#{U_CHARS2})*/x # [97]
112
- PN_CHARS = /-|[0-9]|#{PN_CHARS_U}|#{U_CHARS2}/ # [98]
111
+ (?:[0-9]|#{PN_CHARS_U}|#{U_CHARS2})*/x # \[97\]
112
+ PN_CHARS = /-|[0-9]|#{PN_CHARS_U}|#{U_CHARS2}/ # \[98\]
113
113
  PN_CHARS_BODY = /(?:(?:\.|#{PN_CHARS})*#{PN_CHARS})?/
114
- PN_PREFIX = /#{PN_CHARS_BASE}#{PN_CHARS_BODY}/ # [99]
115
- PN_LOCAL = /(?:[0-9]|#{PN_CHARS_U})#{PN_CHARS_BODY}/ # [100]
116
-
117
- IRI_REF = /<([^<>"{}|^`\\\x00-\x20]*)>/ # [70]
118
- PNAME_NS = /(#{PN_PREFIX}?):/ # [71]
119
- PNAME_LN = /#{PNAME_NS}(#{PN_LOCAL})/ # [72]
120
- BLANK_NODE_LABEL = /_:(#{PN_LOCAL})/ # [73]
121
- VAR1 = /\?(#{VARNAME})/ # [74]
122
- VAR2 = /\$(#{VARNAME})/ # [75]
123
- LANGTAG = /@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)/ # [76]
124
- INTEGER = /[0-9]+/ # [77]
125
- DECIMAL = /(?:[0-9]+\.[0-9]*|\.[0-9]+)/ # [78]
126
- EXPONENT = /[eE][+-]?[0-9]+/ # [86]
127
- DOUBLE = /(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)#{EXPONENT}/ # [79]
128
- ECHAR = /\\[tbnrf\\"']/ # [91]
129
- STRING_LITERAL1 = /'((?:[^\x27\x5C\x0A\x0D]|#{ECHAR})*)'/ # [87]
130
- STRING_LITERAL2 = /"((?:[^\x22\x5C\x0A\x0D]|#{ECHAR})*)"/ # [88]
131
- STRING_LITERAL_LONG1 = /'''((?:(?:'|'')?(?:[^'\\]|#{ECHAR})+)*)'''/m # [89]
132
- STRING_LITERAL_LONG2 = /"""((?:(?:"|"")?(?:[^"\\]|#{ECHAR})+)*)"""/m # [90]
133
- WS = /\x20|\x09|\x0D|\x0A/ # [93]
134
- NIL = /\(#{WS}*\)/ # [92]
135
- ANON = /\[#{WS}*\]/ # [94]
136
-
137
- BooleanLiteral = /true|false/ # [65]
114
+ PN_PREFIX = /#{PN_CHARS_BASE}#{PN_CHARS_BODY}/ # \[99\]
115
+ PN_LOCAL = /(?:[0-9]|#{PN_CHARS_U})#{PN_CHARS_BODY}/ # \[100\]
116
+
117
+ IRI_REF = /<([^<>"{}|^`\\\x00-\x20]*)>/ # \[70\]
118
+ PNAME_NS = /(#{PN_PREFIX}?):/ # \[71\]
119
+ PNAME_LN = /#{PNAME_NS}(#{PN_LOCAL})/ # \[72\]
120
+ BLANK_NODE_LABEL = /_:(#{PN_LOCAL})/ # \[73\]
121
+ VAR1 = /\?(#{VARNAME})/ # \[74\]
122
+ VAR2 = /\$(#{VARNAME})/ # \[75\]
123
+ LANGTAG = /@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)/ # \[76\]
124
+ INTEGER = /[0-9]+/ # \[77\]
125
+ DECIMAL = /(?:[0-9]+\.[0-9]*|\.[0-9]+)/ # \[78\]
126
+ EXPONENT = /[eE][+-]?[0-9]+/ # \[86\]
127
+ DOUBLE = /(?:[0-9]+\.[0-9]*|\.[0-9]+|[0-9]+)#{EXPONENT}/ # \[79\]
128
+ ECHAR = /\\[tbnrf\\"']/ # \[91\]
129
+ STRING_LITERAL1 = /'((?:[^\x27\x5C\x0A\x0D]|#{ECHAR})*)'/ # \[87\]
130
+ STRING_LITERAL2 = /"((?:[^\x22\x5C\x0A\x0D]|#{ECHAR})*)"/ # \[88\]
131
+ STRING_LITERAL_LONG1 = /'''((?:(?:'|'')?(?:[^'\\]|#{ECHAR})+)*)'''/m # \[89\]
132
+ STRING_LITERAL_LONG2 = /"""((?:(?:"|"")?(?:[^"\\]|#{ECHAR})+)*)"""/m # \[90\]
133
+ WS = /\x20|\x09|\x0D|\x0A/ # \[93\]
134
+ NIL = /\(#{WS}*\)/ # \[92\]
135
+ ANON = /\[#{WS}*\]/ # \[94\]
136
+
137
+ BooleanLiteral = /true|false/ # \[65\]
138
138
  String = /#{STRING_LITERAL_LONG1}|#{STRING_LITERAL_LONG2}|
139
- #{STRING_LITERAL1}|#{STRING_LITERAL2}/x # [66]
139
+ #{STRING_LITERAL1}|#{STRING_LITERAL2}/x # \[66\]
140
140
 
141
141
  # Make all defined regular expression constants immutable:
142
142
  constants.each { |name| const_get(name).freeze }
@@ -1,12 +1,16 @@
1
1
  # This file is automatically generated by script/build_meta
2
2
  # Branch and Regexp tables derived from /Users/gregg/Projects/sparql-grammar/etc/sparql-selectors.n3
3
3
  # Note, branch tables completed with conflicts, may need to be resolved manually:
4
- # Conflict: in :UnaryExpression:
5
- # "+" is the condition for ["\"+\"", ":PrimaryExpression"].
6
- # We are changing it to :PrimaryExpression.
7
- # Conflict: in :UnaryExpression:
8
- # "-" is the condition for ["\"-\"", ":PrimaryExpression"].
9
- # We are changing it to :PrimaryExpression.
4
+ #
5
+ # Conflict: in :UnaryExpression:
6
+ # "+" is the condition for ["\"+\"", ":PrimaryExpression"].
7
+ #
8
+ # We are changing it to :PrimaryExpression.
9
+ #
10
+ # Conflict: in :UnaryExpression:
11
+ # "-" is the condition for ["\"-\"", ":PrimaryExpression"].
12
+ #
13
+ # We are changing it to :PrimaryExpression.
10
14
  module SPARQL::Grammar::Meta
11
15
  BRANCHES = {
12
16
  :AdditiveExpression => {
@@ -25,7 +25,7 @@ module SPARQL
25
25
  {n => {:type => "bnode", :value => s.id }}
26
26
  when RDF::Literal
27
27
  if s.datatype?
28
- {n => {:type => "literal", :datatype => s.datatype.to_s, :value => s.to_s }}
28
+ {n => {:type => "typed-literal", :datatype => s.datatype.to_s, :value => s.to_s }}
29
29
  elsif s.language
30
30
  {n => {:type => "literal", "xml:lang" => s.language.to_s, :value => s.to_s }}
31
31
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-07-05 00:00:00.000000000 Z
14
+ date: 2012-12-31 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rdf
@@ -386,7 +386,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
386
  version: '0'
387
387
  requirements: []
388
388
  rubyforge_project: sparql
389
- rubygems_version: 1.8.23
389
+ rubygems_version: 1.8.24
390
390
  signing_key:
391
391
  specification_version: 3
392
392
  summary: SPARQL library for Ruby.