cypher-textmate 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +22 -12
- data/Rakefile +4 -4
- data/bin/textmate +65 -34
- metadata +4 -4
data/README.markdown
CHANGED
@@ -1,31 +1,41 @@
|
|
1
|
-
textmate
|
2
|
-
========
|
1
|
+
# textmate
|
3
2
|
|
4
3
|
A binary that provides package management for TextMate.
|
5
4
|
|
6
|
-
Usage
|
7
|
-
=====
|
5
|
+
# Usage
|
8
6
|
|
9
7
|
`textmate [COMMAND] [*PARAMS]`
|
10
8
|
|
11
9
|
Textmate bundles are automatically reloaded after install or uninstall operations.
|
12
10
|
|
11
|
+
## List available remote bundles
|
12
|
+
|
13
13
|
`textmate remote [SEARCH]`
|
14
|
-
------------------------
|
15
14
|
|
16
|
-
List all of the available bundles in the remote repository
|
15
|
+
List all of the available bundles in the remote repository, optionally filtering by `search`.
|
16
|
+
|
17
|
+
## List installed bundles
|
18
|
+
|
19
|
+
`textmate list [SEARCH]`
|
17
20
|
|
18
|
-
|
19
|
-
--------------------
|
21
|
+
List all of the bundles that are installed on the local system, optionally filtering by `search`.
|
20
22
|
|
21
|
-
|
23
|
+
## Installing new bundles
|
22
24
|
|
23
25
|
`textmate install NAME [SOURCE]`
|
24
|
-
-----------------------
|
25
26
|
|
26
|
-
Installs a bundle from the remote repository. SOURCE filters known remote bundle locations.
|
27
|
+
Installs a bundle from the remote repository. SOURCE filters known remote bundle locations.
|
28
|
+
For example, if you want to install the "Ruby on Rails" bundle off GitHub, you'd type the following:
|
29
|
+
|
30
|
+
`textmate install "Ruby on Rails" GitHub`
|
31
|
+
|
32
|
+
Available remote bundle locations are:
|
33
|
+
* Macromates Trunk
|
34
|
+
* Macromates Review
|
35
|
+
* GitHub
|
36
|
+
|
37
|
+
## Uninstalling bundles
|
27
38
|
|
28
39
|
`textmate uninstall NAME`
|
29
|
-
-------------------------
|
30
40
|
|
31
41
|
Uninstalls a bundle from the local repository.
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rake/gempackagetask'
|
|
3
3
|
require 'date'
|
4
4
|
|
5
5
|
GEM = "textmate"
|
6
|
-
GEM_VERSION = "0.9.
|
6
|
+
GEM_VERSION = "0.9.2"
|
7
7
|
AUTHOR = "Yehuda Katz"
|
8
8
|
EMAIL = "wycats@gmail.com"
|
9
9
|
HOMEPAGE = "http://yehudakatz.com"
|
@@ -21,11 +21,11 @@ spec = Gem::Specification.new do |s|
|
|
21
21
|
s.email = EMAIL
|
22
22
|
s.homepage = HOMEPAGE
|
23
23
|
|
24
|
-
s.add_dependency "thor", ">= 0.9.
|
24
|
+
s.add_dependency "thor", ">= 0.9.2"
|
25
25
|
|
26
|
-
s.require_path = '
|
26
|
+
s.require_path = 'bin' # Yes, it's a hack, but otherwise gem complains on install
|
27
27
|
s.autorequire = GEM
|
28
|
-
s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{bin,
|
28
|
+
s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{bin,specs}/**/*")
|
29
29
|
s.bindir = "bin"
|
30
30
|
s.executables = %w( textmate )
|
31
31
|
end
|
data/bin/textmate
CHANGED
@@ -3,39 +3,45 @@
|
|
3
3
|
require "fileutils"
|
4
4
|
require "rubygems"
|
5
5
|
require "thor"
|
6
|
+
require "open-uri"
|
7
|
+
require "yaml"
|
6
8
|
|
7
9
|
class TextmateInstaller < Thor
|
8
10
|
|
9
11
|
# CHANGED: renamed list to remote. Could there be a better name?
|
10
12
|
desc "remote [SEARCH]", "Lists all the matching remote bundles"
|
11
|
-
def remote(
|
12
|
-
|
13
|
+
def remote(search_term = "")
|
14
|
+
search_term = Regexp.new(".*#{search_term}.*", "i")
|
13
15
|
|
14
16
|
remote_bundle_locations.each do |name,location|
|
15
17
|
puts "\n" << name.to_s << " Remote Bundles\n" << name.to_s.gsub(/./,'-') << '---------------'
|
16
18
|
|
17
|
-
results =
|
18
|
-
|
19
|
+
results = case location[:scm]
|
20
|
+
when :svn
|
21
|
+
%x[svn list #{e_sh location[:url]}].map {|x| x.split(".")[0]}.select {|x| x =~ search_term}.join("\n")
|
22
|
+
when :git
|
23
|
+
'git remotes not implemented yet'
|
24
|
+
when :github
|
25
|
+
find_github_bundles(search_term).map{|result| normalize_github_repo_name(result['name']).split('.').first}
|
26
|
+
end
|
19
27
|
|
20
|
-
puts
|
28
|
+
puts results
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
24
32
|
desc "list [SEARCH]", "lists all the bundles installed locally"
|
25
|
-
def list(
|
26
|
-
|
33
|
+
def list(search_term = "")
|
34
|
+
search_term = Regexp.new(".*#{search_term}.*", "i")
|
27
35
|
|
28
36
|
local_bundle_paths.each do |name,bundles_path|
|
29
37
|
puts "\n" << name.to_s << " Bundles\n" << name.to_s.gsub(/./,'-') << '--------'
|
30
38
|
puts Dir["#{e_sh bundles_path}/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.
|
31
|
-
select {|x| x =~
|
39
|
+
select {|x| x =~ search_term}.join("\n")
|
32
40
|
end
|
33
41
|
end
|
34
42
|
|
35
|
-
# TODO: Add a DESTINATION option to decide where to install. Maybe make some sort of ~/.textmate-cli config file?
|
36
43
|
desc "install NAME [SOURCE]", "install a bundle"
|
37
44
|
def install(bundle_name, remote_bundle_location_name=nil)
|
38
|
-
# TODO: Add an option to remove all other versions of the same bundle
|
39
45
|
FileUtils.mkdir_p install_bundles_path
|
40
46
|
puts "Checking out #{bundle_name}..."
|
41
47
|
|
@@ -44,66 +50,72 @@ class TextmateInstaller < Thor
|
|
44
50
|
remote_bundle_locations.each do |remote_name,location|
|
45
51
|
next unless remote_name.to_s.downcase.include? remote_bundle_location_name.to_s.downcase if remote_bundle_location_name
|
46
52
|
|
47
|
-
cmd =
|
48
|
-
|
53
|
+
cmd = case location[:scm]
|
54
|
+
when :git
|
55
|
+
'echo "git remotes not implemented yet"'
|
56
|
+
when :svn
|
57
|
+
%[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
|
58
|
+
when :github
|
59
|
+
repo = find_github_bundles(denormalize_github_repo_name(bundle_name)).first
|
60
|
+
%[git clone #{e_sh repo['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
|
61
|
+
end
|
62
|
+
|
49
63
|
res = %x{#{cmd}}
|
50
64
|
|
51
|
-
puts cmd, res.gsub(/^/,' ')
|
65
|
+
puts cmd, res.gsub(/^/,' ')
|
52
66
|
|
53
67
|
installed=true and break if res =~ /Checked out revision|Initialized empty Git repository/
|
54
68
|
end
|
55
|
-
abort 'Not Installed' unless installed
|
69
|
+
abort 'Not Installed' unless installed
|
56
70
|
|
57
|
-
|
58
|
-
reload_textmate!
|
59
|
-
puts "Done."
|
71
|
+
reload :verbose => true
|
60
72
|
end
|
61
73
|
|
62
74
|
desc "uninstall NAME", "uninstall a bundle"
|
63
75
|
def uninstall(bundle_name)
|
64
76
|
puts "Removing bundle..."
|
65
|
-
# FIXME: Move deleted bundles to the trash instead of rm_rf-ing them?
|
66
77
|
# When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
|
67
78
|
# named as the bundles_path key. Just in case there are multiple versions of
|
68
79
|
# the same bundle in multiple bundle paths
|
69
80
|
local_bundle_paths.each do |name,bundles_path|
|
70
|
-
|
81
|
+
bundle_path = "#{bundles_path}/#{bundle_name}.tmbundle"
|
82
|
+
if File.exist? bundle_path
|
83
|
+
%x[osascript -e 'tell application "Finder" to move the POSIX file "#{bundle_path}" to trash']
|
84
|
+
end
|
71
85
|
end
|
72
|
-
|
73
|
-
|
74
|
-
puts "Done."
|
86
|
+
|
87
|
+
reload :verbose => true
|
75
88
|
end
|
76
89
|
|
77
|
-
|
78
|
-
|
90
|
+
desc "reload", "Reloads TextMate Bundles"
|
91
|
+
method_options :verbose => :boolean
|
92
|
+
def reload(opts = {})
|
93
|
+
puts "Reloading bundles..." if opts[:verbose]
|
79
94
|
%x[osascript -e 'tell app "TextMate" to reload bundles']
|
95
|
+
puts "Done." if opts[:verbose]
|
80
96
|
end
|
81
97
|
|
98
|
+
private
|
82
99
|
def remote_bundle_locations
|
83
|
-
{ :'
|
84
|
-
:'
|
100
|
+
{ :'Macromates Trunk' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Bundles'},
|
101
|
+
:'Macromates Review' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Review/Bundles'},
|
85
102
|
|
86
|
-
# TODO: Add Git support to remote_bundle_locations. Define some sort of standard way of listing git repos, checkout how rubygems does it
|
87
103
|
# :'Bunch of Git Bundles' => {:scm => :git, :url => 'git://NotImplemented'},
|
88
104
|
|
89
|
-
|
90
|
-
# This will require fetching the html of the search page, scanning for urls and converting them to git urls
|
91
|
-
# :'GitHub' => {:scm => :github, :url => 'http://github.com/search?q=tmbundle'},
|
105
|
+
:'GitHub' => {:scm => :github, :url => 'http://github.com/search?q=tmbundle'},
|
92
106
|
}
|
93
|
-
# TODO: Add some way to add more custom remotes
|
94
107
|
end
|
95
108
|
|
96
109
|
def local_bundle_paths
|
97
110
|
{ :Application => '/Applications/TextMate.app/Contents/SharedSupport/Bundles',
|
98
111
|
:User => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
|
99
112
|
:System => '/Library/Application Support/TextMate/Bundles',
|
100
|
-
:'User Pristine' => "#{ENV["HOME"]}/Library/Application Support/TextMate/Pristine Copy",
|
101
|
-
:'System Pristine' => '/Library/Application Support/TextMate/Pristine Copy',
|
113
|
+
:'User Pristine' => "#{ENV["HOME"]}/Library/Application Support/TextMate/Pristine Copy/Bundles",
|
114
|
+
:'System Pristine' => '/Library/Application Support/TextMate/Pristine Copy/Bundles',
|
102
115
|
}
|
103
116
|
end
|
104
117
|
|
105
118
|
def install_bundles_path
|
106
|
-
#TODO: Add some way for the user to configure where they'd prefer to install bundles
|
107
119
|
local_bundle_paths[:'User Pristine']
|
108
120
|
end
|
109
121
|
|
@@ -113,6 +125,25 @@ class TextmateInstaller < Thor
|
|
113
125
|
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
|
114
126
|
end
|
115
127
|
|
128
|
+
CAPITALIZATION_EXCEPTIONS = %w[tmbundle on]
|
129
|
+
# Convert a GitHub repo name into a "normal" TM bundle name
|
130
|
+
# e.g. ruby-on-rails-tmbundle => Ruby on Rails.tmbundle
|
131
|
+
def normalize_github_repo_name(name)
|
132
|
+
name = name.gsub("-", " ").split.each{|part| part.capitalize! unless CAPITALIZATION_EXCEPTIONS.include? part}.join(" ")
|
133
|
+
name[-9] = ?. if name =~ / tmbundle$/
|
134
|
+
name
|
135
|
+
end
|
136
|
+
|
137
|
+
# Does the opposite of normalize_github_repo_name
|
138
|
+
def denormalize_github_repo_name(name)
|
139
|
+
name += " tmbundle" unless name =~ / tmbundle$/
|
140
|
+
name.split(' ').each{|part| part.downcase!}.join(' ').gsub(' ', '-')
|
141
|
+
end
|
142
|
+
|
143
|
+
def find_github_bundles(search_term)
|
144
|
+
YAML.load(open('http://github.com/api/v1/yaml/search/tmbundle'))['repositories'].find_all{|result| result['name'].match(search_term)}
|
145
|
+
end
|
146
|
+
|
116
147
|
end
|
117
148
|
|
118
149
|
# TODO: create a "monument to personal cleverness" by class-izing everything?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cypher-textmate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire: textmate
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-28 00:00:00 -07:00
|
13
13
|
default_executable: textmate
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.9.
|
22
|
+
version: 0.9.2
|
23
23
|
version:
|
24
24
|
description: Command-line textmate package manager
|
25
25
|
email: wycats@gmail.com
|
@@ -41,7 +41,7 @@ post_install_message:
|
|
41
41
|
rdoc_options: []
|
42
42
|
|
43
43
|
require_paths:
|
44
|
-
-
|
44
|
+
- bin
|
45
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|