pho 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/CHANGES +6 -0
  2. data/README +9 -1
  3. data/Rakefile +1 -1
  4. data/doc/index.html +3 -1
  5. data/doc/rdoc/classes/Pho/Analyzers.html +310 -0
  6. data/doc/rdoc/classes/Pho/CommandLine.html +770 -0
  7. data/doc/rdoc/classes/Pho/DatatypeProperty.html +241 -0
  8. data/doc/rdoc/classes/Pho/Enrichment/StoreEnricher.html +410 -0
  9. data/doc/rdoc/classes/Pho/Enrichment.html +119 -0
  10. data/doc/rdoc/classes/Pho/Etags.html +310 -0
  11. data/doc/rdoc/classes/Pho/Facet/Results.html +299 -0
  12. data/doc/rdoc/classes/Pho/Facet/Term.html +177 -0
  13. data/doc/rdoc/classes/Pho/Facet.html +119 -0
  14. data/doc/rdoc/classes/Pho/FieldPredicateMap.html +695 -0
  15. data/doc/rdoc/classes/Pho/FieldWeighting.html +230 -0
  16. data/doc/rdoc/classes/Pho/FileManagement/AbstractFileManager.html +478 -0
  17. data/doc/rdoc/classes/Pho/FileManagement/FileManager.html +264 -0
  18. data/doc/rdoc/classes/Pho/FileManagement/RDFManager.html +259 -0
  19. data/doc/rdoc/classes/Pho/FileManagement.html +121 -0
  20. data/doc/rdoc/classes/Pho/Job.html +627 -0
  21. data/doc/rdoc/classes/Pho/JobUpdate.html +141 -0
  22. data/doc/rdoc/classes/Pho/Jobs.html +538 -0
  23. data/doc/rdoc/classes/Pho/Namespaces.html +164 -0
  24. data/doc/rdoc/classes/Pho/OAI/Record.html +165 -0
  25. data/doc/rdoc/classes/Pho/OAI/Records.html +331 -0
  26. data/doc/rdoc/classes/Pho/OAI.html +118 -0
  27. data/doc/rdoc/classes/Pho/QueryProfile.html +524 -0
  28. data/doc/rdoc/classes/Pho/RDF/Parser.html +279 -0
  29. data/doc/rdoc/classes/Pho/RDF.html +120 -0
  30. data/doc/rdoc/classes/Pho/RDFCollection.html +119 -0
  31. data/doc/rdoc/classes/Pho/ResourceHash/Converter.html +325 -0
  32. data/doc/rdoc/classes/Pho/ResourceHash/SetAlgebra.html +241 -0
  33. data/doc/rdoc/classes/Pho/ResourceHash.html +123 -0
  34. data/doc/rdoc/classes/Pho/Snapshot.html +402 -0
  35. data/doc/rdoc/classes/Pho/Sparql/SparqlClient.html +594 -0
  36. data/doc/rdoc/classes/Pho/Sparql/SparqlHelper.html +696 -0
  37. data/doc/rdoc/classes/Pho/Sparql.html +187 -0
  38. data/doc/rdoc/classes/Pho/Status.html +296 -0
  39. data/doc/rdoc/classes/Pho/Store.html +1569 -0
  40. data/doc/rdoc/classes/Pho/StoreSparqlClient.html +183 -0
  41. data/doc/rdoc/classes/Pho/Update/Changeset.html +521 -0
  42. data/doc/rdoc/classes/Pho/Update/ChangesetBuilder.html +330 -0
  43. data/doc/rdoc/classes/Pho/Update/ChangesetHelper.html +159 -0
  44. data/doc/rdoc/classes/Pho/Update/Changesets.html +205 -0
  45. data/doc/rdoc/classes/Pho/Update/LiteralStatement.html +257 -0
  46. data/doc/rdoc/classes/Pho/Update/ResourceStatement.html +237 -0
  47. data/doc/rdoc/classes/Pho/Update/Statement.html +303 -0
  48. data/doc/rdoc/classes/Pho/Update.html +128 -0
  49. data/doc/rdoc/classes/Pho.html +283 -0
  50. data/doc/rdoc/classes/String.html +146 -0
  51. data/doc/rdoc/created.rid +1 -0
  52. data/doc/rdoc/files/CHANGES.html +373 -0
  53. data/doc/rdoc/files/README.html +204 -0
  54. data/doc/rdoc/files/lib/pho/changeset_builder_rb.html +108 -0
  55. data/doc/rdoc/files/lib/pho/changeset_rb.html +108 -0
  56. data/doc/rdoc/files/lib/pho/command_line_rb.html +101 -0
  57. data/doc/rdoc/files/lib/pho/converter_rb.html +108 -0
  58. data/doc/rdoc/files/lib/pho/enrichment_rb.html +101 -0
  59. data/doc/rdoc/files/lib/pho/etags_rb.html +108 -0
  60. data/doc/rdoc/files/lib/pho/facet_rb.html +101 -0
  61. data/doc/rdoc/files/lib/pho/field_predicate_map_rb.html +101 -0
  62. data/doc/rdoc/files/lib/pho/file_management_rb.html +101 -0
  63. data/doc/rdoc/files/lib/pho/file_manager_rb.html +108 -0
  64. data/doc/rdoc/files/lib/pho/job_rb.html +101 -0
  65. data/doc/rdoc/files/lib/pho/oai_rb.html +101 -0
  66. data/doc/rdoc/files/lib/pho/query_profile_rb.html +101 -0
  67. data/doc/rdoc/files/lib/pho/rdf_collection_rb.html +101 -0
  68. data/doc/rdoc/files/lib/pho/rdf_rb.html +108 -0
  69. data/doc/rdoc/files/lib/pho/resource_hash_rb.html +101 -0
  70. data/doc/rdoc/files/lib/pho/snapshot_rb.html +109 -0
  71. data/doc/rdoc/files/lib/pho/sparql_rb.html +101 -0
  72. data/doc/rdoc/files/lib/pho/status_rb.html +101 -0
  73. data/doc/rdoc/files/lib/pho/store_rb.html +108 -0
  74. data/doc/rdoc/files/lib/pho_rb.html +133 -0
  75. data/doc/rdoc/fr_class_index.html +72 -0
  76. data/doc/rdoc/fr_file_index.html +49 -0
  77. data/doc/rdoc/fr_method_index.html +239 -0
  78. data/doc/rdoc/index.html +24 -0
  79. data/doc/rdoc/rdoc-style.css +208 -0
  80. data/lib/pho/enrichment.rb +1 -0
  81. data/lib/pho/field_predicate_map.rb +5 -0
  82. data/lib/pho/query_profile.rb +5 -0
  83. data/lib/pho/store.rb +4 -1
  84. data/tests/tc_field_predicate_map.rb +7 -1
  85. data/tests/tc_query_profile.rb +6 -0
  86. data/tests/tc_store_util.rb +7 -0
  87. metadata +134 -21
@@ -0,0 +1,123 @@
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>Module: Pho::ResourceHash</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>Module</strong></td>
53
+ <td class="class-name-in-header">Pho::ResourceHash</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/pho/converter_rb.html">
59
+ lib/pho/converter.rb
60
+ </a>
61
+ <br />
62
+ <a href="../../files/lib/pho/resource_hash_rb.html">
63
+ lib/pho/resource_hash.rb
64
+ </a>
65
+ <br />
66
+ </td>
67
+ </tr>
68
+
69
+ </table>
70
+ </div>
71
+ <!-- banner header -->
72
+
73
+ <div id="bodyContent">
74
+
75
+
76
+
77
+ <div id="contextContent">
78
+
79
+ <div id="description">
80
+ <p>
81
+ Module providing code for manipulating resource hashes structured according
82
+ to the <a href="RDF.html">RDF</a> in JSON spec
83
+ </p>
84
+
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+
93
+
94
+ <!-- if includes -->
95
+
96
+ <div id="section">
97
+
98
+ <div id="class-list">
99
+ <h3 class="section-bar">Classes and Modules</h3>
100
+
101
+ Class <a href="ResourceHash/Converter.html" class="link">Pho::ResourceHash::Converter</a><br />
102
+ Class <a href="ResourceHash/SetAlgebra.html" class="link">Pho::ResourceHash::SetAlgebra</a><br />
103
+
104
+ </div>
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <!-- if method_list -->
113
+
114
+
115
+ </div>
116
+
117
+
118
+ <div id="validator-badges">
119
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
120
+ </div>
121
+
122
+ </body>
123
+ </html>
@@ -0,0 +1,402 @@
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::Snapshot</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::Snapshot</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/pho/snapshot_rb.html">
59
+ lib/pho/snapshot.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
+ In the Talis Platform a &quot;snapshot&quot; is an <a
84
+ href="Snapshot.html#M000195">backup</a> of the contents of a <a
85
+ href="Store.html">Store</a>
86
+ </p>
87
+ <p>
88
+ A snapshot consists of a tar file that contains all data (contentbox and
89
+ metabox) in the store. The snapshot also contains the store configuration
90
+ but this is encrypted and not intended for reuse.
91
+ </p>
92
+ <p>
93
+ A snapshot can be generated (or scheduled) using the Store.snapshot method.
94
+ </p>
95
+
96
+ </div>
97
+
98
+
99
+ </div>
100
+
101
+ <div id="method-list">
102
+ <h3 class="section-bar">Methods</h3>
103
+
104
+ <div class="name-list">
105
+ <a href="#M000195">backup</a>&nbsp;&nbsp;
106
+ <a href="#M000193">new</a>&nbsp;&nbsp;
107
+ <a href="#M000192">parse</a>&nbsp;&nbsp;
108
+ <a href="#M000191">read_from_store</a>&nbsp;&nbsp;
109
+ <a href="#M000194">read_md5</a>&nbsp;&nbsp;
110
+ </div>
111
+ </div>
112
+
113
+ </div>
114
+
115
+
116
+ <!-- if includes -->
117
+
118
+ <div id="section">
119
+
120
+
121
+
122
+
123
+
124
+ <div id="attribute-list">
125
+ <h3 class="section-bar">Attributes</h3>
126
+
127
+ <div class="name-list">
128
+ <table>
129
+ <tr class="top-aligned-row context-row">
130
+ <td class="context-item-name">date</td>
131
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
132
+ <td class="context-item-desc">
133
+ Date when snapshot was taken
134
+
135
+ </td>
136
+ </tr>
137
+ <tr class="top-aligned-row context-row">
138
+ <td class="context-item-name">md5_url</td>
139
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
140
+ <td class="context-item-desc">
141
+ The URL from which the MD5 for the snapshot can be retrieved
142
+
143
+ </td>
144
+ </tr>
145
+ <tr class="top-aligned-row context-row">
146
+ <td class="context-item-name">size</td>
147
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
148
+ <td class="context-item-desc">
149
+ Size of the snapshot
150
+
151
+ </td>
152
+ </tr>
153
+ <tr class="top-aligned-row context-row">
154
+ <td class="context-item-name">units</td>
155
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
156
+ <td class="context-item-desc">
157
+ Units for Size, e.g. KB
158
+
159
+ </td>
160
+ </tr>
161
+ <tr class="top-aligned-row context-row">
162
+ <td class="context-item-name">url</td>
163
+ <td class="context-item-value">&nbsp;[R]&nbsp;</td>
164
+ <td class="context-item-desc">
165
+ The URL from which the snapshot can be retrieved
166
+
167
+ </td>
168
+ </tr>
169
+ </table>
170
+ </div>
171
+ </div>
172
+
173
+
174
+
175
+ <!-- if method_list -->
176
+ <div id="methods">
177
+ <h3 class="section-bar">Public Class methods</h3>
178
+
179
+ <div id="method-M000193" class="method-detail">
180
+ <a name="M000193"></a>
181
+
182
+ <div class="method-heading">
183
+ <a href="#M000193" class="method-signature">
184
+ <span class="method-name">new</span><span class="method-args">(url, md5_url, size, units, date)</span>
185
+ </a>
186
+ </div>
187
+
188
+ <div class="method-description">
189
+ <p><a class="source-toggle" href="#"
190
+ onclick="toggleCode('M000193-source');return false;">[Source]</a></p>
191
+ <div class="method-source-code" id="M000193-source">
192
+ <pre>
193
+ <span class="ruby-comment cmt"># File lib/pho/snapshot.rb, line 81</span>
194
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">md5_url</span>, <span class="ruby-identifier">size</span>, <span class="ruby-identifier">units</span>, <span class="ruby-identifier">date</span>)
195
+ <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">url</span>
196
+ <span class="ruby-ivar">@md5_url</span> = <span class="ruby-identifier">md5_url</span>
197
+ <span class="ruby-ivar">@size</span> = <span class="ruby-identifier">size</span>
198
+ <span class="ruby-ivar">@units</span> = <span class="ruby-identifier">units</span>
199
+ <span class="ruby-ivar">@date</span> = <span class="ruby-identifier">date</span>
200
+ <span class="ruby-keyword kw">end</span>
201
+ </pre>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <div id="method-M000192" class="method-detail">
207
+ <a name="M000192"></a>
208
+
209
+ <div class="method-heading">
210
+ <a href="#M000192" class="method-signature">
211
+ <span class="method-name">parse</span><span class="method-args">(storeuri, content)</span>
212
+ </a>
213
+ </div>
214
+
215
+ <div class="method-description">
216
+ <p>
217
+ Class method to <a href="Snapshot.html#M000192">parse</a> the <a
218
+ href="RDF.html">RDF</a> response from the API, e.g. as produced by the <a
219
+ href="Store.html#M000185">Store.get_snapshots</a> method and create a <a
220
+ href="Snapshot.html#M000193">new</a> <a href="Snapshot.html">Snapshot</a>
221
+ object. At the moment the Platform only supports single snapshot.
222
+ </p>
223
+ <p>
224
+ If the response was an error, then an exception will be thrown. If no
225
+ snapshot can be found, then the method returns nil
226
+ </p>
227
+ <pre>
228
+ storeuri:: URI of the store
229
+ content:: response from the API
230
+ </pre>
231
+ <p><a class="source-toggle" href="#"
232
+ onclick="toggleCode('M000192-source');return false;">[Source]</a></p>
233
+ <div class="method-source-code" id="M000192-source">
234
+ <pre>
235
+ <span class="ruby-comment cmt"># File lib/pho/snapshot.rb, line 53</span>
236
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">storeuri</span>, <span class="ruby-identifier">content</span>)
237
+
238
+ <span class="ruby-identifier">doc</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">content</span>)
239
+ <span class="ruby-identifier">root</span> = <span class="ruby-identifier">doc</span>.<span class="ruby-identifier">root</span>
240
+
241
+ <span class="ruby-identifier">store</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">root</span>, <span class="ruby-node">&quot;//*[@rdf:about='#{storeuri}']&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span> )
242
+ <span class="ruby-comment cmt">#not found if there's no snapshot for this store</span>
243
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">store</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">nil</span>
244
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
245
+ <span class="ruby-keyword kw">end</span>
246
+ <span class="ruby-identifier">snapshot</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">store</span>, <span class="ruby-value str">&quot;bf:snapshot&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span>)
247
+ <span class="ruby-identifier">snapshot_url</span> = <span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;rdf:resource&quot;</span>]
248
+ <span class="ruby-identifier">snapshot_el</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">root</span>, <span class="ruby-node">&quot;//*[@rdf:about='#{snapshot_url}']&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span> )
249
+
250
+ <span class="ruby-identifier">el</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">snapshot_el</span>, <span class="ruby-value str">&quot;bf:md5&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span>)
251
+ <span class="ruby-identifier">snapshot_md5_url</span> = <span class="ruby-identifier">el</span>.<span class="ruby-identifier">attributes</span>[<span class="ruby-value str">&quot;rdf:resource&quot;</span>]
252
+
253
+ <span class="ruby-identifier">el</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">snapshot_el</span>, <span class="ruby-value str">&quot;bf:filesize&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span>)
254
+ <span class="ruby-identifier">snapshot_size</span> = <span class="ruby-identifier">el</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot; &quot;</span>)[<span class="ruby-value">0</span>]
255
+ <span class="ruby-identifier">snapshot_units</span> = <span class="ruby-identifier">el</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot; &quot;</span>)[<span class="ruby-value">1</span>]
256
+
257
+ <span class="ruby-identifier">el</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">XPath</span>.<span class="ruby-identifier">first</span>(<span class="ruby-identifier">snapshot_el</span>, <span class="ruby-value str">&quot;dc:date&quot;</span>, <span class="ruby-constant">Pho</span><span class="ruby-operator">::</span><span class="ruby-constant">Namespaces</span><span class="ruby-operator">::</span><span class="ruby-constant">MAPPING</span>)
258
+ <span class="ruby-identifier">snapshot_date</span> = <span class="ruby-identifier">el</span>.<span class="ruby-identifier">text</span>
259
+
260
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">snapshot_url</span>, <span class="ruby-identifier">snapshot_md5_url</span>, <span class="ruby-identifier">snapshot_size</span>, <span class="ruby-identifier">snapshot_units</span>, <span class="ruby-identifier">snapshot_date</span>)
261
+
262
+ <span class="ruby-keyword kw">end</span>
263
+ </pre>
264
+ </div>
265
+ </div>
266
+ </div>
267
+
268
+ <div id="method-M000191" class="method-detail">
269
+ <a name="M000191"></a>
270
+
271
+ <div class="method-heading">
272
+ <a href="#M000191" class="method-signature">
273
+ <span class="method-name">read_from_store</span><span class="method-args">(store)</span>
274
+ </a>
275
+ </div>
276
+
277
+ <div class="method-description">
278
+ <p>
279
+ Read snapshot data from the given store
280
+ </p>
281
+ <table>
282
+ <tr><td valign="top">store:</td><td>reference to a <a href="Store.html">Store</a> object
283
+
284
+ </td></tr>
285
+ </table>
286
+ <p><a class="source-toggle" href="#"
287
+ onclick="toggleCode('M000191-source');return false;">[Source]</a></p>
288
+ <div class="method-source-code" id="M000191-source">
289
+ <pre>
290
+ <span class="ruby-comment cmt"># File lib/pho/snapshot.rb, line 34</span>
291
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Snapshot</span>.<span class="ruby-identifier">read_from_store</span>(<span class="ruby-identifier">store</span>)
292
+ <span class="ruby-identifier">resp</span> = <span class="ruby-identifier">store</span>.<span class="ruby-identifier">get_snapshots</span>()
293
+
294
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">resp</span>.<span class="ruby-identifier">status</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">200</span>)
295
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Response was not successful. Status code was: #{resp.status}&quot;</span>
296
+ <span class="ruby-keyword kw">end</span>
297
+ <span class="ruby-identifier">content</span> = <span class="ruby-identifier">resp</span>.<span class="ruby-identifier">content</span>
298
+
299
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">parse</span>(<span class="ruby-identifier">store</span>.<span class="ruby-identifier">storeuri</span>, <span class="ruby-identifier">content</span>)
300
+ <span class="ruby-keyword kw">end</span>
301
+ </pre>
302
+ </div>
303
+ </div>
304
+ </div>
305
+
306
+ <h3 class="section-bar">Public Instance methods</h3>
307
+
308
+ <div id="method-M000195" class="method-detail">
309
+ <a name="M000195"></a>
310
+
311
+ <div class="method-heading">
312
+ <a href="#M000195" class="method-signature">
313
+ <span class="method-name">backup</span><span class="method-args">(store, dir=Dir.tmpdir)</span>
314
+ </a>
315
+ </div>
316
+
317
+ <div class="method-description">
318
+ <p>
319
+ Download this snapshot to the specified directory. Will automatically
320
+ calculate an MD5 checksum for the download and compare it against the
321
+ published value. If they don&#8216;t match then a RuntimeError will be
322
+ raised
323
+ </p>
324
+ <table>
325
+ <tr><td valign="top">store:</td><td>the store to <a href="Snapshot.html#M000195">backup</a>
326
+
327
+ </td></tr>
328
+ <tr><td valign="top">dir:</td><td>directory in which snapshot will be stored
329
+
330
+ </td></tr>
331
+ </table>
332
+ <p><a class="source-toggle" href="#"
333
+ onclick="toggleCode('M000195-source');return false;">[Source]</a></p>
334
+ <div class="method-source-code" id="M000195-source">
335
+ <pre>
336
+ <span class="ruby-comment cmt"># File lib/pho/snapshot.rb, line 101</span>
337
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">backup</span>(<span class="ruby-identifier">store</span>, <span class="ruby-identifier">dir</span>=<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">tmpdir</span>)
338
+
339
+ <span class="ruby-identifier">published_md5</span> = <span class="ruby-identifier">read_md5</span>(<span class="ruby-identifier">store</span>.<span class="ruby-identifier">client</span>)
340
+
341
+ <span class="ruby-identifier">digest</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">MD5</span>.<span class="ruby-identifier">new</span>()
342
+
343
+ <span class="ruby-identifier">filename</span> = <span class="ruby-ivar">@url</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">&quot;/&quot;</span>).<span class="ruby-identifier">last</span>
344
+ <span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>( <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>, <span class="ruby-identifier">filename</span>), <span class="ruby-value str">&quot;w&quot;</span> ) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
345
+
346
+ <span class="ruby-comment cmt">#FIXME: this is not efficient as the snapshot may be very large and this</span>
347
+ <span class="ruby-comment cmt">#will just read all of the data into memory</span>
348
+ <span class="ruby-identifier">content</span> = <span class="ruby-identifier">store</span>.<span class="ruby-identifier">client</span>.<span class="ruby-identifier">get_content</span>(<span class="ruby-ivar">@url</span>)
349
+ <span class="ruby-identifier">file</span>.<span class="ruby-identifier">print</span>(<span class="ruby-identifier">content</span>)
350
+ <span class="ruby-identifier">digest</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">content</span>
351
+
352
+ <span class="ruby-keyword kw">end</span>
353
+
354
+ <span class="ruby-identifier">calc_md5</span> = <span class="ruby-identifier">digest</span>.<span class="ruby-identifier">hexdigest</span>
355
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">calc_md5</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">published_md5</span>)
356
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Calculated digest of #{calc_md5} but does not match published md5 #{published_md5}&quot;</span>
357
+ <span class="ruby-keyword kw">end</span>
358
+ <span class="ruby-keyword kw">end</span>
359
+ </pre>
360
+ </div>
361
+ </div>
362
+ </div>
363
+
364
+ <div id="method-M000194" class="method-detail">
365
+ <a name="M000194"></a>
366
+
367
+ <div class="method-heading">
368
+ <a href="#M000194" class="method-signature">
369
+ <span class="method-name">read_md5</span><span class="method-args">(client=HttpClient.new())</span>
370
+ </a>
371
+ </div>
372
+
373
+ <div class="method-description">
374
+ <p>
375
+ Read the published MD5 value
376
+ </p>
377
+ <p><a class="source-toggle" href="#"
378
+ onclick="toggleCode('M000194-source');return false;">[Source]</a></p>
379
+ <div class="method-source-code" id="M000194-source">
380
+ <pre>
381
+ <span class="ruby-comment cmt"># File lib/pho/snapshot.rb, line 91</span>
382
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_md5</span>(<span class="ruby-identifier">client</span>=<span class="ruby-constant">HttpClient</span>.<span class="ruby-identifier">new</span>())
383
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">client</span>.<span class="ruby-identifier">get_content</span>(<span class="ruby-ivar">@md5_url</span>)
384
+ <span class="ruby-keyword kw">end</span>
385
+ </pre>
386
+ </div>
387
+ </div>
388
+ </div>
389
+
390
+
391
+ </div>
392
+
393
+
394
+ </div>
395
+
396
+
397
+ <div id="validator-badges">
398
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
399
+ </div>
400
+
401
+ </body>
402
+ </html>