forked from defunkt/gist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
44 lines (35 loc) · 1.2 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
task :default => :test
desc 'run the tests' # that's non-DRY
task :test do
sh 'rspec spec'
end
task :clipfailtest do
sh 'PATH=/ /usr/bin/ruby -Ilib -S bin/gist -ac < lib/gist.rb'
end
task :man do
mkdir_p "build"
File.write "README.md.ron", File.read("README.md").gsub("\u200c", "* ")
sh 'ronn --roff --manual="Gist manual" README.md.ron'
rm 'README.md.ron'
mv 'README.1', 'build/gist.1'
end
task :standalone do
mkdir_p "build"
File.open("build/gist", "w") do |f|
f.puts "#!/usr/bin/env ruby"
f.puts "# This is generated from https://github.com/defunkt/gist using 'rake standalone'"
f.puts "# any changes will be overwritten."
f.puts File.read("lib/gist.rb").split("require 'json'\n").join(File.read("vendor/json.rb"))
f.puts File.read("bin/gist").gsub(/^require.*gist.*\n/, '');
end
sh 'chmod +x build/gist'
end
task :build => [:man, :standalone]
desc "Install standalone script and man pages"
task :install => :standalone do
prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
FileUtils.mkdir_p "#{prefix}/bin"
FileUtils.cp "build/gist", "#{prefix}/bin"
FileUtils.mkdir_p "#{prefix}/share/man/man1"
FileUtils.cp "build/gist.1", "#{prefix}/share/man/man1"
end