textmate 0.9.0

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 (6) hide show
  1. data/LICENSE +20 -0
  2. data/README.markdown +31 -0
  3. data/Rakefile +38 -0
  4. data/bin/textmate +71 -0
  5. data/lib/class_cli.rb +77 -0
  6. metadata +66 -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 list [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 installed`
19
+ --------------------
20
+
21
+ List all of the bundles that are installed on the local system.
22
+
23
+ `textmate install NAME`
24
+ -----------------------
25
+
26
+ Installs a bundle from the remote repository.
27
+
28
+ `textmate uninstall NAME`
29
+ -------------------------
30
+
31
+ Uninstalls a bundle from the local repository.
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+
4
+ GEM = "textmate"
5
+ GEM_VERSION = "0.9.0"
6
+ AUTHOR = "Yehuda Katz"
7
+ EMAIL = "wycats@gmail.com"
8
+ HOMEPAGE = "http://yehudakatz.com"
9
+ SUMMARY = "Command-line textmate package manager"
10
+
11
+ spec = Gem::Specification.new do |s|
12
+ s.name = GEM
13
+ s.version = GEM_VERSION
14
+ s.platform = Gem::Platform::RUBY
15
+ s.has_rdoc = true
16
+ s.extra_rdoc_files = ["README.markdown", "LICENSE"]
17
+ s.summary = SUMMARY
18
+ s.description = s.summary
19
+ s.author = AUTHOR
20
+ s.email = EMAIL
21
+ s.homepage = HOMEPAGE
22
+
23
+ s.add_dependency "thor", ">= 0.9.1"
24
+
25
+ s.require_path = 'lib'
26
+ s.autorequire = GEM
27
+ s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{bin,lib,specs}/**/*")
28
+ s.bindir = "bin"
29
+ s.executables = %w( textmate )
30
+ end
31
+
32
+ Rake::GemPackageTask.new(spec) do |pkg|
33
+ pkg.gem_spec = spec
34
+ end
35
+
36
+ task :install => [:package] do
37
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION} --no-rdoc --no-ri}
38
+ end
data/bin/textmate ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "fileutils"
4
+ require "thor"
5
+
6
+ class TextmateInstaller < Thor
7
+
8
+ desc "list [SEARCH]", "Lists all the matching remote bundles"
9
+ def list(limit = "")
10
+ limit = Regexp.new(".*#{limit}.*", "i")
11
+ puts "\nBundles\n-------\n"
12
+ results = %x[svn list #{svn_for("bundles")}]
13
+ puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n")
14
+ puts "\nReview\n------\n"
15
+ results = %x[svn list #{svn_for("review")}]
16
+ puts results.map {|x| x.split(".")[0]}.select {|x| x =~ limit}.join("\n")
17
+ end
18
+
19
+ desc "installed", "lists all the bundles installed locally"
20
+ def installed()
21
+ puts "\nSystem\n------\n"
22
+ puts Dir["/Library/Application Support/TextMate/Bundles/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
23
+ puts "\nUser\n----\n"
24
+ puts Dir["#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles/*.tmbundle"].map {|x| x.split("/").last.split(".").first}.join("\n")
25
+ end
26
+
27
+ desc "install NAME", "install a bundle"
28
+ def install(name)
29
+ FileUtils.mkdir_p "/Library/Application Support/TextMate/Bundles"
30
+ quoted_name = name.gsub(" ", "\\ ")
31
+ type = where(name)
32
+ puts "Checking out #{name}..."
33
+ res = %x[svn co #{svn_for(type)}/#{quoted_name}.tmbundle /Library/Application\\ Support/TextMate/Bundles/#{quoted_name}.tmbundle]
34
+ puts "Reloading Bundles..."
35
+ reload_textmate!
36
+ puts "Done."
37
+ end
38
+
39
+ desc "uninstall NAME", "uninstall a bundle"
40
+ def uninstall(name)
41
+ puts "Removing bundle..."
42
+ FileUtils.rm_rf("/Library/Application Support/TextMate/Bundles/#{name}.tmbundle")
43
+ FileUtils.rm_rf("#{ENV["HOME"]}/Library/Application Support/TextMate/Bundles/#{name}.tmbundle")
44
+ puts "Reloading bundles..."
45
+ reload_textmate!
46
+ puts "Done."
47
+ end
48
+
49
+ private
50
+ def reload_textmate!
51
+ %x[osascript -e 'tell app "TextMate" to reload bundles']
52
+ end
53
+
54
+ def where(bundle)
55
+ bundles = %x[svn list #{svn_for("bundles")}].map {|x| x.split(".")[0]}
56
+ review = %x[svn list #{svn_for("review")}].map {|x| x.split(".")[0]}
57
+ return "bundles" if bundles.include?(bundle)
58
+ return "review" if review.include?(bundle)
59
+ end
60
+
61
+ def svn_for(type)
62
+ if type =~ /bundles/i
63
+ "http://macromates.com/svn/Bundles/trunk/Bundles"
64
+ elsif type =~ /review/i
65
+ "http://macromates.com/svn/Bundles/trunk/Review/Bundles"
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ TextmateInstaller.start
data/lib/class_cli.rb ADDED
@@ -0,0 +1,77 @@
1
+ require "getopt/long"
2
+
3
+ module Hermes
4
+ def self.extended(klass)
5
+ klass.class_eval <<-RUBY, "class_cli.rb", 6
6
+
7
+ def self.method_added(meth)
8
+ return if !public_instance_methods.include?(meth.to_s) || !@@usage
9
+ @@descriptions = defined?(@@descriptions) ? @@descriptions : []
10
+ @@usages = defined?(@@usages) ? @@usages : []
11
+ @@opts = defined?(@@opts) ? @@opts : []
12
+ @@descriptions << [meth.to_s, @@desc]
13
+ @@usages << [meth.to_s, @@usage]
14
+ if defined?(@@method_options) && @@method_options
15
+ @@opts << [meth.to_s, @@method_options]
16
+ end
17
+ @@usage, @@desc, @@method_options = nil
18
+ end
19
+
20
+ def self.desc(usage, description)
21
+ @@usage, @@desc = usage, description
22
+ end
23
+
24
+ def self.method_options(opts)
25
+ @@method_options = opts
26
+ end
27
+
28
+ def self.start
29
+ meth = ARGV.shift
30
+ params = ARGV.inject([]) do |accum, arg|
31
+ accum << ARGV.delete(arg) unless arg =~ /^\-/
32
+ accum
33
+ end
34
+ if @@opts.assoc(meth)
35
+ opts = @@opts.assoc(meth).last.map {|opt, val| [opt, val == true ? Getopt::BOOLEAN : Getopt.const_get(val)].flatten}
36
+ options = Getopt::Long.getopts(*opts)
37
+ params << options
38
+ end
39
+ new(meth, params)
40
+ end
41
+
42
+ def initialize(op, params)
43
+ send(op.to_sym, *params) if public_methods.include?(op)
44
+ end
45
+
46
+ private
47
+ def format_opts(opts)
48
+ return "" unless opts
49
+ opts.map do |opt, val|
50
+ if val == true || val == "BOOLEAN"
51
+ opt
52
+ elsif val == "REQUIRED"
53
+ opt + "=" + opt.gsub(/\-/, "").upcase
54
+ elsif val == "OPTIONAL"
55
+ "[" + opt + "=" + opt.gsub(/\-/, "").upcase + "]"
56
+ end
57
+ end.join(" ")
58
+ end
59
+
60
+ public
61
+ desc "help", "show this screen"
62
+ def help
63
+ puts "Options"
64
+ puts "-------"
65
+ max_usage = @@usages.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last.size
66
+ max_opts = @@opts.empty? ? 0 : format_opts(@@opts.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last).size
67
+ max_desc = @@descriptions.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last.size
68
+ @@usages.each do |meth, usage|
69
+ format = "%-" + (max_usage + max_opts + 4).to_s + "s"
70
+ print format % (@@usages.assoc(meth)[1] + (@@opts.assoc(meth) ? " " + format_opts(@@opts.assoc(meth)[1]) : ""))
71
+ # print format % (@@usages.assoc(meth)[1] + @@opts.assoc(meth) ? format_opts(@@opts.assoc(meth)[1]) : ""))
72
+ puts @@descriptions.assoc(meth)[1]
73
+ end
74
+ end
75
+ RUBY
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: textmate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Yehuda Katz
8
+ autorequire: textmate
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-12 00:00:00 -07:00
13
+ default_executable:
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
+ - lib/class_cli.rb
39
+ has_rdoc: true
40
+ homepage: http://yehudakatz.com
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.0.1
62
+ signing_key:
63
+ specification_version: 2
64
+ summary: Command-line textmate package manager
65
+ test_files: []
66
+