pho 0.7.4 → 0.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +9 -0
- data/Rakefile +1 -1
- data/doc/index.html +1 -1
- data/doc/rdoc/classes/Pho/CommandLine.html +108 -108
- data/doc/rdoc/classes/Pho/DatatypeProperty.html +12 -12
- data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +29 -29
- data/doc/rdoc/classes/Pho/Etags.html +36 -36
- data/doc/rdoc/classes/Pho/Facet/Results.html +19 -19
- data/doc/rdoc/classes/Pho/Facet/Term.html +6 -6
- data/doc/rdoc/classes/Pho/FieldPredicateMap.html +146 -112
- data/doc/rdoc/classes/Pho/FieldWeighting.html +12 -12
- data/doc/rdoc/classes/Pho/Job.html +64 -64
- data/doc/rdoc/classes/Pho/Jobs.html +60 -60
- data/doc/rdoc/classes/Pho/OAI.html +1 -0
- data/doc/rdoc/classes/Pho/OAI/Record.html +1 -1
- data/doc/rdoc/classes/Pho/OAI/Records.html +4 -4
- data/doc/rdoc/classes/Pho/QueryProfile.html +66 -66
- data/doc/rdoc/classes/Pho/RDF/Parser.html +24 -24
- data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +36 -36
- data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +12 -12
- data/doc/rdoc/classes/Pho/Snapshot.html +35 -35
- data/doc/rdoc/classes/Pho/Status.html +26 -26
- data/doc/rdoc/classes/Pho/Store.html +215 -215
- data/doc/rdoc/classes/Pho/StoreSparqlClient.html +12 -12
- data/doc/rdoc/classes/String.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +17 -1
- data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/oai_rb.html +1 -1
- data/doc/rdoc/files/lib/pho_rb.html +2 -1
- data/doc/rdoc/fr_class_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +152 -149
- data/lib/pho.rb +1 -0
- data/lib/pho/field_predicate_map.rb +18 -7
- data/lib/pho/oai.rb +25 -0
- data/tests/tc_command_line.rb +1 -1
- data/tests/tc_field_predicate_map.rb +36 -5
- data/tests/tc_oai.rb +37 -0
- metadata +4 -4
data/lib/pho.rb
CHANGED
@@ -134,7 +134,7 @@ module Pho
|
|
134
134
|
return fpmap
|
135
135
|
end
|
136
136
|
|
137
|
-
#Create a DatatypeProperty instance, automatically assigning a unique identifier to it, and
|
137
|
+
#Create a DatatypeProperty instance, automatically assigning a unique identifier to it, and
|
138
138
|
#validating the supplied data to ensure it matches the platform rules
|
139
139
|
def FieldPredicateMap.create_mapping(store, property_uri, name, analyzer=nil)
|
140
140
|
check_value("property_uri", property_uri)
|
@@ -150,6 +150,16 @@ module Pho
|
|
150
150
|
return DatatypeProperty.new(mapping_uri, property_uri, name, analyzer)
|
151
151
|
end
|
152
152
|
|
153
|
+
#Create a DatatypeProperty instance, automatically assigning a unique identifier to it, and
|
154
|
+
#validating the supplied data to ensure it matches the platform rules.
|
155
|
+
#
|
156
|
+
#Then automatically appends it to the provided fpmap instance
|
157
|
+
def FieldPredicateMap.add_mapping(fpmap, store, property_uri, name, analyzer=nil)
|
158
|
+
mapping = create_mapping(store, property_uri, name, analyzer)
|
159
|
+
fpmap << mapping
|
160
|
+
return mapping
|
161
|
+
end
|
162
|
+
|
153
163
|
def initialize(uri, label, datatype_properties = [])
|
154
164
|
@uri = uri
|
155
165
|
@label = label
|
@@ -162,7 +172,7 @@ module Pho
|
|
162
172
|
def <<(obj)
|
163
173
|
@datatype_properties << obj
|
164
174
|
end
|
165
|
-
|
175
|
+
|
166
176
|
#Lookup the name mapped to the specified uri
|
167
177
|
#
|
168
178
|
#uri:: the property uri to search for
|
@@ -265,11 +275,12 @@ module Pho
|
|
265
275
|
|
266
276
|
private
|
267
277
|
def FieldPredicateMap.get_suffix(uri)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
278
|
+
return Digest::MD5.hexdigest(uri)
|
279
|
+
# candidate_suffix = uri.split("/").last
|
280
|
+
# if candidate_suffix.index("#") != -1
|
281
|
+
# return candidate_suffix.split("#").last
|
282
|
+
# end
|
283
|
+
# return candidate_suffix
|
273
284
|
end
|
274
285
|
|
275
286
|
def FieldPredicateMap.check_value(name, val)
|
data/lib/pho/oai.rb
CHANGED
@@ -3,6 +3,31 @@ module Pho
|
|
3
3
|
#OAI-PMH Support
|
4
4
|
module OAI
|
5
5
|
|
6
|
+
#Access basic store statistics via the OAI interface
|
7
|
+
class Statistics
|
8
|
+
|
9
|
+
#Datestamp of last updated record in the store
|
10
|
+
#
|
11
|
+
#This reads the OAI-PMH interface and retrieves the datestamp of the most
|
12
|
+
#recently updated item
|
13
|
+
def Statistics.last_updated(store)
|
14
|
+
records = Records.read_from_store(store)
|
15
|
+
return records.records[0].datestamp
|
16
|
+
end
|
17
|
+
|
18
|
+
#Number of entities in the store. This includes all resources in both the
|
19
|
+
#metabox AND the contentbox
|
20
|
+
def Statistics.num_of_entities(store)
|
21
|
+
records = Records.read_from_store(store)
|
22
|
+
if records.resumption_token != nil
|
23
|
+
return records.list_size
|
24
|
+
else
|
25
|
+
return records.records.length
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
6
31
|
class Record
|
7
32
|
|
8
33
|
attr_reader :identifier
|
data/tests/tc_command_line.rb
CHANGED
@@ -198,7 +198,7 @@ EOL
|
|
198
198
|
mc = mock()
|
199
199
|
mc.expects(:build_uri).with("/config/fpmaps/1").returns( "http://api.talis.com/stores/testing/config/fpmaps/1" )
|
200
200
|
mc.expects(:get_field_predicate_map).returns( HTTP::Message.new_response(TEST_FPMAP) )
|
201
|
-
mc.expects(:build_uri).with("/config/fpmaps/1
|
201
|
+
mc.expects(:build_uri).with("/config/fpmaps/1##{Digest::MD5.hexdigest("http://www.example.org/test")}").returns( "http://api.talis.com/stores/testing/config/fpmaps/1##{Digest::MD5.hexdigest("http://www.example.org/test")}" )
|
202
202
|
mc.expects(:put_field_predicate_map).returns( HTTP::Message.new_response("") )
|
203
203
|
|
204
204
|
@opts["field"] = "test"
|
@@ -253,31 +253,62 @@ EOL
|
|
253
253
|
end
|
254
254
|
|
255
255
|
def test_create_mapping_with_slash_uri
|
256
|
+
digest = Digest::MD5.hexdigest("http://www.example.org/ns/title")
|
256
257
|
mc = mock()
|
257
258
|
mc.stub_everything
|
258
|
-
mc.expects(:build_uri).with("/config/fpmaps/1
|
259
|
+
mc.expects(:build_uri).with("/config/fpmaps/1##{digest}").returns("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}")
|
259
260
|
|
260
261
|
mapping = Pho::FieldPredicateMap.create_mapping(mc, "http://www.example.org/ns/title", "title")
|
261
262
|
assert_not_nil(mapping)
|
262
|
-
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1
|
263
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}", mapping.uri)
|
263
264
|
assert_equal("http://www.example.org/ns/title", mapping.property_uri)
|
264
265
|
assert_equal("title", mapping.name)
|
265
266
|
assert_equal(nil, mapping.analyzer)
|
266
267
|
end
|
267
268
|
|
268
269
|
def test_create_mapping_with_hash_uri
|
270
|
+
digest = Digest::MD5.hexdigest("http://www.example.org/ns/things#document")
|
269
271
|
mc = mock()
|
270
272
|
mc.stub_everything
|
271
|
-
mc.expects(:build_uri).with("/config/fpmaps/1
|
273
|
+
mc.expects(:build_uri).with("/config/fpmaps/1##{digest}").returns("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}")
|
272
274
|
|
273
275
|
mapping = Pho::FieldPredicateMap.create_mapping(mc, "http://www.example.org/ns/things#document", "document", Pho::Analyzers::DUTCH)
|
274
276
|
assert_not_nil(mapping)
|
275
|
-
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1
|
277
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}", mapping.uri)
|
276
278
|
assert_equal("http://www.example.org/ns/things#document", mapping.property_uri)
|
277
279
|
assert_equal("document", mapping.name)
|
278
280
|
assert_equal(Pho::Analyzers::DUTCH, mapping.analyzer)
|
279
281
|
end
|
280
|
-
|
282
|
+
|
283
|
+
def test_add_mapping
|
284
|
+
digest = Digest::MD5.hexdigest("http://www.example.org/ns/things#document")
|
285
|
+
mc = mock()
|
286
|
+
mc.stub_everything
|
287
|
+
mc.expects(:build_uri).with("/config/fpmaps/1##{digest}").returns("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}")
|
288
|
+
|
289
|
+
fpmap = Pho::FieldPredicateMap.new("http://api.talis.com/stores/testing/fpmaps/1#mapping", "Test Mapping")
|
290
|
+
|
291
|
+
mapping = Pho::FieldPredicateMap.add_mapping(fpmap, mc, "http://www.example.org/ns/things#document", "document", Pho::Analyzers::DUTCH)
|
292
|
+
assert_not_nil(mapping)
|
293
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1##{digest}", mapping.uri)
|
294
|
+
assert_equal("http://www.example.org/ns/things#document", mapping.property_uri)
|
295
|
+
assert_equal("document", mapping.name)
|
296
|
+
assert_equal(Pho::Analyzers::DUTCH, mapping.analyzer)
|
297
|
+
end
|
298
|
+
|
299
|
+
def test_add_mapping_with_similar_uri_suffix
|
300
|
+
mc = mock()
|
301
|
+
mc.stub_everything
|
302
|
+
mc.expects(:build_uri).with("/config/fpmaps/1##{Digest::MD5.hexdigest("http://www.example.org/ns/things#document")}").returns(
|
303
|
+
"http://api.talis.com/stores/testing/config/fpmaps/1##{Digest::MD5.hexdigest("http://www.example.org/ns/things#document")}")
|
304
|
+
|
305
|
+
fpmap = Pho::FieldPredicateMap.new("http://api.talis.com/stores/testing/fpmaps/1#mapping", "Test Mapping")
|
306
|
+
|
307
|
+
mapping = Pho::FieldPredicateMap.add_mapping(fpmap, mc, "http://www.example.org/ns/things#document", "document", Pho::Analyzers::DUTCH)
|
308
|
+
assert_equal("http://api.talis.com/stores/testing/config/fpmaps/1##{Digest::MD5.hexdigest("http://www.example.org/ns/things#document")}", mapping.uri)
|
309
|
+
|
310
|
+
end
|
311
|
+
|
281
312
|
def test_create_mapping_with_invalid_name
|
282
313
|
assert_raise RuntimeError do
|
283
314
|
Pho::FieldPredicateMap.create_mapping(nil, "http://www.example.org/ns/things#document", "12345")
|
data/tests/tc_oai.rb
CHANGED
@@ -135,4 +135,41 @@ EOL
|
|
135
135
|
assert_equal(0, results.cursor)
|
136
136
|
assert_equal("b2FpX2RjfDEwMHwxOTcwLTAxLTAxVDAwOjAwOjAwWnwyMDEwLTA0LTA0VDEzOjU0OjMyWg==", results.resumption_token)
|
137
137
|
end
|
138
|
+
|
139
|
+
def test_statistics_last_updated
|
140
|
+
mc = mock()
|
141
|
+
mc.expects(:set_auth)
|
142
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/services/oai-pmh", {"verb" => "ListRecords", "metadataPrefix" => "oai_dc"} ).returns(
|
143
|
+
HTTP::Message.new_response(LIST_RECORDS))
|
144
|
+
|
145
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
146
|
+
|
147
|
+
updated = Pho::OAI::Statistics.last_updated(store)
|
148
|
+
assert_equal(DateTime.parse("2010-03-19T12:57:06Z"), updated)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_statistics_num_entities
|
152
|
+
mc = mock()
|
153
|
+
mc.expects(:set_auth)
|
154
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/services/oai-pmh", {"verb" => "ListRecords", "metadataPrefix" => "oai_dc"} ).returns(
|
155
|
+
HTTP::Message.new_response(LIST_RECORDS))
|
156
|
+
|
157
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
158
|
+
|
159
|
+
size = Pho::OAI::Statistics.num_of_entities(store)
|
160
|
+
assert_equal(2, size)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_statistics_num_entities_with_resumption
|
164
|
+
mc = mock()
|
165
|
+
mc.expects(:set_auth)
|
166
|
+
mc.expects(:get).with("http://api.talis.com/stores/testing/services/oai-pmh", {"verb" => "ListRecords", "metadataPrefix" => "oai_dc"} ).returns(
|
167
|
+
HTTP::Message.new_response(LIST_RECORDS_WITH_TOKEN))
|
168
|
+
|
169
|
+
store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
|
170
|
+
|
171
|
+
size = Pho::OAI::Statistics.num_of_entities(store)
|
172
|
+
assert_equal(6151294, size)
|
173
|
+
end
|
174
|
+
|
138
175
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 5
|
10
|
+
version: 0.7.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Leigh Dodds
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-01 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|