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,325 @@
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::ResourceHash::Converter</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::ResourceHash::Converter</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
+ </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 for converting to and from resource hashes
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="#M000086">parse</a>&nbsp;&nbsp;
96
+ <a href="#M000082">parse_json</a>&nbsp;&nbsp;
97
+ <a href="#M000084">parse_ntriples</a>&nbsp;&nbsp;
98
+ <a href="#M000083">parse_rdfxml</a>&nbsp;&nbsp;
99
+ <a href="#M000085">parse_turtle</a>&nbsp;&nbsp;
100
+ <a href="#M000087">serialize_json</a>&nbsp;&nbsp;
101
+ </div>
102
+ </div>
103
+
104
+ </div>
105
+
106
+
107
+ <!-- if includes -->
108
+
109
+ <div id="section">
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <!-- if method_list -->
119
+ <div id="methods">
120
+ <h3 class="section-bar">Public Class methods</h3>
121
+
122
+ <div id="method-M000086" class="method-detail">
123
+ <a name="M000086"></a>
124
+
125
+ <div class="method-heading">
126
+ <a href="#M000086" class="method-signature">
127
+ <span class="method-name">parse</span><span class="method-args">(data, base_uri, format=&quot;rdfxml&quot;)</span>
128
+ </a>
129
+ </div>
130
+
131
+ <div class="method-description">
132
+ <p>
133
+ Convert specified format into a <a
134
+ href="../ResourceHash.html">ResourceHash</a>
135
+ </p>
136
+ <pre>
137
+ format:: one of rdfxml, ntriples, turtle
138
+ data:: String containing the data to be parsed
139
+ base_uri:: base uri of the data
140
+ </pre>
141
+ <p><a class="source-toggle" href="#"
142
+ onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
143
+ <div class="method-source-code" id="M000086-source">
144
+ <pre>
145
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 53</span>
146
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">base_uri</span>, <span class="ruby-identifier">format</span>=<span class="ruby-value str">&quot;rdfxml&quot;</span>)
147
+ <span class="ruby-identifier">model</span> = <span class="ruby-constant">Redland</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span>.<span class="ruby-identifier">new</span>()
148
+ <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">format</span>
149
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;rdfxml&quot;</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">mime</span>=<span class="ruby-value str">&quot;application/rdf+xml&quot;</span>
150
+ <span class="ruby-keyword kw">when</span> <span class="ruby-value str">&quot;json&quot;</span> <span class="ruby-keyword kw">then</span> <span class="ruby-identifier">mime</span>=<span class="ruby-value str">&quot;application/json&quot;</span>
151
+ <span class="ruby-keyword kw">else</span> <span class="ruby-identifier">mime</span>=<span class="ruby-value str">&quot;&quot;</span>
152
+ <span class="ruby-keyword kw">end</span>
153
+
154
+ <span class="ruby-identifier">parser</span> = <span class="ruby-constant">Redland</span><span class="ruby-operator">::</span><span class="ruby-constant">Parser</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">format</span>, <span class="ruby-identifier">mime</span>)
155
+ <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">parse_string_into_model</span>(<span class="ruby-identifier">model</span>, <span class="ruby-identifier">data</span>, <span class="ruby-identifier">base_uri</span>)
156
+ <span class="ruby-identifier">serializer</span> = <span class="ruby-constant">Redland</span><span class="ruby-operator">::</span><span class="ruby-constant">Serializer</span>.<span class="ruby-identifier">new</span>( <span class="ruby-value str">&quot;json&quot;</span>, <span class="ruby-value str">&quot;application/json&quot;</span> )
157
+ <span class="ruby-identifier">json</span> = <span class="ruby-identifier">serializer</span>.<span class="ruby-identifier">model_to_string</span>(<span class="ruby-constant">Redland</span><span class="ruby-operator">::</span><span class="ruby-constant">Uri</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">base_uri</span>), <span class="ruby-identifier">model</span>)
158
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>( <span class="ruby-identifier">json</span> )
159
+ <span class="ruby-keyword kw">end</span>
160
+ </pre>
161
+ </div>
162
+ </div>
163
+ </div>
164
+
165
+ <div id="method-M000082" class="method-detail">
166
+ <a name="M000082"></a>
167
+
168
+ <div class="method-heading">
169
+ <a href="#M000082" class="method-signature">
170
+ <span class="method-name">parse_json</span><span class="method-args">(json)</span>
171
+ </a>
172
+ </div>
173
+
174
+ <div class="method-description">
175
+ <p>
176
+ Parse JSON structured according to the <a
177
+ href="../RDF.html">RDF</a>-in-JSON specification into a Ruby resource hash.
178
+ Simply invokes the JSON parser.
179
+ </p>
180
+ <pre>
181
+ json:: valid RDF-in-JSON
182
+ </pre>
183
+ <p><a class="source-toggle" href="#"
184
+ onclick="toggleCode('M000082-source');return false;">[Source]</a></p>
185
+ <div class="method-source-code" id="M000082-source">
186
+ <pre>
187
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 23</span>
188
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_json</span>(<span class="ruby-identifier">json</span>)
189
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">json</span>)
190
+ <span class="ruby-keyword kw">end</span>
191
+ </pre>
192
+ </div>
193
+ </div>
194
+ </div>
195
+
196
+ <div id="method-M000084" class="method-detail">
197
+ <a name="M000084"></a>
198
+
199
+ <div class="method-heading">
200
+ <a href="#M000084" class="method-signature">
201
+ <span class="method-name">parse_ntriples</span><span class="method-args">(ntriples, base_uri)</span>
202
+ </a>
203
+ </div>
204
+
205
+ <div class="method-description">
206
+ <p>
207
+ Parse a string containing N-Triples into a resource hash
208
+ </p>
209
+ <pre>
210
+ ntriples:: a String containing N-Triples
211
+ </pre>
212
+ <p><a class="source-toggle" href="#"
213
+ onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
214
+ <div class="method-source-code" id="M000084-source">
215
+ <pre>
216
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 37</span>
217
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_ntriples</span>(<span class="ruby-identifier">ntriples</span>, <span class="ruby-identifier">base_uri</span>)
218
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">ntriples</span>, <span class="ruby-identifier">base_uri</span>, <span class="ruby-value str">&quot;ntriples&quot;</span>)
219
+ <span class="ruby-keyword kw">end</span>
220
+ </pre>
221
+ </div>
222
+ </div>
223
+ </div>
224
+
225
+ <div id="method-M000083" class="method-detail">
226
+ <a name="M000083"></a>
227
+
228
+ <div class="method-heading">
229
+ <a href="#M000083" class="method-signature">
230
+ <span class="method-name">parse_rdfxml</span><span class="method-args">(rdfxml, base_uri)</span>
231
+ </a>
232
+ </div>
233
+
234
+ <div class="method-description">
235
+ <p>
236
+ Parse a string containing <a href="../RDF.html">RDF</a>/XML into a resource
237
+ hash
238
+ </p>
239
+ <pre>
240
+ rdfxml: a String containing RDF/XML
241
+ </pre>
242
+ <p><a class="source-toggle" href="#"
243
+ onclick="toggleCode('M000083-source');return false;">[Source]</a></p>
244
+ <div class="method-source-code" id="M000083-source">
245
+ <pre>
246
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 30</span>
247
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_rdfxml</span>(<span class="ruby-identifier">rdfxml</span>, <span class="ruby-identifier">base_uri</span>)
248
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">rdfxml</span>, <span class="ruby-identifier">base_uri</span>, <span class="ruby-value str">&quot;rdfxml&quot;</span>)
249
+ <span class="ruby-keyword kw">end</span>
250
+ </pre>
251
+ </div>
252
+ </div>
253
+ </div>
254
+
255
+ <div id="method-M000085" class="method-detail">
256
+ <a name="M000085"></a>
257
+
258
+ <div class="method-heading">
259
+ <a href="#M000085" class="method-signature">
260
+ <span class="method-name">parse_turtle</span><span class="method-args">(turtle, base_uri)</span>
261
+ </a>
262
+ </div>
263
+
264
+ <div class="method-description">
265
+ <p>
266
+ Parse a string containing Turtle into a resource hash
267
+ </p>
268
+ <pre>
269
+ ntriples:: a String containing Turtle
270
+ </pre>
271
+ <p><a class="source-toggle" href="#"
272
+ onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
273
+ <div class="method-source-code" id="M000085-source">
274
+ <pre>
275
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 44</span>
276
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse_turtle</span>(<span class="ruby-identifier">turtle</span>, <span class="ruby-identifier">base_uri</span>)
277
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-identifier">turtle</span>, <span class="ruby-identifier">base_uri</span>, <span class="ruby-value str">&quot;turtle&quot;</span>)
278
+ <span class="ruby-keyword kw">end</span>
279
+ </pre>
280
+ </div>
281
+ </div>
282
+ </div>
283
+
284
+ <div id="method-M000087" class="method-detail">
285
+ <a name="M000087"></a>
286
+
287
+ <div class="method-heading">
288
+ <a href="#M000087" class="method-signature">
289
+ <span class="method-name">serialize_json</span><span class="method-args">(hash)</span>
290
+ </a>
291
+ </div>
292
+
293
+ <div class="method-description">
294
+ <p>
295
+ Serialize a resource hash as <a href="../RDF.html">RDF</a>-in-JSON
296
+ </p>
297
+ <pre>
298
+ hash:: the resource hash to serialize
299
+ </pre>
300
+ <p><a class="source-toggle" href="#"
301
+ onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
302
+ <div class="method-source-code" id="M000087-source">
303
+ <pre>
304
+ <span class="ruby-comment cmt"># File lib/pho/converter.rb, line 71</span>
305
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">Converter</span>.<span class="ruby-identifier">serialize_json</span>(<span class="ruby-identifier">hash</span>)
306
+ <span class="ruby-keyword kw">return</span> <span class="ruby-constant">JSON</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">hash</span>)
307
+ <span class="ruby-keyword kw">end</span>
308
+ </pre>
309
+ </div>
310
+ </div>
311
+ </div>
312
+
313
+
314
+ </div>
315
+
316
+
317
+ </div>
318
+
319
+
320
+ <div id="validator-badges">
321
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
322
+ </div>
323
+
324
+ </body>
325
+ </html>
@@ -0,0 +1,241 @@
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::ResourceHash::SetAlgebra</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::ResourceHash::SetAlgebra</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/pho/resource_hash_rb.html">
59
+ lib/pho/resource_hash.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 providing set algebra methods over triple hashes
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="#M000088">minus</a>&nbsp;&nbsp;
96
+ <a href="#M000089">object_in_array?</a>&nbsp;&nbsp;
97
+ </div>
98
+ </div>
99
+
100
+ </div>
101
+
102
+
103
+ <!-- if includes -->
104
+
105
+ <div id="section">
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+ <!-- if method_list -->
115
+ <div id="methods">
116
+ <h3 class="section-bar">Public Class methods</h3>
117
+
118
+ <div id="method-M000088" class="method-detail">
119
+ <a name="M000088"></a>
120
+
121
+ <div class="method-heading">
122
+ <a href="#M000088" class="method-signature">
123
+ <span class="method-name">minus</span><span class="method-args">(first, second)</span>
124
+ </a>
125
+ </div>
126
+
127
+ <div class="method-description">
128
+ <p>
129
+ Accepts two triple hashes, expressed as <a
130
+ href="../RDF.html">RDF</a>-in-JSON and returns a new Ruby data structure
131
+ that constitutes the different between the two graphs
132
+ </p>
133
+ <p>
134
+ i.e. the return value will be a hash containing the triples that are in the
135
+ first graph but which are not present in the second.
136
+ </p>
137
+ <pre>
138
+ first:: the first graph
139
+ second:: the second graph.
140
+ </pre>
141
+ <p><a class="source-toggle" href="#"
142
+ onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
143
+ <div class="method-source-code" id="M000088-source">
144
+ <pre>
145
+ <span class="ruby-comment cmt"># File lib/pho/resource_hash.rb, line 20</span>
146
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">SetAlgebra</span>.<span class="ruby-identifier">minus</span>(<span class="ruby-identifier">first</span>, <span class="ruby-identifier">second</span>)
147
+
148
+ <span class="ruby-identifier">difference</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
149
+ <span class="ruby-identifier">first</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">uri</span>,<span class="ruby-identifier">properties</span><span class="ruby-operator">|</span>
150
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">second</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">uri</span>)
151
+ <span class="ruby-identifier">properties</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">predicate</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
152
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">second</span>[<span class="ruby-identifier">uri</span>].<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">predicate</span>)
153
+ <span class="ruby-comment cmt">#second hash has same uri and predicate, so check value arrays </span>
154
+ <span class="ruby-identifier">second_value</span> = <span class="ruby-identifier">second</span>[<span class="ruby-identifier">uri</span>][<span class="ruby-identifier">predicate</span>]
155
+ <span class="ruby-identifier">value</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span>
156
+
157
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">object_in_array?</span>(<span class="ruby-identifier">second_value</span>, <span class="ruby-identifier">val</span>)
158
+
159
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
160
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>][<span class="ruby-identifier">predicate</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
161
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>][<span class="ruby-identifier">predicate</span>] <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">val</span>
162
+ <span class="ruby-keyword kw">end</span>
163
+ <span class="ruby-keyword kw">end</span>
164
+
165
+ <span class="ruby-keyword kw">else</span>
166
+ <span class="ruby-comment cmt">#uri is in second, but not this property and value</span>
167
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>] <span class="ruby-operator">||=</span> <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>
168
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>][<span class="ruby-identifier">predicate</span>] = <span class="ruby-identifier">value</span>
169
+ <span class="ruby-keyword kw">end</span>
170
+ <span class="ruby-keyword kw">end</span>
171
+ <span class="ruby-keyword kw">else</span>
172
+ <span class="ruby-comment cmt">#uri not in second, so pass all straight-through</span>
173
+ <span class="ruby-identifier">difference</span>[<span class="ruby-identifier">uri</span>] = <span class="ruby-identifier">properties</span>
174
+ <span class="ruby-keyword kw">end</span>
175
+
176
+ <span class="ruby-keyword kw">end</span>
177
+
178
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">difference</span>
179
+
180
+ <span class="ruby-keyword kw">end</span>
181
+ </pre>
182
+ </div>
183
+ </div>
184
+ </div>
185
+
186
+ <div id="method-M000089" class="method-detail">
187
+ <a name="M000089"></a>
188
+
189
+ <div class="method-heading">
190
+ <a href="#M000089" class="method-signature">
191
+ <span class="method-name">object_in_array?</span><span class="method-args">(array, val)</span>
192
+ </a>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+ <p>
197
+ Is there an object in the specified array, that matches the provided
198
+ description
199
+ </p>
200
+ <p><a class="source-toggle" href="#"
201
+ onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
202
+ <div class="method-source-code" id="M000089-source">
203
+ <pre>
204
+ <span class="ruby-comment cmt"># File lib/pho/resource_hash.rb, line 57</span>
205
+ <span class="ruby-keyword kw">def</span> <span class="ruby-constant">SetAlgebra</span>.<span class="ruby-identifier">object_in_array?</span>(<span class="ruby-identifier">array</span>, <span class="ruby-identifier">val</span>)
206
+ <span class="ruby-identifier">array</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">entry</span><span class="ruby-operator">|</span>
207
+
208
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">val</span>[<span class="ruby-value str">&quot;type&quot;</span>]
209
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>[<span class="ruby-value str">&quot;value&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">val</span>[<span class="ruby-value str">&quot;value&quot;</span>]
210
+
211
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>[<span class="ruby-value str">&quot;type&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;literal&quot;</span>
212
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">entry</span>[<span class="ruby-value str">&quot;datatype&quot;</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">val</span>[<span class="ruby-value str">&quot;datatype&quot;</span>] <span class="ruby-operator">&amp;&amp;</span>
213
+ <span class="ruby-identifier">entry</span>[<span class="ruby-value str">&quot;lang&quot;</span>] = <span class="ruby-identifier">val</span>[<span class="ruby-value str">&quot;lang&quot;</span>]
214
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
215
+ <span class="ruby-keyword kw">end</span>
216
+ <span class="ruby-keyword kw">end</span>
217
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
218
+ <span class="ruby-keyword kw">end</span>
219
+
220
+ <span class="ruby-keyword kw">end</span>
221
+ <span class="ruby-keyword kw">end</span>
222
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span>
223
+ <span class="ruby-keyword kw">end</span>
224
+ </pre>
225
+ </div>
226
+ </div>
227
+ </div>
228
+
229
+
230
+ </div>
231
+
232
+
233
+ </div>
234
+
235
+
236
+ <div id="validator-badges">
237
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
238
+ </div>
239
+
240
+ </body>
241
+ </html>