6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/curdle/tasks.rb', line 6
def install(gemspec_file = find_gemspec)
task :build do
require 'tmpdir'
require 'fileutils'
Dir.mktmpdir do |build_dir|
spec = Bundler.load_gemspec(gemspec_file)
spec.files.each do |source_path|
next if File.directory?(source_path)
dest_path = File.join(build_dir, source_path)
FileUtils.mkdir_p(File.dirname(dest_path))
if File.extname(source_path) == '.rb'
File.write(dest_path, Curdle.process(File.read(source_path)))
else
FileUtils.cp(source_path, dest_path)
end
end
Dir.chdir(build_dir) do
system("gem build --silent")
end
artifact = File.join(build_dir, "#{spec.name}-#{spec.version}.gem")
FileUtils.mkdir_p('pkg')
artifact_dest = File.join('pkg', File.basename(artifact))
FileUtils.mv(artifact, artifact_dest)
puts "#{spec.name} #{spec.version} built to #{artifact_dest}."
end
end
end
|