-
Notifications
You must be signed in to change notification settings - Fork 10
/
Rakefile
90 lines (71 loc) · 2.42 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
require 'yaml'
require 'plist'
config_file = 'config.yml'
workflow_home=File.expand_path("~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows")
$config = YAML.load_file(config_file)
$config["bundleid"] = "#{$config["domain"]}.#{$config["id"]}"
$config["plist"] = File.join($config["path"], "info.plist")
$config["workflow_dbx"] = File.join(File.expand_path($config["dropbox"]), "/Alfred.alfredpreferences/workflows")
# import sub-rakefiles
FileList['*/Rakefile'].each { |file|
import file
}
task :config do
info = Plist::parse_xml($config["plist"])
unless info['bundleid'].eql?($config["bundleid"])
info['bundleid'] = $config["bundleid"]
File.open($config["plist"], "wb") { |file| file.write(info.to_plist) }
end
end
task :chdir => [:config] do
chdir $config['path']
end
desc "Install Gems"
task "bundle:install" => [:chdir] do
sh %Q{bundle install --standalone --clean} do |ok, res|
if ! ok
puts "fail to install gems (status = #{res.exitstatus})"
else
sh %Q{find bundle -type d \\(-name vendor -o -name cache -o -name spec -o -name test \\) -print0 | xargs -0 rm -rf}
end
end
end
desc "Update Gems"
task "bundle:update" => [:chdir] do
sh %Q{bundle update && bundle install --standalone --clean} do |ok, res|
if ! ok
puts "fail to update gems (status = #{res.exitstatus})"
else
sh %Q{find bundle -type d \\( -name vendor -o -name cache -o -name spec -o -name test \\) -print0 | xargs -0 rm -rf}
end
end
end
desc "Generate Doc"
task :doc do
sh %Q{pandoc -f markdown -o "#{$config['path']}/README.pdf" README.md}
end
desc "Install to Alfred"
task :install => [:config] do
ln_sf File.expand_path($config["path"]), File.join(workflow_home, $config["bundleid"])
end
desc "Unlink from Alfred"
task :uninstall => [:config] do
rm File.join(workflow_home, $config["bundleid"])
end
desc "Install to Dropbox"
task :dbxinstall => [:config] do
ln_sf File.expand_path($config["path"]), File.join($config["workflow_dbx"], $config["bundleid"])
end
desc "Unlink from Dropbox"
task :dbxuninstall => [:config] do
rm File.join($config["workflow_dbx"], $config["bundleid"])
end
desc "Clean up all the extras"
task :clean => [:config] do
end
desc "Remove any generated file"
task :clobber => [:clean] do
rmtree File.join($config["path"], ".bundle")
rmtree File.join($config["path"], "bundle")
end