hyrax-ingest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +52 -0
  3. data/config/routes.rb +2 -0
  4. data/lib/hyrax/ingest.rb +12 -0
  5. data/lib/hyrax/ingest/batch_runner.rb +130 -0
  6. data/lib/hyrax/ingest/configuration.rb +54 -0
  7. data/lib/hyrax/ingest/engine.rb +6 -0
  8. data/lib/hyrax/ingest/errors.rb +186 -0
  9. data/lib/hyrax/ingest/fetcher.rb +55 -0
  10. data/lib/hyrax/ingest/fetcher/base.rb +78 -0
  11. data/lib/hyrax/ingest/fetcher/csv_file.rb +89 -0
  12. data/lib/hyrax/ingest/fetcher/date_time.rb +15 -0
  13. data/lib/hyrax/ingest/fetcher/literal.rb +24 -0
  14. data/lib/hyrax/ingest/fetcher/premis_event_type.rb +28 -0
  15. data/lib/hyrax/ingest/fetcher/rdf_uri.rb +21 -0
  16. data/lib/hyrax/ingest/fetcher/xml_file.rb +54 -0
  17. data/lib/hyrax/ingest/fetcher/yaml_file.rb +36 -0
  18. data/lib/hyrax/ingest/has_depositor.rb +13 -0
  19. data/lib/hyrax/ingest/has_iteration.rb +18 -0
  20. data/lib/hyrax/ingest/has_logger.rb +29 -0
  21. data/lib/hyrax/ingest/has_report.rb +17 -0
  22. data/lib/hyrax/ingest/has_shared_sip.rb +20 -0
  23. data/lib/hyrax/ingest/has_sip.rb +20 -0
  24. data/lib/hyrax/ingest/ingester.rb +75 -0
  25. data/lib/hyrax/ingest/ingester/active_fedora_base_ingester.rb +136 -0
  26. data/lib/hyrax/ingest/ingester/active_fedora_file_ingester.rb +17 -0
  27. data/lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb +67 -0
  28. data/lib/hyrax/ingest/ingester/base.rb +28 -0
  29. data/lib/hyrax/ingest/ingester/file_set_ingester.rb +68 -0
  30. data/lib/hyrax/ingest/ingester/preservation_event_ingester.rb +27 -0
  31. data/lib/hyrax/ingest/ingester/work_ingester.rb +55 -0
  32. data/lib/hyrax/ingest/reporting.rb +13 -0
  33. data/lib/hyrax/ingest/reporting/configuration.rb +22 -0
  34. data/lib/hyrax/ingest/reporting/report.rb +79 -0
  35. data/lib/hyrax/ingest/reporting/views/hyrax_ingest_report.html.erb +77 -0
  36. data/lib/hyrax/ingest/reporting/views/hyrax_ingest_report.txt.erb +21 -0
  37. data/lib/hyrax/ingest/runner.rb +103 -0
  38. data/lib/hyrax/ingest/sip.rb +92 -0
  39. data/lib/hyrax/ingest/transformer.rb +42 -0
  40. data/lib/hyrax/ingest/transformer/base.rb +12 -0
  41. data/lib/hyrax/ingest/transformer/to_date.rb +33 -0
  42. data/lib/hyrax/ingest/version.rb +5 -0
  43. data/lib/tasks/ingest_tasks.rake +22 -0
  44. metadata +330 -0
@@ -0,0 +1,42 @@
1
+ require 'hyrax/ingest/transformer/to_date'
2
+ require 'hyrax/ingest/errors'
3
+
4
+ module Hyrax
5
+ module Ingest
6
+ module Transformer
7
+ class << self
8
+ # @return Set The set of all transformer classes.
9
+ def all_classes
10
+ @all_classes ||= Set.new.tap do |all_classes|
11
+ all_classes << Hyrax::Ingest::Transformer::ToDate
12
+ end
13
+ end
14
+
15
+ # @param [Hash] options The key is the transformer class name
16
+ # and the value is the hash of options to pass to the constructor of the transformer
17
+ # class.
18
+ # @return An instance of the transformer class.
19
+ def factory(class_name, options={})
20
+ find_class_by_name(class_name).new(options)
21
+ end
22
+
23
+ # @param [String] class_name The stringified class name, with or
24
+ # without namespaces.
25
+ # @raise [Hyrax::Ingest::Errors::UnknownTransformerClass] When there is no
26
+ # corresponding transformer class for the given value of the `class_name`
27
+ # param.
28
+ # @raise [Hyrax::Ingest::Errors::UnknowntransformerClass] When the value of
29
+ # `class_name` param is insufficient in determining a transformer class.
30
+ # @return [Class] The appropriate transformer class.
31
+ def find_class_by_name(class_name)
32
+ found_classes = all_classes.select do |class_const|
33
+ (class_const.to_s == class_name) || (class_const.to_s =~ /::#{class_name}/)
34
+ end
35
+ raise Hyrax::Ingest::Errors::UnknownTransformerClass.new(class_name, all_classes) if found_classes.count == 0
36
+ raise Hyrax::Ingest::Errors::AmbiguousTransformerClass.new(class_name, found_classes) if found_classes.count > 1
37
+ found_classes.first
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ module Hyrax
2
+ module Ingest
3
+ module Transformer
4
+ class Base
5
+ # no-op; intended to be overwritten
6
+ def transform(value)
7
+ value
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'hyrax/ingest/transformer/base'
2
+
3
+ module Hyrax
4
+ module Ingest
5
+ module Transformer
6
+ class ToDate < Base
7
+ attr_reader :orig_format
8
+
9
+ def initialize(orig_format)
10
+ @orig_format = orig_format.to_sym
11
+ end
12
+
13
+ def transform(value)
14
+ return transform_multiple(value) if value.respond_to?(:each)
15
+ case orig_format
16
+ when :from_timestamp_with_ms
17
+ DateTime.strptime(value, '%Q')
18
+ when :"from_yyyy-mm-dd"
19
+ DateTime.parse(value)
20
+ else
21
+ raise Hyrax::Ingest::Errors::UnrecognizedTransformOption.new(orig_format)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def transform_multiple(values)
28
+ values.map { |value| transform(value) }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Hyrax
2
+ module Ingest
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'hyrax/ingest/batch_runner'
2
+ require 'rails'
3
+
4
+ namespace :hyrax do
5
+ desc 'Ingest one or more SIPs, using a specified package configuration'
6
+ task :ingest => :environment do
7
+ config_file_path = ENV['config_file']
8
+ # Globbed paths represent batches, so expand them and add to the list of sip_paths.
9
+ sip_paths = ENV['sip_paths'].to_s.split(',').map! do |sip_path|
10
+ batch = Dir.glob(sip_path)
11
+ batch.empty? ? sip_path : batch
12
+ end.flatten
13
+ shared_sip_path = ENV['shared_sip_path']
14
+
15
+ if !config_file_path || (sip_paths.empty? && !shared_sip_path)
16
+ abort "Error: Invalid Parameters\n\nUsage: rake hyrax:ingest config_file=FILE [sip_paths=PATH1[,PATH2,...]] [shared_sip_path=SHARED_PATH]\n\n"
17
+ end
18
+
19
+ batch_runner = Hyrax::Ingest::BatchRunner.new(config_file_path: config_file_path, sip_paths: sip_paths, shared_sip_path: shared_sip_path)
20
+ batch_runner.run!
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,330 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hyrax-ingest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Myers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hyrax
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.0.3
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitar
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.6.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.6.1
61
+ - !ruby/object:Gem::Dependency
62
+ name: nokogiri
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.8'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.8.2
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.8'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 1.8.2
81
+ - !ruby/object:Gem::Dependency
82
+ name: roo
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.7'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 2.7.0
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '2.7'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 2.7.0
101
+ - !ruby/object:Gem::Dependency
102
+ name: hyrax-preservation
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.1'
108
+ type: :runtime
109
+ prerelease: false
110
+ version_requirements: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - "~>"
113
+ - !ruby/object:Gem::Version
114
+ version: '0.1'
115
+ - !ruby/object:Gem::Dependency
116
+ name: interloper
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - "~>"
120
+ - !ruby/object:Gem::Version
121
+ version: 0.2.3
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - "~>"
127
+ - !ruby/object:Gem::Version
128
+ version: 0.2.3
129
+ - !ruby/object:Gem::Dependency
130
+ name: functional_hash
131
+ requirement: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - "~>"
134
+ - !ruby/object:Gem::Version
135
+ version: 0.2.1
136
+ type: :runtime
137
+ prerelease: false
138
+ version_requirements: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - "~>"
141
+ - !ruby/object:Gem::Version
142
+ version: 0.2.1
143
+ - !ruby/object:Gem::Dependency
144
+ name: sqlite3
145
+ requirement: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - "~>"
148
+ - !ruby/object:Gem::Version
149
+ version: '1.3'
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 1.3.13
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.3'
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: 1.3.13
163
+ - !ruby/object:Gem::Dependency
164
+ name: rspec
165
+ requirement: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '3.7'
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: 3.7.0
173
+ type: :development
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '3.7'
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: 3.7.0
183
+ - !ruby/object:Gem::Dependency
184
+ name: engine_cart
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '1.2'
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: 1.2.0
193
+ type: :development
194
+ prerelease: false
195
+ version_requirements: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - "~>"
198
+ - !ruby/object:Gem::Version
199
+ version: '1.2'
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 1.2.0
203
+ - !ruby/object:Gem::Dependency
204
+ name: pry-byebug
205
+ requirement: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - "~>"
208
+ - !ruby/object:Gem::Version
209
+ version: '3.5'
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: 3.5.1
213
+ type: :development
214
+ prerelease: false
215
+ version_requirements: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - "~>"
218
+ - !ruby/object:Gem::Version
219
+ version: '3.5'
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: 3.5.1
223
+ - !ruby/object:Gem::Dependency
224
+ name: solr_wrapper
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: 1.2.0
230
+ - - ">="
231
+ - !ruby/object:Gem::Version
232
+ version: 1.2.0
233
+ type: :development
234
+ prerelease: false
235
+ version_requirements: !ruby/object:Gem::Requirement
236
+ requirements:
237
+ - - "~>"
238
+ - !ruby/object:Gem::Version
239
+ version: 1.2.0
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: 1.2.0
243
+ - !ruby/object:Gem::Dependency
244
+ name: fcrepo_wrapper
245
+ requirement: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: 0.9.0
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: 0.9.0
257
+ description: Description of Hyrax::Ingest.
258
+ email:
259
+ - afredmyers@gmail.com
260
+ executables: []
261
+ extensions: []
262
+ extra_rdoc_files: []
263
+ files:
264
+ - README.md
265
+ - config/routes.rb
266
+ - lib/hyrax/ingest.rb
267
+ - lib/hyrax/ingest/batch_runner.rb
268
+ - lib/hyrax/ingest/configuration.rb
269
+ - lib/hyrax/ingest/engine.rb
270
+ - lib/hyrax/ingest/errors.rb
271
+ - lib/hyrax/ingest/fetcher.rb
272
+ - lib/hyrax/ingest/fetcher/base.rb
273
+ - lib/hyrax/ingest/fetcher/csv_file.rb
274
+ - lib/hyrax/ingest/fetcher/date_time.rb
275
+ - lib/hyrax/ingest/fetcher/literal.rb
276
+ - lib/hyrax/ingest/fetcher/premis_event_type.rb
277
+ - lib/hyrax/ingest/fetcher/rdf_uri.rb
278
+ - lib/hyrax/ingest/fetcher/xml_file.rb
279
+ - lib/hyrax/ingest/fetcher/yaml_file.rb
280
+ - lib/hyrax/ingest/has_depositor.rb
281
+ - lib/hyrax/ingest/has_iteration.rb
282
+ - lib/hyrax/ingest/has_logger.rb
283
+ - lib/hyrax/ingest/has_report.rb
284
+ - lib/hyrax/ingest/has_shared_sip.rb
285
+ - lib/hyrax/ingest/has_sip.rb
286
+ - lib/hyrax/ingest/ingester.rb
287
+ - lib/hyrax/ingest/ingester/active_fedora_base_ingester.rb
288
+ - lib/hyrax/ingest/ingester/active_fedora_file_ingester.rb
289
+ - lib/hyrax/ingest/ingester/active_fedora_property_assigner.rb
290
+ - lib/hyrax/ingest/ingester/base.rb
291
+ - lib/hyrax/ingest/ingester/file_set_ingester.rb
292
+ - lib/hyrax/ingest/ingester/preservation_event_ingester.rb
293
+ - lib/hyrax/ingest/ingester/work_ingester.rb
294
+ - lib/hyrax/ingest/reporting.rb
295
+ - lib/hyrax/ingest/reporting/configuration.rb
296
+ - lib/hyrax/ingest/reporting/report.rb
297
+ - lib/hyrax/ingest/reporting/views/hyrax_ingest_report.html.erb
298
+ - lib/hyrax/ingest/reporting/views/hyrax_ingest_report.txt.erb
299
+ - lib/hyrax/ingest/runner.rb
300
+ - lib/hyrax/ingest/sip.rb
301
+ - lib/hyrax/ingest/transformer.rb
302
+ - lib/hyrax/ingest/transformer/base.rb
303
+ - lib/hyrax/ingest/transformer/to_date.rb
304
+ - lib/hyrax/ingest/version.rb
305
+ - lib/tasks/ingest_tasks.rake
306
+ homepage: https://github.com/IUBLibTech/hyrax-ingest
307
+ licenses:
308
+ - MIT
309
+ metadata: {}
310
+ post_install_message:
311
+ rdoc_options: []
312
+ require_paths:
313
+ - lib
314
+ required_ruby_version: !ruby/object:Gem::Requirement
315
+ requirements:
316
+ - - ">="
317
+ - !ruby/object:Gem::Version
318
+ version: '0'
319
+ required_rubygems_version: !ruby/object:Gem::Requirement
320
+ requirements:
321
+ - - ">="
322
+ - !ruby/object:Gem::Version
323
+ version: '0'
324
+ requirements: []
325
+ rubyforge_project:
326
+ rubygems_version: 2.7.6
327
+ signing_key:
328
+ specification_version: 4
329
+ summary: Summary of Hyrax::Ingest.
330
+ test_files: []