Skip to content

Commit

Permalink
Merge 7c65f39 into 92ea588
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Aug 15, 2019
2 parents 92ea588 + 7c65f39 commit 87cece9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
6 changes: 1 addition & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
source 'https://rubygems.org'

group :development do
gem 'debugger', platform: :ruby_19
gem 'pry-debugger', platform: :ruby_19
gem 'rcov', platform: :ruby_18
gem 'ruby-debug', platform: :ruby_18
gem 'simplecov', platform: %i[ruby_19 ruby_20]
gem 'byebug'
end

gemspec
1 change: 1 addition & 0 deletions druid-tools.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = File.read('VERSION').strip

gem.add_dependency 'deprecation'
gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'rake', '>= 10.1.0'
gem.add_development_dependency 'rspec', '~> 3.0'
Expand Down
10 changes: 10 additions & 0 deletions lib/druid_tools/druid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

require 'pathname'
require 'fileutils'
require 'deprecation'

module DruidTools
class Druid
extend Deprecation
self.deprecation_horizon = 'druid-tools 3.0.0'

attr_accessor :druid, :base

# See https://consul.stanford.edu/pages/viewpage.action?title=SURI+2.0+Specification&spaceKey=chimera
Expand Down Expand Up @@ -122,6 +126,7 @@ def mkdir_with_final_link(source, extra = nil)
FileUtils.mkdir_p(real_path)
FileUtils.ln_s(source, new_path, force: true)
end
deprecation_deprecate :mkdir_with_final_link

def rmdir(extra = nil)
parts = tree
Expand All @@ -137,6 +142,7 @@ def rmdir(extra = nil)
parts.pop
end
end
deprecation_deprecate :rmdir

def pathname
Pathname path
Expand All @@ -152,6 +158,8 @@ def prune!
parent.rmtree if parent.exist? && parent != base_pathname
prune_ancestors parent.parent
end
deprecation_deprecate :prune!


# @param [Pathname] outermost_branch The branch at which pruning begins
# @return [void] Ascend the druid tree and prune empty branches
Expand All @@ -162,5 +170,7 @@ def prune_ancestors(outermost_branch)
break if outermost_branch == base_pathname
end
end
deprecation_deprecate :prune_ancestors

end
end
11 changes: 10 additions & 1 deletion spec/druid_tools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
end

it '#mkdir, #rmdir create and destroy druid directories' do
allow(Deprecation).to receive(:warn)
expect(File.exist?(tree1)).to eq false
expect(File.exist?(tree2)).to eq false

Expand Down Expand Up @@ -269,7 +270,10 @@
source_dir = '/tmp/content_dir'
FileUtils.mkdir_p(source_dir)
dr = described_class.new(strictly_valid_druid_str, fixture_dir)
dr.mkdir_with_final_link(source_dir)
new_path = dr.path
FileUtils.mkdir_p(File.expand_path('..', new_path))
FileUtils.ln_s(source_dir, new_path, force: true)

expect { dr.mkdir }.to raise_error(DruidTools::DifferentContentExistsError)
end
end
Expand All @@ -279,6 +283,7 @@
let(:druid_obj) { described_class.new(strictly_valid_druid_str, fixture_dir) }

before do
allow(Deprecation).to receive(:warn)
FileUtils.mkdir_p(source_dir)
end

Expand Down Expand Up @@ -306,6 +311,10 @@
let(:dr2) { described_class.new(strictly_valid_druid_str, workspace) }
let(:pathname1) { dr1.pathname }

before do
allow(Deprecation).to receive(:warn)
end

after do
FileUtils.remove_entry workspace
end
Expand Down

0 comments on commit 87cece9

Please sign in to comment.