assembly-utils 1.4.6 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cab491b6f6fa7b7ef55be7efe3778c938f86021
4
- data.tar.gz: 3dd67bee16cac2409e1838c69d9baa1404d6d748
3
+ metadata.gz: 8c19397f0ebcaf5de55f5688ad4ba4b200381bd3
4
+ data.tar.gz: 969da5c2c4405fad4b673ce1e9a9440ffe2a9bb8
5
5
  SHA512:
6
- metadata.gz: 229e597cc957ad504ea2f90f3b6299908ef9b07853ab3e6fcfde235d7aa5cabeca6a6d3ffc5654699fe081b2c5a0189ff6e638400e3c9bee61ad35efcb385a28
7
- data.tar.gz: 09f142c4c163d41ee9e6e62f1c2129317190a99d7c2c0c8ba41202dffcc2300570dba2d081f4bb9c004169f651e3dddc02f87543a76a18864c4841847cdddda9
6
+ metadata.gz: 1c2737172052da178d7406749e03fba104e6eadc7c670eb84f0a95f70bf530b2ffe236cf9f5d35c8cdecfed850f4dcf45e4ed5a22c925638592409196c1c0ee9
7
+ data.tar.gz: ff3d45febaa56d776f2cf4d1e9b56ae60d116b11a587bc631f503abf8d2b28fe4a62aae91d51787011f27524ed1c385b6ecb2196808f2a51573213f74889b55d
@@ -5,9 +5,8 @@ Style/SpaceBeforeBlockBraces:
5
5
  Exclude:
6
6
  - 'spec/**/*_spec.rb'
7
7
 
8
- # Allow for alignment
9
8
  Style/SpaceAroundOperators:
10
- MultiSpaceAllowedForOperators: true
9
+ AllowForAlignment: true
11
10
 
12
11
  Style/EmptyLineBetweenDefs:
13
12
  AllowAdjacentOneLineDefs: true
data/README.md CHANGED
@@ -49,6 +49,7 @@ manipulate DOR objects for assembly and accessioning.
49
49
  * 1.2.8 add a new constant for technical metadata filename
50
50
  * 1.4.1-2 update gems and fix typos
51
51
  * 1.4.6 rubocop fixes, and other refactoring
52
+ * 1.5.0 relax dependency pinning to support rails 5, and dor-workflow-service
52
53
 
53
54
  ## Running tests
54
55
 
@@ -18,15 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ['lib']
19
19
 
20
20
  s.add_dependency 'nokogiri'
21
- s.add_dependency 'csv-mapper'
22
- s.add_dependency 'fastercsv'
23
21
  s.add_dependency 'druid-tools', '>= 0.2.6'
24
22
 
25
- s.add_dependency 'dor-services', '~> 5.3'
26
- s.add_dependency 'dor-workflow-service', '>=1.3.1'
27
-
28
- s.add_dependency 'activesupport'
29
- s.add_dependency 'activeresource'
23
+ s.add_dependency 'dor-services', '~> 5.5'
30
24
 
31
25
  s.add_development_dependency 'rake'
32
26
  s.add_development_dependency 'rspec', '~> 3.1'
@@ -9,5 +9,3 @@ puts "RUNNING IN #{environment} mode"
9
9
  $LOAD_PATH.unshift(project_root + '/lib')
10
10
 
11
11
  require 'assembly-utils'
12
-
13
- Dor::WorkflowService.configure(Dor::Config.workflow.url)
@@ -1,6 +1,5 @@
1
1
  require 'net/ssh'
2
2
  require 'csv'
3
- require 'csv-mapper'
4
3
  require 'druid-tools'
5
4
 
6
5
  begin
@@ -11,7 +10,6 @@ end
11
10
  module Assembly
12
11
  # The Utils class contains methods to help with accessioning and assembly
13
12
  class Utils
14
- WFS = Dor::WorkflowService
15
13
  REPO = 'dor'
16
14
 
17
15
  # Get the staging directory tree given a druid, and optionally prepend a basepath.
@@ -163,7 +161,7 @@ module Assembly
163
161
  # puts Assembly::Utils.get_workflow_status('druid:aa000aa0001','assemblyWF','jp2-create')
164
162
  # > "completed"
165
163
  def self.get_workflow_status(druid, workflow, step)
166
- Dor::WorkflowService.get_workflow_status('dor', druid, workflow, step)
164
+ Dor::Config.workflow.client.get_workflow_status('dor', druid, workflow, step)
167
165
  end
168
166
 
169
167
  # Cleanup a list of objects and associated files given a list of druids. WARNING: VERY DESTRUCTIVE.
@@ -264,8 +262,8 @@ module Assembly
264
262
  if steps.include?(:workflows)
265
263
  puts "-- deleting #{pid} accessionWF and assemblyWF workflows from Fedora #{ENV['ROBOT_ENVIRONMENT']}"
266
264
  unless dry_run
267
- Dor::WorkflowService.delete_workflow('dor', pid, 'accessionWF')
268
- Dor::WorkflowService.delete_workflow('dor', pid, 'assemblyWF')
265
+ Dor::Config.workflow.client.delete_workflow('dor', pid, 'accessionWF')
266
+ Dor::Config.workflow.client.delete_workflow('dor', pid, 'assemblyWF')
269
267
  end
270
268
  end
271
269
  rescue Exception => e
@@ -428,7 +426,7 @@ module Assembly
428
426
  wf_name = Assembly::ASSEMBLY_WF
429
427
  msg = 'Integration testing'
430
428
  params = ['dor', pid, wf_name, step, msg]
431
- resp = Dor::WorkflowService.update_workflow_error_status *params
429
+ resp = Dor::Config.workflow.client.update_workflow_error_status *params
432
430
  raise 'update_workflow_error_status() returned false.' unless resp == true
433
431
  end
434
432
 
@@ -440,7 +438,7 @@ module Assembly
440
438
  # e.g.
441
439
  # Assembly::Utils.delete_all_workflows('druid:oo000oo0001')
442
440
  def self.delete_all_workflows(pid, repo = 'dor')
443
- Dor::WorkflowService.get_workflows(pid).each {|workflow| Dor::WorkflowService.delete_workflow(repo, pid, workflow)}
441
+ Dor::Config.workflow.client.get_workflows(pid).each {|workflow| Dor::Config.workflow.client.delete_workflow(repo, pid, workflow)}
444
442
  end
445
443
 
446
444
  # Reindex the supplied PID in solr.
@@ -460,7 +458,7 @@ module Assembly
460
458
  repo = 'dor'
461
459
  wf = 'assemblyWF'
462
460
  msg = 'Integration testing'
463
- wfs = Dor::WorkflowService
461
+ wfs = Dor::Config.workflow.client
464
462
  steps = Assembly::ASSEMBLY_WF_STEPS.map { |s| s[0] }
465
463
  completed = steps[0]
466
464
 
@@ -483,7 +481,7 @@ module Assembly
483
481
  # Assembly::Utils.is_ingested?('druid:oo000oo0001')
484
482
  # > false
485
483
  def self.is_ingested?(pid)
486
- WFS.get_lifecycle(REPO, pid, 'accessioned') ? true : false
484
+ Dor::Config.workflow.client.get_lifecycle(REPO, pid, 'accessioned') ? true : false
487
485
  end
488
486
 
489
487
  # Check if the object is currently in accessioning
@@ -495,7 +493,7 @@ module Assembly
495
493
  # Assembly::Utils.in_accessioning?('druid:oo000oo0001')
496
494
  # > false
497
495
  def self.in_accessioning?(pid)
498
- WFS.get_active_lifecycle(REPO, pid, 'submitted') ? true : false
496
+ Dor::Config.workflow.client.get_active_lifecycle(REPO, pid, 'submitted') ? true : false
499
497
  end
500
498
 
501
499
  # Check if the object is on ingest hold
@@ -507,7 +505,7 @@ module Assembly
507
505
  # Assembly::Utils.ingest_hold?('druid:oo000oo0001')
508
506
  # > false
509
507
  def self.ingest_hold?(pid)
510
- WFS.get_workflow_status(REPO, pid, 'accessionWF', 'sdr-ingest-transfer') == 'hold'
508
+ Dor::Config.workflow.client.get_workflow_status(REPO, pid, 'accessionWF', 'sdr-ingest-transfer') == 'hold'
511
509
  end
512
510
 
513
511
  # Check if the object is submitted
@@ -519,7 +517,7 @@ module Assembly
519
517
  # Assembly::Utils.is_submitted?('druid:oo000oo0001')
520
518
  # > false
521
519
  def self.is_submitted?(pid)
522
- WFS.get_lifecycle(REPO, pid, 'submitted').nil?
520
+ Dor::Config.workflow.client.get_lifecycle(REPO, pid, 'submitted').nil?
523
521
  end
524
522
 
525
523
  # Check if the updates are allowed on the object
@@ -570,7 +568,7 @@ module Assembly
570
568
  workflows.each do |workflow, steps|
571
569
  steps.each do |step|
572
570
  puts "Updating #{workflow}:#{step} to #{state}"
573
- Dor::WorkflowService.update_workflow_status 'dor', druid, workflow, step, state
571
+ Dor::Config.workflow.client.update_workflow_status 'dor', druid, workflow, step, state
574
572
  end
575
573
  end
576
574
  rescue Exception => e
@@ -587,14 +585,14 @@ module Assembly
587
585
  # Example:
588
586
  # Assembly::Utils.read_druids_from_file('download.csv') # ['druid:xxxxx', 'druid:yyyyy']
589
587
  def self.read_druids_from_file(csv_filename)
590
- rows = CsvMapper.import(csv_filename) do read_attributes_from_file end
591
- druids = []
592
- rows.each do |row|
593
- druid = row.druid
588
+ return to_enum(:read_druids_from_file, csv_filename) unless block_given?
589
+
590
+ CSV.foreach(csv_filename, :headers => true) do |row|
591
+ druid = row['druid']
594
592
  druid = "druid:#{druid}" unless druid.include?('druid:')
595
- druids << druid
593
+
594
+ yield druid
596
595
  end
597
- druids
598
596
  end
599
597
 
600
598
  # Get a list of druids that have errored out in a particular workflow and step
@@ -608,7 +606,7 @@ module Assembly
608
606
  # result=Assembly::Utils.get_errored_objects_for_workstep('accessionWF','content-metadata','Project : Revs')
609
607
  # => {"druid:qd556jq0580"=>"druid:qd556jq0580 - Item error; caused by #<Rubydora::FedoraInvalidRequest: Error modifying datastream contentMetadata for druid:qd556jq0580. See logger for details>"}
610
608
  def self.get_errored_objects_for_workstep(workflow, step, tag = '')
611
- result = Dor::WorkflowService.get_errored_objects_for_workstep workflow, step, 'dor'
609
+ result = Dor::Config.workflow.client.get_errored_objects_for_workstep workflow, step, 'dor'
612
610
  return result if tag == ''
613
611
  filtered_result = {}
614
612
  result.each do |druid, error|
@@ -3,6 +3,6 @@ module Assembly
3
3
  # Main Utils class
4
4
  class Utils
5
5
  # Project version number
6
- VERSION = '1.4.6'
6
+ VERSION = '1.5.0'
7
7
  end
8
8
  end
@@ -2,7 +2,8 @@ TEST_PID = 'druid:dd999dd9999'
2
2
  TEST_PID_FILENAME = TEST_PID.tr(':', '_')
3
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')
5
+ FIXTURES_DIR = File.join(PATH, 'test_data')
6
+ TEST_OUTPUT_DIR = File.join(FIXTURES_DIR, 'output')
6
7
  ENV['ROBOT_ENVIRONMENT'] = 'development'
7
8
 
8
9
  require 'rspec'
@@ -0,0 +1,4 @@
1
+ druid,x,y
2
+ a,0,1
3
+ b,1,2
4
+ druid:c,3,4
@@ -115,4 +115,12 @@ describe Assembly::Utils do
115
115
 
116
116
  end
117
117
 
118
+ describe '.read_druids_from_file' do
119
+ it 'extracts the druids from a CSV file' do
120
+ druids = Assembly::Utils.read_druids_from_file(File.join(FIXTURES_DIR, 'druids.csv'))
121
+
122
+ expect(druids.to_a).to match_array ['druid:a', 'druid:b', 'druid:c']
123
+ end
124
+ end
125
+
118
126
  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.6
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-08 00:00:00.000000000 Z
12
+ date: 2016-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -25,34 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: csv-mapper
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: fastercsv
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
28
  - !ruby/object:Gem::Dependency
57
29
  name: druid-tools
58
30
  requirement: !ruby/object:Gem::Requirement
@@ -73,56 +45,14 @@ dependencies:
73
45
  requirements:
74
46
  - - "~>"
75
47
  - !ruby/object:Gem::Version
76
- version: '5.3'
48
+ version: '5.5'
77
49
  type: :runtime
78
50
  prerelease: false
79
51
  version_requirements: !ruby/object:Gem::Requirement
80
52
  requirements:
81
53
  - - "~>"
82
54
  - !ruby/object:Gem::Version
83
- version: '5.3'
84
- - !ruby/object:Gem::Dependency
85
- name: dor-workflow-service
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 1.3.1
91
- type: :runtime
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: 1.3.1
98
- - !ruby/object:Gem::Dependency
99
- name: activesupport
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :runtime
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: activeresource
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">="
117
- - !ruby/object:Gem::Version
118
- version: '0'
119
- type: :runtime
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- version: '0'
55
+ version: '5.5'
126
56
  - !ruby/object:Gem::Dependency
127
57
  name: rake
128
58
  requirement: !ruby/object:Gem::Requirement
@@ -195,6 +125,7 @@ files:
195
125
  - spec/spec_helper.rb
196
126
  - spec/test_data/druid_aa000bb1111.xml
197
127
  - spec/test_data/druid_dd999dd9999.xml
128
+ - spec/test_data/druids.csv
198
129
  - spec/test_data/local_dev_revs.yaml
199
130
  - spec/test_data/test_log.yaml
200
131
  - spec/utils_spec.rb
@@ -217,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
148
  version: '0'
218
149
  requirements: []
219
150
  rubyforge_project: assembly-utils
220
- rubygems_version: 2.4.6
151
+ rubygems_version: 2.5.1
221
152
  signing_key:
222
153
  specification_version: 4
223
154
  summary: Ruby gem of methods usesful for assembly and accessioning.
@@ -225,7 +156,7 @@ test_files:
225
156
  - spec/spec_helper.rb
226
157
  - spec/test_data/druid_aa000bb1111.xml
227
158
  - spec/test_data/druid_dd999dd9999.xml
159
+ - spec/test_data/druids.csv
228
160
  - spec/test_data/local_dev_revs.yaml
229
161
  - spec/test_data/test_log.yaml
230
162
  - spec/utils_spec.rb
231
- has_rdoc: