Skip to content

Commit 5a1d587

Browse files
committed
pull source dir creation into its own stage post-validation
1 parent 9611c51 commit 5a1d587

File tree

12 files changed

+125
-9
lines changed

12 files changed

+125
-9
lines changed

config/config.dlxs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ stages:
99
- name: Pagination Check
1010
class: PaginationCheck
1111
file: pagination_check
12+
- name: Create Source Directory
13+
class: CreateSourceDirectory
14+
file: create_source_directory
1215
- name: Tagger
1316
class: Tagger
1417
file: tagger

config/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ stages:
99
- name: Pagination Check
1010
class: PaginationCheck
1111
file: pagination_check
12+
- name: Create Source Directory
13+
class: CreateSourceDirectory
14+
file: create_source_directory
1215
- name: Tagger
1316
class: Tagger
1417
file: tagger
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require "stage"
2+
3+
class CreateSourceDirectory < Stage
4+
def run(agenda)
5+
setup_source_directory
6+
end
7+
8+
private
9+
10+
def setup_source_directory
11+
shipment.setup_source_directory do |objid|
12+
@bar.next! "setup source/#{objid}"
13+
end
14+
shipment.checksum_source_directory do |objid|
15+
@bar.next! "checksum source/#{objid}"
16+
end
17+
end
18+
end

lib/stage/pagination_check.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,13 @@ def duplicate_pages(pages)
6666
dups.delete_if { |_k, v| v.size == 1 }
6767
dups.keys.map(&:to_s)
6868
end
69+
70+
def setup_source_directory
71+
shipment.setup_source_directory do |objid|
72+
@bar.next! "setup source/#{objid}"
73+
end
74+
shipment.checksum_source_directory do |objid|
75+
@bar.next! "checksum source/#{objid}"
76+
end
77+
end
6978
end

lib/stage/preflight.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def run(agenda)
4040
@bar.next! "validate #{File.split(shipment_directory)[-1]}"
4141
validate_shipment_directory
4242
validate_objects agenda
43-
return if fatal_error?
43+
nil if fatal_error?
4444

45-
setup_source_directory
45+
# setup_source_directory
4646
end
4747

4848
private

test/config/config.dlxs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ stages:
99
- name: Pagination Check
1010
class: PaginationCheck
1111
file: pagination_check
12+
- name: Create Source Directory
13+
class: CreateSourceDirectory
14+
file: create_source_directory
1215
- name: Tagger
1316
class: Tagger
1417
file: tagger

test/config/config.dlxsfails.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
shipment_class: DLXSShipment
2+
stages:
3+
- name: Preflight
4+
class: Preflight
5+
file: preflight
6+
- name: Image Validator
7+
class: ImageValidator
8+
file: image_validator
9+
- name: Pagination Check
10+
class: PaginationCheck
11+
file: pagination_check
12+
- name: Create Source Directory
13+
class: CreateSourceDirectory
14+
file: create_source_directory
15+
- name: Fails
16+
class: Fails
17+
file: fails
18+
- name: Tagger
19+
class: Tagger
20+
file: tagger
21+
- name: Compression
22+
class: Compression
23+
file: compression
24+
- name: DLXSCompressor
25+
class: DLXSCompressor
26+
file: dlxs_compressor
27+
- name: Postflight
28+
class: Postflight
29+
file: postflight
30+

test/config/config.fails.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
stages:
2+
- name: Preflight
3+
class: Preflight
4+
file: preflight
5+
- name: Image Validator
6+
class: ImageValidator
7+
file: image_validator
8+
- name: Pagination Check
9+
class: PaginationCheck
10+
file: pagination_check
11+
- name: Create Source Directory
12+
class: CreateSourceDirectory
13+
file: create_source_directory
14+
- name: Fails
15+
class: Fails
16+
file: fails
17+
- name: Tagger
18+
class: Tagger
19+
file: tagger
20+
- name: Compression
21+
class: Compression
22+
file: compression
23+
- name: Postflight
24+
class: Postflight
25+
file: postflight
26+

test/config/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ stages:
99
- name: Pagination Check
1010
class: PaginationCheck
1111
file: pagination_check
12+
- name: Create Source Directory
13+
class: CreateSourceDirectory
14+
file: create_source_directory
1215
- name: Tagger
1316
class: Tagger
1417
file: tagger

test/postflight_test.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# frozen_string_literal: true
33

44
require "minitest/autorun"
5+
require_relative "test_helper"
6+
require "create_source_directory"
7+
require "preflight"
58
require "postflight"
69

710
class PostflightTest < Minitest::Test
@@ -32,6 +35,8 @@ def self.gen_run
3235
shipment = shipment_class.new(test_shipment.directory)
3336
stage = Preflight.new(shipment, config: opts.merge(@config))
3437
stage.run!
38+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
39+
stage.run!
3540
stage = Postflight.new(shipment, config: opts.merge(@config))
3641
stage.run!
3742
assert_equal 0, stage.errors.count, "stage runs without errors"
@@ -46,6 +51,8 @@ def self.gen_metadata_mismatch_removed
4651
shipment = shipment_class.new(test_shipment.directory)
4752
stage = Preflight.new(shipment, config: opts.merge(@config))
4853
stage.run!
54+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
55+
stage.run!
4956
FileUtils.rm_r(File.join(shipment.directory,
5057
shipment.objid_to_path(shipment.objids[0])),
5158
force: true)
@@ -62,7 +69,7 @@ def self.gen_metadata_mismatch_added
6269
spec = "BC T bitonal 1 BC T bitonal 1"
6370
test_shipment = test_shipment_class.new(dir, spec)
6471
shipment = shipment_class.new(test_shipment.directory)
65-
stage = Preflight.new(shipment, config: opts.merge(@config))
72+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
6673
stage.run!
6774
new_objid = test_shipment_class.generate_objid
6875
FileUtils.mkdir_p File.join(shipment.directory,
@@ -79,7 +86,7 @@ def self.gen_feed_validate_error
7986
test_proc = proc { |shipment_class, test_shipment_class, dir, opts|
8087
test_shipment = test_shipment_class.new(dir, "BC T bitonal 1 T contone 2")
8188
shipment = shipment_class.new(test_shipment.directory)
82-
stage = Preflight.new(shipment, config: opts.merge(@config))
89+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
8390
stage.run!
8491
tiff = File.join(shipment.objid_to_path(shipment.objids[0]),
8592
"00000001.tif")
@@ -105,7 +112,7 @@ def self.gen_feed_validate_crash
105112
ENV["FAKE_FEED_VALIDATE_CRASH"] = "1"
106113
test_shipment = test_shipment_class.new(dir, "BC T bitonal 1 T contone 2")
107114
shipment = shipment_class.new(test_shipment.directory)
108-
stage = Preflight.new(shipment, config: opts.merge(@config))
115+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
109116
stage.run!
110117
stage = Postflight.new(shipment, config: opts.merge(@config))
111118
stage.run!
@@ -120,7 +127,7 @@ def self.gen_checksum_mismatch
120127
test_proc = proc { |shipment_class, test_shipment_class, dir, opts|
121128
test_shipment = test_shipment_class.new(dir, "BC T bitonal 1 T contone 2")
122129
shipment = shipment_class.new(test_shipment.directory)
123-
stage = Preflight.new(shipment, config: opts.merge(@config))
130+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
124131
stage.run!
125132
tiff = File.join(shipment.source_directory,
126133
shipment.objid_to_path(shipment.objids[0]),
@@ -138,7 +145,7 @@ def self.gen_file_missing
138145
test_proc = proc { |shipment_class, test_shipment_class, dir, opts|
139146
test_shipment = test_shipment_class.new(dir, "BC T bitonal 1 T contone 2")
140147
shipment = shipment_class.new(test_shipment.directory)
141-
stage = Preflight.new(shipment, config: opts.merge(@config))
148+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
142149
stage.run!
143150
tiff = File.join(shipment.source_directory,
144151
shipment.objid_to_path(shipment.objids[0]),
@@ -156,7 +163,7 @@ def self.gen_file_added
156163
test_proc = proc { |shipment_class, test_shipment_class, dir, opts|
157164
test_shipment = test_shipment_class.new(dir, "BC T bitonal 1 T contone 2")
158165
shipment = shipment_class.new(test_shipment.directory)
159-
stage = Preflight.new(shipment, config: opts.merge(@config))
166+
stage = CreateSourceDirectory.new(shipment, config: opts.merge(@config))
160167
stage.run!
161168
tiff = File.join(shipment.source_directory,
162169
shipment.objid_to_path(shipment.objids[0]),

0 commit comments

Comments
 (0)