sasquatch 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/sasquatch/store.rb +11 -12
- metadata +6 -8
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/lib/sasquatch/store.rb
CHANGED
@@ -2,10 +2,9 @@ module Sasquatch
|
|
2
2
|
class Store
|
3
3
|
include HTTParty
|
4
4
|
default_timeout 30
|
5
|
-
|
5
|
+
base_uri "http://api.talis.com/stores"
|
6
6
|
attr_reader :store_name, :last_response, :sparql_clients
|
7
7
|
def initialize(storename, options={})
|
8
|
-
self.class.base_uri "http://api.talis.com/stores/#{storename}"
|
9
8
|
@store_name = storename
|
10
9
|
if options[:username]
|
11
10
|
set_credentials(options[:username], options[:password])
|
@@ -15,12 +14,12 @@ module Sasquatch
|
|
15
14
|
|
16
15
|
def set_credentials(username, password)
|
17
16
|
@auth = {:username => username, :password => password}
|
18
|
-
@auth[:headers] = self.get("/snapshots", {}).headers['www-authenticate']
|
17
|
+
@auth[:headers] = self.get("/#{@store_name}/snapshots", {}).headers['www-authenticate']
|
19
18
|
end
|
20
19
|
|
21
20
|
def describe(uri)
|
22
21
|
options = {:query=>{:about=>uri, :output=>"ntriples"}}
|
23
|
-
@last_response = get("/meta", options)
|
22
|
+
@last_response = get("/#{@store_name}/meta", options)
|
24
23
|
graph = parse_ntriples(@last_response.body)
|
25
24
|
graph.set_requested_resource(uri)
|
26
25
|
graph
|
@@ -30,7 +29,7 @@ module Sasquatch
|
|
30
29
|
sparql = "DESCRIBE "
|
31
30
|
uris.each {|uri| sparql << "<#{uri}> "}
|
32
31
|
options = {:query=>{:query=>sparql, :output=>"ntriples"}}
|
33
|
-
@last_response = get("/services/sparql", options)
|
32
|
+
@last_response = get("/#{@store_name}/services/sparql", options)
|
34
33
|
graph = parse_ntriples(@last_response.body)
|
35
34
|
graph
|
36
35
|
end
|
@@ -52,7 +51,7 @@ module Sasquatch
|
|
52
51
|
end
|
53
52
|
sparql << "\nWHERE\n{ #{where.join(" UNION ")} }"
|
54
53
|
options = {:body=>{:query=>sparql, :output=>"ntriples"}}
|
55
|
-
@last_response = post("/services/sparql", options)
|
54
|
+
@last_response = post("/#{@store_name}/services/sparql", options)
|
56
55
|
graph = parse_ntriples(@last_response.body)
|
57
56
|
graph
|
58
57
|
end
|
@@ -66,7 +65,7 @@ module Sasquatch
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def save(graph_statement_or_resource, graph_name=nil)
|
69
|
-
path = "/meta"
|
68
|
+
path = "/#{@store_name}/meta"
|
70
69
|
path << "/graphs/#{graph_name}" if graph_name
|
71
70
|
options = {:headers=>{"Content-Type"=> "text/turtle"}, :body=>graph_statement_or_resource.to_ntriples, :digest_auth=>@auth}
|
72
71
|
@last_response = post(path, options )
|
@@ -80,7 +79,7 @@ module Sasquatch
|
|
80
79
|
def search(query, options={})
|
81
80
|
accept = self.class.headers['Accept']
|
82
81
|
self.class.headers 'Accept' => 'application/json'
|
83
|
-
path = "/items"
|
82
|
+
path = "/#{@store_name}/items"
|
84
83
|
opts = {:query=>options}
|
85
84
|
opts[:query][:query] = query
|
86
85
|
@last_response = get(path, opts)
|
@@ -175,7 +174,7 @@ module Sasquatch
|
|
175
174
|
end
|
176
175
|
|
177
176
|
def send_changeset(graph, versioned=false, creator="sasquatch.rb")
|
178
|
-
path = "/meta"
|
177
|
+
path = "/#{@store_name}/meta"
|
179
178
|
path << "/changesets" if versioned
|
180
179
|
|
181
180
|
graph.query(:predicate=>RDF.type, :object=>RDF::Talis::Changeset.ChangeSet).each_subject do |cs|
|
@@ -220,7 +219,7 @@ module Sasquatch
|
|
220
219
|
end
|
221
220
|
|
222
221
|
def sparql_describe(query, graph=:default)
|
223
|
-
path = "/services/sparql"
|
222
|
+
path = "/#{@store_name}/services/sparql"
|
224
223
|
unless graph == :default
|
225
224
|
path << "/graphs/#{graph}"
|
226
225
|
end
|
@@ -233,7 +232,7 @@ module Sasquatch
|
|
233
232
|
alias :sparql_construct :sparql_describe
|
234
233
|
|
235
234
|
def sparql_select(query, graph=:default)
|
236
|
-
path = "/services/sparql"
|
235
|
+
path = "/#{@store_name}/services/sparql"
|
237
236
|
unless graph == :default
|
238
237
|
path << "/graphs/#{graph}"
|
239
238
|
end
|
@@ -247,7 +246,7 @@ module Sasquatch
|
|
247
246
|
def access_status
|
248
247
|
accept = self.class.headers['Accept']
|
249
248
|
self.class.headers 'Accept' => 'application/json'
|
250
|
-
path = "/config/access-status"
|
249
|
+
path = "/#{@store_name}/config/access-status"
|
251
250
|
@last_response = get(path, {})
|
252
251
|
graph = parse_json(@last_response.body)
|
253
252
|
self.class.headers 'Accept' => accept
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sasquatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ross Singer
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-07-25 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: httparty
|
@@ -119,7 +118,6 @@ files:
|
|
119
118
|
- lib/sasquatch/sparql_builder.rb
|
120
119
|
- lib/sasquatch/store.rb
|
121
120
|
- lib/sasquatch.rb
|
122
|
-
has_rdoc: false
|
123
121
|
homepage: http://github.com/rsinger/sasquatch
|
124
122
|
licenses:
|
125
123
|
- MIT
|
@@ -151,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
149
|
requirements: []
|
152
150
|
|
153
151
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.
|
152
|
+
rubygems_version: 1.8.1
|
155
153
|
signing_key:
|
156
154
|
specification_version: 3
|
157
155
|
summary: A highly opinionated Ruby client for the Talis Platform.
|