|
1 | | -require 'yaml' |
2 | | -require 'plist' |
| 1 | +BUNDLE_ID = "co.randompaper.qiita.alfred" |
| 2 | +PACKAGE_FILE = "info.plist" |
3 | 3 |
|
4 | | -config_file = 'config.yml' |
5 | | -workflow_home = File.expand_path('~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows') |
6 | | - |
7 | | -$config = YAML.load_file config_file |
8 | | -$config['bundleid'] = "#{$config['domain']}.#{$config['id']}" |
9 | | -$config['package_file'] = File.join($config['path'], 'info.plist') |
10 | | -$config['dbx_workflow_path'] = File.join(File.expand_path($config['dropbox']), '/Alfred.alfredpreferences/workflows') |
11 | | - |
12 | | -desc "Generate a plist file for Alfred from config.yml" |
13 | | -task :configure do |
14 | | - package = Plist::parse_xml $config['package_file'] |
15 | | - |
16 | | - unless package['bundleid'].eql?($config["bundleid"]) |
17 | | - package['bundleid'] = $config['bundleid'] |
18 | | - File.open($config['package_file'], 'wb') do |f| |
19 | | - f.write package.to_plist |
20 | | - end |
21 | | - end |
22 | | -end |
| 4 | +workflow_home = File.expand_path('~/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows') |
| 5 | +dbx_workflow_path = File.expand_path('~/Dropbox/アプリ/Alfred.alfredpreferences/workflows') |
23 | 6 |
|
24 | 7 | desc "Link to Alfred" |
25 | 8 | task :link => [:configure] do |
26 | | - ln_sf File.expand_path($config["path"]), File.join(workflow_home, $config["bundleid"]) |
| 9 | + ln_sf File.expand_path('../', __FILE__), File.join(workflow_home, BUNDLE_ID) |
27 | 10 | end |
28 | 11 |
|
29 | 12 | desc "Unlink from Alfred" |
30 | 13 | task :unlink => [:configure] do |
31 | | - rm File.join(workflow_home, $config["bundleid"]) |
| 14 | + rm File.join(workflow_home, BUNDLE_ID) |
32 | 15 | end |
33 | 16 |
|
34 | 17 | desc "Install to Alfred Sync folder on Dropbox" |
35 | | -task :install => [:configure] do |
36 | | - ln_sf File.expand_path($config["path"]), File.join($config["dbx_workflow_path"], $config["bundleid"]) |
| 18 | +task :link_dropbox => [:configure] do |
| 19 | + ln_sf File.expand_path('../', __FILE__), File.join(dbx_workflow_path, BUNDLE_ID) |
37 | 20 | end |
38 | 21 |
|
39 | 22 | desc "Unlink from Alfred Sync folder on Dropbox" |
40 | | -task :uninstall => [:configure] do |
41 | | - rm File.join($config["dbx_workflow_path"], $config["bundleid"]) |
| 23 | +task :unlink_dropbox => [:configure] do |
| 24 | + rm File.join(dbx_workflow_path, BUNDLE_ID) |
42 | 25 | end |
0 commit comments