longleaf 0.2.0.pre.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +84 -0
  3. data/.gitignore +4 -2
  4. data/.rubocop.yml +42 -2
  5. data/.rubocop_todo.yml +390 -311
  6. data/.yardopts +1 -0
  7. data/Gemfile +16 -1
  8. data/README.md +67 -13
  9. data/Rakefile +6 -0
  10. data/bin/setup +16 -1
  11. data/docs/aboutlongleaf.md +28 -0
  12. data/docs/extra.css +32 -0
  13. data/docs/img/change-file.png +0 -0
  14. data/docs/img/ll-example-preserved.png +0 -0
  15. data/docs/index.md +19 -0
  16. data/docs/install.md +66 -0
  17. data/docs/ll-example/config-example-relative.yml +33 -0
  18. data/docs/ll-example/files-dir/LLexample-PDF.pdf +0 -0
  19. data/docs/ll-example/files-dir/LLexample-TOCHANGE.txt +15 -0
  20. data/docs/ll-example/files-dir/LLexample-tokeep.txt +10 -0
  21. data/docs/ll-example/metadata-dir/.gitkeep +0 -0
  22. data/docs/ll-example/replica-files/.gitkeep +0 -0
  23. data/docs/ll-example/replica-metadata/.gitkeep +0 -0
  24. data/docs/quickstart.md +270 -0
  25. data/docs/rdocs/Longleaf.html +135 -0
  26. data/docs/rdocs/Longleaf/AppFields.html +178 -0
  27. data/docs/rdocs/Longleaf/ApplicationConfigDeserializer.html +631 -0
  28. data/docs/rdocs/Longleaf/ApplicationConfigManager.html +610 -0
  29. data/docs/rdocs/Longleaf/ApplicationConfigValidator.html +238 -0
  30. data/docs/rdocs/Longleaf/CLI.html +909 -0
  31. data/docs/rdocs/Longleaf/ChecksumMismatchError.html +151 -0
  32. data/docs/rdocs/Longleaf/ConfigBuilder.html +1339 -0
  33. data/docs/rdocs/Longleaf/ConfigurationError.html +143 -0
  34. data/docs/rdocs/Longleaf/ConfigurationValidator.html +227 -0
  35. data/docs/rdocs/Longleaf/DeregisterCommand.html +420 -0
  36. data/docs/rdocs/Longleaf/DeregisterEvent.html +453 -0
  37. data/docs/rdocs/Longleaf/DeregistrationError.html +151 -0
  38. data/docs/rdocs/Longleaf/DigestHelper.html +419 -0
  39. data/docs/rdocs/Longleaf/EventError.html +147 -0
  40. data/docs/rdocs/Longleaf/EventNames.html +163 -0
  41. data/docs/rdocs/Longleaf/EventStatusTracking.html +656 -0
  42. data/docs/rdocs/Longleaf/FileCheckService.html +540 -0
  43. data/docs/rdocs/Longleaf/FileHelpers.html +520 -0
  44. data/docs/rdocs/Longleaf/FileRecord.html +716 -0
  45. data/docs/rdocs/Longleaf/FileSelector.html +901 -0
  46. data/docs/rdocs/Longleaf/FixityCheckService.html +691 -0
  47. data/docs/rdocs/Longleaf/IndexManager.html +1155 -0
  48. data/docs/rdocs/Longleaf/InvalidDigestAlgorithmError.html +143 -0
  49. data/docs/rdocs/Longleaf/InvalidStoragePathError.html +143 -0
  50. data/docs/rdocs/Longleaf/Logging.html +405 -0
  51. data/docs/rdocs/Longleaf/Logging/RedirectingLogger.html +1213 -0
  52. data/docs/rdocs/Longleaf/LongleafError.html +139 -0
  53. data/docs/rdocs/Longleaf/MDFields.html +193 -0
  54. data/docs/rdocs/Longleaf/MetadataBuilder.html +787 -0
  55. data/docs/rdocs/Longleaf/MetadataDeserializer.html +537 -0
  56. data/docs/rdocs/Longleaf/MetadataError.html +143 -0
  57. data/docs/rdocs/Longleaf/MetadataPersistenceManager.html +539 -0
  58. data/docs/rdocs/Longleaf/MetadataRecord.html +1411 -0
  59. data/docs/rdocs/Longleaf/MetadataSerializer.html +786 -0
  60. data/docs/rdocs/Longleaf/PreservationServiceError.html +147 -0
  61. data/docs/rdocs/Longleaf/PreserveCommand.html +410 -0
  62. data/docs/rdocs/Longleaf/PreserveEvent.html +491 -0
  63. data/docs/rdocs/Longleaf/RegisterCommand.html +428 -0
  64. data/docs/rdocs/Longleaf/RegisterEvent.html +628 -0
  65. data/docs/rdocs/Longleaf/RegisteredFileSelector.html +446 -0
  66. data/docs/rdocs/Longleaf/RegistrationError.html +151 -0
  67. data/docs/rdocs/Longleaf/ReindexCommand.html +576 -0
  68. data/docs/rdocs/Longleaf/RsyncReplicationService.html +1180 -0
  69. data/docs/rdocs/Longleaf/SequelIndexDriver.html +1978 -0
  70. data/docs/rdocs/Longleaf/ServiceCandidateFilesystemIterator.html +572 -0
  71. data/docs/rdocs/Longleaf/ServiceCandidateIndexIterator.html +532 -0
  72. data/docs/rdocs/Longleaf/ServiceCandidateLocator.html +333 -0
  73. data/docs/rdocs/Longleaf/ServiceClassCache.html +725 -0
  74. data/docs/rdocs/Longleaf/ServiceDateHelper.html +425 -0
  75. data/docs/rdocs/Longleaf/ServiceDefinition.html +683 -0
  76. data/docs/rdocs/Longleaf/ServiceDefinitionManager.html +371 -0
  77. data/docs/rdocs/Longleaf/ServiceDefinitionValidator.html +269 -0
  78. data/docs/rdocs/Longleaf/ServiceFields.html +173 -0
  79. data/docs/rdocs/Longleaf/ServiceManager.html +1229 -0
  80. data/docs/rdocs/Longleaf/ServiceMappingManager.html +410 -0
  81. data/docs/rdocs/Longleaf/ServiceMappingValidator.html +347 -0
  82. data/docs/rdocs/Longleaf/ServiceRecord.html +821 -0
  83. data/docs/rdocs/Longleaf/StorageLocation.html +985 -0
  84. data/docs/rdocs/Longleaf/StorageLocationManager.html +729 -0
  85. data/docs/rdocs/Longleaf/StorageLocationUnavailableError.html +143 -0
  86. data/docs/rdocs/Longleaf/StorageLocationValidator.html +373 -0
  87. data/docs/rdocs/Longleaf/StoragePathValidator.html +253 -0
  88. data/docs/rdocs/Longleaf/SystemConfigBuilder.html +441 -0
  89. data/docs/rdocs/Longleaf/SystemConfigFields.html +163 -0
  90. data/docs/rdocs/Longleaf/ValidateConfigCommand.html +451 -0
  91. data/docs/rdocs/Longleaf/ValidateMetadataCommand.html +408 -0
  92. data/docs/rdocs/_index.html +660 -0
  93. data/docs/rdocs/class_list.html +51 -0
  94. data/docs/rdocs/css/common.css +1 -0
  95. data/docs/rdocs/css/full_list.css +58 -0
  96. data/docs/rdocs/css/style.css +496 -0
  97. data/docs/rdocs/file.README.html +165 -0
  98. data/docs/rdocs/file_list.html +56 -0
  99. data/docs/rdocs/frames.html +17 -0
  100. data/docs/rdocs/index.html +165 -0
  101. data/docs/rdocs/js/app.js +303 -0
  102. data/docs/rdocs/js/full_list.js +216 -0
  103. data/docs/rdocs/js/jquery.js +4 -0
  104. data/docs/rdocs/method_list.html +2051 -0
  105. data/docs/rdocs/top-level-namespace.html +110 -0
  106. data/lib/longleaf/candidates/file_selector.rb +47 -15
  107. data/lib/longleaf/candidates/registered_file_selector.rb +67 -0
  108. data/lib/longleaf/candidates/service_candidate_filesystem_iterator.rb +29 -35
  109. data/lib/longleaf/candidates/service_candidate_index_iterator.rb +84 -0
  110. data/lib/longleaf/candidates/service_candidate_locator.rb +9 -4
  111. data/lib/longleaf/cli.rb +162 -80
  112. data/lib/longleaf/commands/deregister_command.rb +12 -11
  113. data/lib/longleaf/commands/preserve_command.rb +13 -8
  114. data/lib/longleaf/commands/register_command.rb +9 -6
  115. data/lib/longleaf/commands/reindex_command.rb +92 -0
  116. data/lib/longleaf/commands/validate_config_command.rb +27 -6
  117. data/lib/longleaf/commands/validate_metadata_command.rb +11 -9
  118. data/lib/longleaf/errors.rb +12 -12
  119. data/lib/longleaf/events/deregister_event.rb +13 -15
  120. data/lib/longleaf/events/event_status_tracking.rb +7 -7
  121. data/lib/longleaf/events/preserve_event.rb +24 -14
  122. data/lib/longleaf/events/register_event.rb +21 -35
  123. data/lib/longleaf/helpers/digest_helper.rb +4 -4
  124. data/lib/longleaf/helpers/service_date_helper.rb +5 -6
  125. data/lib/longleaf/indexing/index_manager.rb +101 -0
  126. data/lib/longleaf/indexing/sequel_index_driver.rb +324 -0
  127. data/lib/longleaf/logging.rb +4 -4
  128. data/lib/longleaf/logging/redirecting_logger.rb +20 -20
  129. data/lib/longleaf/models/app_fields.rb +2 -1
  130. data/lib/longleaf/models/file_record.rb +10 -6
  131. data/lib/longleaf/models/md_fields.rb +1 -1
  132. data/lib/longleaf/models/metadata_record.rb +22 -12
  133. data/lib/longleaf/models/service_definition.rb +3 -3
  134. data/lib/longleaf/models/service_fields.rb +1 -1
  135. data/lib/longleaf/models/service_record.rb +6 -5
  136. data/lib/longleaf/models/storage_location.rb +26 -7
  137. data/lib/longleaf/models/system_config_fields.rb +9 -0
  138. data/lib/longleaf/preservation_services/file_check_service.rb +58 -0
  139. data/lib/longleaf/preservation_services/fixity_check_service.rb +16 -14
  140. data/lib/longleaf/preservation_services/rsync_replication_service.rb +32 -31
  141. data/lib/longleaf/services/application_config_deserializer.rb +55 -18
  142. data/lib/longleaf/services/application_config_manager.rb +16 -4
  143. data/lib/longleaf/services/application_config_validator.rb +1 -2
  144. data/lib/longleaf/services/configuration_validator.rb +6 -4
  145. data/lib/longleaf/services/metadata_deserializer.rb +40 -38
  146. data/lib/longleaf/services/metadata_persistence_manager.rb +46 -0
  147. data/lib/longleaf/services/metadata_serializer.rb +23 -22
  148. data/lib/longleaf/services/service_class_cache.rb +15 -15
  149. data/lib/longleaf/services/service_definition_manager.rb +5 -6
  150. data/lib/longleaf/services/service_definition_validator.rb +5 -6
  151. data/lib/longleaf/services/service_manager.rb +37 -17
  152. data/lib/longleaf/services/service_mapping_manager.rb +9 -9
  153. data/lib/longleaf/services/service_mapping_validator.rb +9 -10
  154. data/lib/longleaf/services/storage_location_manager.rb +22 -8
  155. data/lib/longleaf/services/storage_location_validator.rb +11 -8
  156. data/lib/longleaf/services/storage_path_validator.rb +1 -1
  157. data/lib/longleaf/specs/config_builder.rb +30 -17
  158. data/lib/longleaf/specs/custom_matchers.rb +1 -1
  159. data/lib/longleaf/specs/file_helpers.rb +15 -14
  160. data/lib/longleaf/specs/metadata_builder.rb +91 -0
  161. data/lib/longleaf/specs/system_config_builder.rb +27 -0
  162. data/lib/longleaf/version.rb +1 -1
  163. data/longleaf.gemspec +17 -7
  164. data/mkdocs.yml +20 -0
  165. metadata +233 -22
@@ -0,0 +1,333 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Longleaf::ServiceCandidateLocator
8
+
9
+ &mdash; Documentation by YARD 0.9.19
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Longleaf::ServiceCandidateLocator";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Longleaf.html" title="Longleaf (module)">Longleaf</a></span></span>
41
+ &raquo;
42
+ <span class="title">ServiceCandidateLocator</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Longleaf::ServiceCandidateLocator
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Longleaf::ServiceCandidateLocator</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/longleaf/candidates/service_candidate_locator.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Service which locates files that have services which need to be performed on them.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+ <h2>
122
+ Instance Method Summary
123
+ <small><a href="#" class="summary_toggle">collapse</a></small>
124
+ </h2>
125
+
126
+ <ul class="summary">
127
+
128
+ <li class="public ">
129
+ <span class="summary_signature">
130
+
131
+ <a href="#candidate_iterator-instance_method" title="#candidate_iterator (instance method)">#<strong>candidate_iterator</strong>(file_selector, event, force = false) &#x21d2; Object </a>
132
+
133
+
134
+
135
+ </span>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+ <span class="summary_desc"><div class='inline'>
146
+ <p>Get a iterator of the candidates matching the given FileSelector which need services run.</p>
147
+ </div></span>
148
+
149
+ </li>
150
+
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(app_config) &#x21d2; ServiceCandidateLocator </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+ <span class="note title constructor">constructor</span>
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+ <span class="summary_desc"><div class='inline'>
172
+ <p>A new instance of ServiceCandidateLocator.</p>
173
+ </div></span>
174
+
175
+ </li>
176
+
177
+
178
+ </ul>
179
+
180
+
181
+ <div id="constructor_details" class="method_details_list">
182
+ <h2>Constructor Details</h2>
183
+
184
+ <div class="method_details first">
185
+ <h3 class="signature first" id="initialize-instance_method">
186
+
187
+ #<strong>initialize</strong>(app_config) &#x21d2; <tt><span class='object_link'><a href="" title="Longleaf::ServiceCandidateLocator (class)">ServiceCandidateLocator</a></span></tt>
188
+
189
+
190
+
191
+
192
+
193
+ </h3><div class="docstring">
194
+ <div class="discussion">
195
+
196
+ <p>Returns a new instance of ServiceCandidateLocator</p>
197
+
198
+
199
+ </div>
200
+ </div>
201
+ <div class="tags">
202
+
203
+
204
+ </div><table class="source_code">
205
+ <tr>
206
+ <td>
207
+ <pre class="lines">
208
+
209
+
210
+ 7
211
+ 8
212
+ 9</pre>
213
+ </td>
214
+ <td>
215
+ <pre class="code"><span class="info file"># File 'lib/longleaf/candidates/service_candidate_locator.rb', line 7</span>
216
+
217
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app_config'>app_config</span><span class='rparen'>)</span>
218
+ <span class='ivar'>@app_config</span> <span class='op'>=</span> <span class='id identifier rubyid_app_config'>app_config</span>
219
+ <span class='kw'>end</span></pre>
220
+ </td>
221
+ </tr>
222
+ </table>
223
+ </div>
224
+
225
+ </div>
226
+
227
+
228
+ <div id="instance_method_details" class="method_details_list">
229
+ <h2>Instance Method Details</h2>
230
+
231
+
232
+ <div class="method_details first">
233
+ <h3 class="signature first" id="candidate_iterator-instance_method">
234
+
235
+ #<strong>candidate_iterator</strong>(file_selector, event, force = false) &#x21d2; <tt>Object</tt>
236
+
237
+
238
+
239
+
240
+
241
+ </h3><div class="docstring">
242
+ <div class="discussion">
243
+
244
+ <p>Get a iterator of the candidates matching the given FileSelector which need services run.</p>
245
+
246
+
247
+ </div>
248
+ </div>
249
+ <div class="tags">
250
+ <p class="tag_title">Parameters:</p>
251
+ <ul class="param">
252
+
253
+ <li>
254
+
255
+ <span class='name'>file_selector</span>
256
+
257
+
258
+ <span class='type'>(<tt><span class='object_link'><a href="FileSelector.html" title="Longleaf::FileSelector (class)">FileSelector</a></span></tt>)</span>
259
+
260
+
261
+
262
+ &mdash;
263
+ <div class='inline'>
264
+ <p>selector identifying the files to pull candidates from.</p>
265
+ </div>
266
+
267
+ </li>
268
+
269
+ </ul>
270
+
271
+ <p class="tag_title">Returns:</p>
272
+ <ul class="return">
273
+
274
+ <li>
275
+
276
+
277
+ <span class='type'></span>
278
+
279
+
280
+
281
+
282
+ <div class='inline'>
283
+ <p>an iterator</p>
284
+ </div>
285
+
286
+ </li>
287
+
288
+ </ul>
289
+
290
+ </div><table class="source_code">
291
+ <tr>
292
+ <td>
293
+ <pre class="lines">
294
+
295
+
296
+ 14
297
+ 15
298
+ 16
299
+ 17
300
+ 18
301
+ 19
302
+ 20
303
+ 21</pre>
304
+ </td>
305
+ <td>
306
+ <pre class="code"><span class="info file"># File 'lib/longleaf/candidates/service_candidate_locator.rb', line 14</span>
307
+
308
+ <span class='kw'>def</span> <span class='id identifier rubyid_candidate_iterator'>candidate_iterator</span><span class='lparen'>(</span><span class='id identifier rubyid_file_selector'>file_selector</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='comma'>,</span> <span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
309
+ <span class='kw'>if</span> <span class='ivar'>@app_config</span><span class='period'>.</span><span class='id identifier rubyid_index_manager'>index_manager</span><span class='period'>.</span><span class='id identifier rubyid_using_index?'>using_index?</span>
310
+ <span class='const'><span class='object_link'><a href="ServiceCandidateIndexIterator.html" title="Longleaf::ServiceCandidateIndexIterator (class)">ServiceCandidateIndexIterator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ServiceCandidateIndexIterator.html#initialize-instance_method" title="Longleaf::ServiceCandidateIndexIterator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_file_selector'>file_selector</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='comma'>,</span> <span class='ivar'>@app_config</span><span class='comma'>,</span> <span class='id identifier rubyid_force'>force</span><span class='rparen'>)</span>
311
+ <span class='kw'>else</span>
312
+ <span class='comment'># Get filesystem based implementation
313
+ </span> <span class='const'><span class='object_link'><a href="ServiceCandidateFilesystemIterator.html" title="Longleaf::ServiceCandidateFilesystemIterator (class)">ServiceCandidateFilesystemIterator</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ServiceCandidateFilesystemIterator.html#initialize-instance_method" title="Longleaf::ServiceCandidateFilesystemIterator#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_file_selector'>file_selector</span><span class='comma'>,</span> <span class='id identifier rubyid_event'>event</span><span class='comma'>,</span> <span class='ivar'>@app_config</span><span class='comma'>,</span> <span class='id identifier rubyid_force'>force</span><span class='rparen'>)</span>
314
+ <span class='kw'>end</span>
315
+ <span class='kw'>end</span></pre>
316
+ </td>
317
+ </tr>
318
+ </table>
319
+ </div>
320
+
321
+ </div>
322
+
323
+ </div>
324
+
325
+ <div id="footer">
326
+ Generated on Tue May 28 15:48:02 2019 by
327
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
328
+ 0.9.19 (ruby-2.6.3).
329
+ </div>
330
+
331
+ </div>
332
+ </body>
333
+ </html>
@@ -0,0 +1,725 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: Longleaf::ServiceClassCache
8
+
9
+ &mdash; Documentation by YARD 0.9.19
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "Longleaf::ServiceClassCache";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (S)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Longleaf.html" title="Longleaf (module)">Longleaf</a></span></span>
41
+ &raquo;
42
+ <span class="title">ServiceClassCache</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: Longleaf::ServiceClassCache
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">Longleaf::ServiceClassCache</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/longleaf/services/service_class_cache.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Cache for loading and retrieving preservation service classes</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+ <h2>
116
+ Constant Summary
117
+ <small><a href="#" class="constants_summary_toggle">collapse</a></small>
118
+ </h2>
119
+
120
+ <dl class="constants">
121
+
122
+ <dt id="STD_PRESERVATION_SERVICE_PATH-constant" class="">STD_PRESERVATION_SERVICE_PATH =
123
+
124
+ </dt>
125
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>longleaf/preservation_services/</span><span class='tstring_end'>&#39;</span></span></pre></dd>
126
+
127
+ </dl>
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ <h2>
138
+ Instance Method Summary
139
+ <small><a href="#" class="summary_toggle">collapse</a></small>
140
+ </h2>
141
+
142
+ <ul class="summary">
143
+
144
+ <li class="private ">
145
+ <span class="summary_signature">
146
+
147
+ <a href="#constantize-instance_method" title="#constantize (instance method)">#<strong>constantize</strong>(str) &#x21d2; Object </a>
148
+
149
+
150
+
151
+ </span>
152
+
153
+
154
+
155
+ <span class="note title private">private</span>
156
+
157
+
158
+
159
+
160
+
161
+ <span class="summary_desc"><div class='inline'>
162
+ <p>Borrowed from sidekiq implementation.</p>
163
+ </div></span>
164
+
165
+ </li>
166
+
167
+
168
+ <li class="private ">
169
+ <span class="summary_signature">
170
+
171
+ <a href="#from_permitted_path%3F-instance_method" title="#from_permitted_path? (instance method)">#<strong>from_permitted_path?</strong>(script_path) &#x21d2; Boolean </a>
172
+
173
+
174
+
175
+ </span>
176
+
177
+
178
+
179
+ <span class="note title private">private</span>
180
+
181
+
182
+
183
+
184
+
185
+ <span class="summary_desc"><div class='inline'></div></span>
186
+
187
+ </li>
188
+
189
+
190
+ <li class="public ">
191
+ <span class="summary_signature">
192
+
193
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(app_manager) &#x21d2; ServiceClassCache </a>
194
+
195
+
196
+
197
+ </span>
198
+
199
+
200
+ <span class="note title constructor">constructor</span>
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+ <span class="summary_desc"><div class='inline'>
210
+ <p>A new instance of ServiceClassCache.</p>
211
+ </div></span>
212
+
213
+ </li>
214
+
215
+
216
+ <li class="public ">
217
+ <span class="summary_signature">
218
+
219
+ <a href="#service_class-instance_method" title="#service_class (instance method)">#<strong>service_class</strong>(service_def) &#x21d2; Class </a>
220
+
221
+
222
+
223
+ </span>
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+ <span class="summary_desc"><div class='inline'>
234
+ <p>Load and return the PreservationService class assigned to the provided service definition, based on the work_script and work_class properties provided.</p>
235
+ </div></span>
236
+
237
+ </li>
238
+
239
+
240
+ <li class="public ">
241
+ <span class="summary_signature">
242
+
243
+ <a href="#service_instance-instance_method" title="#service_instance (instance method)">#<strong>service_instance</strong>(service_def) &#x21d2; PreservationService </a>
244
+
245
+
246
+
247
+ </span>
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <span class="summary_desc"><div class='inline'>
258
+ <p>Returns an instance of the preversation service defined for the provided service definition, based on the work_script and work_class properties provided.</p>
259
+ </div></span>
260
+
261
+ </li>
262
+
263
+
264
+ </ul>
265
+
266
+
267
+ <div id="constructor_details" class="method_details_list">
268
+ <h2>Constructor Details</h2>
269
+
270
+ <div class="method_details first">
271
+ <h3 class="signature first" id="initialize-instance_method">
272
+
273
+ #<strong>initialize</strong>(app_manager) &#x21d2; <tt><span class='object_link'><a href="" title="Longleaf::ServiceClassCache (class)">ServiceClassCache</a></span></tt>
274
+
275
+
276
+
277
+
278
+
279
+ </h3><div class="docstring">
280
+ <div class="discussion">
281
+
282
+ <p>Returns a new instance of ServiceClassCache</p>
283
+
284
+
285
+ </div>
286
+ </div>
287
+ <div class="tags">
288
+
289
+
290
+ </div><table class="source_code">
291
+ <tr>
292
+ <td>
293
+ <pre class="lines">
294
+
295
+
296
+ 8
297
+ 9
298
+ 10
299
+ 11
300
+ 12
301
+ 13
302
+ 14</pre>
303
+ </td>
304
+ <td>
305
+ <pre class="code"><span class="info file"># File 'lib/longleaf/services/service_class_cache.rb', line 8</span>
306
+
307
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_app_manager'>app_manager</span><span class='rparen'>)</span>
308
+ <span class='ivar'>@app_manager</span> <span class='op'>=</span> <span class='id identifier rubyid_app_manager'>app_manager</span>
309
+ <span class='comment'># Cache storing per service definition instances of service classes
310
+ </span> <span class='ivar'>@service_instance_cache</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
311
+ <span class='comment'># Cache storing per script path class of service
312
+ </span> <span class='ivar'>@class_cache</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
313
+ <span class='kw'>end</span></pre>
314
+ </td>
315
+ </tr>
316
+ </table>
317
+ </div>
318
+
319
+ </div>
320
+
321
+
322
+ <div id="instance_method_details" class="method_details_list">
323
+ <h2>Instance Method Details</h2>
324
+
325
+
326
+ <div class="method_details first">
327
+ <h3 class="signature first" id="constantize-instance_method">
328
+
329
+ #<strong>constantize</strong>(str) &#x21d2; <tt>Object</tt> <span class="extras">(private)</span>
330
+
331
+
332
+
333
+
334
+
335
+ </h3><div class="docstring">
336
+ <div class="discussion">
337
+
338
+ <p>Borrowed from sidekiq implementation</p>
339
+
340
+
341
+ </div>
342
+ </div>
343
+ <div class="tags">
344
+
345
+
346
+ </div><table class="source_code">
347
+ <tr>
348
+ <td>
349
+ <pre class="lines">
350
+
351
+
352
+ 92
353
+ 93
354
+ 94
355
+ 95
356
+ 96
357
+ 97
358
+ 98
359
+ 99
360
+ 100
361
+ 101</pre>
362
+ </td>
363
+ <td>
364
+ <pre class="code"><span class="info file"># File 'lib/longleaf/services/service_class_cache.rb', line 92</span>
365
+
366
+ <span class='kw'>def</span> <span class='id identifier rubyid_constantize'>constantize</span><span class='lparen'>(</span><span class='id identifier rubyid_str'>str</span><span class='rparen'>)</span>
367
+ <span class='id identifier rubyid_names'>names</span> <span class='op'>=</span> <span class='id identifier rubyid_str'>str</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>::</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
368
+ <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_shift'>shift</span> <span class='kw'>if</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>||</span> <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
369
+
370
+ <span class='id identifier rubyid_names'>names</span><span class='period'>.</span><span class='id identifier rubyid_inject'>inject</span><span class='lparen'>(</span><span class='const'>Object</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_constant'>constant</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='op'>|</span>
371
+ <span class='comment'># the false flag limits search for name to under the constant namespace
372
+ </span> <span class='comment'># which mimics Rails&#39; behaviour
373
+ </span> <span class='id identifier rubyid_constant'>constant</span><span class='period'>.</span><span class='id identifier rubyid_const_defined?'>const_defined?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_constant'>constant</span><span class='period'>.</span><span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_constant'>constant</span><span class='period'>.</span><span class='id identifier rubyid_const_missing'>const_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
374
+ <span class='kw'>end</span>
375
+ <span class='kw'>end</span></pre>
376
+ </td>
377
+ </tr>
378
+ </table>
379
+ </div>
380
+
381
+ <div class="method_details ">
382
+ <h3 class="signature " id="from_permitted_path?-instance_method">
383
+
384
+ #<strong>from_permitted_path?</strong>(script_path) &#x21d2; <tt>Boolean</tt> <span class="extras">(private)</span>
385
+
386
+
387
+
388
+
389
+
390
+ </h3><div class="docstring">
391
+ <div class="discussion">
392
+
393
+
394
+ </div>
395
+ </div>
396
+ <div class="tags">
397
+
398
+ <p class="tag_title">Returns:</p>
399
+ <ul class="return">
400
+
401
+ <li>
402
+
403
+
404
+ <span class='type'>(<tt>Boolean</tt>)</span>
405
+
406
+
407
+
408
+ </li>
409
+
410
+ </ul>
411
+
412
+ </div><table class="source_code">
413
+ <tr>
414
+ <td>
415
+ <pre class="lines">
416
+
417
+
418
+ 103
419
+ 104
420
+ 105
421
+ 106
422
+ 107
423
+ 108
424
+ 109
425
+ 110</pre>
426
+ </td>
427
+ <td>
428
+ <pre class="code"><span class="info file"># File 'lib/longleaf/services/service_class_cache.rb', line 103</span>
429
+
430
+ <span class='kw'>def</span> <span class='id identifier rubyid_from_permitted_path?'>from_permitted_path?</span><span class='lparen'>(</span><span class='id identifier rubyid_script_path'>script_path</span><span class='rparen'>)</span>
431
+ <span class='gvar'>$LOAD_PATH</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_lib_path'>lib_path</span><span class='op'>|</span>
432
+ <span class='kw'>if</span> <span class='id identifier rubyid_script_path'>script_path</span><span class='period'>.</span><span class='id identifier rubyid_start_with?'>start_with?</span><span class='lparen'>(</span><span class='id identifier rubyid_lib_path'>lib_path</span><span class='rparen'>)</span>
433
+ <span class='kw'>return</span> <span class='kw'>true</span>
434
+ <span class='kw'>end</span>
435
+ <span class='kw'>end</span>
436
+ <span class='kw'>false</span>
437
+ <span class='kw'>end</span></pre>
438
+ </td>
439
+ </tr>
440
+ </table>
441
+ </div>
442
+
443
+ <div class="method_details ">
444
+ <h3 class="signature " id="service_class-instance_method">
445
+
446
+ #<strong>service_class</strong>(service_def) &#x21d2; <tt>Class</tt>
447
+
448
+
449
+
450
+
451
+
452
+ </h3><div class="docstring">
453
+ <div class="discussion">
454
+
455
+ <p>Load and return the PreservationService class assigned to the provided service definition, based on the work_script and work_class properties provided.</p>
456
+
457
+
458
+ </div>
459
+ </div>
460
+ <div class="tags">
461
+ <p class="tag_title">Parameters:</p>
462
+ <ul class="param">
463
+
464
+ <li>
465
+
466
+ <span class='name'>service_def</span>
467
+
468
+
469
+ <span class='type'>(<tt><span class='object_link'><a href="ServiceDefinition.html" title="Longleaf::ServiceDefinition (class)">ServiceDefinition</a></span></tt>)</span>
470
+
471
+
472
+
473
+ &mdash;
474
+ <div class='inline'>
475
+ <p>definition of service to retrieve class for</p>
476
+ </div>
477
+
478
+ </li>
479
+
480
+ </ul>
481
+
482
+ <p class="tag_title">Returns:</p>
483
+ <ul class="return">
484
+
485
+ <li>
486
+
487
+
488
+ <span class='type'>(<tt>Class</tt>)</span>
489
+
490
+
491
+
492
+ &mdash;
493
+ <div class='inline'>
494
+ <p>class of work_script</p>
495
+ </div>
496
+
497
+ </li>
498
+
499
+ </ul>
500
+
501
+ </div><table class="source_code">
502
+ <tr>
503
+ <td>
504
+ <pre class="lines">
505
+
506
+
507
+ 38
508
+ 39
509
+ 40
510
+ 41
511
+ 42
512
+ 43
513
+ 44
514
+ 45
515
+ 46
516
+ 47
517
+ 48
518
+ 49
519
+ 50
520
+ 51
521
+ 52
522
+ 53
523
+ 54
524
+ 55
525
+ 56
526
+ 57
527
+ 58
528
+ 59
529
+ 60
530
+ 61
531
+ 62
532
+ 63
533
+ 64
534
+ 65
535
+ 66
536
+ 67
537
+ 68
538
+ 69
539
+ 70
540
+ 71
541
+ 72
542
+ 73
543
+ 74
544
+ 75
545
+ 76
546
+ 77
547
+ 78
548
+ 79
549
+ 80
550
+ 81
551
+ 82
552
+ 83
553
+ 84
554
+ 85
555
+ 86
556
+ 87
557
+ 88</pre>
558
+ </td>
559
+ <td>
560
+ <pre class="code"><span class="info file"># File 'lib/longleaf/services/service_class_cache.rb', line 38</span>
561
+
562
+ <span class='kw'>def</span> <span class='id identifier rubyid_service_class'>service_class</span><span class='lparen'>(</span><span class='id identifier rubyid_service_def'>service_def</span><span class='rparen'>)</span>
563
+ <span class='id identifier rubyid_service_name'>service_name</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
564
+ <span class='id identifier rubyid_work_script'>work_script</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_work_script'>work_script</span>
565
+
566
+ <span class='kw'>if</span> <span class='id identifier rubyid_work_script'>work_script</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
567
+ <span class='id identifier rubyid_expanded_path'>expanded_path</span> <span class='op'>=</span> <span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_work_script'>work_script</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_expand_path'>expand_path</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
568
+ <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_from_permitted_path?'>from_permitted_path?</span><span class='lparen'>(</span><span class='id identifier rubyid_expanded_path'>expanded_path</span><span class='rparen'>)</span>
569
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ConfigurationError.html" title="Longleaf::ConfigurationError (class)">ConfigurationError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Unable to load work_script for service </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_name'>service_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_work_script'>work_script</span><span class='embexpr_end'>}</span><span class='tstring_content'> is not in a known library path.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
570
+ <span class='kw'>end</span>
571
+
572
+ <span class='id identifier rubyid_last_slash_index'>last_slash_index</span> <span class='op'>=</span> <span class='id identifier rubyid_work_script'>work_script</span><span class='period'>.</span><span class='id identifier rubyid_rindex'>rindex</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
573
+ <span class='id identifier rubyid_script_path'>script_path</span> <span class='op'>=</span> <span class='id identifier rubyid_work_script'>work_script</span><span class='lbracket'>[</span><span class='int'>0</span><span class='op'>..</span><span class='id identifier rubyid_last_slash_index'>last_slash_index</span><span class='rbracket'>]</span>
574
+ <span class='id identifier rubyid_script_name'>script_name</span> <span class='op'>=</span> <span class='id identifier rubyid_work_script'>work_script</span><span class='lbracket'>[</span><span class='lparen'>(</span><span class='id identifier rubyid_last_slash_index'>last_slash_index</span> <span class='op'>+</span> <span class='int'>1</span><span class='rparen'>)</span><span class='op'>..</span><span class='op'>-</span><span class='int'>1</span><span class='rbracket'>]</span>
575
+ <span class='kw'>else</span>
576
+ <span class='id identifier rubyid_script_path'>script_path</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#STD_PRESERVATION_SERVICE_PATH-constant" title="Longleaf::ServiceClassCache::STD_PRESERVATION_SERVICE_PATH (constant)">STD_PRESERVATION_SERVICE_PATH</a></span></span>
577
+ <span class='id identifier rubyid_script_name'>script_name</span> <span class='op'>=</span> <span class='id identifier rubyid_work_script'>work_script</span>
578
+ <span class='kw'>end</span>
579
+
580
+ <span class='comment'># Strip off the extension
581
+ </span> <span class='id identifier rubyid_script_name'>script_name</span><span class='period'>.</span><span class='id identifier rubyid_sub!'>sub!</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.rb</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
582
+
583
+ <span class='id identifier rubyid_require_path'>require_path</span> <span class='op'>=</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='id identifier rubyid_script_path'>script_path</span><span class='comma'>,</span> <span class='id identifier rubyid_script_name'>script_name</span><span class='rparen'>)</span>
584
+ <span class='comment'># Return the cached Class if this path has been encountered before
585
+ </span> <span class='kw'>if</span> <span class='ivar'>@class_cache</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_require_path'>require_path</span><span class='rparen'>)</span>
586
+ <span class='kw'>return</span> <span class='ivar'>@class_cache</span><span class='lbracket'>[</span><span class='id identifier rubyid_require_path'>require_path</span><span class='rbracket'>]</span>
587
+ <span class='kw'>end</span>
588
+
589
+ <span class='comment'># Load the script
590
+ </span> <span class='kw'>begin</span>
591
+ <span class='id identifier rubyid_require'>require</span> <span class='id identifier rubyid_require_path'>require_path</span>
592
+ <span class='kw'>rescue</span> <span class='const'>LoadError</span>
593
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ConfigurationError.html" title="Longleaf::ConfigurationError (class)">ConfigurationError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Failed to load work_script &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_script_name'>script_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for service </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_name'>service_name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
594
+ <span class='kw'>end</span>
595
+
596
+ <span class='comment'># Generate the class name, either configured or from file naming convention if possible
597
+ </span> <span class='kw'>if</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_work_class'>work_class</span>
598
+ <span class='id identifier rubyid_class_name'>class_name</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_work_class'>work_class</span>
599
+ <span class='kw'>else</span>
600
+ <span class='id identifier rubyid_class_name'>class_name</span> <span class='op'>=</span> <span class='id identifier rubyid_script_name'>script_name</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>_</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:capitalize</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span>
601
+ <span class='comment'># Assume the longleaf module for classes in the standard path
602
+ </span> <span class='id identifier rubyid_class_name'>class_name</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Longleaf::</span><span class='tstring_end'>&#39;</span></span> <span class='op'>+</span> <span class='id identifier rubyid_class_name'>class_name</span> <span class='kw'>if</span> <span class='id identifier rubyid_script_path'>script_path</span> <span class='op'>==</span> <span class='const'><span class='object_link'><a href="#STD_PRESERVATION_SERVICE_PATH-constant" title="Longleaf::ServiceClassCache::STD_PRESERVATION_SERVICE_PATH (constant)">STD_PRESERVATION_SERVICE_PATH</a></span></span>
603
+ <span class='kw'>end</span>
604
+
605
+ <span class='kw'>begin</span>
606
+ <span class='id identifier rubyid_class_constant'>class_constant</span> <span class='op'>=</span> <span class='id identifier rubyid_constantize'>constantize</span><span class='lparen'>(</span><span class='id identifier rubyid_class_name'>class_name</span><span class='rparen'>)</span>
607
+ <span class='comment'># cache the class for this work_script and return it
608
+ </span> <span class='ivar'>@class_cache</span><span class='lbracket'>[</span><span class='id identifier rubyid_require_path'>require_path</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_class_constant'>class_constant</span>
609
+ <span class='kw'>rescue</span> <span class='const'>NameError</span>
610
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="ConfigurationError.html" title="Longleaf::ConfigurationError (class)">ConfigurationError</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Failed to load work_script &#39;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_script_name'>script_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>&#39; for service </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service_name'>service_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>, class name </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_class_name'>class_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> was not found.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
611
+ <span class='kw'>end</span>
612
+ <span class='kw'>end</span></pre>
613
+ </td>
614
+ </tr>
615
+ </table>
616
+ </div>
617
+
618
+ <div class="method_details ">
619
+ <h3 class="signature " id="service_instance-instance_method">
620
+
621
+ #<strong>service_instance</strong>(service_def) &#x21d2; <tt>PreservationService</tt>
622
+
623
+
624
+
625
+
626
+
627
+ </h3><div class="docstring">
628
+ <div class="discussion">
629
+
630
+ <p>Returns an instance of the preversation service defined for the provided service definition, based on the work_script and work_class properties provided.</p>
631
+
632
+
633
+ </div>
634
+ </div>
635
+ <div class="tags">
636
+ <p class="tag_title">Parameters:</p>
637
+ <ul class="param">
638
+
639
+ <li>
640
+
641
+ <span class='name'>service_def</span>
642
+
643
+
644
+ <span class='type'>(<tt><span class='object_link'><a href="ServiceDefinition.html" title="Longleaf::ServiceDefinition (class)">ServiceDefinition</a></span></tt>)</span>
645
+
646
+
647
+
648
+ &mdash;
649
+ <div class='inline'>
650
+ <p>definition of service to instantiate</p>
651
+ </div>
652
+
653
+ </li>
654
+
655
+ </ul>
656
+
657
+ <p class="tag_title">Returns:</p>
658
+ <ul class="return">
659
+
660
+ <li>
661
+
662
+
663
+ <span class='type'>(<tt>PreservationService</tt>)</span>
664
+
665
+
666
+
667
+ &mdash;
668
+ <div class='inline'>
669
+ <p>Instance of the preservation service class for the definition.</p>
670
+ </div>
671
+
672
+ </li>
673
+
674
+ </ul>
675
+
676
+ </div><table class="source_code">
677
+ <tr>
678
+ <td>
679
+ <pre class="lines">
680
+
681
+
682
+ 21
683
+ 22
684
+ 23
685
+ 24
686
+ 25
687
+ 26
688
+ 27
689
+ 28
690
+ 29
691
+ 30
692
+ 31</pre>
693
+ </td>
694
+ <td>
695
+ <pre class="code"><span class="info file"># File 'lib/longleaf/services/service_class_cache.rb', line 21</span>
696
+
697
+ <span class='kw'>def</span> <span class='id identifier rubyid_service_instance'>service_instance</span><span class='lparen'>(</span><span class='id identifier rubyid_service_def'>service_def</span><span class='rparen'>)</span>
698
+ <span class='id identifier rubyid_service_name'>service_name</span> <span class='op'>=</span> <span class='id identifier rubyid_service_def'>service_def</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span>
699
+ <span class='comment'># Return the cached instance of the service
700
+ </span> <span class='kw'>if</span> <span class='ivar'>@service_instance_cache</span><span class='period'>.</span><span class='id identifier rubyid_key?'>key?</span><span class='lparen'>(</span><span class='id identifier rubyid_service_name'>service_name</span><span class='rparen'>)</span>
701
+ <span class='kw'>return</span> <span class='ivar'>@service_instance_cache</span><span class='lbracket'>[</span><span class='id identifier rubyid_service_name'>service_name</span><span class='rbracket'>]</span>
702
+ <span class='kw'>end</span>
703
+
704
+ <span class='id identifier rubyid_clazz'>clazz</span> <span class='op'>=</span> <span class='id identifier rubyid_service_class'>service_class</span><span class='lparen'>(</span><span class='id identifier rubyid_service_def'>service_def</span><span class='rparen'>)</span>
705
+ <span class='comment'># Cache and return the class instance
706
+ </span> <span class='ivar'>@service_instance_cache</span><span class='lbracket'>[</span><span class='id identifier rubyid_service_name'>service_name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_clazz'>clazz</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_service_def'>service_def</span><span class='comma'>,</span> <span class='ivar'>@app_manager</span><span class='rparen'>)</span>
707
+ <span class='kw'>end</span></pre>
708
+ </td>
709
+ </tr>
710
+ </table>
711
+ </div>
712
+
713
+ </div>
714
+
715
+ </div>
716
+
717
+ <div id="footer">
718
+ Generated on Tue May 28 15:48:02 2019 by
719
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
720
+ 0.9.19 (ruby-2.6.3).
721
+ </div>
722
+
723
+ </div>
724
+ </body>
725
+ </html>