cypher-textmate 0.9.1

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.
Files changed (5) hide show
  1. data/LICENSE +20 -0
  2. data/README.markdown +31 -0
  3. data/Rakefile +46 -0
  4. data/bin/textmate +152 -0
  5. 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,31 @@
1
+ textmate
2
+ ========
3
+
4
+ A binary that provides package management for TextMate.
5
+
6
+ Usage
7
+ =====
8
+
9
+ `textmate [COMMAND] [*PARAMS]`
10
+
11
+ Textmate bundles are automatically reloaded after install or uninstall operations.
12
+
13
+ `textmate remote [SEARCH]`
14
+ ------------------------
15
+
16
+ List all of the available bundles in the remote repository that have a substring `search`. By default, list all bundles.
17
+
18
+ `textmate list`
19
+ --------------------
20
+
21
+ List all of the bundles that are installed on the local system.
22
+
23
+ `textmate install NAME [SOURCE]`
24
+ -----------------------
25
+
26
+ Installs a bundle from the remote repository. SOURCE filters known remote bundle locations.
27
+
28
+ `textmate uninstall NAME`
29
+ -------------------------
30
+
31
+ 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.1"
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 "thor", ">= 0.9.1"
25
+
26
+ s.require_path = 'lib'
27
+ s.autorequire = GEM
28
+ s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{bin,lib,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,152 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "fileutils"
4
+ require "rubygems"
5
+ require "thor"
6
+
7
+ class TextmateInstaller < Thor
8
+
9
+ # CHANGED: renamed list to remote. Could there be a better name?
10
+ desc "remote [SEARCH]", "Lists all the matching remote bundles"
11
+ def remote(limit = "")
12
+ limit = Regexp.new(".*#{limit}.*", "i")
13
+
14
+ remote_bundle_locations.each do |name,location|
15
+ puts "\n" << name.to_s << " Remote Bundles\n" << name.to_s.gsub(/./,'-') << '---------------'
16
+
17
+ results = %x[svn list #{e_sh location[:url]}] if location[:scm]==:svn
18
+ puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n") if results
19
+
20
+ puts 'git remotes not implemented yet' if location[:scm]==:git
21
+ end
22
+ end
23
+
24
+ desc "list [SEARCH]", "lists all the bundles installed locally"
25
+ def list(limit = "")
26
+ limit = Regexp.new(".*#{limit}.*", "i")
27
+
28
+ local_bundle_paths.each do |name,bundles_path|
29
+ puts "\n" << name.to_s << " Bundles\n" << name.to_s.gsub(/./,'-') << '--------'
30
+ puts Dir["#{e_sh bundles_path}/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.
31
+ select {|x| x =~ limit}.join("\n")
32
+ end
33
+ end
34
+
35
+ # TODO: Add a DESTINATION option to decide where to install. Maybe make some sort of ~/.textmate-cli config file?
36
+ desc "install NAME [SOURCE]", "install a bundle"
37
+ def install(bundle_name, remote_bundle_location_name=nil)
38
+ # TODO: Add an option to remove all other versions of the same bundle
39
+ FileUtils.mkdir_p install_bundles_path
40
+ puts "Checking out #{bundle_name}..."
41
+
42
+ # CHANGED: It's faster to just try and fail for each repo than to search them all first
43
+ installed=false
44
+ remote_bundle_locations.each do |remote_name,location|
45
+ next unless remote_name.to_s.downcase.include? remote_bundle_location_name.to_s.downcase if remote_bundle_location_name
46
+
47
+ cmd = 'echo "git remotes not implemented yet"' if location[:scm]==:git
48
+ cmd = %[svn co #{e_sh location[:url]}/#{e_sh bundle_name}.tmbundle #{e_sh install_bundles_path}/#{e_sh bundle_name}.tmbundle 2>&1] if location[:scm]==:svn
49
+ res = %x{#{cmd}}
50
+
51
+ puts cmd, res.gsub(/^/,' ') #if verbose # TODO: Implement a verbose mode to toggle showing all the gory details
52
+
53
+ installed=true and break if res =~ /Checked out revision|Initialized empty Git repository/
54
+ end
55
+ abort 'Not Installed' unless installed # TODO: Offer suggestions for alternate bundles with similar names. Maybe let them choose
56
+
57
+ puts "Reloading Bundles..."
58
+ reload_textmate!
59
+ puts "Done."
60
+ end
61
+
62
+ desc "uninstall NAME", "uninstall a bundle"
63
+ def uninstall(bundle_name)
64
+ puts "Removing bundle..."
65
+ # FIXME: Move deleted bundles to the trash instead of rm_rf-ing them?
66
+ # When moving to the trash, maybe move the bundle into a trash/disabled_bundles subfolder
67
+ # named as the bundles_path key. Just in case there are multiple versions of
68
+ # the same bundle in multiple bundle paths
69
+ local_bundle_paths.each do |name,bundles_path|
70
+ FileUtils.rm_rf("#{bundles_path}/#{bundle_name}.tmbundle")
71
+ end
72
+ puts "Reloading bundles..."
73
+ reload_textmate!
74
+ puts "Done."
75
+ end
76
+
77
+ private
78
+ def reload_textmate!
79
+ %x[osascript -e 'tell app "TextMate" to reload bundles']
80
+ end
81
+
82
+ def remote_bundle_locations
83
+ { :'Marcomates Trunk' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Bundles'},
84
+ :'Marcomates Review' => {:scm => :svn, :url => 'http://macromates.com/svn/Bundles/trunk/Review/Bundles'},
85
+
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
+ # :'Bunch of Git Bundles' => {:scm => :git, :url => 'git://NotImplemented'},
88
+
89
+ # TODO: Add GitHub support as a remote_bundle_location
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'},
92
+ }
93
+ # TODO: Add some way to add more custom remotes
94
+ end
95
+
96
+ def local_bundle_paths
97
+ { :Application => '/Applications/TextMate.app/Contents/SharedSupport/Bundles',
98
+ :User => "#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles",
99
+ :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',
102
+ }
103
+ end
104
+
105
+ def install_bundles_path
106
+ #TODO: Add some way for the user to configure where they'd prefer to install bundles
107
+ local_bundle_paths[:'User Pristine']
108
+ end
109
+
110
+ # Copied from http://macromates.com/svn/Bundles/trunk/Support/lib/escape.rb
111
+ # escape text to make it useable in a shell script as one “word” (string)
112
+ def e_sh(str)
113
+ str.to_s.gsub(/(?=[^a-zA-Z0-9_.\/\-\x7F-\xFF\n])/, '\\').gsub(/\n/, "'\n'").sub(/^$/, "''")
114
+ end
115
+
116
+ end
117
+
118
+ # TODO: create a "monument to personal cleverness" by class-izing everything?
119
+ # class TextMateBundle
120
+ # def self.find_local(bundle_name)
121
+ #
122
+ # end
123
+ #
124
+ # def self.find_remote(bundle_name)
125
+ #
126
+ # end
127
+ # attr_reader :name
128
+ # attr_reader :location
129
+ # attr_reader :scm
130
+ # def initialize(name, location, scm)
131
+ # @name = name
132
+ # @location = location
133
+ # @scm = scm
134
+ # end
135
+ #
136
+ # def install!
137
+ #
138
+ # end
139
+ #
140
+ # def uninstall!
141
+ #
142
+ # end
143
+ #
144
+ #
145
+ # def installed?
146
+ # # List all the installed versions, and where they're at
147
+ # end
148
+ #
149
+ # # TODO: dirty? method to show if there are any deltas
150
+ # end
151
+
152
+ TextmateInstaller.start
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cypher-textmate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Yehuda Katz
8
+ autorequire: textmate
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-19 00:00:00 -07:00
13
+ default_executable: textmate
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thor
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.9.1
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
+ - lib
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.0.1
61
+ signing_key:
62
+ specification_version: 2
63
+ summary: Command-line textmate package manager
64
+ test_files: []
65
+