Skip to content
This repository has been archived by the owner on Jun 8, 2018. It is now read-only.

Commit

Permalink
Copy gem contents into folder
Browse files Browse the repository at this point in the history
  • Loading branch information
luislavena committed Dec 24, 2010
1 parent 4f681a3 commit 0ce8b67
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions lib/isolate/lockdown/rake.rb
Expand Up @@ -9,7 +9,7 @@
temp_folder = "#{folder}.#{$$}"

# remove previous safe folder if exists
when_writing "remove previous safe folder" do
when_writing "Removing previous safe folder" do
FileUtils.rm_rf safe_folder if File.exist?(safe_folder)
end

Expand All @@ -23,7 +23,7 @@
require_paths = []

specs.each do |spec|
puts "Locking down #{spec.name} version #{spec.version}..."
puts "Locking down #{spec.name} version #{spec.version}"

base = spec.full_gem_path

Expand All @@ -34,6 +34,29 @@
FileUtils.mkdir_p(bin_dir) unless File.exist?(bin_dir)
FileUtils.cp full_exe, bin_dir
end

spec.require_paths.each do |path|
# do not add bindir to load path
next if path == spec.bindir

lib_dir = File.join(temp_folder, path)
require_paths << File.join(folder, path)

FileUtils.mkdir_p(lib_dir)

glob = File.join(base, path, '*')
Dir.glob(glob).each do |full_lib|
if File.file?(full_lib)
FileUtils.cp(full_lib, lib_dir)
else
FileUtils.cp_r(full_lib, lib_dir)
end
end
end
end

FileUtils.mv(folder, safe_folder) if File.exist?(folder)
FileUtils.mv(temp_folder, folder)
end
end
end

0 comments on commit 0ce8b67

Please sign in to comment.