jballanc-textmate 0.9.3
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/LICENSE +20 -0
- data/README.markdown +41 -0
- data/Rakefile +46 -0
- data/bin/textmate +226 -0
- metadata +65 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Yehuda Katz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# textmate
|
2
|
+
|
3
|
+
A binary that provides package management for TextMate.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
`textmate [COMMAND] [*PARAMS]`
|
8
|
+
|
9
|
+
Textmate bundles are automatically reloaded after install or uninstall operations.
|
10
|
+
|
11
|
+
## List available remote bundles
|
12
|
+
|
13
|
+
`textmate remote [SEARCH]`
|
14
|
+
|
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]`
|
20
|
+
|
21
|
+
List all of the bundles that are installed on the local system, optionally filtering by `search`.
|
22
|
+
|
23
|
+
## Installing new bundles
|
24
|
+
|
25
|
+
`textmate install NAME [SOURCE]`
|
26
|
+
|
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
|
38
|
+
|
39
|
+
`textmate uninstall NAME`
|
40
|
+
|
41
|
+
Uninstalls a bundle from the local repository.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
GEM = "textmate"
|
6
|
+
GEM_VERSION = "0.9.3"
|
7
|
+
AUTHOR = "Yehuda Katz"
|
8
|
+
EMAIL = "wycats@gmail.com"
|
9
|
+
HOMEPAGE = "http://yehudakatz.com"
|
10
|
+
SUMMARY = "Command-line textmate package manager"
|
11
|
+
|
12
|
+
spec = Gem::Specification.new do |s|
|
13
|
+
s.name = GEM
|
14
|
+
s.version = GEM_VERSION
|
15
|
+
s.platform = Gem::Platform::RUBY
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE"]
|
18
|
+
s.summary = SUMMARY
|
19
|
+
s.description = s.summary
|
20
|
+
s.author = AUTHOR
|
21
|
+
s.email = EMAIL
|
22
|
+
s.homepage = HOMEPAGE
|
23
|
+
|
24
|
+
s.add_dependency "wycats-thor", ">= 0.9.2"
|
25
|
+
|
26
|
+
s.require_path = 'bin' # Yes, it's a hack, but otherwise gem complains on install
|
27
|
+
s.autorequire = GEM
|
28
|
+
s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{bin,specs}/**/*")
|
29
|
+
s.bindir = "bin"
|
30
|
+
s.executables = %w( textmate )
|
31
|
+
end
|
32
|
+
|
33
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
34
|
+
pkg.gem_spec = spec
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "make a gemspec file"
|
38
|
+
task :make_spec do
|
39
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
40
|
+
file.puts spec.to_ruby
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task :install => [:package] do
|
45
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION} --no-rdoc --no-ri}
|
46
|
+
end
|
data/bin/textmate
ADDED
@@ -0,0 +1,226 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
require "rubygems"
|
5
|
+
require "thor"
|
6
|
+
require "open-uri"
|
7
|
+
require "yaml"
|
8
|
+
|
9
|
+
class TextmateInstaller < Thor
|
10
|
+
|
11
|
+
# CHANGED: renamed list to remote. Could there be a better name?
|
12
|
+
desc "remote [SEARCH]", "Lists all the matching remote bundles"
|
13
|
+
def remote(search_term = "")
|
14
|
+
search_term = Regexp.new(".*#{search_term}.*", "i")
|
15
|
+
|
16
|
+
remote_bundle_locations.each do |name,location|
|
17
|
+
puts "\n" << name.to_s << " Remote Bundles\n" << name.to_s.gsub(/./,'-') << '---------------'
|
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|
|
26
|
+
"%s (by %s)" %
|
27
|
+
[
|
28
|
+
normalize_github_repo_name(result['name']).split('.').first,
|
29
|
+
result['url'][/github\.com\/([a-zA-Z0-9]+)\//, 1] # Extract the username out of the repo URL
|
30
|
+
]
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
puts results
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "list [SEARCH]", "lists all the bundles installed locally"
|
39
|
+
def list(search_term = "")
|
40
|
+
search_term = Regexp.new(".*#{search_term}.*", "i")
|
41
|
+
|
42
|
+
local_bundle_paths.each do |name,bundles_path|
|
43
|
+
puts "\n" << name.to_s << " Bundles\n" << name.to_s.gsub(/./,'-') << '--------'
|
44
|
+
puts Dir["#{e_sh bundles_path}/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.
|
45
|
+
select {|x| x =~ search_term}.join("\n")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "install NAME [SOURCE]", "install a bundle"
|
50
|
+
def install(bundle_name, remote_bundle_location_name=nil)
|
51
|
+
FileUtils.mkdir_p install_bundles_path
|
52
|
+
puts "Checking out #{bundle_name}..."
|
53
|
+
|
54
|
+
# CHANGED: It's faster to just try and fail for each repo than to search them all first
|
55
|
+
installed=false
|
56
|
+
remote_bundle_locations.each do |remote_name,location|
|
57
|
+
next unless remote_name.to_s.downcase.include? remote_bundle_location_name.to_s.downcase if remote_bundle_location_name
|
58
|
+
|
59
|
+
cmd = case location[:scm]
|
60
|
+
when :git
|
61
|
+
'echo "git remotes not implemented yet"'
|
62
|
+
when :svn
|
63
|
+
%[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
|
64
|
+
when :github
|
65
|
+
repos = find_github_bundles(denormalize_github_repo_name(bundle_name))
|
66
|
+
|
67
|
+
# Handle possible multiple Repos with the same name
|
68
|
+
case repos.size
|
69
|
+
when 0
|
70
|
+
'echo "Sorry, no such bundle found"'
|
71
|
+
when 1
|
72
|
+
%[git clone #{e_sh repos.first['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
|
73
|
+
else
|
74
|
+
puts "Multiple bundles with that name found. Please choose which one you want to install:"
|
75
|
+
repos.each_with_index {|repo, idx|
|
76
|
+
puts "%d: %s by %s" %
|
77
|
+
[
|
78
|
+
idx + 1,
|
79
|
+
normalize_github_repo_name(repo['name']),
|
80
|
+
repo['url'][/github\.com\/([a-zA-Z0-9]+)\//, 1]
|
81
|
+
]
|
82
|
+
}
|
83
|
+
print "Your choice: "
|
84
|
+
|
85
|
+
# Since to_i defaults to 0, we have to use Integer
|
86
|
+
choice = Integer(STDIN.gets.chomp) rescue nil
|
87
|
+
until choice && (0...repos.size).include?( choice - 1 ) do
|
88
|
+
print "Sorry, invalid choice. Please enter a valid number or Ctrl+C to stop: "
|
89
|
+
choice = Integer(STDIN.gets.chomp) rescue nil
|
90
|
+
end
|
91
|
+
|
92
|
+
%[git clone #{e_sh repos[choice - 1]['url'].sub('http', 'git') + '.git'} #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
res = %x{#{cmd}}
|
97
|
+
|
98
|
+
puts cmd, res.gsub(/^/,' ')
|
99
|
+
|
100
|
+
installed=true and break if res =~ /Checked out revision|Initialized empty Git repository/
|
101
|
+
end
|
102
|
+
abort 'Not Installed' unless installed
|
103
|
+
|
104
|
+
reload :verbose => true
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "uninstall NAME", "uninstall a bundle"
|
108
|
+
def uninstall(bundle_name)
|
109
|
+
puts "Removing bundle..."
|
110
|
+
# When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
|
111
|
+
# named as the bundles_path key. Just in case there are multiple versions of
|
112
|
+
# the same bundle in multiple bundle paths
|
113
|
+
local_bundle_paths.each do |name,bundles_path|
|
114
|
+
bundle_path = "#{bundles_path}/#{bundle_name}.tmbundle"
|
115
|
+
if File.exist? bundle_path
|
116
|
+
%x[osascript -e 'tell application "Finder" to move the POSIX file "#{bundle_path}" to trash']
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
reload :verbose => true
|
121
|
+
end
|
122
|
+
|
123
|
+
desc "reload", "Reloads TextMate Bundles"
|
124
|
+
method_options :verbose => :boolean
|
125
|
+
def reload(opts = {})
|
126
|
+
puts "Reloading bundles..." if opts[:verbose]
|
127
|
+
%x[osascript -e 'tell app "TextMate" to reload bundles']
|
128
|
+
puts "Done." if opts[:verbose]
|
129
|
+
end
|
130
|
+
|
131
|
+
private
|
132
|
+
def remote_bundle_locations
|
133
|
+
{ :'Macromates Trunk' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Bundles'},
|
134
|
+
:'Macromates Review' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Review/Bundles'},
|
135
|
+
|
136
|
+
# :'Bunch of Git Bundles' => {:scm => :git, :url => 'git://NotImplemented'},
|
137
|
+
|
138
|
+
:'GitHub' => {:scm => :github, :url => 'http://github.com/search?q=tmbundle'},
|
139
|
+
}
|
140
|
+
end
|
141
|
+
|
142
|
+
def local_bundle_paths
|
143
|
+
{ :Application => '/Applications/TextMate.app/Contents/SharedSupport/Bundles',
|
144
|
+
:User => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
|
145
|
+
:System => '/Library/Application Support/TextMate/Bundles',
|
146
|
+
:'User Pristine' => "#{ENV["HOME"]}/Library/Application Support/TextMate/Pristine Copy/Bundles",
|
147
|
+
:'System Pristine' => '/Library/Application Support/TextMate/Pristine Copy/Bundles',
|
148
|
+
}
|
149
|
+
end
|
150
|
+
|
151
|
+
def install_bundles_path
|
152
|
+
local_bundle_paths[:'User Pristine']
|
153
|
+
end
|
154
|
+
|
155
|
+
# Copied from http://macromates.com/svn/Bundles/trunk/Support/lib/escape.rb
|
156
|
+
# escape text to make it useable in a shell script as one “word” (string)
|
157
|
+
def e_sh(str)
|
158
|
+
str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
|
159
|
+
end
|
160
|
+
|
161
|
+
CAPITALIZATION_EXCEPTIONS = %w[tmbundle on]
|
162
|
+
# Convert a GitHub repo name into a "normal" TM bundle name
|
163
|
+
# e.g. ruby-on-rails-tmbundle => Ruby on Rails.tmbundle
|
164
|
+
def normalize_github_repo_name(name)
|
165
|
+
name = name.gsub("-", " ").split.each{|part| part.capitalize! unless CAPITALIZATION_EXCEPTIONS.include? part}.join(" ")
|
166
|
+
name[-9] = ?. if name =~ / tmbundle$/
|
167
|
+
name
|
168
|
+
end
|
169
|
+
|
170
|
+
# Does the opposite of normalize_github_repo_name
|
171
|
+
def denormalize_github_repo_name(name)
|
172
|
+
name += " tmbundle" unless name =~ / tmbundle$/
|
173
|
+
name.split(' ').each{|part| part.downcase!}.join(' ').gsub(' ', '-')
|
174
|
+
end
|
175
|
+
|
176
|
+
def find_github_bundles(search_term)
|
177
|
+
# Until GitHub fixes http://support.github.com/discussions/feature-requests/11-api-search-results,
|
178
|
+
# we need to account for multiple pages of results:
|
179
|
+
page = 1
|
180
|
+
repositories = YAML.load(open("http://github.com/api/v1/yaml/search/tmbundle?page=#{page}"))['repositories']
|
181
|
+
results = []
|
182
|
+
until repositories.empty?
|
183
|
+
results += repositories.find_all{|result| result['name'].match(search_term)}
|
184
|
+
page += 1
|
185
|
+
repositories = YAML.load(open("http://github.com/api/v1/yaml/search/tmbundle?page=#{page}"))['repositories']
|
186
|
+
end
|
187
|
+
results.sort{|a,b| a['name'] <=> b['name']}
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
# TODO: create a "monument to personal cleverness" by class-izing everything?
|
193
|
+
# class TextMateBundle
|
194
|
+
# def self.find_local(bundle_name)
|
195
|
+
#
|
196
|
+
# end
|
197
|
+
#
|
198
|
+
# def self.find_remote(bundle_name)
|
199
|
+
#
|
200
|
+
# end
|
201
|
+
# attr_reader :name
|
202
|
+
# attr_reader :location
|
203
|
+
# attr_reader :scm
|
204
|
+
# def initialize(name, location, scm)
|
205
|
+
# @name = name
|
206
|
+
# @location = location
|
207
|
+
# @scm = scm
|
208
|
+
# end
|
209
|
+
#
|
210
|
+
# def install!
|
211
|
+
#
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
# def uninstall!
|
215
|
+
#
|
216
|
+
# end
|
217
|
+
#
|
218
|
+
#
|
219
|
+
# def installed?
|
220
|
+
# # List all the installed versions, and where they're at
|
221
|
+
# end
|
222
|
+
#
|
223
|
+
# # TODO: dirty? method to show if there are any deltas
|
224
|
+
# end
|
225
|
+
|
226
|
+
TextmateInstaller.start
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jballanc-textmate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yehuda Katz
|
8
|
+
autorequire: textmate
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-06-20 00:00:00 -07:00
|
13
|
+
default_executable: textmate
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: wycats-thor
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.2
|
23
|
+
version:
|
24
|
+
description: Command-line textmate package manager
|
25
|
+
email: wycats@gmail.com
|
26
|
+
executables:
|
27
|
+
- textmate
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.markdown
|
32
|
+
- LICENSE
|
33
|
+
files:
|
34
|
+
- LICENSE
|
35
|
+
- README.markdown
|
36
|
+
- Rakefile
|
37
|
+
- bin/textmate
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://yehudakatz.com
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
|
43
|
+
require_paths:
|
44
|
+
- bin
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.2.0
|
61
|
+
signing_key:
|
62
|
+
specification_version: 2
|
63
|
+
summary: Command-line textmate package manager
|
64
|
+
test_files: []
|
65
|
+
|