druid-tools 2.2.1 → 3.0.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
  SHA256:
3
- metadata.gz: ae5225239dbe4cabc2b4380a386d476b73d9ae21af9f3791df9b1d44cb90f04e
4
- data.tar.gz: 1a3274f2ba03e506cc1289715df194cbf8f6cf16b0d23a0367ee13ed0cae9e11
3
+ metadata.gz: 4e1cf67f6458c6ada6365aaa5efa859c9b145c95052c56a1dced7daa84b0a72a
4
+ data.tar.gz: f01aee261d0a590df682c1b2372a8d2c6bcd3c86ae1049ac28aef679130645f8
5
5
  SHA512:
6
- metadata.gz: 25274f7e81d1694cbbef1419165dc517ca40ada672a9d4a76f9c8c38781a3782520992050ce2f056f6d954a9fd74adea1c5483b3f4297d7918c512697ab1148a
7
- data.tar.gz: 259575663aa19d712b31aa5f62f4204b6779dae6deec8512a0fba5dcb98df50af8f44d7a51b2b5b88573fd51acf9716d46e2a9bdb2a354b50f379406166e609e
6
+ metadata.gz: 637824152edc8b881ff720d1813099856c34d97a55186706caf60e2074a0a6ab63fb97f883631d194ab628f7222d82977a9f06e2649eba0384267d70dc854221
7
+ data.tar.gz: f161e8cee7ef2efd112c351d87022a48f2e25b22dafd2d853d535e8bdb78712f3dbbf24730636a25aa3374d98a2a214143a62f8e69a02db482750958b6781792
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@3.0.1
3
+ ruby-rails: sul-dlss/ruby-rails@3.1.2
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/.gitignore CHANGED
@@ -16,7 +16,6 @@ tmp
16
16
  .rvmrc
17
17
  .ruby-version
18
18
  .ruby-gemset
19
- Gemfile.lock
20
19
  .project
21
20
  doc
22
21
  .pry_history
data/.rubocop.yml CHANGED
@@ -20,8 +20,6 @@ Naming/FileName:
20
20
  - druid-tools.gemspec
21
21
  - lib/druid-tools.rb
22
22
 
23
- Gemspec/DateAssignment: # new in 1.10
24
- Enabled: true
25
23
  Gemspec/RequireMFA: # new in 1.23
26
24
  Enabled: true
27
25
  Layout/LineEndStringConcatenationIndentation: # new in 1.18
@@ -136,3 +134,33 @@ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
136
134
  Enabled: true
137
135
  RSpec/Rails/AvoidSetupHook: # new in 2.4
138
136
  Enabled: true
137
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
138
+ Enabled: true
139
+ Layout/LineContinuationLeadingSpace: # new in 1.31
140
+ Enabled: true
141
+ Layout/LineContinuationSpacing: # new in 1.31
142
+ Enabled: true
143
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
144
+ Enabled: true
145
+ Lint/NonAtomicFileOperation: # new in 1.31
146
+ Enabled: true
147
+ Lint/RefinementImportMethods: # new in 1.27
148
+ Enabled: true
149
+ Security/CompoundHash: # new in 1.28
150
+ Enabled: true
151
+ Style/EnvHome: # new in 1.29
152
+ Enabled: true
153
+ Style/FetchEnvVar: # new in 1.28
154
+ Enabled: true
155
+ Style/MapCompactWithConditionalBlock: # new in 1.30
156
+ Enabled: true
157
+ Style/NestedFileDirname: # new in 1.26
158
+ Enabled: true
159
+ Style/ObjectThen: # new in 1.28
160
+ Enabled: true
161
+ Style/RedundantInitialize: # new in 1.27
162
+ Enabled: true
163
+ RSpec/ChangeByZero: # new in 2.11.0
164
+ Enabled: true
165
+ RSpec/VerifiedDoubleReference: # new in 2.10.0
166
+ Enabled: true
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ druid-tools (3.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ byebug (11.1.3)
11
+ diff-lcs (1.5.0)
12
+ docile (1.4.0)
13
+ json (2.6.2)
14
+ parallel (1.22.1)
15
+ parser (3.1.2.0)
16
+ ast (~> 2.4.1)
17
+ rainbow (3.1.1)
18
+ rake (13.0.6)
19
+ regexp_parser (2.5.0)
20
+ rexml (3.2.5)
21
+ rspec (3.11.0)
22
+ rspec-core (~> 3.11.0)
23
+ rspec-expectations (~> 3.11.0)
24
+ rspec-mocks (~> 3.11.0)
25
+ rspec-core (3.11.0)
26
+ rspec-support (~> 3.11.0)
27
+ rspec-expectations (3.11.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.11.0)
30
+ rspec-mocks (3.11.1)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.11.0)
33
+ rspec-support (3.11.0)
34
+ rubocop (1.32.0)
35
+ json (~> 2.3)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.1.0.0)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
+ rexml (>= 3.2.5, < 4.0)
41
+ rubocop-ast (>= 1.19.1, < 2.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 1.4.0, < 3.0)
44
+ rubocop-ast (1.19.1)
45
+ parser (>= 3.1.1.0)
46
+ rubocop-rake (0.6.0)
47
+ rubocop (~> 1.0)
48
+ rubocop-rspec (2.12.1)
49
+ rubocop (~> 1.31)
50
+ ruby-progressbar (1.11.0)
51
+ simplecov (0.16.1)
52
+ docile (~> 1.1)
53
+ json (>= 1.8, < 3)
54
+ simplecov-html (~> 0.10.0)
55
+ simplecov-html (0.10.2)
56
+ unicode-display_width (2.2.0)
57
+
58
+ PLATFORMS
59
+ x86_64-darwin-21
60
+ x86_64-linux
61
+
62
+ DEPENDENCIES
63
+ byebug
64
+ druid-tools!
65
+ rake (>= 10.1.0)
66
+ rspec (~> 3.0)
67
+ rubocop
68
+ rubocop-rake
69
+ rubocop-rspec
70
+ simplecov
71
+
72
+ BUNDLED WITH
73
+ 2.3.17
data/README.md CHANGED
@@ -71,8 +71,6 @@ d.mkdir
71
71
  d.mkdir('temp')
72
72
  # Remove a druid tree, but only up to the last shared branch directory
73
73
  d.rmdir
74
- # Link content from another source into a druid tree
75
- d.mkdir_with_final_link('/some/other/content/location')
76
74
  ```
77
75
 
78
76
  ### Content-specific methods create the relevant directories if they don't exist
@@ -110,19 +108,6 @@ d.find_content('this/file/does/not/exist.jpg')
110
108
  => nil
111
109
  ```
112
110
 
113
- ### Pruning: removes leaves of tree up to non-empty branches
114
-
115
- ```ruby
116
- d1 = DruidTools::Druid.new('druid:cd456ef7890', '/workspace')
117
- d1.mkdir
118
- d2 = DruidTools::Druid.new('druid:cd456gh1234', '/workspace')
119
- d2.mkdir
120
-
121
- # /workspace/cd/456/gh/1234/cd456gh1234 pruned down to /workspace/cd/456
122
- # /workspace/cd/456/ef/7890/cd456ef7890 left intact
123
- d2.prune!
124
- ```
125
-
126
111
  ### Stacks and Purl compatible Druid. All files at the leaf directories
127
112
 
128
113
  ```ruby
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 3.0.0
data/druid-tools.gemspec CHANGED
@@ -13,15 +13,14 @@ Gem::Specification.new do |gem|
13
13
 
14
14
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^spec/})
17
16
  gem.name = 'druid-tools'
18
17
  gem.require_paths = ['lib']
19
18
  gem.version = File.read('VERSION').strip
20
19
 
21
- gem.add_dependency 'deprecation'
22
- gem.add_development_dependency 'coveralls'
23
20
  gem.add_development_dependency 'rake', '>= 10.1.0'
24
21
  gem.add_development_dependency 'rspec', '~> 3.0'
25
22
  gem.add_development_dependency 'rubocop'
23
+ gem.add_development_dependency 'rubocop-rake'
26
24
  gem.add_development_dependency 'rubocop-rspec'
25
+ gem.add_development_dependency 'simplecov'
27
26
  end
@@ -2,13 +2,9 @@
2
2
 
3
3
  require 'pathname'
4
4
  require 'fileutils'
5
- require 'deprecation'
6
5
 
7
6
  module DruidTools
8
7
  class Druid
9
- extend Deprecation
10
- self.deprecation_horizon = 'druid-tools 3.0.0'
11
-
12
8
  attr_accessor :druid, :base
13
9
 
14
10
  # See https://consul.stanford.edu/pages/viewpage.action?title=SURI+2.0+Specification&spaceKey=chimera
@@ -128,34 +124,6 @@ module DruidTools
128
124
  found_dir
129
125
  end
130
126
 
131
- def mkdir_with_final_link(source, extra = nil)
132
- new_path = path(extra)
133
- if File.directory?(new_path) && !File.symlink?(new_path)
134
- raise DruidTools::DifferentContentExistsError, "Unable to create link, directory already exists: #{new_path}"
135
- end
136
-
137
- real_path = File.expand_path('..', new_path)
138
- FileUtils.mkdir_p(real_path)
139
- FileUtils.ln_s(source, new_path, force: true)
140
- end
141
- deprecation_deprecate :mkdir_with_final_link
142
-
143
- def rmdir(extra = nil)
144
- parts = tree
145
- parts << extra unless extra.nil?
146
- until parts.empty?
147
- dir = File.join(base, *parts)
148
- begin
149
- FileUtils.rm(File.join(dir, '.DS_Store'), force: true)
150
- FileUtils.rmdir(dir)
151
- rescue Errno::ENOTEMPTY
152
- break
153
- end
154
- parts.pop
155
- end
156
- end
157
- deprecation_deprecate :rmdir
158
-
159
127
  def pathname
160
128
  Pathname path
161
129
  end
@@ -167,22 +135,5 @@ module DruidTools
167
135
  def pruning_base
168
136
  pathname.parent
169
137
  end
170
-
171
- def prune!
172
- pruning_base.rmtree if pruning_base.exist? && pruning_base != base_pathname
173
- prune_ancestors pruning_base.parent
174
- end
175
- deprecation_deprecate :prune!
176
-
177
- # @param [Pathname] outermost_branch The branch at which pruning begins
178
- # @return [void] Ascend the druid tree and prune empty branches
179
- def prune_ancestors(outermost_branch)
180
- while outermost_branch.exist? && outermost_branch.children.empty?
181
- outermost_branch.rmdir
182
- outermost_branch = outermost_branch.parent
183
- break if outermost_branch == base_pathname
184
- end
185
- end
186
- deprecation_deprecate :prune_ancestors
187
138
  end
188
139
  end
@@ -119,8 +119,7 @@ RSpec.describe DruidTools::Druid do
119
119
  expect(druid.path).to eq(tree1)
120
120
  end
121
121
 
122
- it '#mkdir creates, and #rmdir destroys, *only* the expected druid directory' do
123
- allow(Deprecation).to receive(:warn)
122
+ it '#mkdir creates the expected druid directory' do
124
123
  expect(File.exist?(tree1)).to be false
125
124
  expect(File.exist?(tree2)).to be false
126
125
  expect(File.exist?(tree3)).to be false
@@ -143,22 +142,6 @@ RSpec.describe DruidTools::Druid do
143
142
  expect(File.exist?(tree1)).to be true
144
143
  expect(File.exist?(tree2)).to be true
145
144
  expect(File.exist?(tree3)).to be true
146
-
147
- druid3.rmdir
148
- expect(File.exist?(tree1)).to be true
149
- expect(File.exist?(tree2)).to be true
150
- expect(File.exist?(tree3)).to be false
151
-
152
- druid2.rmdir
153
- expect(File.exist?(tree1)).to be true
154
- expect(File.exist?(tree2)).to be false
155
- expect(File.exist?(tree3)).to be false
156
-
157
- druid1.rmdir
158
- expect(File.exist?(tree1)).to be false
159
- expect(File.exist?(tree2)).to be false
160
- expect(File.exist?(tree3)).to be false
161
- expect(File.exist?(File.join(fixture_dir, 'cd'))).to be false
162
145
  end
163
146
 
164
147
  describe 'alternate prefixes' do
@@ -304,116 +287,4 @@ RSpec.describe DruidTools::Druid do
304
287
  expect { dr.mkdir }.to raise_error(DruidTools::DifferentContentExistsError)
305
288
  end
306
289
  end
307
-
308
- describe '#mkdir_with_final_link' do
309
- let(:source_dir) { '/tmp/content_dir' }
310
- let(:druid_obj) { described_class.new(strictly_valid_druid_str, fixture_dir) }
311
-
312
- before do
313
- allow(Deprecation).to receive(:warn)
314
- FileUtils.mkdir_p(source_dir)
315
- end
316
-
317
- it 'creates a druid tree in the workspace with the final directory being a link to the passed in source' do
318
- druid_obj.mkdir_with_final_link(source_dir)
319
- expect(File).to be_symlink(druid_obj.path)
320
- expect(File.readlink(tree2)).to eq(source_dir)
321
- end
322
-
323
- it 'does not error out if the link to source already exists' do
324
- druid_obj.mkdir_with_final_link(source_dir)
325
- expect(File).to be_symlink(druid_obj.path)
326
- expect(File.readlink(tree2)).to eq(source_dir)
327
- end
328
-
329
- it 'raises DifferentContentExistsError if a directory already exists in the workspace for this druid' do
330
- druid_obj.mkdir(fixture_dir)
331
- expect { druid_obj.mkdir_with_final_link(source_dir) }.to raise_error(DruidTools::DifferentContentExistsError)
332
- end
333
- end
334
-
335
- describe '#prune!' do
336
- let(:workspace) { Dir.mktmpdir }
337
- let(:dr1) { described_class.new(druid_str, workspace) }
338
- let(:dr2) { described_class.new(strictly_valid_druid_str, workspace) }
339
- let(:dr3) { DruidTools::AccessDruid.new(access_druid_str, workspace) }
340
- let(:pathname1) { dr1.pathname }
341
-
342
- before do
343
- allow(Deprecation).to receive(:warn)
344
- end
345
-
346
- after do
347
- FileUtils.remove_entry workspace
348
- end
349
-
350
- context 'with an access druid sharing the first three path segments' do
351
- before do
352
- # Nil the create records for this context because we're in a known read only one
353
- dr1.mkdir
354
- dr2.mkdir
355
- dr3.mkdir
356
- dr3.prune!
357
- end
358
-
359
- it 'deletes the outermost directory' do
360
- expect(File).not_to exist(dr3.pruning_base)
361
- end
362
-
363
- it 'does not delete unrelated ancestor directories' do
364
- expect(File).to exist(dr1.pruning_base)
365
- expect(File).to exist(dr1.pruning_base.parent)
366
- end
367
-
368
- it 'stops at ancestor directories that have children' do
369
- # 'cd/456/ef' should still exist because of dr1
370
- shared_ancestor = dr1.pruning_base.parent
371
- expect(shared_ancestor.to_s).to match(%r{cd/456/ef$})
372
- expect(File).to exist(shared_ancestor)
373
- end
374
- end
375
-
376
- context 'when there is a shared ancestor' do
377
- before do
378
- # Nil the create records for this context because we're in a known read only one
379
- dr1.mkdir
380
- dr2.mkdir
381
- dr1.prune!
382
- end
383
-
384
- it 'deletes the outermost directory' do
385
- expect(File).not_to exist(dr1.path)
386
- end
387
-
388
- it 'deletes empty ancestor directories' do
389
- expect(File).not_to exist(pathname1.parent)
390
- expect(File).not_to exist(pathname1.parent.parent)
391
- end
392
-
393
- it 'stops at ancestor directories that have children' do
394
- # 'cd/456' should still exist because of druid2
395
- shared_ancestor = pathname1.parent.parent.parent
396
- expect(shared_ancestor.to_s).to match(%r{cd/456$})
397
- expect(File).to exist(shared_ancestor)
398
- end
399
- end
400
-
401
- it 'removes all directories up to the base path when there are no common ancestors' do
402
- # Nil the create records for this test
403
- dr1.mkdir
404
- dr1.prune!
405
- expect(File).not_to exist(File.join(workspace, 'cd'))
406
- expect(File).to exist(workspace)
407
- end
408
-
409
- it 'removes directories with symlinks' do
410
- # Nil the create records for this test
411
- source_dir = File.join workspace, 'src_dir'
412
- FileUtils.mkdir_p(source_dir)
413
- dr2.mkdir_with_final_link(source_dir)
414
- dr2.prune!
415
- expect(File).not_to exist(dr2.path)
416
- expect(File).not_to exist(File.join(workspace, 'cd'))
417
- end
418
- end
419
290
  end
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # $LOAD_PATH.unshift(File.expand_path('../../lib',__FILE__))
4
-
5
- require 'coveralls'
6
- Coveralls.wear_merged! # because we run travis on multiple rubies
7
-
8
3
  require 'simplecov'
9
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
4
+ require 'tmpdir' # Dir.mktmpdir
10
5
  SimpleCov.start do
11
6
  add_filter 'spec'
12
7
  end
metadata CHANGED
@@ -1,74 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druid-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein
8
8
  - Darren Hardy
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-01 00:00:00.000000000 Z
12
+ date: 2022-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: deprecation
15
+ name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
20
+ version: 10.1.0
21
+ type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '0'
27
+ version: 10.1.0
28
28
  - !ruby/object:Gem::Dependency
29
- name: coveralls
29
+ name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0'
34
+ version: '3.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0'
41
+ version: '3.0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: rubocop
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 10.1.0
48
+ version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 10.1.0
55
+ version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
- name: rspec
57
+ name: rubocop-rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: '3.0'
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: '3.0'
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: rubocop
71
+ name: rubocop-rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
@@ -82,7 +82,7 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: rubocop-rspec
85
+ name: simplecov
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
@@ -109,6 +109,7 @@ files:
109
109
  - ".rubocop.yml"
110
110
  - ".rubocop_todo.yml"
111
111
  - Gemfile
112
+ - Gemfile.lock
112
113
  - LICENSE
113
114
  - README.md
114
115
  - Rakefile
@@ -129,7 +130,7 @@ licenses:
129
130
  - Stanford University Libraries
130
131
  metadata:
131
132
  rubygems_mfa_required: 'true'
132
- post_install_message:
133
+ post_install_message:
133
134
  rdoc_options: []
134
135
  require_paths:
135
136
  - lib
@@ -144,11 +145,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  - !ruby/object:Gem::Version
145
146
  version: '0'
146
147
  requirements: []
147
- rubygems_version: 3.2.32
148
- signing_key:
148
+ rubygems_version: 3.3.7
149
+ signing_key:
149
150
  specification_version: 4
150
151
  summary: Tools to manipulate DRUID trees and content directories
151
- test_files:
152
- - spec/druid_tools/purl_druid_spec.rb
153
- - spec/druid_tools_spec.rb
154
- - spec/spec_helper.rb
152
+ test_files: []