sparql 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.markdown +30 -9
  2. data/VERSION +1 -1
  3. data/lib/sparql/results.rb +5 -4
  4. metadata +37 -37
data/README.markdown CHANGED
@@ -120,16 +120,31 @@ a full set of RDF formats.
120
120
 
121
121
  ### Adding SPARQL content negotiation to a classic Sinatra application
122
122
 
123
- #!/usr/bin/env ruby -rubygems
123
+ # Sinatra example
124
+ #
125
+ # Call as http://localhost:4567/sparql?query=uri,
126
+ # where `uri` is the URI of a SPARQL query, or
127
+ # a URI-escaped SPARQL query, for example:
128
+ # http://localhost:4567/?query=SELECT%20?s%20?p%20?o%20WHERE%20%7B?s%20?p%20?o%7D
124
129
  require 'sinatra'
125
130
  require 'sinatra/sparql'
126
-
127
- repository = RDF::Repository.new do |graph|
128
- graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
129
- end
130
-
131
- get '/sparql' do
132
- SPARQL.execute("SELECT * WHERE { ?s ?p ?o }", repository)
131
+ require 'uri'
132
+
133
+ get '/' do
134
+ settings.sparql_options.replace(:standard_prefixes => true)
135
+ repository = RDF::Repository.new do |graph|
136
+ graph << [RDF::Node.new, RDF::DC.title, "Hello, world!"]
137
+ end
138
+ if params["query"]
139
+ query = params["query"].to_s.match(/^http:/) ? RDF::Util::File.open_file(params["query"]) : ::URI.decode(params["query"].to_s)
140
+ SPARQL.execute(query, repository)
141
+ else
142
+ settings.sparql_options.merge!(:prefixes => {
143
+ :ssd => "http://www.w3.org/ns/sparql-service-description#",
144
+ :void => "http://rdfs.org/ns/void#"
145
+ })
146
+ service_description(:repo => repository)
147
+ end
133
148
  end
134
149
 
135
150
  ## Documentation
@@ -158,7 +173,13 @@ Full documentation available on [Rubydoc.info][SPARQL doc]
158
173
  * [SXP](https://rubygems.org/gems/sxp) (>= 0.0.15)
159
174
  * [Builder](https://rubygems.org/gems/builder) (>= 3.0.0)
160
175
  * [JSON](https://rubygems.org/gems/json) (>= 1.5.1)
161
- * Soft dependency on [Linked Data][]
176
+ * Soft dependency on [Linked Data][] (>= 0.3.5)
177
+ * Soft dependency on [Nokogiri](http://rubygems.org/gems/nokogiri) (>= 1.3.3)
178
+ Falls back to REXML for XML parsing Builder for XML serializing. Nokogiri is much more efficient
179
+ * Soft dependency on [Equivalent XML](https://rubygems.org/gems/equivalent-xml) (>= 0.2.9)
180
+ Equivalent XML performs more efficient comparisons of XML Literals when Nokogiri is included
181
+ * Soft dependency on [Rack][] (>= 1.3.2)
182
+ * Soft dependency on [Sinatra][] (>= 1.4.1)
162
183
 
163
184
  ## Installation
164
185
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -17,8 +17,8 @@ module SPARQL
17
17
  require 'json' unless defined?(::JSON)
18
18
 
19
19
  bindings = self.map do |solution|
20
- variable_names.map do |n|
21
- case s = solution[n]
20
+ variable_names.inject({}) do |memo, n|
21
+ memo.merge case s = solution[n]
22
22
  when RDF::URI
23
23
  {n => {:type => "uri", :value => s.to_s }}
24
24
  when RDF::Node
@@ -32,8 +32,8 @@ module SPARQL
32
32
  {n => {:type => "literal", :value => s.to_s }}
33
33
  end
34
34
  end
35
- end.compact
36
- end.flatten
35
+ end
36
+ end
37
37
 
38
38
  {
39
39
  :head => { :vars => variable_names },
@@ -177,6 +177,7 @@ module SPARQL
177
177
  end
178
178
  fmt = RDF::Format.for(format ? format.to_sym : {:content_type => content_type})
179
179
  fmt ||= RDF::NTriples::Format
180
+ puts "fmt: #{fmt.inspect}, format: #{format.inspect}, content_type: #{content_type}"
180
181
  format ||= fmt.to_sym
181
182
  content_type ||= fmt.content_type.first
182
183
  results = solutions.dump(format, options)
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.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-01-31 00:00:00.000000000Z
14
+ date: 2012-03-19 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rdf
18
- requirement: &2165243520 !ruby/object:Gem::Requirement
18
+ requirement: &70212556937120 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 0.3.5
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2165243520
26
+ version_requirements: *70212556937120
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
- requirement: &2165242720 !ruby/object:Gem::Requirement
29
+ requirement: &70212556936660 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 3.0.0
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2165242720
37
+ version_requirements: *70212556936660
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: json
40
- requirement: &2165241340 !ruby/object:Gem::Requirement
40
+ requirement: &70212556936200 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: 1.5.1
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2165241340
48
+ version_requirements: *70212556936200
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: sxp
51
- requirement: &2165240320 !ruby/object:Gem::Requirement
51
+ requirement: &70212556935740 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.0.14
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2165240320
59
+ version_requirements: *70212556935740
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: sparql-client
62
- requirement: &2165237360 !ruby/object:Gem::Requirement
62
+ requirement: &70212556935280 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: 0.0.11
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *2165237360
70
+ version_requirements: *70212556935280
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rdf-xsd
73
- requirement: &2165236080 !ruby/object:Gem::Requirement
73
+ requirement: &70212556934820 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 0.3.5
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *2165236080
81
+ version_requirements: *70212556934820
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sinatra
84
- requirement: &2165234460 !ruby/object:Gem::Requirement
84
+ requirement: &70212556934360 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: 1.3.2
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *2165234460
92
+ version_requirements: *70212556934360
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: rack
95
- requirement: &2165232960 !ruby/object:Gem::Requirement
95
+ requirement: &70212556933900 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: 1.4.1
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *2165232960
103
+ version_requirements: *70212556933900
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rack-test
106
- requirement: &2165230920 !ruby/object:Gem::Requirement
106
+ requirement: &70212556933440 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: 0.6.1
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *2165230920
114
+ version_requirements: *70212556933440
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: linkeddata
117
- requirement: &2165224020 !ruby/object:Gem::Requirement
117
+ requirement: &70212556932980 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,10 +122,10 @@ dependencies:
122
122
  version: 0.3.5
123
123
  type: :development
124
124
  prerelease: false
125
- version_requirements: *2165224020
125
+ version_requirements: *70212556932980
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rdf-spec
128
- requirement: &2165221300 !ruby/object:Gem::Requirement
128
+ requirement: &70212556932460 !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
131
  - - ! '>='
@@ -133,10 +133,10 @@ dependencies:
133
133
  version: 0.3.5
134
134
  type: :development
135
135
  prerelease: false
136
- version_requirements: *2165221300
136
+ version_requirements: *70212556932460
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: open-uri-cached
139
- requirement: &2165218280 !ruby/object:Gem::Requirement
139
+ requirement: &70212556931940 !ruby/object:Gem::Requirement
140
140
  none: false
141
141
  requirements:
142
142
  - - ! '>='
@@ -144,10 +144,10 @@ dependencies:
144
144
  version: 0.0.4
145
145
  type: :development
146
146
  prerelease: false
147
- version_requirements: *2165218280
147
+ version_requirements: *70212556931940
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: equivalent-xml
150
- requirement: &2165215280 !ruby/object:Gem::Requirement
150
+ requirement: &70212556931400 !ruby/object:Gem::Requirement
151
151
  none: false
152
152
  requirements:
153
153
  - - ! '>='
@@ -155,10 +155,10 @@ dependencies:
155
155
  version: 0.2.8
156
156
  type: :development
157
157
  prerelease: false
158
- version_requirements: *2165215280
158
+ version_requirements: *70212556931400
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: nokogiri
161
- requirement: &2165202460 !ruby/object:Gem::Requirement
161
+ requirement: &70212556930880 !ruby/object:Gem::Requirement
162
162
  none: false
163
163
  requirements:
164
164
  - - ! '>='
@@ -166,10 +166,10 @@ dependencies:
166
166
  version: 1.5.0
167
167
  type: :development
168
168
  prerelease: false
169
- version_requirements: *2165202460
169
+ version_requirements: *70212556930880
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: rspec
172
- requirement: &2165199020 !ruby/object:Gem::Requirement
172
+ requirement: &70212556930400 !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements:
175
175
  - - ! '>='
@@ -177,10 +177,10 @@ dependencies:
177
177
  version: 2.8.0
178
178
  type: :development
179
179
  prerelease: false
180
- version_requirements: *2165199020
180
+ version_requirements: *70212556930400
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: spira
183
- requirement: &2165196200 !ruby/object:Gem::Requirement
183
+ requirement: &70212556929900 !ruby/object:Gem::Requirement
184
184
  none: false
185
185
  requirements:
186
186
  - - ! '>='
@@ -188,10 +188,10 @@ dependencies:
188
188
  version: 0.0.12
189
189
  type: :development
190
190
  prerelease: false
191
- version_requirements: *2165196200
191
+ version_requirements: *70212556929900
192
192
  - !ruby/object:Gem::Dependency
193
193
  name: yard
194
- requirement: &2165194600 !ruby/object:Gem::Requirement
194
+ requirement: &70212556929440 !ruby/object:Gem::Requirement
195
195
  none: false
196
196
  requirements:
197
197
  - - ! '>='
@@ -199,7 +199,7 @@ dependencies:
199
199
  version: 0.7.5
200
200
  type: :development
201
201
  prerelease: false
202
- version_requirements: *2165194600
202
+ version_requirements: *70212556929440
203
203
  description: ! "\n Implements SPARQL grammar parsing to SPARQL Algebra, SPARQL
204
204
  Algebra processing\n and includes SPARQL Client for accessing remote repositories."
205
205
  email: public-rdf-ruby@w3.org
@@ -301,7 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
301
301
  version: '0'
302
302
  requirements: []
303
303
  rubyforge_project: sparql
304
- rubygems_version: 1.8.10
304
+ rubygems_version: 1.8.17
305
305
  signing_key:
306
306
  specification_version: 3
307
307
  summary: SPARQL library for Ruby.