-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
57 lines (48 loc) · 1.71 KB
/
Rakefile
1
2
3
4
5
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
file "./standalone/infect" => FileList.new("lib/infect.rb", "lib/infect/*.rb") do |task|
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
require 'infect/standalone'
Infect::Standalone.save("./standalone/infect")
end
desc "Build standalone script"
task :standalone => "./standalone/infect"
namespace :build do
task :standalone_parallel => [:clean] do
Rake::Task[:standalone].invoke
pmap = Gem::Specification.find_by_name('pmap')
pmap_lib = Dir["#{File.join(pmap.lib_dirs_glob, 'pmap.rb')}"].first
content = File.read(pmap_lib)
preamble = <<PREAMBLE
#####
# This file is generated code. DO NOT send patches for it.
#
# Original source files with comments are at:
# https://github.com/csexton/infect
#####
PREAMBLE
license = File.read("#{File.join(pmap.lib_dirs_glob, '..', 'LICENSE')}")
infect = File.read('standalone/infect')
.gsub(%r{#!/usr/bin/.* ruby$}, '')
.gsub(%r{#!/usr/bin/ruby$}, '')
.gsub(%r{require 'pmap'}, '')
output = [ "#!/usr/bin/env ruby",
preamble,
"=begin",
"Content related to pmap belongs to the #{pmap.name} gem",
"See source at https://github.com/bruceadams/pmap",
"License",
license,
"=end",
content,
"# End of PMap gem",
infect,
].join("\n")
File.write(File.expand_path('standalone/infect'), output)
end
end
task :clean do
FileUtils.rm_f 'standalone/infect'
end