-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRakefile
65 lines (50 loc) · 1.58 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
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("~/Documents/Bruno/Alfred/Alfred.alfredpreferences/workflows")
task :config do
$config = YAML.load_file(config_file)
$config["bundleid"] = "#{$config["domain"]}.#{$config["id"]}"
$config["plist"] = File.join($config["path"], "info.plist")
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})"
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})"
end
end
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 "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