pho 0.6.2 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGES +12 -0
  2. data/Rakefile +1 -1
  3. data/bin/talis_store +98 -24
  4. data/doc/rdoc/classes/Pho.html +15 -0
  5. data/doc/rdoc/classes/Pho/CommandLine.html +353 -91
  6. data/doc/rdoc/classes/Pho/DatatypeProperty.html +12 -12
  7. data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +29 -29
  8. data/doc/rdoc/classes/Pho/Etags.html +36 -36
  9. data/doc/rdoc/classes/Pho/Facet/Results.html +19 -19
  10. data/doc/rdoc/classes/Pho/Facet/Term.html +6 -6
  11. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +105 -106
  12. data/doc/rdoc/classes/Pho/FieldWeighting.html +12 -12
  13. data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +31 -8
  14. data/doc/rdoc/classes/Pho/Job.html +64 -64
  15. data/doc/rdoc/classes/Pho/Jobs.html +60 -60
  16. data/doc/rdoc/classes/Pho/QueryProfile.html +60 -60
  17. data/doc/rdoc/classes/Pho/RDF/Parser.html +28 -26
  18. data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +36 -36
  19. data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +12 -12
  20. data/doc/rdoc/classes/Pho/Snapshot.html +35 -35
  21. data/doc/rdoc/classes/Pho/Status.html +26 -26
  22. data/doc/rdoc/classes/Pho/Store.html +289 -245
  23. data/doc/rdoc/classes/Pho/StoreSparqlClient.html +14 -14
  24. data/doc/rdoc/classes/String.html +1 -1
  25. data/doc/rdoc/created.rid +1 -1
  26. data/doc/rdoc/files/CHANGES.html +35 -1
  27. data/doc/rdoc/files/lib/pho/command_line_rb.html +1 -1
  28. data/doc/rdoc/files/lib/pho/converter_rb.html +1 -1
  29. data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +1 -1
  30. data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +1 -1
  31. data/doc/rdoc/files/lib/pho/rdf_rb.html +1 -1
  32. data/doc/rdoc/files/lib/pho/store_rb.html +1 -1
  33. data/doc/rdoc/files/lib/pho_rb.html +2 -1
  34. data/doc/rdoc/fr_class_index.html +3 -0
  35. data/doc/rdoc/fr_file_index.html +1 -0
  36. data/doc/rdoc/fr_method_index.html +153 -141
  37. data/lib/pho.rb +3 -0
  38. data/lib/pho/command_line.rb +139 -14
  39. data/lib/pho/field_predicate_map.rb +1 -2
  40. data/lib/pho/oai.rb +58 -0
  41. data/lib/pho/rdf.rb +2 -0
  42. data/lib/pho/rdf_collection.rb +16 -4
  43. data/lib/pho/store.rb +23 -5
  44. data/tests/tc_command_line.rb +229 -0
  45. data/tests/tc_field_predicate_map.rb +5 -1
  46. data/tests/tc_metabox.rb +29 -1
  47. data/tests/tc_oai.rb +31 -0
  48. data/tests/tc_rdf_collection.rb +80 -15
  49. data/tests/ts_pho.rb +3 -1
  50. metadata +5 -2
@@ -68,7 +68,10 @@ EOL
68
68
 
69
69
  p = @fpmap.remove_by_name("title")
70
70
  assert_not_nil(p)
71
-
71
+
72
+ p = @fpmap.remove_by_name("iamnotthere")
73
+ assert_nil(p)
74
+
72
75
  p = @fpmap.remove_by_uri("http://www.example.org/ns/address")
73
76
  assert_not_nil(p)
74
77
 
@@ -173,6 +176,7 @@ EOL
173
176
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
174
177
  @fpmap.upload(store)
175
178
  end
179
+
176
180
  def test_read_from_store
177
181
  mc = mock()
178
182
  mc.expects(:set_auth)
@@ -22,6 +22,23 @@ class MetaboxTest < Test::Unit::TestCase
22
22
  store.store_data("data")
23
23
  end
24
24
 
25
+ def test_store_data_as_turtle
26
+ mc = mock()
27
+ mc.expects(:set_auth)
28
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "text/turtle"} )
29
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
30
+ store.store_data("data", nil, "text/turtle")
31
+ end
32
+
33
+ def test_store_data_as_ntriples
34
+ mc = mock()
35
+ mc.expects(:set_auth)
36
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "text/turtle"} )
37
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
38
+ store.store_data("data", nil, "text/plain")
39
+ end
40
+
41
+
25
42
  def test_store_data_in_graph
26
43
  mc = mock()
27
44
  mc.expects(:set_auth)
@@ -40,7 +57,18 @@ class MetaboxTest < Test::Unit::TestCase
40
57
  store.store_file( io )
41
58
  assert_equal(true, io.closed?)
42
59
  end
43
-
60
+
61
+ def test_store_file_turtle
62
+ mc = mock()
63
+ mc.expects(:set_auth)
64
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "data", {"Content-Type" => "text/turtle"} )
65
+
66
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
67
+ io = StringIO.new("data")
68
+ store.store_file( io, nil, "text/turtle" )
69
+ assert_equal(true, io.closed?)
70
+ end
71
+
44
72
  def test_store_url
45
73
  mc = mock()
46
74
  mc.expects(:set_auth)
@@ -0,0 +1,31 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require 'pho'
3
+ require 'test/unit'
4
+ require 'mocha'
5
+ require 'rexml/document'
6
+
7
+ class OAITest < Test::Unit::TestCase
8
+
9
+ LIST_RECORDS = <<-EOL
10
+ <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"><responseDate>2010-03-19T13:02:14Z</responseDate><request from="2010-03-19T13:02:14Z" metadataPrefix="oai_dc" verb="ListRecords">http://api.talis.com/stores/ldodds-dev1/services/oai-pmh</request><ListRecords><record><header><identifier>http://www.example.org</identifier><datestamp>2010-03-19T12:57:06Z</datestamp></header><metadata><oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"><dc:identifier>http://www.example.org</dc:identifier></oai_dc:dc></metadata></record><record><header><identifier>http://api.talis.com/stores/ldodds-dev1/items/atom.xml</identifier><datestamp>2010-03-19T12:57:10Z</datestamp></header><metadata><oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"><dc:identifier>http://api.talis.com/stores/ldodds-dev1/items/atom.xml</dc:identifier></oai_dc:dc></metadata></record></ListRecords></OAI-PMH>
11
+ EOL
12
+
13
+ def test_request
14
+ mc = mock()
15
+ mc.expects(:set_auth)
16
+ mc.expects(:get).with("http://api.talis.com/stores/testing/services/oai-pmh", {"verb" => "ListRecords", "metadataPrefix" => "oai_dc"} ).returns(
17
+ HTTP::Message.new_response(LIST_RECORDS))
18
+
19
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
20
+ response = store.list_records()
21
+ assert_equal(LIST_RECORDS, response.content)
22
+ end
23
+
24
+ def test_parse
25
+
26
+ results = Pho::OAI::Records.parse(LIST_RECORDS)
27
+ assert_not_nil(results)
28
+ assert_equal(2, results.records.size)
29
+ end
30
+
31
+ end
@@ -22,7 +22,13 @@ class RDFCollectionTest < Test::Unit::TestCase
22
22
  file = File.new( File.join("/tmp", "#{num}.fail"), "w" )
23
23
  file.write("FAIL")
24
24
  file.close()
25
- end
25
+ end
26
+ 3.times do |i|
27
+ num = 10 + i
28
+ file = File.new( File.join("/tmp", "#{num}.ttl"), "w" )
29
+ file.write("TTL#{num}")
30
+ file.close()
31
+ end
26
32
  end
27
33
 
28
34
  def teardown()
@@ -35,32 +41,35 @@ class RDFCollectionTest < Test::Unit::TestCase
35
41
  Dir.glob("/tmp/*.fail") do |file|
36
42
  File.delete(file)
37
43
  end
44
+ Dir.glob("/tmp/*.ttl") do |file|
45
+ File.delete(file)
46
+ end
38
47
  end
39
48
 
40
49
  def test_get_fail_file_for()
41
50
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
42
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
51
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
43
52
 
44
53
  assert_equal("foo.fail", collection.get_fail_file_for("foo.rdf") )
45
54
  end
46
55
 
47
56
  def test_get_fail_file_for_with_ext_in_path()
48
57
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
49
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp/rdf")
58
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp/rdf", ["rdf"])
50
59
 
51
60
  assert_equal("/tmp/rdf/foo.fail", collection.get_fail_file_for("/tmp/rdf/foo.rdf") )
52
61
  end
53
62
 
54
63
  def test_get_ok_file_for()
55
64
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
56
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
65
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
57
66
 
58
67
  assert_equal("foo.ok", collection.get_ok_file_for("foo.rdf") )
59
68
  end
60
69
 
61
70
  def test_get_ok_file_for_with_ext_in_path()
62
71
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
63
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp/js")
72
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp/js", ["rdf"])
64
73
 
65
74
  assert_equal("/tmp/js/foo.ok", collection.get_ok_file_for("/tmp/js/foo.js") )
66
75
  end
@@ -68,7 +77,7 @@ class RDFCollectionTest < Test::Unit::TestCase
68
77
 
69
78
  def test_successes()
70
79
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
71
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
80
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
72
81
 
73
82
  success = collection.successes()
74
83
  success.sort!
@@ -82,7 +91,7 @@ class RDFCollectionTest < Test::Unit::TestCase
82
91
 
83
92
  def test_failures()
84
93
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
85
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
94
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
86
95
 
87
96
  fails = collection.failures()
88
97
  fails.sort!
@@ -94,17 +103,31 @@ class RDFCollectionTest < Test::Unit::TestCase
94
103
 
95
104
  def test_new_files()
96
105
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
97
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
106
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
98
107
 
99
108
  newfiles = collection.new_files()
100
109
  newfiles.sort!
101
110
  assert_equal(3, newfiles.size)
102
111
  assert_equal("/tmp/7.rdf", newfiles[0])
103
112
  assert_equal("/tmp/8.rdf", newfiles[1])
104
- assert_equal("/tmp/9.rdf", newfiles[2])
105
-
113
+ assert_equal("/tmp/9.rdf", newfiles[2])
106
114
  end
107
115
 
116
+ def test_new_files_all_serializations()
117
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
118
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
119
+
120
+ newfiles = collection.new_files()
121
+ newfiles.sort!
122
+ assert_equal(6, newfiles.size)
123
+ assert_equal("/tmp/10.ttl", newfiles[0])
124
+ assert_equal("/tmp/11.ttl", newfiles[1])
125
+ assert_equal("/tmp/12.ttl", newfiles[2])
126
+ assert_equal("/tmp/7.rdf", newfiles[3])
127
+ assert_equal("/tmp/8.rdf", newfiles[4])
128
+ assert_equal("/tmp/9.rdf", newfiles[5])
129
+ end
130
+
108
131
  def test_store()
109
132
  mc = mock()
110
133
  mc.stub_everything()
@@ -113,7 +136,7 @@ class RDFCollectionTest < Test::Unit::TestCase
113
136
  mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
114
137
 
115
138
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
116
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
139
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
117
140
  collection.store()
118
141
 
119
142
  assert_equal(true, File.exists?("/tmp/7.ok") )
@@ -121,10 +144,51 @@ class RDFCollectionTest < Test::Unit::TestCase
121
144
  assert_equal(true, File.exists?("/tmp/9.ok") )
122
145
 
123
146
  end
124
-
147
+
148
+ def test_store_turtle()
149
+ mc = mock()
150
+ #mc.stub_everything()
151
+ mc.expects(:set_auth)
152
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL10", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
153
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL11", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
154
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL12", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
155
+
156
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
157
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["ttl"])
158
+ collection.store()
159
+
160
+ assert_equal(true, File.exists?("/tmp/10.ok") )
161
+ assert_equal(true, File.exists?("/tmp/11.ok") )
162
+ assert_equal(true, File.exists?("/tmp/12.ok") )
163
+ end
164
+
165
+ def test_store_all_serializations()
166
+ mc = mock()
167
+ #mc.stub_everything()
168
+ mc.expects(:set_auth)
169
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL10", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
170
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL11", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
171
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "TTL12", {"Content-Type" => "text/turtle"}).returns( HTTP::Message.new_response("OK") )
172
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF7", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
173
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF8", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
174
+ mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
175
+
176
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
177
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
178
+ collection.store()
179
+
180
+ assert_equal(true, File.exists?("/tmp/10.ok") )
181
+ assert_equal(true, File.exists?("/tmp/11.ok") )
182
+ assert_equal(true, File.exists?("/tmp/12.ok") )
183
+ assert_equal(true, File.exists?("/tmp/7.ok") )
184
+ assert_equal(true, File.exists?("/tmp/8.ok") )
185
+ assert_equal(true, File.exists?("/tmp/9.ok") )
186
+
187
+ end
188
+
125
189
  def test_reset()
126
190
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
127
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
191
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
128
192
 
129
193
  collection.reset()
130
194
  newfiles = collection.new_files()
@@ -133,7 +197,7 @@ class RDFCollectionTest < Test::Unit::TestCase
133
197
 
134
198
  def test_list()
135
199
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
136
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
200
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
137
201
 
138
202
  files = collection.list()
139
203
  assert_equal(10, files.size)
@@ -141,7 +205,8 @@ class RDFCollectionTest < Test::Unit::TestCase
141
205
 
142
206
  def test_summary()
143
207
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
144
- collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
208
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp", ["rdf"])
145
209
  end
146
210
 
147
211
  end
212
+
@@ -22,4 +22,6 @@ require 'tc_changeset.rb'
22
22
  require 'tc_changesets.rb'
23
23
  require 'tc_converter.rb'
24
24
  require 'tc_enrichment.rb'
25
- require 'tc_rdf_parser.rb'
25
+ require 'tc_rdf_parser.rb'
26
+ require 'tc_command_line.rb'
27
+ require 'tc_oai.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: "0.7"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leigh Dodds
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-02 00:00:00 +01:00
12
+ date: 2010-03-31 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -161,7 +161,9 @@ files:
161
161
  - tests/tc_changeset_builder.rb
162
162
  - tests/tc_rdf_collection.rb
163
163
  - tests/tc_rdf_parser.rb
164
+ - tests/tc_command_line.rb
164
165
  - tests/ts_pho.rb
166
+ - tests/tc_oai.rb
165
167
  - tests/tc_resource_hash.rb
166
168
  - tests/tc_sparql_helper.rb
167
169
  - tests/tc_jobcontrol.rb
@@ -205,6 +207,7 @@ files:
205
207
  - lib/pho/sparql.rb
206
208
  - lib/pho/resource_hash.rb
207
209
  - lib/pho/changeset.rb
210
+ - lib/pho/oai.rb
208
211
  - lib/pho/file_management.rb
209
212
  - lib/pho/facet.rb
210
213
  - lib/pho/query_profile.rb