From 8bcb9c8e4a945e73cec7648d11fbdefa7ac42122 Mon Sep 17 00:00:00 2001 From: Markus Prinz Date: Tue, 20 May 2008 18:51:27 +0200 Subject: [PATCH] Remove lib/class_cli.rb, as it is no longer needed --- lib/class_cli.rb | 77 ------------------------------------------------ textmate.gemspec | 2 +- 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 lib/class_cli.rb diff --git a/lib/class_cli.rb b/lib/class_cli.rb deleted file mode 100644 index 0c70507..0000000 --- a/lib/class_cli.rb +++ /dev/null @@ -1,77 +0,0 @@ -require "getopt/long" - -module Hermes - def self.extended(klass) - klass.class_eval <<-RUBY, "class_cli.rb", 6 - - def self.method_added(meth) - return if !public_instance_methods.include?(meth.to_s) || !@@usage - @@descriptions = defined?(@@descriptions) ? @@descriptions : [] - @@usages = defined?(@@usages) ? @@usages : [] - @@opts = defined?(@@opts) ? @@opts : [] - @@descriptions << [meth.to_s, @@desc] - @@usages << [meth.to_s, @@usage] - if defined?(@@method_options) && @@method_options - @@opts << [meth.to_s, @@method_options] - end - @@usage, @@desc, @@method_options = nil - end - - def self.desc(usage, description) - @@usage, @@desc = usage, description - end - - def self.method_options(opts) - @@method_options = opts - end - - def self.start - meth = ARGV.shift - params = ARGV.inject([]) do |accum, arg| - accum << ARGV.delete(arg) unless arg =~ /^\-/ - accum - end - if @@opts.assoc(meth) - opts = @@opts.assoc(meth).last.map {|opt, val| [opt, val == true ? Getopt::BOOLEAN : Getopt.const_get(val)].flatten} - options = Getopt::Long.getopts(*opts) - params << options - end - new(meth, params) - end - - def initialize(op, params) - send(op.to_sym, *params) if public_methods.include?(op) - end - - private - def format_opts(opts) - return "" unless opts - opts.map do |opt, val| - if val == true || val == "BOOLEAN" - opt - elsif val == "REQUIRED" - opt + "=" + opt.gsub(/\-/, "").upcase - elsif val == "OPTIONAL" - "[" + opt + "=" + opt.gsub(/\-/, "").upcase + "]" - end - end.join(" ") - end - - public - desc "help", "show this screen" - def help - puts "Options" - puts "-------" - max_usage = @@usages.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last.size - max_opts = @@opts.empty? ? 0 : format_opts(@@opts.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last).size - max_desc = @@descriptions.max {|x,y| x.last.to_s.size <=> y.last.to_s.size}.last.size - @@usages.each do |meth, usage| - format = "%-" + (max_usage + max_opts + 4).to_s + "s" - print format % (@@usages.assoc(meth)[1] + (@@opts.assoc(meth) ? " " + format_opts(@@opts.assoc(meth)[1]) : "")) - # print format % (@@usages.assoc(meth)[1] + @@opts.assoc(meth) ? format_opts(@@opts.assoc(meth)[1]) : "")) - puts @@descriptions.assoc(meth)[1] - end - end - RUBY - end -end diff --git a/textmate.gemspec b/textmate.gemspec index bc305ca..da3f430 100644 --- a/textmate.gemspec +++ b/textmate.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.email = %q{wycats@gmail.com} s.executables = ["textmate"] s.extra_rdoc_files = ["README.markdown", "LICENSE"] - s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/textmate", "lib/class_cli.rb"] + s.files = ["LICENSE", "README.markdown", "Rakefile", "bin/textmate"] s.has_rdoc = true s.homepage = %q{http://yehudakatz.com} s.require_paths = ["lib"]