assembly-utils 1.4.5 → 1.4.6
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.
- checksums.yaml +5 -13
- data/.gitignore +2 -1
- data/.rubocop.yml +17 -0
- data/.rubocop_todo.yml +196 -0
- data/.travis.yml +8 -0
- data/Gemfile +1 -2
- data/README.md +7 -4
- data/Rakefile +2 -2
- data/assembly-utils.gemspec +14 -15
- data/config/boot.rb +1 -1
- data/config/connect_to_dor.rb +1 -1
- data/lib/assembly-utils.rb +30 -32
- data/lib/assembly-utils/utils.rb +320 -384
- data/lib/assembly-utils/version.rb +2 -2
- data/spec/spec_helper.rb +5 -11
- data/spec/utils_spec.rb +52 -52
- metadata +35 -46
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,15 @@
|
|
1
|
-
TEST_PID='druid:dd999dd9999'
|
2
|
-
TEST_PID_FILENAME=TEST_PID.
|
3
|
-
TEST_APO_OBJECT='druid:qv648vd4392'
|
1
|
+
TEST_PID = 'druid:dd999dd9999'
|
2
|
+
TEST_PID_FILENAME = TEST_PID.tr(':', '_')
|
3
|
+
TEST_APO_OBJECT = 'druid:qv648vd4392' # this is a real APO object in dor-dev that must exist for the tests to pass
|
4
4
|
PATH = File.expand_path(File.dirname(__FILE__))
|
5
|
-
TEST_OUTPUT_DIR=File.join(PATH,'test_data','output')
|
6
|
-
ENV['ROBOT_ENVIRONMENT']='development'
|
5
|
+
TEST_OUTPUT_DIR = File.join(PATH, 'test_data', 'output')
|
6
|
+
ENV['ROBOT_ENVIRONMENT'] = 'development'
|
7
7
|
|
8
8
|
require 'rspec'
|
9
|
-
|
10
9
|
require "#{PATH}/../config/boot"
|
11
10
|
require "#{PATH}/../config/connect_to_dor"
|
12
11
|
|
13
|
-
|
14
12
|
RSpec.configure do |config|
|
15
|
-
|
16
13
|
end
|
17
14
|
|
18
15
|
def remove_files(dir)
|
@@ -26,6 +23,3 @@ end
|
|
26
23
|
def delete_test_object
|
27
24
|
Dor::Config.fedora.client["objects/#{TEST_PID}"].delete
|
28
25
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
data/spec/utils_spec.rb
CHANGED
@@ -2,57 +2,57 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Assembly::Utils do
|
4
4
|
|
5
|
-
it
|
6
|
-
path=Assembly::Utils.get_staging_path('aa000aa0001')
|
5
|
+
it 'should compute the correct staging path given a druid' do
|
6
|
+
path = Assembly::Utils.get_staging_path('aa000aa0001')
|
7
7
|
expect(path).to eq('aa/000/aa/0001')
|
8
8
|
end
|
9
9
|
|
10
|
-
it
|
11
|
-
path=Assembly::Utils.get_staging_path('aa000aa0001','/tmp')
|
10
|
+
it 'should compute the correct staging path given a druid and a pre-pend path' do
|
11
|
+
path = Assembly::Utils.get_staging_path('aa000aa0001', '/tmp')
|
12
12
|
expect(path).to eq('/tmp/aa/000/aa/0001')
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
result=Assembly::Utils.symbolize_keys({'foo'=>'bar','ppuff'=>'doofus'})
|
17
|
-
expect(result).to eq({:foo=>'bar'
|
15
|
+
it 'should symbolize hash keys correctly' do
|
16
|
+
result = Assembly::Utils.symbolize_keys({'foo' => 'bar', 'ppuff' => 'doofus'})
|
17
|
+
expect(result).to eq({:foo => 'bar', :ppuff => 'doofus'})
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
result=Assembly::Utils.values_to_symbols!({'foo'=>'bar','ppuff'=>'doofus'})
|
22
|
-
expect(result).to eq({'foo'
|
20
|
+
it 'should symbolize hash values correctly' do
|
21
|
+
result = Assembly::Utils.values_to_symbols!({'foo' => 'bar', 'ppuff' => 'doofus'})
|
22
|
+
expect(result).to eq({'foo' => :bar, 'ppuff' => :doofus})
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
bogus_filename='crap/dude'
|
25
|
+
it 'should return a blank string if a file is not found to read in' do
|
26
|
+
bogus_filename = 'crap/dude'
|
27
27
|
expect(Assembly::Utils.read_file(bogus_filename)).to eq('')
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
progress_filename='spec/test_data/test_log.yaml'
|
30
|
+
it 'should return a string with the file content if the file is found' do
|
31
|
+
progress_filename = 'spec/test_data/test_log.yaml'
|
32
32
|
expect(Assembly::Utils.read_file(progress_filename)).to match(/:pid: druid:bg598tg6338/)
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
progress_filename='spec/test_data/test_log.yaml'
|
37
|
-
druids=Assembly::Utils.get_druids_from_log(progress_filename)
|
38
|
-
expect(druids).to eq(['druid:bc006dj2846','druid:bg598tg6338'])
|
35
|
+
it 'should read in a list of completed druids from a progress log file' do
|
36
|
+
progress_filename = 'spec/test_data/test_log.yaml'
|
37
|
+
druids = Assembly::Utils.get_druids_from_log(progress_filename)
|
38
|
+
expect(druids).to eq(['druid:bc006dj2846', 'druid:bg598tg6338'])
|
39
39
|
end
|
40
40
|
|
41
|
-
it
|
42
|
-
progress_filename='spec/test_data/test_log.yaml'
|
43
|
-
druids=Assembly::Utils.get_druids_from_log(progress_filename,false)
|
41
|
+
it 'should read in a list of failed druids from a progress log file' do
|
42
|
+
progress_filename = 'spec/test_data/test_log.yaml'
|
43
|
+
druids = Assembly::Utils.get_druids_from_log(progress_filename, false)
|
44
44
|
expect(druids).to eq(['druid:bh634sp8073'])
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
config_filename='spec/test_data/local_dev_revs.yaml'
|
49
|
-
config=Assembly::Utils.load_config(config_filename)
|
47
|
+
it 'should read in a YAML configuration file and turn it into a hash' do
|
48
|
+
config_filename = 'spec/test_data/local_dev_revs.yaml'
|
49
|
+
config = Assembly::Utils.load_config(config_filename)
|
50
50
|
expect(config['progress_log_file']).to eq('tmp/progress_revs.yaml')
|
51
51
|
end
|
52
52
|
|
53
53
|
###################################################################################
|
54
54
|
# NOTE: All the tests below depend on being able to connect successfully to DOR Dev
|
55
|
-
describe
|
55
|
+
describe 'dor-only-tests' do
|
56
56
|
|
57
57
|
before(:all) do
|
58
58
|
delete_test_object rescue nil
|
@@ -64,53 +64,53 @@ describe Assembly::Utils do
|
|
64
64
|
delete_test_object
|
65
65
|
end
|
66
66
|
|
67
|
-
it
|
67
|
+
it 'should find druids by source ID', :type => 'integration' do
|
68
68
|
expect(Dor::SearchService).to receive(:query_by_id).with('testing-assembly-utils-gem').and_return TEST_PID
|
69
|
-
druids=Assembly::Utils.get_druids_by_sourceid(['testing-assembly-utils-gem'])
|
69
|
+
druids = Assembly::Utils.get_druids_by_sourceid(['testing-assembly-utils-gem'])
|
70
70
|
expect(druids).to eq([TEST_PID])
|
71
71
|
end
|
72
72
|
|
73
|
-
it
|
74
|
-
new_content=
|
75
|
-
datastream=
|
76
|
-
druids=[TEST_PID]
|
77
|
-
Assembly::Utils.replace_datastreams(druids,datastream,new_content)
|
73
|
+
it 'should replace the datastream of an object', :type => 'integration' do
|
74
|
+
new_content = '<xml><tag>stuff</tag></xml>'
|
75
|
+
datastream = 'test'
|
76
|
+
druids = [TEST_PID]
|
77
|
+
Assembly::Utils.replace_datastreams(druids, datastream, new_content)
|
78
78
|
obj = Dor::Item.find(TEST_PID)
|
79
79
|
expect(obj.datastreams[datastream].content).to match(/<tag>stuff<\/tag>/)
|
80
80
|
end
|
81
81
|
|
82
|
-
it
|
83
|
-
find_content=
|
84
|
-
replace_content=
|
85
|
-
datastream=
|
86
|
-
druids=[TEST_PID]
|
87
|
-
Assembly::Utils.update_datastreams(druids,datastream,find_content,replace_content)
|
82
|
+
it 'should search and replace the datastream of an object', :type => 'integration' do
|
83
|
+
find_content = 'stuff'
|
84
|
+
replace_content = 'new'
|
85
|
+
datastream = 'test'
|
86
|
+
druids = [TEST_PID]
|
87
|
+
Assembly::Utils.update_datastreams(druids, datastream, find_content, replace_content)
|
88
88
|
obj = Dor::Item.find(TEST_PID)
|
89
89
|
expect(obj.datastreams[datastream].content).to match(/<tag>new<\/tag>/)
|
90
90
|
end
|
91
91
|
|
92
|
-
it
|
93
|
-
expect(File.
|
94
|
-
Dir.mkdir(TEST_OUTPUT_DIR) unless Dir.
|
95
|
-
Assembly::Utils.export_objects(TEST_PID,TEST_OUTPUT_DIR)
|
96
|
-
expect(File.
|
92
|
+
it 'should export a PID to FOXML', :type => 'integration' do
|
93
|
+
expect(File.exist?(File.join(TEST_OUTPUT_DIR, "#{TEST_PID_FILENAME}.foxml.xml"))).to be false
|
94
|
+
Dir.mkdir(TEST_OUTPUT_DIR) unless Dir.exist?(TEST_OUTPUT_DIR)
|
95
|
+
Assembly::Utils.export_objects(TEST_PID, TEST_OUTPUT_DIR)
|
96
|
+
expect(File.exist?(File.join(TEST_OUTPUT_DIR, "#{TEST_PID_FILENAME}.foxml.xml"))).to be true
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
100
|
-
expect(Assembly::Utils.get_workflow_status(TEST_PID,'assemblyWF','jp2-create')).to be_nil
|
99
|
+
it 'should return nil when the workflow state is not found in an object', :type => 'integration' do
|
100
|
+
expect(Assembly::Utils.get_workflow_status(TEST_PID, 'assemblyWF', 'jp2-create')).to be_nil
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT,'accessionWF')).to be true
|
105
|
-
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT,'accessioning')).to be true
|
103
|
+
it 'should indicate if the specified workflow is defined in an APO object', :type => 'integration' do
|
104
|
+
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT, 'accessionWF')).to be true
|
105
|
+
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT, 'accessioning')).to be true
|
106
106
|
end
|
107
107
|
|
108
|
-
it
|
109
|
-
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT,'crapsticks')).to be false
|
108
|
+
it 'should indicate if the specified workflow is not defined in an APO object', :type => 'integration' do
|
109
|
+
expect(Assembly::Utils.apo_workflow_defined?(TEST_APO_OBJECT, 'crapsticks')).to be false
|
110
110
|
end
|
111
111
|
|
112
|
-
it
|
113
|
-
expect{Assembly::Utils.apo_workflow_defined?(TEST_PID,'crapsticks')}.to raise_error
|
112
|
+
it 'should indicate if the specified object is not an APO', :type => 'integration' do
|
113
|
+
expect{Assembly::Utils.apo_workflow_defined?(TEST_PID, 'crapsticks')}.to raise_error
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: assembly-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Mangiafico
|
@@ -9,174 +9,160 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: csv-mapper
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: fastercsv
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: druid-tools
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 0.2.6
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.2.6
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: dor-services
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - ~>
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '5.3'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - ~>
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '5.3'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: dor-workflow-service
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 1.3.1
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 1.3.1
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: activesupport
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: activeresource
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: addressable
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - '='
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 2.3.5
|
133
|
-
type: :runtime
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - '='
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: 2.3.5
|
140
126
|
- !ruby/object:Gem::Dependency
|
141
127
|
name: rake
|
142
128
|
requirement: !ruby/object:Gem::Requirement
|
143
129
|
requirements:
|
144
|
-
- -
|
130
|
+
- - ">="
|
145
131
|
- !ruby/object:Gem::Version
|
146
132
|
version: '0'
|
147
133
|
type: :development
|
148
134
|
prerelease: false
|
149
135
|
version_requirements: !ruby/object:Gem::Requirement
|
150
136
|
requirements:
|
151
|
-
- -
|
137
|
+
- - ">="
|
152
138
|
- !ruby/object:Gem::Version
|
153
139
|
version: '0'
|
154
140
|
- !ruby/object:Gem::Dependency
|
155
141
|
name: rspec
|
156
142
|
requirement: !ruby/object:Gem::Requirement
|
157
143
|
requirements:
|
158
|
-
- - ~>
|
144
|
+
- - "~>"
|
159
145
|
- !ruby/object:Gem::Version
|
160
146
|
version: '3.1'
|
161
147
|
type: :development
|
162
148
|
prerelease: false
|
163
149
|
version_requirements: !ruby/object:Gem::Requirement
|
164
150
|
requirements:
|
165
|
-
- - ~>
|
151
|
+
- - "~>"
|
166
152
|
- !ruby/object:Gem::Version
|
167
153
|
version: '3.1'
|
168
154
|
- !ruby/object:Gem::Dependency
|
169
155
|
name: yard
|
170
156
|
requirement: !ruby/object:Gem::Requirement
|
171
157
|
requirements:
|
172
|
-
- -
|
158
|
+
- - ">="
|
173
159
|
- !ruby/object:Gem::Version
|
174
160
|
version: '0'
|
175
161
|
type: :development
|
176
162
|
prerelease: false
|
177
163
|
version_requirements: !ruby/object:Gem::Requirement
|
178
164
|
requirements:
|
179
|
-
- -
|
165
|
+
- - ">="
|
180
166
|
- !ruby/object:Gem::Version
|
181
167
|
version: '0'
|
182
168
|
description: Contains classes to manipulate DOR objects for assembly and accessioning
|
@@ -188,9 +174,12 @@ executables:
|
|
188
174
|
extensions: []
|
189
175
|
extra_rdoc_files: []
|
190
176
|
files:
|
191
|
-
- .gitignore
|
192
|
-
- .rspec
|
193
|
-
- .
|
177
|
+
- ".gitignore"
|
178
|
+
- ".rspec"
|
179
|
+
- ".rubocop.yml"
|
180
|
+
- ".rubocop_todo.yml"
|
181
|
+
- ".rvmrc.example"
|
182
|
+
- ".travis.yml"
|
194
183
|
- Gemfile
|
195
184
|
- LICENSE
|
196
185
|
- README.md
|
@@ -218,17 +207,17 @@ require_paths:
|
|
218
207
|
- lib
|
219
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
220
209
|
requirements:
|
221
|
-
- -
|
210
|
+
- - ">="
|
222
211
|
- !ruby/object:Gem::Version
|
223
212
|
version: '0'
|
224
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
214
|
requirements:
|
226
|
-
- -
|
215
|
+
- - ">="
|
227
216
|
- !ruby/object:Gem::Version
|
228
217
|
version: '0'
|
229
218
|
requirements: []
|
230
219
|
rubyforge_project: assembly-utils
|
231
|
-
rubygems_version: 2.4.
|
220
|
+
rubygems_version: 2.4.6
|
232
221
|
signing_key:
|
233
222
|
specification_version: 4
|
234
223
|
summary: Ruby gem of methods usesful for assembly and accessioning.
|