pho 0.5 → 0.6

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.
Files changed (80) hide show
  1. data/CHANGES +17 -0
  2. data/Rakefile +10 -2
  3. data/bin/talis_store +37 -92
  4. data/doc/rdoc/classes/Pho.html +11 -0
  5. data/doc/rdoc/classes/Pho/CommandLine.html +508 -0
  6. data/doc/rdoc/classes/Pho/DatatypeProperty.html +15 -15
  7. data/doc/rdoc/classes/Pho/Enrichment.html +1 -1
  8. data/doc/rdoc/classes/Pho/Enrichment/{ResourceEnricher.html → StoreEnricher.html} +158 -58
  9. data/doc/rdoc/classes/Pho/Etags.html +36 -36
  10. data/doc/rdoc/classes/Pho/Facet/Results.html +19 -19
  11. data/doc/rdoc/classes/Pho/Facet/Term.html +6 -6
  12. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +94 -94
  13. data/doc/rdoc/classes/Pho/FieldWeighting.html +14 -14
  14. data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +126 -91
  15. data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +68 -62
  16. data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +22 -57
  17. data/doc/rdoc/classes/Pho/Job.html +68 -67
  18. data/doc/rdoc/classes/Pho/Jobs.html +62 -62
  19. data/doc/rdoc/classes/Pho/QueryProfile.html +64 -64
  20. data/doc/rdoc/classes/Pho/RDF.html +120 -0
  21. data/doc/rdoc/classes/Pho/RDF/Parser.html +277 -0
  22. data/doc/rdoc/classes/Pho/ResourceHash.html +1 -1
  23. data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +48 -46
  24. data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +15 -14
  25. data/doc/rdoc/classes/Pho/Snapshot.html +36 -36
  26. data/doc/rdoc/classes/Pho/Sparql.html +50 -0
  27. data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +147 -68
  28. data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +195 -114
  29. data/doc/rdoc/classes/Pho/Status.html +26 -26
  30. data/doc/rdoc/classes/Pho/Store.html +271 -264
  31. data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
  32. data/doc/rdoc/classes/Pho/Update.html +1 -0
  33. data/doc/rdoc/classes/Pho/Update/Changeset.html +69 -68
  34. data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +24 -24
  35. data/doc/rdoc/classes/Pho/Update/Changesets.html +15 -14
  36. data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +18 -18
  37. data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +24 -24
  38. data/doc/rdoc/classes/Pho/Update/Statement.html +28 -27
  39. data/doc/rdoc/classes/String.html +1 -1
  40. data/doc/rdoc/created.rid +1 -1
  41. data/doc/rdoc/files/CHANGES.html +53 -1
  42. data/doc/rdoc/files/lib/pho/changeset_rb.html +1 -1
  43. data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
  44. data/doc/rdoc/files/lib/pho/converter_rb.html +1 -1
  45. data/doc/rdoc/files/lib/pho/enrichment_rb.html +1 -1
  46. data/doc/rdoc/files/lib/pho/file_management_rb.html +1 -1
  47. data/doc/rdoc/files/lib/pho/file_manager_rb.html +1 -1
  48. data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +1 -1
  49. data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
  50. data/doc/rdoc/files/lib/pho/sparql_rb.html +1 -1
  51. data/doc/rdoc/files/lib/pho/store_rb.html +8 -1
  52. data/doc/rdoc/files/lib/pho_rb.html +4 -2
  53. data/doc/rdoc/fr_class_index.html +6 -1
  54. data/doc/rdoc/fr_file_index.html +2 -0
  55. data/doc/rdoc/fr_method_index.html +192 -172
  56. data/examples/calais/bio.txt +7 -0
  57. data/examples/calais/dump.rb +17 -0
  58. data/examples/calais/enlighten.rb +23 -0
  59. data/examples/calais/output.rdf +25 -0
  60. data/examples/sinatra/viewer.rb +20 -0
  61. data/lib/pho.rb +4 -1
  62. data/lib/pho/changeset.rb +17 -1
  63. data/lib/pho/command_line.rb +166 -0
  64. data/lib/pho/converter.rb +8 -3
  65. data/lib/pho/enrichment.rb +93 -28
  66. data/lib/pho/file_management.rb +32 -19
  67. data/lib/pho/file_manager.rb +22 -26
  68. data/lib/pho/rdf.rb +74 -0
  69. data/lib/pho/rdf_collection.rb +2 -17
  70. data/lib/pho/sparql.rb +150 -38
  71. data/lib/pho/store.rb +28 -2
  72. data/tests/tc_contentbox.rb +41 -0
  73. data/tests/tc_enrichment.rb +41 -4
  74. data/tests/tc_file_manager.rb +97 -7
  75. data/tests/tc_rdf_collection.rb +25 -13
  76. data/tests/tc_rdf_parser.rb +37 -0
  77. data/tests/tc_sparql.rb +72 -2
  78. data/tests/tc_sparql_helper.rb +16 -0
  79. data/tests/ts_pho.rb +2 -1
  80. metadata +20 -3
@@ -1,5 +1,7 @@
1
1
  module Pho
2
2
 
3
+ require 'pho/sparql'
4
+
3
5
  #TODO:
4
6
  #
5
7
  # Conditional deletions
@@ -180,7 +182,7 @@ module Pho
180
182
  u = self.build_uri("/services/sparql")
181
183
  end
182
184
 
183
- sparql_client = Pho::Sparql::SparqlClient.new(u, @client)
185
+ sparql_client = StoreSparqlClient.new(@self, u, @client)
184
186
  sparql_client.supports_rdf_json = true
185
187
  sparql_client.supports_sparql_json = true
186
188
 
@@ -341,7 +343,12 @@ module Pho
341
343
  response = @client.post(u, data, headers)
342
344
  else
343
345
  if !uri.start_with?(@storeuri)
344
- uri = build_uri(uri)
346
+ if uri.start_with?("/")
347
+ uri = build_uri("/items#{uri}")
348
+ else
349
+ uri = build_uri("/items/#{uri}")
350
+ end
351
+
345
352
  end
346
353
  response = @client.put(uri, data, headers)
347
354
  end
@@ -472,4 +479,23 @@ module Pho
472
479
 
473
480
  end
474
481
 
482
+ class StoreSparqlClient < Pho::Sparql::SparqlClient
483
+
484
+ def initialize(store, endpoint, client=HTTPClient.new() )
485
+ super(endpoint, client)
486
+ @store = store
487
+ end
488
+
489
+ #Override default behaviour to use the Stores Describe service instead
490
+ #when requesting CBDs
491
+ def describe_uri(uri, format="application/rdf+xml", type=:cbd)
492
+ if type == :cbd
493
+ return @store.describe(uri, format)
494
+ else
495
+ return super
496
+ end
497
+ end
498
+
499
+ end
500
+
475
501
  end
@@ -24,6 +24,47 @@ class ContentboxTest < Test::Unit::TestCase
24
24
 
25
25
  end
26
26
 
27
+ def test_upload_item_to_uri_with_relative
28
+ mc = mock()
29
+ mc.expects(:set_auth)
30
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/1/2/3", "data", {"Content-Type" => "text/plain"})
31
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
32
+ f = StringIO.new("data")
33
+ resp = store.upload_item(f, "text/plain", "/1/2/3")
34
+
35
+ end
36
+
37
+ def test_upload_item_to_uri_with_relative_file
38
+ mc = mock()
39
+ mc.expects(:set_auth)
40
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/a.txt", "data", {"Content-Type" => "text/plain"})
41
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
42
+ f = StringIO.new("data")
43
+ resp = store.upload_item(f, "text/plain", "/a.txt")
44
+
45
+ end
46
+
47
+ def test_upload_item_to_uri_with_relative2
48
+ mc = mock()
49
+ mc.expects(:set_auth)
50
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/1/2/3", "data", {"Content-Type" => "text/plain"})
51
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
52
+ f = StringIO.new("data")
53
+ resp = store.upload_item(f, "text/plain", "1/2/3")
54
+
55
+ end
56
+
57
+ def test_upload_item_to_uri_with_relative_file2
58
+ mc = mock()
59
+ mc.expects(:set_auth)
60
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/a.txt", "data", {"Content-Type" => "text/plain"})
61
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
62
+ f = StringIO.new("data")
63
+ resp = store.upload_item(f, "text/plain", "a.txt")
64
+
65
+ end
66
+
67
+
27
68
  def test_delete
28
69
  mc = mock()
29
70
  mc.expects(:set_auth)
@@ -25,12 +25,31 @@ class EnrichmentTest < Test::Unit::TestCase
25
25
  mc = mock()
26
26
  mc.expects(:query).with( query, "application/rdf+xml" ).returns( HTTP::Message.new_response(RDFXML) )
27
27
 
28
- enricher = Pho::Enrichment::ResourceEnricher.new(mock_store, mc)
28
+ enricher = Pho::Enrichment::StoreEnricher.new(mock_store, mc)
29
29
  resp = enricher.merge(query)
30
30
  assert_not_nil(resp)
31
31
 
32
32
  end
33
33
 
34
+ def test_merge_with_block()
35
+
36
+ query = "DESCRIBE <http://www.example.org>"
37
+ mock_store = mock()
38
+ mock_store.expects(:store_data).with(RDFXML).returns( HTTP::Message.new_response("OK") )
39
+
40
+ mc = mock()
41
+ mc.expects(:query).with( query, "application/rdf+xml" ).returns( HTTP::Message.new_response(RDFXML) )
42
+
43
+ enricher = Pho::Enrichment::StoreEnricher.new(mock_store, mc)
44
+ resp = enricher.merge(query) do |resp, data|
45
+ assert_equal( 200, resp.status )
46
+ assert_equal( RDFXML, data)
47
+ end
48
+
49
+ assert_not_nil(resp)
50
+
51
+ end
52
+
34
53
  def test_merge_with_failed_query()
35
54
 
36
55
  query = "DESCRIBE <http://www.example.org>"
@@ -41,7 +60,7 @@ class EnrichmentTest < Test::Unit::TestCase
41
60
  msg.status = 500
42
61
  mc.expects(:query).with( query, "application/rdf+xml" ).returns( msg )
43
62
 
44
- enricher = Pho::Enrichment::ResourceEnricher.new(mock_store, mc)
63
+ enricher = Pho::Enrichment::StoreEnricher.new(mock_store, mc)
45
64
  assert_raises RuntimeError do
46
65
  results = enricher.merge(query)
47
66
  end
@@ -59,7 +78,7 @@ class EnrichmentTest < Test::Unit::TestCase
59
78
  mc = mock()
60
79
  mc.expects(:query).with( query, "application/rdf+xml" ).returns( HTTP::Message.new_response(RDFXML) )
61
80
 
62
- enricher = Pho::Enrichment::ResourceEnricher.new(mock_store, mc)
81
+ enricher = Pho::Enrichment::StoreEnricher.new(mock_store, mc)
63
82
  resp = enricher.merge(query)
64
83
  assert_equal(500, resp.status)
65
84
 
@@ -75,9 +94,27 @@ class EnrichmentTest < Test::Unit::TestCase
75
94
  mock_store.expects(:sparql_client).returns(mc)
76
95
  mock_store.expects(:store_data).with(RDFXML).returns( HTTP::Message.new_response("OK") )
77
96
 
78
- resp = Pho::Enrichment::ResourceEnricher.infer(mock_store, query)
97
+ resp = Pho::Enrichment::StoreEnricher.infer(mock_store, query)
79
98
  assert_not_nil(resp)
80
99
 
81
100
  end
101
+
102
+ def test_infer_with_block()
103
+ query = "CONSTRUCT { ?s ex:foo ?o } WHERE { ?s ex:bar ?o }"
104
+
105
+ mc = mock()
106
+ mc.expects(:query).with( query, "application/rdf+xml" ).returns( HTTP::Message.new_response(RDFXML) )
107
+
108
+ mock_store = mock()
109
+ mock_store.expects(:sparql_client).returns(mc)
110
+ mock_store.expects(:store_data).with(RDFXML).returns( HTTP::Message.new_response("OK") )
111
+
112
+ resp = Pho::Enrichment::StoreEnricher.infer(mock_store, query) do |resp, data|
113
+ assert_equal(200, resp.status)
114
+ assert_equal(RDFXML, data)
115
+ end
82
116
 
117
+ assert_not_nil(resp)
118
+
119
+ end
83
120
  end
@@ -7,6 +7,8 @@ class FileManagerTest < Test::Unit::TestCase
7
7
 
8
8
  def setup()
9
9
  Dir.mkdir("/tmp/pho") unless File.exists?("/tmp/pho")
10
+ Dir.mkdir("/tmp/pho/a") unless File.exists?("/tmp/pho/a")
11
+ Dir.mkdir("/tmp/pho/b") unless File.exists?("/tmp/pho/b")
10
12
  7.times do |i|
11
13
  file = File.new( File.join("/tmp/pho", "#{i}.css"), "w" )
12
14
  file.write("CSS#{i}")
@@ -28,7 +30,24 @@ class FileManagerTest < Test::Unit::TestCase
28
30
  file = File.new( File.join("/tmp/pho", "#{num}.fail"), "w" )
29
31
  file.write("FAIL")
30
32
  file.close()
31
- end
33
+ end
34
+
35
+ #/tmp/pho/a
36
+ 2.times do |i|
37
+ num = i
38
+ file = File.new( File.join("/tmp/pho/a", "#{num}.txt"), "w" )
39
+ file.write("TXT#{num}")
40
+ file.close()
41
+ end
42
+
43
+ #/tmp/pho/b
44
+ 1.times do |i|
45
+ num = i
46
+ file = File.new( File.join("/tmp/pho/b", "#{num}.txt"), "w" )
47
+ file.write("TXT#{num}")
48
+ file.close()
49
+ end
50
+
32
51
  end
33
52
 
34
53
  def teardown()
@@ -38,12 +57,15 @@ class FileManagerTest < Test::Unit::TestCase
38
57
  Dir.glob("/tmp/pho/*.js") do |file|
39
58
  File.delete(file)
40
59
  end
41
- Dir.glob("/tmp/pho/*.ok") do |file|
60
+ Dir.glob("/tmp/pho/**/*.ok") do |file|
42
61
  File.delete(file)
43
62
  end
44
- Dir.glob("/tmp/pho/*.fail") do |file|
63
+ Dir.glob("/tmp/pho/**/*.fail") do |file|
45
64
  File.delete(file)
46
- end
65
+ end
66
+ Dir.glob("/tmp/pho/**/*.txt") do |file|
67
+ File.delete(file)
68
+ end
47
69
  end
48
70
 
49
71
  def test_new_files()
@@ -58,14 +80,31 @@ class FileManagerTest < Test::Unit::TestCase
58
80
  assert_equal("/tmp/pho/9.js", newfiles[2])
59
81
 
60
82
  end
83
+
84
+ def test_new_files_recursive()
85
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
86
+ collection = Pho::FileManagement::FileManager.new(store, "/tmp/pho")
87
+
88
+ newfiles = collection.new_files(:recurse)
89
+ newfiles.sort!
90
+
91
+ assert_equal(6, newfiles.size)
92
+ assert_equal("/tmp/pho/7.js", newfiles[0])
93
+ assert_equal("/tmp/pho/8.js", newfiles[1])
94
+ assert_equal("/tmp/pho/9.js", newfiles[2])
95
+ assert_equal("/tmp/pho/a/0.txt", newfiles[3])
96
+ assert_equal("/tmp/pho/a/1.txt", newfiles[4])
97
+ assert_equal("/tmp/pho/b/0.txt", newfiles[5])
98
+
99
+ end
61
100
 
62
101
  def test_store()
63
102
  mc = mock()
64
103
  mc.expects(:set_auth)
65
104
  #mc.stub_everything()
66
- mc.expects(:post).with("http://api.talis.com/stores/testing/items", "JS7", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
67
- mc.expects(:post).with("http://api.talis.com/stores/testing/items", "JS8", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
68
- mc.expects(:post).with("http://api.talis.com/stores/testing/items", "JS9", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
105
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/7.js", "JS7", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
106
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/8.js", "JS8", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
107
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/9.js", "JS9", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
69
108
 
70
109
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
71
110
  collection = Pho::FileManagement::FileManager.new(store, "/tmp/pho")
@@ -76,6 +115,49 @@ class FileManagerTest < Test::Unit::TestCase
76
115
  assert_equal(true, File.exists?("/tmp/pho/9.ok") )
77
116
 
78
117
  end
118
+
119
+ def test_store_with_base()
120
+ mc = mock()
121
+ mc.expects(:set_auth)
122
+ #mc.stub_everything()
123
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/assets/7.js", "JS7", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
124
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/assets/8.js", "JS8", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
125
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/assets/9.js", "JS9", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
126
+
127
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
128
+ collection = Pho::FileManagement::FileManager.new(store, "/tmp/pho", "assets")
129
+ collection.store()
130
+
131
+ assert_equal(true, File.exists?("/tmp/pho/7.ok") )
132
+ assert_equal(true, File.exists?("/tmp/pho/8.ok") )
133
+ assert_equal(true, File.exists?("/tmp/pho/9.ok") )
134
+
135
+ end
136
+
137
+
138
+ def test_store_recursive()
139
+ mc = mock()
140
+ mc.expects(:set_auth)
141
+ #mc.stub_everything()
142
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/7.js", "JS7", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
143
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/8.js", "JS8", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
144
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/9.js", "JS9", {"Content-Type" => "application/javascript"}).returns( HTTP::Message.new_response("OK"))
145
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/a/0.txt", "TXT0", {"Content-Type" => "text/plain"}).returns( HTTP::Message.new_response("OK"))
146
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/a/1.txt", "TXT1", {"Content-Type" => "text/plain"}).returns( HTTP::Message.new_response("OK"))
147
+ mc.expects(:put).with("http://api.talis.com/stores/testing/items/b/0.txt", "TXT0", {"Content-Type" => "text/plain"}).returns( HTTP::Message.new_response("OK"))
148
+
149
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
150
+ collection = Pho::FileManagement::FileManager.new(store, "/tmp/pho")
151
+ collection.store(:recursive)
152
+
153
+ assert_equal(true, File.exists?("/tmp/pho/7.ok") )
154
+ assert_equal(true, File.exists?("/tmp/pho/8.ok") )
155
+ assert_equal(true, File.exists?("/tmp/pho/9.ok") )
156
+ assert_equal(true, File.exists?("/tmp/pho/a/0.ok") )
157
+ assert_equal(true, File.exists?("/tmp/pho/a/1.ok") )
158
+ assert_equal(true, File.exists?("/tmp/pho/b/0.ok") )
159
+
160
+ end
79
161
 
80
162
  def test_list()
81
163
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
@@ -85,4 +167,12 @@ class FileManagerTest < Test::Unit::TestCase
85
167
  assert_equal(10, files.size)
86
168
  end
87
169
 
170
+ def test_list_recursive()
171
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
172
+ collection = Pho::FileManagement::FileManager.new(store, "/tmp/pho")
173
+
174
+ files = collection.list(:recurse)
175
+ assert_equal(13, files.size)
176
+ end
177
+
88
178
  end
@@ -4,7 +4,6 @@ require 'test/unit'
4
4
  require 'mocha'
5
5
 
6
6
  #TODO factor out tests for AbstractFileManager
7
- #TODO alter so we're testing the non-deprecated version of the Class
8
7
  class RDFCollectionTest < Test::Unit::TestCase
9
8
 
10
9
  def setup()
@@ -40,21 +39,36 @@ class RDFCollectionTest < Test::Unit::TestCase
40
39
 
41
40
  def test_get_fail_file_for()
42
41
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
43
- collection = Pho::RDFCollection.new(store, "/tmp")
42
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
44
43
 
45
44
  assert_equal("foo.fail", collection.get_fail_file_for("foo.rdf") )
46
45
  end
47
-
46
+
47
+ def test_get_fail_file_for_with_ext_in_path()
48
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
49
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp/rdf")
50
+
51
+ assert_equal("/tmp/rdf/foo.fail", collection.get_fail_file_for("/tmp/rdf/foo.rdf") )
52
+ end
53
+
48
54
  def test_get_ok_file_for()
49
55
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
50
- collection = Pho::RDFCollection.new(store, "/tmp")
56
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
51
57
 
52
58
  assert_equal("foo.ok", collection.get_ok_file_for("foo.rdf") )
53
59
  end
54
60
 
61
+ def test_get_ok_file_for_with_ext_in_path()
62
+ store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
63
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp/js")
64
+
65
+ assert_equal("/tmp/js/foo.ok", collection.get_ok_file_for("/tmp/js/foo.js") )
66
+ end
67
+
68
+
55
69
  def test_successes()
56
70
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
57
- collection = Pho::RDFCollection.new(store, "/tmp")
71
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
58
72
 
59
73
  success = collection.successes()
60
74
  success.sort!
@@ -68,7 +82,7 @@ class RDFCollectionTest < Test::Unit::TestCase
68
82
 
69
83
  def test_failures()
70
84
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
71
- collection = Pho::RDFCollection.new(store, "/tmp")
85
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
72
86
 
73
87
  fails = collection.failures()
74
88
  fails.sort!
@@ -80,7 +94,7 @@ class RDFCollectionTest < Test::Unit::TestCase
80
94
 
81
95
  def test_new_files()
82
96
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
83
- collection = Pho::RDFCollection.new(store, "/tmp")
97
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
84
98
 
85
99
  newfiles = collection.new_files()
86
100
  newfiles.sort!
@@ -99,7 +113,7 @@ class RDFCollectionTest < Test::Unit::TestCase
99
113
  mc.expects(:post).with("http://api.talis.com/stores/testing/meta", "RDF9", {"Content-Type" => "application/rdf+xml"}).returns( HTTP::Message.new_response("OK"))
100
114
 
101
115
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass", mc)
102
- collection = Pho::RDFCollection.new(store, "/tmp")
116
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
103
117
  collection.store()
104
118
 
105
119
  assert_equal(true, File.exists?("/tmp/7.ok") )
@@ -110,7 +124,7 @@ class RDFCollectionTest < Test::Unit::TestCase
110
124
 
111
125
  def test_reset()
112
126
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
113
- collection = Pho::RDFCollection.new(store, "/tmp")
127
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
114
128
 
115
129
  collection.reset()
116
130
  newfiles = collection.new_files()
@@ -119,7 +133,7 @@ class RDFCollectionTest < Test::Unit::TestCase
119
133
 
120
134
  def test_list()
121
135
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
122
- collection = Pho::RDFCollection.new(store, "/tmp")
136
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
123
137
 
124
138
  files = collection.list()
125
139
  assert_equal(10, files.size)
@@ -127,9 +141,7 @@ class RDFCollectionTest < Test::Unit::TestCase
127
141
 
128
142
  def test_summary()
129
143
  store = Pho::Store.new("http://api.talis.com/stores/testing", "user", "pass")
130
- collection = Pho::RDFCollection.new(store, "/tmp")
131
-
132
- collection.summary()
144
+ collection = Pho::FileManagement::RDFManager.new(store, "/tmp")
133
145
  end
134
146
 
135
147
  end
@@ -0,0 +1,37 @@
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 RdfParserTest < Test::Unit::TestCase
8
+
9
+ NTRIPLES = <<-EOL
10
+ <http://www.example.org> <http://www.example.org/ns/resource> <http://www.example.org/page>.
11
+ EOL
12
+
13
+ def setup()
14
+ Dir.mkdir("/tmp/pho") unless File.exists?("/tmp/pho")
15
+ @file = File.new( File.join("/tmp/pho", "test.nt"), "w" )
16
+ @file.write(NTRIPLES)
17
+ @file.close()
18
+ end
19
+
20
+ def teardown()
21
+ Dir.glob("/tmp/pho/*.nt") do |file|
22
+ File.delete(file)
23
+ end
24
+ end
25
+
26
+ def test_parse_ntriples
27
+ data = Pho::RDF::Parser.parse_ntriples(@file)
28
+ assert_not_nil(data)
29
+ REXML::Document.new(data)
30
+ end
31
+
32
+ def test_parse_ntriples_from_string
33
+ data = Pho::RDF::Parser.parse_ntriples_from_string(NTRIPLES, "http://www.example.org")
34
+ assert_not_nil(data)
35
+ REXML::Document.new(data)
36
+ end
37
+ end