pho 0.7.8 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +8 -0
- data/Rakefile +4 -2
- data/doc/rdoc/classes/Pho.html +4 -0
- data/doc/rdoc/classes/Pho/CommandLine.html +114 -114
- 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 +102 -102
- data/doc/rdoc/classes/Pho/FieldWeighting.html +12 -12
- data/doc/rdoc/classes/Pho/FileManagement.html +16 -0
- data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +168 -108
- data/doc/rdoc/classes/Pho/FileManagement/BNodeRewritingHandler.html +226 -0
- data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +48 -35
- data/doc/rdoc/classes/Pho/FileManagement/FileSplitter.html +291 -0
- data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +22 -22
- data/doc/rdoc/classes/Pho/FileManagement/StatementHandler.html +152 -0
- data/doc/rdoc/classes/Pho/FileManagement/Util.html +212 -0
- data/doc/rdoc/classes/Pho/Job.html +64 -64
- data/doc/rdoc/classes/Pho/Jobs.html +60 -60
- data/doc/rdoc/classes/Pho/OAI/Record.html +6 -6
- data/doc/rdoc/classes/Pho/OAI/Records.html +24 -24
- data/doc/rdoc/classes/Pho/OAI/Statistics.html +12 -12
- data/doc/rdoc/classes/Pho/QueryProfile.html +66 -66
- 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/Sparql/SparqlClient.html +74 -74
- data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +78 -78
- 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/Pho/Update/Changeset.html +63 -63
- data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +24 -24
- data/doc/rdoc/classes/Pho/Update/ChangesetHelper.html +6 -6
- data/doc/rdoc/classes/Pho/Update/Changesets.html +12 -12
- 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 +24 -24
- data/doc/rdoc/classes/String.html +1 -1
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +13 -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/upload_rb.html +101 -0
- data/doc/rdoc/files/lib/pho_rb.html +4 -2
- data/doc/rdoc/fr_class_index.html +4 -0
- data/doc/rdoc/fr_file_index.html +1 -0
- data/doc/rdoc/fr_method_index.html +228 -218
- data/lib/pho.rb +4 -1
- data/lib/pho/file_management.rb +30 -1
- data/lib/pho/file_manager.rb +7 -0
- data/lib/pho/rdf_collection.rb +4 -4
- data/lib/pho/upload.rb +156 -0
- data/tests/tc_bnodehandler.rb +42 -0
- data/tests/tc_filesplitter.rb +51 -0
- data/tests/ts_pho.rb +3 -1
- metadata +56 -8
@@ -0,0 +1,226 @@
|
|
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::FileManagement::BNodeRewritingHandler</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::FileManagement::BNodeRewritingHandler</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/pho/upload_rb.html">
|
59
|
+
lib/pho/upload.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
|
+
Remove bnodes from the input data by assigning URIs to them
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
This implementation generates a simple hexdigest based on the node id and
|
87
|
+
uses that to construct a uri based on a base uri provided in the
|
88
|
+
constructor
|
89
|
+
</p>
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<div id="method-list">
|
97
|
+
<h3 class="section-bar">Methods</h3>
|
98
|
+
|
99
|
+
<div class="name-list">
|
100
|
+
<a href="#M000034">assign_uri</a>
|
101
|
+
<a href="#M000033">handle</a>
|
102
|
+
<a href="#M000032">new</a>
|
103
|
+
</div>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
</div>
|
107
|
+
|
108
|
+
|
109
|
+
<!-- if includes -->
|
110
|
+
|
111
|
+
<div id="section">
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<!-- if method_list -->
|
121
|
+
<div id="methods">
|
122
|
+
<h3 class="section-bar">Public Class methods</h3>
|
123
|
+
|
124
|
+
<div id="method-M000032" class="method-detail">
|
125
|
+
<a name="M000032"></a>
|
126
|
+
|
127
|
+
<div class="method-heading">
|
128
|
+
<a href="#M000032" class="method-signature">
|
129
|
+
<span class="method-name">new</span><span class="method-args">(base)</span>
|
130
|
+
</a>
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="method-description">
|
134
|
+
<table>
|
135
|
+
<tr><td valign="top">base:</td><td>base uri for URIs generated for blank nodes
|
136
|
+
|
137
|
+
</td></tr>
|
138
|
+
</table>
|
139
|
+
<p><a class="source-toggle" href="#"
|
140
|
+
onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
|
141
|
+
<div class="method-source-code" id="M000032-source">
|
142
|
+
<pre>
|
143
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 19</span>
|
144
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">base</span>)
|
145
|
+
<span class="ruby-ivar">@base</span> = <span class="ruby-identifier">base</span>
|
146
|
+
<span class="ruby-keyword kw">end</span>
|
147
|
+
</pre>
|
148
|
+
</div>
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
153
|
+
|
154
|
+
<div id="method-M000034" class="method-detail">
|
155
|
+
<a name="M000034"></a>
|
156
|
+
|
157
|
+
<div class="method-heading">
|
158
|
+
<a href="#M000034" class="method-signature">
|
159
|
+
<span class="method-name">assign_uri</span><span class="method-args">(node)</span>
|
160
|
+
</a>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
<div class="method-description">
|
164
|
+
<p>
|
165
|
+
FIXME semantics for this is wrong if nodeIds are reused across datasets
|
166
|
+
</p>
|
167
|
+
<p><a class="source-toggle" href="#"
|
168
|
+
onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
|
169
|
+
<div class="method-source-code" id="M000034-source">
|
170
|
+
<pre>
|
171
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 40</span>
|
172
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">assign_uri</span>(<span class="ruby-identifier">node</span>)
|
173
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{@base}/#{Digest::MD5.hexdigest( node.id )}#self"</span>
|
174
|
+
<span class="ruby-keyword kw">end</span>
|
175
|
+
</pre>
|
176
|
+
</div>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
<div id="method-M000033" class="method-detail">
|
181
|
+
<a name="M000033"></a>
|
182
|
+
|
183
|
+
<div class="method-heading">
|
184
|
+
<a href="#M000033" class="method-signature">
|
185
|
+
<span class="method-name">handle</span><span class="method-args">(statement)</span>
|
186
|
+
</a>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div class="method-description">
|
190
|
+
<p><a class="source-toggle" href="#"
|
191
|
+
onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
|
192
|
+
<div class="method-source-code" id="M000033-source">
|
193
|
+
<pre>
|
194
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 23</span>
|
195
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle</span>(<span class="ruby-identifier">statement</span>)
|
196
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">statement</span>.<span class="ruby-identifier">has_blank_nodes?</span>
|
197
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">statement</span>
|
198
|
+
<span class="ruby-keyword kw">end</span>
|
199
|
+
<span class="ruby-identifier">subject</span> = <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">subject</span>
|
200
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">subject</span>.<span class="ruby-identifier">anonymous?</span>
|
201
|
+
<span class="ruby-identifier">subject</span> = <span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">assign_uri</span>(<span class="ruby-identifier">subject</span>) )
|
202
|
+
<span class="ruby-keyword kw">end</span>
|
203
|
+
<span class="ruby-identifier">object</span> = <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">object</span>
|
204
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">object</span>.<span class="ruby-identifier">anonymous?</span>
|
205
|
+
<span class="ruby-identifier">object</span> = <span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">URI</span>.<span class="ruby-identifier">new</span>( <span class="ruby-identifier">assign_uri</span>(<span class="ruby-identifier">object</span>) )
|
206
|
+
<span class="ruby-keyword kw">end</span>
|
207
|
+
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Statement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">subject</span>, <span class="ruby-identifier">statement</span>.<span class="ruby-identifier">predicate</span>, <span class="ruby-identifier">object</span>)
|
208
|
+
<span class="ruby-keyword kw">end</span>
|
209
|
+
</pre>
|
210
|
+
</div>
|
211
|
+
</div>
|
212
|
+
</div>
|
213
|
+
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
|
218
|
+
</div>
|
219
|
+
|
220
|
+
|
221
|
+
<div id="validator-badges">
|
222
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
</body>
|
226
|
+
</html>
|
@@ -80,6 +80,19 @@
|
|
80
80
|
|
81
81
|
<div id="contextContent">
|
82
82
|
|
83
|
+
<div id="description">
|
84
|
+
<p>
|
85
|
+
Manages a collection of files in a directory structure, uploading them to
|
86
|
+
the contentbox of a platform store
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
Allows the base directory of the upload to be specified, giving some
|
90
|
+
flexibility on how the files are published via the contentbox. By default
|
91
|
+
the files will be rooted in /items/ but by specifying the base parameter in
|
92
|
+
the construct, this can be altered to, e.g. /items/foo
|
93
|
+
</p>
|
94
|
+
|
95
|
+
</div>
|
83
96
|
|
84
97
|
|
85
98
|
</div>
|
@@ -88,11 +101,11 @@
|
|
88
101
|
<h3 class="section-bar">Methods</h3>
|
89
102
|
|
90
103
|
<div class="name-list">
|
91
|
-
<a href="#
|
92
|
-
<a href="#
|
93
|
-
<a href="#
|
94
|
-
<a href="#
|
95
|
-
<a href="#
|
104
|
+
<a href="#M000012">create_tracking_dir</a>
|
105
|
+
<a href="#M000009">list</a>
|
106
|
+
<a href="#M000010">name_for_file</a>
|
107
|
+
<a href="#M000008">new</a>
|
108
|
+
<a href="#M000011">store_file</a>
|
96
109
|
</div>
|
97
110
|
</div>
|
98
111
|
|
@@ -127,21 +140,21 @@
|
|
127
140
|
<div id="methods">
|
128
141
|
<h3 class="section-bar">Public Class methods</h3>
|
129
142
|
|
130
|
-
<div id="method-
|
131
|
-
<a name="
|
143
|
+
<div id="method-M000010" class="method-detail">
|
144
|
+
<a name="M000010"></a>
|
132
145
|
|
133
146
|
<div class="method-heading">
|
134
|
-
<a href="#
|
147
|
+
<a href="#M000010" class="method-signature">
|
135
148
|
<span class="method-name">name_for_file</span><span class="method-args">(dir, file, base=nil)</span>
|
136
149
|
</a>
|
137
150
|
</div>
|
138
151
|
|
139
152
|
<div class="method-description">
|
140
153
|
<p><a class="source-toggle" href="#"
|
141
|
-
onclick="toggleCode('
|
142
|
-
<div class="method-source-code" id="
|
154
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
155
|
+
<div class="method-source-code" id="M000010-source">
|
143
156
|
<pre>
|
144
|
-
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line
|
157
|
+
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line 33</span>
|
145
158
|
<span class="ruby-keyword kw">def</span> <span class="ruby-constant">FileManager</span>.<span class="ruby-identifier">name_for_file</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">file</span>, <span class="ruby-identifier">base</span>=<span class="ruby-keyword kw">nil</span>)
|
146
159
|
<span class="ruby-identifier">uri</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">path</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-value str">""</span>)
|
147
160
|
<span class="ruby-identifier">uri</span> = <span class="ruby-node">"#{base}#{uri}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">base</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
|
@@ -152,21 +165,21 @@
|
|
152
165
|
</div>
|
153
166
|
</div>
|
154
167
|
|
155
|
-
<div id="method-
|
156
|
-
<a name="
|
168
|
+
<div id="method-M000008" class="method-detail">
|
169
|
+
<a name="M000008"></a>
|
157
170
|
|
158
171
|
<div class="method-heading">
|
159
|
-
<a href="#
|
172
|
+
<a href="#M000008" class="method-signature">
|
160
173
|
<span class="method-name">new</span><span class="method-args">(store, dir, base = nil, ok_suffix=OK, fail_suffix=FAIL)</span>
|
161
174
|
</a>
|
162
175
|
</div>
|
163
176
|
|
164
177
|
<div class="method-description">
|
165
178
|
<p><a class="source-toggle" href="#"
|
166
|
-
onclick="toggleCode('
|
167
|
-
<div class="method-source-code" id="
|
179
|
+
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
180
|
+
<div class="method-source-code" id="M000008-source">
|
168
181
|
<pre>
|
169
|
-
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line
|
182
|
+
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line 18</span>
|
170
183
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">base</span> = <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">ok_suffix</span>=<span class="ruby-constant">OK</span>, <span class="ruby-identifier">fail_suffix</span>=<span class="ruby-constant">FAIL</span>)
|
171
184
|
<span class="ruby-keyword kw">super</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">ok_suffix</span>, <span class="ruby-identifier">fail_suffix</span>)
|
172
185
|
<span class="ruby-ivar">@base</span> = <span class="ruby-identifier">base</span>
|
@@ -178,11 +191,11 @@
|
|
178
191
|
|
179
192
|
<h3 class="section-bar">Public Instance methods</h3>
|
180
193
|
|
181
|
-
<div id="method-
|
182
|
-
<a name="
|
194
|
+
<div id="method-M000009" class="method-detail">
|
195
|
+
<a name="M000009"></a>
|
183
196
|
|
184
197
|
<div class="method-heading">
|
185
|
-
<a href="#
|
198
|
+
<a href="#M000009" class="method-signature">
|
186
199
|
<span class="method-name">list</span><span class="method-args">(recursive=false)</span>
|
187
200
|
</a>
|
188
201
|
</div>
|
@@ -192,10 +205,10 @@
|
|
192
205
|
List files being managed, i.e. everything not .ok or .fail
|
193
206
|
</p>
|
194
207
|
<p><a class="source-toggle" href="#"
|
195
|
-
onclick="toggleCode('
|
196
|
-
<div class="method-source-code" id="
|
208
|
+
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
209
|
+
<div class="method-source-code" id="M000009-source">
|
197
210
|
<pre>
|
198
|
-
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line
|
211
|
+
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line 24</span>
|
199
212
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">list</span>(<span class="ruby-identifier">recursive</span>=<span class="ruby-keyword kw">false</span>)
|
200
213
|
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">recursive</span>
|
201
214
|
<span class="ruby-identifier">pattern</span> = <span class="ruby-value str">"**/*.*"</span>
|
@@ -211,21 +224,21 @@ List files being managed, i.e. everything not .ok or .fail
|
|
211
224
|
|
212
225
|
<h3 class="section-bar">Protected Instance methods</h3>
|
213
226
|
|
214
|
-
<div id="method-
|
215
|
-
<a name="
|
227
|
+
<div id="method-M000012" class="method-detail">
|
228
|
+
<a name="M000012"></a>
|
216
229
|
|
217
230
|
<div class="method-heading">
|
218
|
-
<a href="#
|
231
|
+
<a href="#M000012" class="method-signature">
|
219
232
|
<span class="method-name">create_tracking_dir</span><span class="method-args">(filename)</span>
|
220
233
|
</a>
|
221
234
|
</div>
|
222
235
|
|
223
236
|
<div class="method-description">
|
224
237
|
<p><a class="source-toggle" href="#"
|
225
|
-
onclick="toggleCode('
|
226
|
-
<div class="method-source-code" id="
|
238
|
+
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
239
|
+
<div class="method-source-code" id="M000012-source">
|
227
240
|
<pre>
|
228
|
-
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line
|
241
|
+
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line 56</span>
|
229
242
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_tracking_dir</span>(<span class="ruby-identifier">filename</span>)
|
230
243
|
<span class="ruby-identifier">path</span> = <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">"/"</span>)[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-2</span>].<span class="ruby-identifier">join</span>(<span class="ruby-value str">"/"</span>)
|
231
244
|
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span>(<span class="ruby-node">"#{path}/#{TRACKING_DIR}"</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-node">"#{path}/#{TRACKING_DIR}"</span>)
|
@@ -235,21 +248,21 @@ List files being managed, i.e. everything not .ok or .fail
|
|
235
248
|
</div>
|
236
249
|
</div>
|
237
250
|
|
238
|
-
<div id="method-
|
239
|
-
<a name="
|
251
|
+
<div id="method-M000011" class="method-detail">
|
252
|
+
<a name="M000011"></a>
|
240
253
|
|
241
254
|
<div class="method-heading">
|
242
|
-
<a href="#
|
255
|
+
<a href="#M000011" class="method-signature">
|
243
256
|
<span class="method-name">store_file</span><span class="method-args">(file, filename)</span>
|
244
257
|
</a>
|
245
258
|
</div>
|
246
259
|
|
247
260
|
<div class="method-description">
|
248
261
|
<p><a class="source-toggle" href="#"
|
249
|
-
onclick="toggleCode('
|
250
|
-
<div class="method-source-code" id="
|
262
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
263
|
+
<div class="method-source-code" id="M000011-source">
|
251
264
|
<pre>
|
252
|
-
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line
|
265
|
+
<span class="ruby-comment cmt"># File lib/pho/file_manager.rb, line 41</span>
|
253
266
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_file</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">filename</span>)
|
254
267
|
<span class="ruby-identifier">uri</span> = <span class="ruby-constant">FileManager</span>.<span class="ruby-identifier">name_for_file</span>(<span class="ruby-ivar">@dir</span>, <span class="ruby-identifier">file</span>, <span class="ruby-ivar">@base</span>)
|
255
268
|
<span class="ruby-identifier">response</span> = <span class="ruby-ivar">@store</span>.<span class="ruby-identifier">upload_item</span>(<span class="ruby-identifier">file</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-identifier">filename</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">uri</span> )
|
@@ -0,0 +1,291 @@
|
|
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::FileManagement::FileSplitter</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::FileManagement::FileSplitter</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/pho/upload_rb.html">
|
59
|
+
lib/pho/upload.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
|
+
Supports splitting RDF data files into smaller chunks of ntriples
|
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="#M000029">new</a>
|
96
|
+
<a href="#M000030">split_file</a>
|
97
|
+
<a href="#M000031">split_files</a>
|
98
|
+
</div>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
<!-- if includes -->
|
105
|
+
|
106
|
+
<div id="section">
|
107
|
+
|
108
|
+
|
109
|
+
<div id="constants-list">
|
110
|
+
<h3 class="section-bar">Constants</h3>
|
111
|
+
|
112
|
+
<div class="name-list">
|
113
|
+
<table summary="Constants">
|
114
|
+
<tr class="top-aligned-row context-row">
|
115
|
+
<td class="context-item-name">DEFAULT_CHUNK_SIZE</td>
|
116
|
+
<td>=</td>
|
117
|
+
<td class="context-item-value">10000</td>
|
118
|
+
</tr>
|
119
|
+
</table>
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<div id="attribute-list">
|
126
|
+
<h3 class="section-bar">Attributes</h3>
|
127
|
+
|
128
|
+
<div class="name-list">
|
129
|
+
<table>
|
130
|
+
<tr class="top-aligned-row context-row">
|
131
|
+
<td class="context-item-name">dir</td>
|
132
|
+
<td class="context-item-value"> [R] </td>
|
133
|
+
<td class="context-item-desc"></td>
|
134
|
+
</tr>
|
135
|
+
<tr class="top-aligned-row context-row">
|
136
|
+
<td class="context-item-name">handler</td>
|
137
|
+
<td class="context-item-value"> [R] </td>
|
138
|
+
<td class="context-item-desc"></td>
|
139
|
+
</tr>
|
140
|
+
<tr class="top-aligned-row context-row">
|
141
|
+
<td class="context-item-name">triples</td>
|
142
|
+
<td class="context-item-value"> [R] </td>
|
143
|
+
<td class="context-item-desc"></td>
|
144
|
+
</tr>
|
145
|
+
</table>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
<!-- if method_list -->
|
152
|
+
<div id="methods">
|
153
|
+
<h3 class="section-bar">Public Class methods</h3>
|
154
|
+
|
155
|
+
<div id="method-M000029" class="method-detail">
|
156
|
+
<a name="M000029"></a>
|
157
|
+
|
158
|
+
<div class="method-heading">
|
159
|
+
<a href="#M000029" class="method-signature">
|
160
|
+
<span class="method-name">new</span><span class="method-args">(dir="/tmp", triples=DEFAULT_CHUNK_SIZE, handler=Pho::FileManagement::StatementHandler.new)</span>
|
161
|
+
</a>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div class="method-description">
|
165
|
+
<p>
|
166
|
+
Create a file splitter instance
|
167
|
+
</p>
|
168
|
+
<pre>
|
169
|
+
dir:: temporary directory into which split files should be written
|
170
|
+
triples:: number of triples per split file
|
171
|
+
handler:: statement handler to allow pre-processing of statements
|
172
|
+
</pre>
|
173
|
+
<p><a class="source-toggle" href="#"
|
174
|
+
onclick="toggleCode('M000029-source');return false;">[Source]</a></p>
|
175
|
+
<div class="method-source-code" id="M000029-source">
|
176
|
+
<pre>
|
177
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 58</span>
|
178
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">dir</span>=<span class="ruby-value str">"/tmp"</span>, <span class="ruby-identifier">triples</span>=<span class="ruby-constant">DEFAULT_CHUNK_SIZE</span>,
|
179
|
+
<span class="ruby-identifier">handler</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">StatementHandler</span>.<span class="ruby-identifier">new</span>)
|
180
|
+
<span class="ruby-ivar">@dir</span> = <span class="ruby-identifier">dir</span>
|
181
|
+
<span class="ruby-ivar">@triples</span> = <span class="ruby-identifier">triples</span>
|
182
|
+
<span class="ruby-ivar">@handler</span> = <span class="ruby-identifier">handler</span>
|
183
|
+
<span class="ruby-keyword kw">end</span>
|
184
|
+
</pre>
|
185
|
+
</div>
|
186
|
+
</div>
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
190
|
+
|
191
|
+
<div id="method-M000030" class="method-detail">
|
192
|
+
<a name="M000030"></a>
|
193
|
+
|
194
|
+
<div class="method-heading">
|
195
|
+
<a href="#M000030" class="method-signature">
|
196
|
+
<span class="method-name">split_file</span><span class="method-args">(filename, format=:ntriples)</span>
|
197
|
+
</a>
|
198
|
+
</div>
|
199
|
+
|
200
|
+
<div class="method-description">
|
201
|
+
<p>
|
202
|
+
Split a single file, in any parseable RDF format into smaller chunks of
|
203
|
+
ntriples. Chunked files are stored in default temporary directory for this
|
204
|
+
instance
|
205
|
+
</p>
|
206
|
+
<pre>
|
207
|
+
filename:: name of the file to split
|
208
|
+
format:: input format, default is :ntriples
|
209
|
+
</pre>
|
210
|
+
<p><a class="source-toggle" href="#"
|
211
|
+
onclick="toggleCode('M000030-source');return false;">[Source]</a></p>
|
212
|
+
<div class="method-source-code" id="M000030-source">
|
213
|
+
<pre>
|
214
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 71</span>
|
215
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">split_file</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-identifier">format</span>=<span class="ruby-identifier">:ntriples</span>)
|
216
|
+
|
217
|
+
<span class="ruby-identifier">basename</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">basename</span>(<span class="ruby-identifier">filename</span>, <span class="ruby-node">".#{filename.split(".").last}"</span>)
|
218
|
+
<span class="ruby-identifier">count</span> = <span class="ruby-value">0</span>
|
219
|
+
<span class="ruby-identifier">stmts</span> = []
|
220
|
+
<span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Reader</span>.<span class="ruby-identifier">for</span>(<span class="ruby-identifier">format</span>).<span class="ruby-identifier">new</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">filename</span>)) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">reader</span><span class="ruby-operator">|</span>
|
221
|
+
<span class="ruby-identifier">reader</span>.<span class="ruby-identifier">each_statement</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">statement</span><span class="ruby-operator">|</span>
|
222
|
+
<span class="ruby-identifier">count</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
223
|
+
<span class="ruby-identifier">stmts</span> <span class="ruby-operator"><<</span> <span class="ruby-ivar">@handler</span>.<span class="ruby-identifier">handle</span>( <span class="ruby-identifier">statement</span> )
|
224
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">count</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@triples</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
|
225
|
+
<span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Writer</span>.<span class="ruby-identifier">open</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@dir</span>, <span class="ruby-node">"#{basename}_#{count}.nt"</span>) ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">writer</span><span class="ruby-operator">|</span>
|
226
|
+
<span class="ruby-identifier">stmts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
|
227
|
+
<span class="ruby-identifier">writer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">s</span>
|
228
|
+
<span class="ruby-keyword kw">end</span>
|
229
|
+
<span class="ruby-keyword kw">end</span>
|
230
|
+
<span class="ruby-identifier">stmts</span> = []
|
231
|
+
<span class="ruby-keyword kw">end</span>
|
232
|
+
<span class="ruby-keyword kw">end</span>
|
233
|
+
<span class="ruby-keyword kw">end</span>
|
234
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">stmts</span>.<span class="ruby-identifier">empty?</span>
|
235
|
+
<span class="ruby-constant">RDF</span><span class="ruby-operator">::</span><span class="ruby-constant">Writer</span>.<span class="ruby-identifier">open</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-ivar">@dir</span>, <span class="ruby-node">"#{basename}_#{count}.nt"</span>) ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">writer</span><span class="ruby-operator">|</span>
|
236
|
+
<span class="ruby-identifier">stmts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
|
237
|
+
<span class="ruby-identifier">writer</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">s</span>
|
238
|
+
<span class="ruby-keyword kw">end</span>
|
239
|
+
<span class="ruby-keyword kw">end</span>
|
240
|
+
<span class="ruby-keyword kw">end</span>
|
241
|
+
<span class="ruby-keyword kw">end</span>
|
242
|
+
</pre>
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
</div>
|
246
|
+
|
247
|
+
<div id="method-M000031" class="method-detail">
|
248
|
+
<a name="M000031"></a>
|
249
|
+
|
250
|
+
<div class="method-heading">
|
251
|
+
<a href="#M000031" class="method-signature">
|
252
|
+
<span class="method-name">split_files</span><span class="method-args">(list_of_filenames, format=:ntriples)</span>
|
253
|
+
</a>
|
254
|
+
</div>
|
255
|
+
|
256
|
+
<div class="method-description">
|
257
|
+
<p>
|
258
|
+
Split a list of files into smaller chunks
|
259
|
+
</p>
|
260
|
+
<pre>
|
261
|
+
list_of_filenames:: array of filenames
|
262
|
+
format:: format of the files, default is :ntriples
|
263
|
+
</pre>
|
264
|
+
<p><a class="source-toggle" href="#"
|
265
|
+
onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
|
266
|
+
<div class="method-source-code" id="M000031-source">
|
267
|
+
<pre>
|
268
|
+
<span class="ruby-comment cmt"># File lib/pho/upload.rb, line 103</span>
|
269
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">split_files</span>(<span class="ruby-identifier">list_of_filenames</span>, <span class="ruby-identifier">format</span>=<span class="ruby-identifier">:ntriples</span>)
|
270
|
+
<span class="ruby-identifier">list_of_filenames</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
|
271
|
+
<span class="ruby-identifier">split_file</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">format</span>)
|
272
|
+
<span class="ruby-keyword kw">end</span>
|
273
|
+
<span class="ruby-keyword kw">end</span>
|
274
|
+
</pre>
|
275
|
+
</div>
|
276
|
+
</div>
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
</div>
|
281
|
+
|
282
|
+
|
283
|
+
</div>
|
284
|
+
|
285
|
+
|
286
|
+
<div id="validator-badges">
|
287
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
288
|
+
</div>
|
289
|
+
|
290
|
+
</body>
|
291
|
+
</html>
|