public
Fork of wycats/textmate
Description: Command-line package manager for textmate. Like rubygems for TextMate Bundles
Homepage: http://www.yehudakatz.com
Clone URL: git://github.com/subtleGradient/textmate.git
Search Repo:
Centralized bundle paths
Added Pristine Copy paths
Made the installed method support all bundle paths
Made the uninstall method support all bundle paths
Use e_sh from textmate for escaping paths
Made the install_bundles_path a method so that we can add some logic cof 
deciding which path to use
[CHANGED] The default install path is now the User Pristine Bundles path.
  This should now work for users who don't have admin access.
  This is also the default for when you double-click on a bundle in the 
  Finder.
Wed May 14 20:39:41 -0700 2008
commit  391b75690ad42e87959c65731f3313ab1ce19e39
tree    754aa1c169e73194cbe26bdfa5983a180b5319ca
parent  03867e60e6cb36009616bbd1d9f67fd181d447b7
...
1
2
3
 
4
5
6
...
15
16
17
18
 
19
20
21
22
23
24
 
 
 
 
25
26
27
28
29
30
 
31
32
33
 
34
35
36
...
39
40
41
42
43
 
 
 
 
 
 
44
45
46
...
66
67
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
70
71
 
 
...
1
2
3
4
5
6
7
...
16
17
18
 
19
20
21
 
 
 
 
22
23
24
25
26
27
28
29
 
 
30
31
32
 
33
34
35
36
...
39
40
41
 
 
42
43
44
45
46
47
48
49
50
...
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
0
@@ -1,6 +1,7 @@
0
 #!/usr/bin/env ruby
0
 
0
 require "fileutils"
0
+require "rubygems"
0
 require "thor"
0
 
0
 class TextmateInstaller < Thor
0
@@ -15,22 +16,21 @@ class TextmateInstaller < Thor
0
     results = %x[svn list #{svn_for("review")}]
0
     puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n")
0
   end
0
-
0
+
0
   desc "installed", "lists all the bundles installed locally"
0
   def installed()
0
- puts "\nSystem\n------\n"
0
- puts Dir["/Library/Application Support/TextMate/Bundles/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
0
- puts "\nUser\n----\n"
0
- puts Dir["#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
0
+ bundles_paths.each do |location,bundles_path|
0
+ puts location.to_s << " Bundles\n" << location.to_s.gsub(/./,'-') << '--------'
0
+ puts Dir["#{e_sh bundles_path}/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
0
+ end
0
   end
0
   
0
   desc "install NAME", "install a bundle"
0
   def install(name)
0
- FileUtils.mkdir_p "/Library/Application Support/TextMate/Bundles"
0
- quoted_name = name.gsub(" ", "\\ ")
0
+ FileUtils.mkdir_p install_bundles_path
0
     type = where(name)
0
     puts "Checking out #{name}..."
0
- res = %x[svn co #{svn_for(type)}/#{quoted_name}.tmbundle /Library/Application\\ Support/TextMate/Bundles/#{quoted_name}.tmbundle]
0
+ res = %x[svn co #{svn_for(type)}/#{e_sh name}.tmbundle #{e_sh install_bundles_path}/#{e_sh name}.tmbundle]
0
     puts "Reloading Bundles..."
0
     reload_textmate!
0
     puts "Done."
0
@@ -39,8 +39,12 @@ class TextmateInstaller < Thor
0
   desc "uninstall NAME", "uninstall a bundle"
0
   def uninstall(name)
0
     puts "Removing bundle..."
0
- FileUtils.rm_rf("/Library/Application Support/TextMate/Bundles/#{name}.tmbundle")
0
- FileUtils.rm_rf("#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles/#{name}.tmbundle")
0
+ # FIXME: Move deleted bundles to the trash instead of rm_rf-ing them?
0
+ bundles_paths.each do |location,bundles_path|
0
+ # When moving to the trash, maybe rename the bundle and add the bundles_path key to the name,
0
+ # just in case there are multiple versions of the same bundle in multiple bundle paths
0
+ FileUtils.rm_rf("#{bundles_path}/#{name}.tmbundle")
0
+ end
0
     puts "Reloading bundles..."
0
     reload_textmate!
0
     puts "Done."
0
@@ -66,6 +70,27 @@ class TextmateInstaller < Thor
0
     end
0
   end
0
   
0
+ def bundles_paths
0
+ { :User => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
0
+ :System => '/Library/Application Support/TextMate/Bundles',
0
+ :'User Pristine' => "#{ENV["HOME"]}/Library/Application Support/TextMate/Pristine Copy",
0
+ :'System Pristine' => '/Library/Application Support/TextMate/Pristine Copy',
0
+ }
0
+ end
0
+
0
+ def install_bundles_path
0
+ #TODO: Add some way for the user to configure where they'd prefer to install bundles
0
+ bundles_paths[:'User Pristine']
0
+ end
0
+
0
+ # Copied from http://macromates.com/svn/Bundles/trunk/Support/lib/escape.rb
0
+ # escape text to make it useable in a shell script as one “word” (string)
0
+ def e_sh(str)
0
+   str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
0
+ end
0
+
0
 end
0
 
0
 TextmateInstaller.start
0
+
0
+# FIXME: Rename methods to more closely match rubygems

Comments

    No one has commented yet.