pho 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +17 -0
- data/Rakefile +10 -2
- data/bin/talis_store +37 -92
- data/doc/rdoc/classes/Pho.html +11 -0
- data/doc/rdoc/classes/Pho/CommandLine.html +508 -0
- data/doc/rdoc/classes/Pho/DatatypeProperty.html +15 -15
- data/doc/rdoc/classes/Pho/Enrichment.html +1 -1
- data/doc/rdoc/classes/Pho/Enrichment/{ResourceEnricher.html → StoreEnricher.html} +158 -58
- 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 +94 -94
- data/doc/rdoc/classes/Pho/FieldWeighting.html +14 -14
- data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +126 -91
- data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +68 -62
- data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +22 -57
- data/doc/rdoc/classes/Pho/Job.html +68 -67
- data/doc/rdoc/classes/Pho/Jobs.html +62 -62
- data/doc/rdoc/classes/Pho/QueryProfile.html +64 -64
- data/doc/rdoc/classes/Pho/RDF.html +120 -0
- data/doc/rdoc/classes/Pho/RDF/Parser.html +277 -0
- data/doc/rdoc/classes/Pho/ResourceHash.html +1 -1
- data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +48 -46
- data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +15 -14
- data/doc/rdoc/classes/Pho/Snapshot.html +36 -36
- data/doc/rdoc/classes/Pho/Sparql.html +50 -0
- data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +147 -68
- data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +195 -114
- data/doc/rdoc/classes/Pho/Status.html +26 -26
- data/doc/rdoc/classes/Pho/Store.html +271 -264
- data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
- data/doc/rdoc/classes/Pho/Update.html +1 -0
- data/doc/rdoc/classes/Pho/Update/Changeset.html +69 -68
- data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +24 -24
- data/doc/rdoc/classes/Pho/Update/Changesets.html +15 -14
- data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +18 -18
- data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +24 -24
- data/doc/rdoc/classes/Pho/Update/Statement.html +28 -27
- data/doc/rdoc/classes/String.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +53 -1
- data/doc/rdoc/files/lib/pho/changeset_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
- data/doc/rdoc/files/lib/pho/converter_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/enrichment_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/file_management_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/file_manager_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
- data/doc/rdoc/files/lib/pho/sparql_rb.html +1 -1
- data/doc/rdoc/files/lib/pho/store_rb.html +8 -1
- data/doc/rdoc/files/lib/pho_rb.html +4 -2
- data/doc/rdoc/fr_class_index.html +6 -1
- data/doc/rdoc/fr_file_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +192 -172
- data/examples/calais/bio.txt +7 -0
- data/examples/calais/dump.rb +17 -0
- data/examples/calais/enlighten.rb +23 -0
- data/examples/calais/output.rdf +25 -0
- data/examples/sinatra/viewer.rb +20 -0
- data/lib/pho.rb +4 -1
- data/lib/pho/changeset.rb +17 -1
- data/lib/pho/command_line.rb +166 -0
- data/lib/pho/converter.rb +8 -3
- data/lib/pho/enrichment.rb +93 -28
- data/lib/pho/file_management.rb +32 -19
- data/lib/pho/file_manager.rb +22 -26
- data/lib/pho/rdf.rb +74 -0
- data/lib/pho/rdf_collection.rb +2 -17
- data/lib/pho/sparql.rb +150 -38
- data/lib/pho/store.rb +28 -2
- data/tests/tc_contentbox.rb +41 -0
- data/tests/tc_enrichment.rb +41 -4
- data/tests/tc_file_manager.rb +97 -7
- data/tests/tc_rdf_collection.rb +25 -13
- data/tests/tc_rdf_parser.rb +37 -0
- data/tests/tc_sparql.rb +72 -2
- data/tests/tc_sparql_helper.rb +16 -0
- data/tests/ts_pho.rb +2 -1
- metadata +20 -3
data/CHANGES
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
Brief notes on significant changes and additions in each release
|
2
2
|
|
3
|
+
== Version 0.6
|
4
|
+
|
5
|
+
* Refactored talis_store command extracting code into Pho::CommandLine
|
6
|
+
* Tweaked talis_store command, so attempt to store .nt file will trigger conversion into RDF/XML before submitting to Platform
|
7
|
+
* Added Pho::RDF module for general rdf utilities. Initially has method to convert ntriples into rdf/xml and to store that in the platform
|
8
|
+
* At suggestion of @chrislowis added rescue around redland dependent requires.
|
9
|
+
* talis_store command-line now supports "upload" option for storing individual files or directories
|
10
|
+
* Added support for directory traversal to RDFManager and FileManager classes
|
11
|
+
* Fixed bug in counting files being managed in RDFManager
|
12
|
+
* Fixed file naming bug in AbstractFileManager, when path contains file extension
|
13
|
+
* Added support for block to StoreEnricher.merge and StoreEnricher.infer
|
14
|
+
* Renamed ResourceEnricher to StoreEnricher
|
15
|
+
* Reimplemented ResourceEnricher.enrich method to support both a callback and a block
|
16
|
+
* Added StoreSparqlClient to extend default client, and rewrite describe_uri queries as describe service calls
|
17
|
+
* Added SparqlClient.describe_uri and SparqlHelper.describe_uri methods for generating different forms
|
18
|
+
of Bounded Description for a resource
|
19
|
+
|
3
20
|
== Version 0.5
|
4
21
|
|
5
22
|
NOTE: Released 0.4.1 version of the gem at this point to support earlier versions of
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
|
|
5
5
|
require 'rake/clean'
|
6
6
|
|
7
7
|
NAME = "pho"
|
8
|
-
VER = "0.
|
8
|
+
VER = "0.6"
|
9
9
|
|
10
10
|
RDOC_OPTS = ['--quiet', '--title', 'Pho (Talis Platform Client) Reference', '--main', 'README']
|
11
11
|
|
@@ -51,17 +51,25 @@ Rake::RDocTask.new do |rdoc|
|
|
51
51
|
|
52
52
|
end
|
53
53
|
|
54
|
+
desc "Publish rdoc output to rubyforge"
|
55
|
+
task "publish-docs" => ["rdoc"] do
|
56
|
+
rubyforge_path = "/var/www/gforge-projects/#{NAME}/"
|
57
|
+
sh "scp -r doc/* " +
|
58
|
+
"#{ENV["RUBYFORGE_USER"]}@rubyforge.org:#{rubyforge_path}",
|
59
|
+
:verbose => true
|
60
|
+
end
|
54
61
|
|
55
62
|
Rake::TestTask.new do |test|
|
56
63
|
test.test_files = FileList['tests/tc_*.rb']
|
57
64
|
end
|
58
65
|
|
66
|
+
desc "Install from a locally built copy of the gem"
|
59
67
|
task :install do
|
60
68
|
sh %{rake package}
|
61
69
|
sh %{sudo gem install pkg/#{NAME}-#{VER}}
|
62
70
|
end
|
63
71
|
|
64
|
-
|
72
|
+
desc "Uninstall the gem"
|
65
73
|
task :uninstall => [:clean] do
|
66
74
|
sh %{sudo gem uninstall #{NAME}}
|
67
75
|
end
|
data/bin/talis_store
CHANGED
@@ -75,7 +75,7 @@ MODE
|
|
75
75
|
Show read-write status of the store
|
76
76
|
|
77
77
|
store
|
78
|
-
Upload some RDF data to the Platform. Can either specify a local file, or a URL
|
78
|
+
Upload some RDF data to the metabox in a Platform store. Can either specify a local file, or a URL
|
79
79
|
When a url is specified, then the data is retrieved and then submitted to the Platform
|
80
80
|
Can also be used to store an entire directory of RDF/XML using the --dir option.
|
81
81
|
|
@@ -84,7 +84,19 @@ MODE
|
|
84
84
|
#{ PROGRAM } store -u user -p pass -s my-dev1 -f /tmp/data.rdf
|
85
85
|
#{ PROGRAM } store -u user -p pass -s my-dev1 -r http://www.example.net/data/somedata.rdf
|
86
86
|
#{ PROGRAM } store -u user -p pass -s my-dev1 -d ~/data
|
87
|
-
|
87
|
+
|
88
|
+
upload
|
89
|
+
Upload some files to the contentbox in a Platform store. Can either specify a local file, or
|
90
|
+
an entire directory of files using the --dir option. Directories can be traversed using the
|
91
|
+
--traverse option.
|
92
|
+
|
93
|
+
example :
|
94
|
+
|
95
|
+
#{ PROGRAM } upload -u user -p pass -s my-dev1 -f /tmp/file.txt
|
96
|
+
#{ PROGRAM } upload -u user -p pass -s my-dev1 -d ~/files
|
97
|
+
#{ PROGRAM } upload -u user -p pass -s my-dev1 --traverse -d ~/files
|
98
|
+
#{ PROGRAM } upload -u user -p pass -s my-dev1 --traverse -d ~/files --base assets
|
99
|
+
|
88
100
|
OPTIONS
|
89
101
|
|
90
102
|
--help , -h
|
@@ -101,7 +113,10 @@ OPTIONS
|
|
101
113
|
specify a file name, e.g. data to upload
|
102
114
|
--dir
|
103
115
|
specify a directory, e.g. containing data to upload or location to place data.
|
104
|
-
|
116
|
+
--traverse
|
117
|
+
recursively store files or RDF
|
118
|
+
--base
|
119
|
+
base path for uploading files to content box
|
105
120
|
EOL
|
106
121
|
|
107
122
|
mode = ARGV.shift
|
@@ -113,7 +128,9 @@ opts = GetoptLong::new(
|
|
113
128
|
[ "--store" , "-s" , GetoptLong::REQUIRED_ARGUMENT ],
|
114
129
|
[ "--url" , "-r" , GetoptLong::REQUIRED_ARGUMENT ],
|
115
130
|
[ "--file" , "-f" , GetoptLong::REQUIRED_ARGUMENT ],
|
116
|
-
[ "--dir" , "-d" , GetoptLong::REQUIRED_ARGUMENT ]
|
131
|
+
[ "--dir" , "-d" , GetoptLong::REQUIRED_ARGUMENT ],
|
132
|
+
[ "--traverse" , "-t" , GetoptLong::NO_ARGUMENT ],
|
133
|
+
[ "--base" , "-b" , GetoptLong::REQUIRED_ARGUMENT ]
|
117
134
|
).enum_for.inject({}) { |h, (k, v)| h.update k.delete('-') => v }
|
118
135
|
|
119
136
|
mode = "help" if opts["--help"]
|
@@ -141,115 +158,43 @@ else
|
|
141
158
|
end
|
142
159
|
|
143
160
|
store = Pho::Store.new(storename, opts["username"], opts["password"])
|
161
|
+
cmds = Pho::CommandLine.new(store, opts)
|
144
162
|
|
145
163
|
#begin
|
146
164
|
|
147
165
|
case mode
|
148
166
|
when "status"
|
149
|
-
status
|
150
|
-
puts "Store Status:\nReadable: #{status.readable?}\nWritable: #{status.writeable?}"
|
167
|
+
cmds.status()
|
151
168
|
when "backup"
|
152
|
-
|
153
|
-
resp = Pho::Jobs.submit_snapshot(store, "Reindex", Time.now)
|
154
|
-
puts "Monitoring Job"
|
155
|
-
job = Pho::Jobs.wait_for_submitted(resp, store) do |job, message, time|
|
156
|
-
puts "#{time} #{message}"
|
157
|
-
end
|
158
|
-
puts "Job Completed"
|
159
|
-
snapshot = Pho::Snapshot.read_from_store(store)
|
160
|
-
puts "Retrieving #{snapshot.url}"
|
161
|
-
dir = opts["dir"] || Dir.tmpdir
|
162
|
-
snapshot.backup(store, dir)
|
163
|
-
puts "Download complete. MD5 OK."
|
169
|
+
cmds.backup()
|
164
170
|
when "snapshot"
|
165
|
-
|
166
|
-
resp = Pho::Jobs.submit_snapshot(store, "Reindex", Time.now)
|
167
|
-
puts "Monitoring Job"
|
168
|
-
job = Pho::Jobs.wait_for_submitted(resp, store) do |job, message, time|
|
169
|
-
puts "#{time} #{message}"
|
170
|
-
end
|
171
|
-
puts "Snapshot Completed"
|
171
|
+
cmds.snapshot()
|
172
172
|
when "reindex"
|
173
|
-
|
174
|
-
resp = Pho::Jobs.submit_reindex(store, "Reindex", Time.now)
|
175
|
-
if resp.status == 201
|
176
|
-
puts "Monitoring Reindex Job: #{resp.header["Location"].first}"
|
177
|
-
end
|
178
|
-
job = Pho::Jobs.wait_for_submitted(resp, store) do |job, message, time|
|
179
|
-
puts "#{time} #{message}"
|
180
|
-
end
|
181
|
-
puts "Reindex Completed"
|
173
|
+
cmds.reindex()
|
182
174
|
when "reset"
|
183
|
-
|
184
|
-
resp = Pho::Jobs.submit_reset(store, "Reset", Time.now)
|
185
|
-
puts "Monitoring Reset Job:"
|
186
|
-
job = Pho::Jobs.wait_for_submitted(resp, store) do |job, message, time|
|
187
|
-
puts "#{time} #{message}"
|
188
|
-
end
|
189
|
-
puts "Reset Completed"
|
175
|
+
cmds.reset()
|
190
176
|
when "restore"
|
191
|
-
|
192
|
-
if url == nil
|
193
|
-
puts "Restore from latest snapshot"
|
194
|
-
snapshot = Pho::Snapshot.read_from_store(store)
|
195
|
-
url = snapshot.url
|
196
|
-
end
|
197
|
-
puts "Restoring from #{url}"
|
198
|
-
resp = Pho::Jobs.submit_restore(store, url, "Reset", Time.now)
|
199
|
-
job = Pho::Jobs.wait_for_submitted(resp, store) do |job, message, time|
|
200
|
-
puts "#{time} #{message}"
|
201
|
-
end
|
202
|
-
puts "Restore Completed"
|
177
|
+
cmds.restore()
|
203
178
|
when "store"
|
204
|
-
|
205
|
-
if opts["url"]
|
206
|
-
puts "Storing remote data: #{opts["url"]}"
|
207
|
-
resp = store.store_url( opts["url"] )
|
208
|
-
elsif opts["file"]
|
209
|
-
puts "Storing local file: #{opts["file"]}"
|
210
|
-
resp = store.store_file( File.new( opts["file"] ) )
|
211
|
-
elsif opts["dir"]
|
212
|
-
puts "Storing contents of directory: #{opts["dir"]}"
|
213
|
-
collection = Pho::RDFCollection.new(store, opts["dir"])
|
214
|
-
collection.store()
|
215
|
-
puts collection.summary()
|
216
|
-
else
|
179
|
+
if opts["file"] == nil && opts["dir"] == nil && opts["url"] == nil
|
217
180
|
abort USAGE
|
218
|
-
end
|
219
|
-
|
220
|
-
if resp != nil
|
221
|
-
if resp.status == 204
|
222
|
-
puts "Complete"
|
223
|
-
else
|
224
|
-
puts "Error: #{resp.status} #{resp.reason}"
|
225
|
-
puts resp.content
|
226
|
-
end
|
227
181
|
end
|
228
|
-
|
182
|
+
cmds.store()
|
183
|
+
when "upload"
|
184
|
+
if opts["file"] == nil && opts["dir"] == nil && opts["url"] == nil
|
185
|
+
abort USAGE
|
186
|
+
end
|
187
|
+
cmds.upload()
|
229
188
|
when "describe"
|
230
189
|
if opts["url"] == nil
|
231
190
|
abort USAGE
|
232
191
|
end
|
233
|
-
|
234
|
-
if resp.status == 200
|
235
|
-
puts resp.content
|
236
|
-
else
|
237
|
-
puts "Error: #{resp.status} #{resp.reason}"
|
238
|
-
puts resp.content
|
239
|
-
end
|
192
|
+
cmds.describe()
|
240
193
|
when "sparql"
|
241
194
|
if opts["file"] == nil
|
242
195
|
abort USAGE
|
243
196
|
end
|
244
|
-
|
245
|
-
resp = store.sparql(query)
|
246
|
-
if resp.status == 200
|
247
|
-
puts resp.content
|
248
|
-
else
|
249
|
-
puts "Error: #{resp.status} #{resp.reason}"
|
250
|
-
puts resp.content
|
251
|
-
end
|
252
|
-
|
197
|
+
cmds.sparql()
|
253
198
|
else
|
254
199
|
abort USAGE
|
255
200
|
end
|
data/doc/rdoc/classes/Pho.html
CHANGED
@@ -62,6 +62,10 @@
|
|
62
62
|
<a href="../files/lib/pho/changeset_builder_rb.html">
|
63
63
|
lib/pho/changeset_builder.rb
|
64
64
|
</a>
|
65
|
+
<br />
|
66
|
+
<a href="../files/lib/pho/rdf_rb.html">
|
67
|
+
lib/pho/rdf.rb
|
68
|
+
</a>
|
65
69
|
<br />
|
66
70
|
<a href="../files/lib/pho/file_manager_rb.html">
|
67
71
|
lib/pho/file_manager.rb
|
@@ -74,6 +78,10 @@
|
|
74
78
|
<a href="../files/lib/pho/enrichment_rb.html">
|
75
79
|
lib/pho/enrichment.rb
|
76
80
|
</a>
|
81
|
+
<br />
|
82
|
+
<a href="../files/lib/pho/command_line_rb.html">
|
83
|
+
lib/pho/command_line.rb
|
84
|
+
</a>
|
77
85
|
<br />
|
78
86
|
<a href="../files/lib/pho/status_rb.html">
|
79
87
|
lib/pho/status.rb
|
@@ -164,10 +172,12 @@ TODO put together proper test suite for this
|
|
164
172
|
Module <a href="Pho/Enrichment.html" class="link">Pho::Enrichment</a><br />
|
165
173
|
Module <a href="Pho/Facet.html" class="link">Pho::Facet</a><br />
|
166
174
|
Module <a href="Pho/FileManagement.html" class="link">Pho::FileManagement</a><br />
|
175
|
+
Module <a href="Pho/RDF.html" class="link">Pho::RDF</a><br />
|
167
176
|
Module <a href="Pho/ResourceHash.html" class="link">Pho::ResourceHash</a><br />
|
168
177
|
Module <a href="Pho/Sparql.html" class="link">Pho::Sparql</a><br />
|
169
178
|
Module <a href="Pho/Update.html" class="link">Pho::Update</a><br />
|
170
179
|
Class <a href="Pho/Analyzers.html" class="link">Pho::Analyzers</a><br />
|
180
|
+
Class <a href="Pho/CommandLine.html" class="link">Pho::CommandLine</a><br />
|
171
181
|
Class <a href="Pho/DatatypeProperty.html" class="link">Pho::DatatypeProperty</a><br />
|
172
182
|
Class <a href="Pho/Etags.html" class="link">Pho::Etags</a><br />
|
173
183
|
Class <a href="Pho/FieldPredicateMap.html" class="link">Pho::FieldPredicateMap</a><br />
|
@@ -181,6 +191,7 @@ Class <a href="Pho/RDFCollection.html" class="link">Pho::RDFCollection</a><br />
|
|
181
191
|
Class <a href="Pho/Snapshot.html" class="link">Pho::Snapshot</a><br />
|
182
192
|
Class <a href="Pho/Status.html" class="link">Pho::Status</a><br />
|
183
193
|
Class <a href="Pho/Store.html" class="link">Pho::Store</a><br />
|
194
|
+
Class <a href="Pho/StoreSparqlClient.html" class="link">Pho::StoreSparqlClient</a><br />
|
184
195
|
|
185
196
|
</div>
|
186
197
|
|
@@ -0,0 +1,508 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Class: Pho::CommandLine</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Pho::CommandLine</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/pho/command_line_rb.html">
|
59
|
+
lib/pho/command_line.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
Class that implements the command-line behaviour
|
84
|
+
</p>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
</div>
|
90
|
+
|
91
|
+
<div id="method-list">
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
93
|
+
|
94
|
+
<div class="name-list">
|
95
|
+
<a href="#M000109">backup</a>
|
96
|
+
<a href="#M000114">describe</a>
|
97
|
+
<a href="#M000107">new</a>
|
98
|
+
<a href="#M000111">reindex</a>
|
99
|
+
<a href="#M000112">reset</a>
|
100
|
+
<a href="#M000113">restore</a>
|
101
|
+
<a href="#M000110">snapshot</a>
|
102
|
+
<a href="#M000115">sparql</a>
|
103
|
+
<a href="#M000108">status</a>
|
104
|
+
<a href="#M000116">store</a>
|
105
|
+
<a href="#M000117">upload</a>
|
106
|
+
</div>
|
107
|
+
</div>
|
108
|
+
|
109
|
+
</div>
|
110
|
+
|
111
|
+
|
112
|
+
<!-- if includes -->
|
113
|
+
|
114
|
+
<div id="section">
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
<!-- if method_list -->
|
124
|
+
<div id="methods">
|
125
|
+
<h3 class="section-bar">Public Class methods</h3>
|
126
|
+
|
127
|
+
<div id="method-M000107" class="method-detail">
|
128
|
+
<a name="M000107"></a>
|
129
|
+
|
130
|
+
<div class="method-heading">
|
131
|
+
<a href="#M000107" class="method-signature">
|
132
|
+
<span class="method-name">new</span><span class="method-args">(store, opts)</span>
|
133
|
+
</a>
|
134
|
+
</div>
|
135
|
+
|
136
|
+
<div class="method-description">
|
137
|
+
<p><a class="source-toggle" href="#"
|
138
|
+
onclick="toggleCode('M000107-source');return false;">[Source]</a></p>
|
139
|
+
<div class="method-source-code" id="M000107-source">
|
140
|
+
<pre>
|
141
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 6</span>
|
142
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">opts</span>)
|
143
|
+
<span class="ruby-ivar">@store</span> = <span class="ruby-identifier">store</span>
|
144
|
+
<span class="ruby-ivar">@opts</span> = <span class="ruby-identifier">opts</span>
|
145
|
+
<span class="ruby-keyword kw">end</span>
|
146
|
+
</pre>
|
147
|
+
</div>
|
148
|
+
</div>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
152
|
+
|
153
|
+
<div id="method-M000109" class="method-detail">
|
154
|
+
<a name="M000109"></a>
|
155
|
+
|
156
|
+
<div class="method-heading">
|
157
|
+
<a href="#M000109" class="method-signature">
|
158
|
+
<span class="method-name">backup</span><span class="method-args">()</span>
|
159
|
+
</a>
|
160
|
+
</div>
|
161
|
+
|
162
|
+
<div class="method-description">
|
163
|
+
<p><a class="source-toggle" href="#"
|
164
|
+
onclick="toggleCode('M000109-source');return false;">[Source]</a></p>
|
165
|
+
<div class="method-source-code" id="M000109-source">
|
166
|
+
<pre>
|
167
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 16</span>
|
168
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">backup</span>()
|
169
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Submitting Snapshot Job"</span>
|
170
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">submit_snapshot</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-value str">"Reindex"</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
|
171
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Monitoring Job"</span>
|
172
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">wait_for_submitted</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-ivar">@store</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">job</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
|
173
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{time} #{message}"</span>
|
174
|
+
<span class="ruby-keyword kw">end</span>
|
175
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Job Completed"</span>
|
176
|
+
<span class="ruby-identifier">snapshot</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">read_from_store</span>(<span class="ruby-ivar">@store</span>)
|
177
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Retrieving #{snapshot.url}"</span>
|
178
|
+
<span class="ruby-identifier">dir</span> = <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"dir"</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>
|
179
|
+
<span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">backup</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-identifier">dir</span>)
|
180
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Download complete. MD5 OK."</span>
|
181
|
+
<span class="ruby-keyword kw">end</span>
|
182
|
+
</pre>
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
</div>
|
186
|
+
|
187
|
+
<div id="method-M000114" class="method-detail">
|
188
|
+
<a name="M000114"></a>
|
189
|
+
|
190
|
+
<div class="method-heading">
|
191
|
+
<a href="#M000114" class="method-signature">
|
192
|
+
<span class="method-name">describe</span><span class="method-args">()</span>
|
193
|
+
</a>
|
194
|
+
</div>
|
195
|
+
|
196
|
+
<div class="method-description">
|
197
|
+
<p><a class="source-toggle" href="#"
|
198
|
+
onclick="toggleCode('M000114-source');return false;">[Source]</a></p>
|
199
|
+
<div class="method-source-code" id="M000114-source">
|
200
|
+
<pre>
|
201
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 78</span>
|
202
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">describe</span>()
|
203
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">describe</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"url"</span>] )
|
204
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
|
205
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
206
|
+
<span class="ruby-keyword kw">else</span>
|
207
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Error: #{resp.status} #{resp.reason}"</span>
|
208
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
209
|
+
<span class="ruby-keyword kw">end</span>
|
210
|
+
<span class="ruby-keyword kw">end</span>
|
211
|
+
</pre>
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
</div>
|
215
|
+
|
216
|
+
<div id="method-M000111" class="method-detail">
|
217
|
+
<a name="M000111"></a>
|
218
|
+
|
219
|
+
<div class="method-heading">
|
220
|
+
<a href="#M000111" class="method-signature">
|
221
|
+
<span class="method-name">reindex</span><span class="method-args">()</span>
|
222
|
+
</a>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
<div class="method-description">
|
226
|
+
<p><a class="source-toggle" href="#"
|
227
|
+
onclick="toggleCode('M000111-source');return false;">[Source]</a></p>
|
228
|
+
<div class="method-source-code" id="M000111-source">
|
229
|
+
<pre>
|
230
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 41</span>
|
231
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reindex</span>()
|
232
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Submitting Reindex Job"</span>
|
233
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">submit_reindex</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-value str">"Reindex"</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
|
234
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">201</span>
|
235
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Monitoring Reindex Job: #{resp.header["Location"].first}"</span>
|
236
|
+
<span class="ruby-keyword kw">end</span>
|
237
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">wait_for_submitted</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-ivar">@store</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">job</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
|
238
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{time} #{message}"</span>
|
239
|
+
<span class="ruby-keyword kw">end</span>
|
240
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Reindex Completed"</span>
|
241
|
+
<span class="ruby-keyword kw">end</span>
|
242
|
+
</pre>
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
<div id="method-M000112" class="method-detail">
|
248
|
+
<a name="M000112"></a>
|
249
|
+
|
250
|
+
<div class="method-heading">
|
251
|
+
<a href="#M000112" class="method-signature">
|
252
|
+
<span class="method-name">reset</span><span class="method-args">()</span>
|
253
|
+
</a>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
<div class="method-description">
|
257
|
+
<p><a class="source-toggle" href="#"
|
258
|
+
onclick="toggleCode('M000112-source');return false;">[Source]</a></p>
|
259
|
+
<div class="method-source-code" id="M000112-source">
|
260
|
+
<pre>
|
261
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 53</span>
|
262
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reset</span>()
|
263
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Resetting Store"</span>
|
264
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">submit_reset</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-value str">"Reset"</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
|
265
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Monitoring Reset Job:"</span>
|
266
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">wait_for_submitted</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-ivar">@store</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">job</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
|
267
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{time} #{message}"</span>
|
268
|
+
<span class="ruby-keyword kw">end</span>
|
269
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Reset Completed"</span>
|
270
|
+
<span class="ruby-keyword kw">end</span>
|
271
|
+
</pre>
|
272
|
+
</div>
|
273
|
+
</div>
|
274
|
+
</div>
|
275
|
+
|
276
|
+
<div id="method-M000113" class="method-detail">
|
277
|
+
<a name="M000113"></a>
|
278
|
+
|
279
|
+
<div class="method-heading">
|
280
|
+
<a href="#M000113" class="method-signature">
|
281
|
+
<span class="method-name">restore</span><span class="method-args">()</span>
|
282
|
+
</a>
|
283
|
+
</div>
|
284
|
+
|
285
|
+
<div class="method-description">
|
286
|
+
<p><a class="source-toggle" href="#"
|
287
|
+
onclick="toggleCode('M000113-source');return false;">[Source]</a></p>
|
288
|
+
<div class="method-source-code" id="M000113-source">
|
289
|
+
<pre>
|
290
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 63</span>
|
291
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">restore</span>()
|
292
|
+
<span class="ruby-identifier">url</span> = <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"url"</span>]
|
293
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">url</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
|
294
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Restore from latest snapshot"</span>
|
295
|
+
<span class="ruby-identifier">snapshot</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">read_from_store</span>(<span class="ruby-ivar">@store</span>)
|
296
|
+
<span class="ruby-identifier">url</span> = <span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">url</span>
|
297
|
+
<span class="ruby-keyword kw">end</span>
|
298
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Restoring from #{url}"</span>
|
299
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">submit_restore</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-identifier">url</span>, <span class="ruby-value str">"Reset"</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
|
300
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">wait_for_submitted</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-ivar">@store</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">job</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
|
301
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{time} #{message}"</span>
|
302
|
+
<span class="ruby-keyword kw">end</span>
|
303
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Restore Completed"</span>
|
304
|
+
<span class="ruby-keyword kw">end</span>
|
305
|
+
</pre>
|
306
|
+
</div>
|
307
|
+
</div>
|
308
|
+
</div>
|
309
|
+
|
310
|
+
<div id="method-M000110" class="method-detail">
|
311
|
+
<a name="M000110"></a>
|
312
|
+
|
313
|
+
<div class="method-heading">
|
314
|
+
<a href="#M000110" class="method-signature">
|
315
|
+
<span class="method-name">snapshot</span><span class="method-args">()</span>
|
316
|
+
</a>
|
317
|
+
</div>
|
318
|
+
|
319
|
+
<div class="method-description">
|
320
|
+
<p><a class="source-toggle" href="#"
|
321
|
+
onclick="toggleCode('M000110-source');return false;">[Source]</a></p>
|
322
|
+
<div class="method-source-code" id="M000110-source">
|
323
|
+
<pre>
|
324
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 31</span>
|
325
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">snapshot</span>()
|
326
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Submitting Snapshot Job"</span>
|
327
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">submit_snapshot</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-value str">"Reindex"</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>)
|
328
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Monitoring Job"</span>
|
329
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Jobs</span>.<span class="ruby-identifier">wait_for_submitted</span>(<span class="ruby-identifier">resp</span>, <span class="ruby-ivar">@store</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">job</span>, <span class="ruby-identifier">message</span>, <span class="ruby-identifier">time</span><span class="ruby-operator">|</span>
|
330
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"#{time} #{message}"</span>
|
331
|
+
<span class="ruby-keyword kw">end</span>
|
332
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Snapshot Completed"</span>
|
333
|
+
<span class="ruby-keyword kw">end</span>
|
334
|
+
</pre>
|
335
|
+
</div>
|
336
|
+
</div>
|
337
|
+
</div>
|
338
|
+
|
339
|
+
<div id="method-M000115" class="method-detail">
|
340
|
+
<a name="M000115"></a>
|
341
|
+
|
342
|
+
<div class="method-heading">
|
343
|
+
<a href="#M000115" class="method-signature">
|
344
|
+
<span class="method-name">sparql</span><span class="method-args">()</span>
|
345
|
+
</a>
|
346
|
+
</div>
|
347
|
+
|
348
|
+
<div class="method-description">
|
349
|
+
<p><a class="source-toggle" href="#"
|
350
|
+
onclick="toggleCode('M000115-source');return false;">[Source]</a></p>
|
351
|
+
<div class="method-source-code" id="M000115-source">
|
352
|
+
<pre>
|
353
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 88</span>
|
354
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sparql</span>()
|
355
|
+
<span class="ruby-identifier">query</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>] ).<span class="ruby-identifier">read</span>()
|
356
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">sparql</span>(<span class="ruby-identifier">query</span>)
|
357
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">200</span>
|
358
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
359
|
+
<span class="ruby-keyword kw">else</span>
|
360
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Error: #{resp.status} #{resp.reason}"</span>
|
361
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
362
|
+
<span class="ruby-keyword kw">end</span>
|
363
|
+
<span class="ruby-keyword kw">end</span>
|
364
|
+
</pre>
|
365
|
+
</div>
|
366
|
+
</div>
|
367
|
+
</div>
|
368
|
+
|
369
|
+
<div id="method-M000108" class="method-detail">
|
370
|
+
<a name="M000108"></a>
|
371
|
+
|
372
|
+
<div class="method-heading">
|
373
|
+
<a href="#M000108" class="method-signature">
|
374
|
+
<span class="method-name">status</span><span class="method-args">()</span>
|
375
|
+
</a>
|
376
|
+
</div>
|
377
|
+
|
378
|
+
<div class="method-description">
|
379
|
+
<p><a class="source-toggle" href="#"
|
380
|
+
onclick="toggleCode('M000108-source');return false;">[Source]</a></p>
|
381
|
+
<div class="method-source-code" id="M000108-source">
|
382
|
+
<pre>
|
383
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 11</span>
|
384
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">status</span>()
|
385
|
+
<span class="ruby-identifier">status</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Status</span>.<span class="ruby-identifier">read_from_store</span>(<span class="ruby-ivar">@store</span>)
|
386
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Store Status:\nReadable: #{status.readable?}\nWritable: #{status.writeable?}"</span>
|
387
|
+
<span class="ruby-keyword kw">end</span>
|
388
|
+
</pre>
|
389
|
+
</div>
|
390
|
+
</div>
|
391
|
+
</div>
|
392
|
+
|
393
|
+
<div id="method-M000116" class="method-detail">
|
394
|
+
<a name="M000116"></a>
|
395
|
+
|
396
|
+
<div class="method-heading">
|
397
|
+
<a href="#M000116" class="method-signature">
|
398
|
+
<span class="method-name">store</span><span class="method-args">()</span>
|
399
|
+
</a>
|
400
|
+
</div>
|
401
|
+
|
402
|
+
<div class="method-description">
|
403
|
+
<p><a class="source-toggle" href="#"
|
404
|
+
onclick="toggleCode('M000116-source');return false;">[Source]</a></p>
|
405
|
+
<div class="method-source-code" id="M000116-source">
|
406
|
+
<pre>
|
407
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 99</span>
|
408
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store</span>()
|
409
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-keyword kw">nil</span>
|
410
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"url"</span>]
|
411
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Storing remote data: #{@opts["url"]}"</span>
|
412
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_url</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"url"</span>] )
|
413
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>]
|
414
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Storing local file: #{@opts["file"]}"</span>
|
415
|
+
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>] )
|
416
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">==</span> <span class="ruby-value str">".nt"</span>
|
417
|
+
<span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">store_ntriples</span>(<span class="ruby-identifier">f</span>, <span class="ruby-ivar">@store</span>)
|
418
|
+
<span class="ruby-keyword kw">else</span>
|
419
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">store_file</span>( <span class="ruby-identifier">f</span> )
|
420
|
+
<span class="ruby-keyword kw">end</span>
|
421
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"dir"</span>]
|
422
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Storing contents of directory: #{@opts["dir"]}"</span>
|
423
|
+
<span class="ruby-identifier">collection</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">RDFCollection</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"dir"</span>])
|
424
|
+
<span class="ruby-identifier">collection</span>.<span class="ruby-identifier">store</span>()
|
425
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">summary</span>()
|
426
|
+
<span class="ruby-keyword kw">else</span>
|
427
|
+
<span class="ruby-comment cmt">#noop</span>
|
428
|
+
<span class="ruby-keyword kw">end</span>
|
429
|
+
|
430
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
431
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">204</span>
|
432
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Complete"</span>
|
433
|
+
<span class="ruby-keyword kw">else</span>
|
434
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Error: #{resp.status} #{resp.reason}"</span>
|
435
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
436
|
+
<span class="ruby-keyword kw">end</span>
|
437
|
+
<span class="ruby-keyword kw">end</span>
|
438
|
+
<span class="ruby-keyword kw">end</span>
|
439
|
+
</pre>
|
440
|
+
</div>
|
441
|
+
</div>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div id="method-M000117" class="method-detail">
|
445
|
+
<a name="M000117"></a>
|
446
|
+
|
447
|
+
<div class="method-heading">
|
448
|
+
<a href="#M000117" class="method-signature">
|
449
|
+
<span class="method-name">upload</span><span class="method-args">()</span>
|
450
|
+
</a>
|
451
|
+
</div>
|
452
|
+
|
453
|
+
<div class="method-description">
|
454
|
+
<p><a class="source-toggle" href="#"
|
455
|
+
onclick="toggleCode('M000117-source');return false;">[Source]</a></p>
|
456
|
+
<div class="method-source-code" id="M000117-source">
|
457
|
+
<pre>
|
458
|
+
<span class="ruby-comment cmt"># File lib/pho/command_line.rb, line 131</span>
|
459
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upload</span>()
|
460
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-keyword kw">nil</span>
|
461
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>]
|
462
|
+
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>] )
|
463
|
+
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>] )
|
464
|
+
<span class="ruby-identifier">uri</span> = <span class="ruby-node">"#{opts["base"]}/#{uri}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"base"</span>]
|
465
|
+
<span class="ruby-identifier">mime</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>.<span class="ruby-identifier">type_for</span>( <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"file"</span>] )[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>
|
466
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Uploading file: #{ @opts["file"] } to /items/#{ uri } as #{mime}"</span>
|
467
|
+
<span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">upload_item</span>( <span class="ruby-identifier">f</span> , <span class="ruby-identifier">mime</span> , <span class="ruby-identifier">uri</span> )
|
468
|
+
<span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"dir"</span>]
|
469
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Uploading contents of directory: #{@opts["dir"]}"</span>
|
470
|
+
<span class="ruby-identifier">collection</span> = <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">FileManagement</span><span class="ruby-operator">::</span><span class="ruby-constant">FileManager</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@store</span>, <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"dir"</span>], <span class="ruby-ivar">@opts</span>[<span class="ruby-value str">"base"</span>])
|
471
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value str">"traverse"</span>]
|
472
|
+
<span class="ruby-identifier">collection</span>.<span class="ruby-identifier">store</span>(<span class="ruby-identifier">:traverse</span>)
|
473
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">summary</span>(<span class="ruby-identifier">:traverse</span>)
|
474
|
+
<span class="ruby-keyword kw">else</span>
|
475
|
+
<span class="ruby-identifier">collection</span>.<span class="ruby-identifier">store</span>()
|
476
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">collection</span>.<span class="ruby-identifier">summary</span>()
|
477
|
+
<span class="ruby-keyword kw">end</span>
|
478
|
+
<span class="ruby-keyword kw">else</span>
|
479
|
+
<span class="ruby-comment cmt">#noop</span>
|
480
|
+
<span class="ruby-keyword kw">end</span>
|
481
|
+
|
482
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
483
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">==</span> <span class="ruby-value">204</span>
|
484
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-value str">"Complete"</span>
|
485
|
+
<span class="ruby-keyword kw">else</span>
|
486
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-node">"Error: #{resp.status} #{resp.reason}"</span>
|
487
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
|
488
|
+
<span class="ruby-keyword kw">end</span>
|
489
|
+
<span class="ruby-keyword kw">end</span>
|
490
|
+
<span class="ruby-keyword kw">end</span>
|
491
|
+
</pre>
|
492
|
+
</div>
|
493
|
+
</div>
|
494
|
+
</div>
|
495
|
+
|
496
|
+
|
497
|
+
</div>
|
498
|
+
|
499
|
+
|
500
|
+
</div>
|
501
|
+
|
502
|
+
|
503
|
+
<div id="validator-badges">
|
504
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
505
|
+
</div>
|
506
|
+
|
507
|
+
</body>
|
508
|
+
</html>
|