[DRE-commits] [SCM] bundler.git branch, master, updated. debian/1.2.1-1-1-gc4c26fa
Christian Hofstaedtler
christian at hofstaedtler.name
Mon Nov 12 01:17:15 UTC 2012
The following commit has been merged in the master branch:
commit c4c26fad371b0ba26343e5e4d39039236105becf
Author: Christian Hofstaedtler <christian at hofstaedtler.name>
Date: Mon Nov 12 01:53:37 2012 +0100
Remove vendored thor, net-http-persistent
diff --git a/debian/changelog b/debian/changelog
index a099554..5be1045 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+bundler (1.2.1-2) unstable; urgency=low
+
+ * Remove vendored thor, net-http-persistent.
+
+ -- Christian Hofstaedtler <christian at hofstaedtler.name> Mon, 12 Nov 2012 01:53:12 +0100
+
bundler (1.2.1-1) unstable; urgency=low
* New upstream release.
diff --git a/debian/control b/debian/control
index 8d0f109..11327a1 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: optional
Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers at lists.alioth.debian.org>
Uploaders: Christian Hofstaedtler <christian at hofstaedtler.name>
DM-Upload-Allowed: yes
-Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.3.0~), ruby-ronn, ruby-rspec, rake
+Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.3.0~), ruby-ronn, ruby-rspec, ruby-thor, rake
Standards-Version: 3.9.3
Vcs-Git: git://git.debian.org/pkg-ruby-extras/bundler.git
Vcs-Browser: http://git.debian.org/?p=pkg-ruby-extras/bundler.git;a=summary
@@ -14,7 +14,7 @@ XS-Ruby-Versions: all
Package: bundler
Architecture: all
XB-Ruby-Versions: ${ruby:Versions}
-Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter
+Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter, ruby-thor (>= 0.15.3-1), ruby-net-http-persistent (>= 2.7-1)
Recommends: sudo, ruby-dev, build-essential, rubygems-integration, less
Description: Manage Ruby application dependencies
Bundler manages a Ruby application's dependencies through its entire
diff --git a/debian/gbp.conf b/debian/gbp.conf
new file mode 100644
index 0000000..1d204d6
--- /dev/null
+++ b/debian/gbp.conf
@@ -0,0 +1,6 @@
+[DEFAULT]
+pristine-tar = True
+
+[git-import-orig]
+filter = lib/bundler/vendor/*
+
diff --git a/debian/rules b/debian/rules
index f5fc425..0095a78 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,5 +19,6 @@ override_dh_auto_build:
cd man && ronn -r *.ronn
override_dh_auto_clean:
+ rm -rf lib/bundler/vendor
dh_auto_clean
rm -f man/*.1 man/*.5
diff --git a/debian/source/local-options b/debian/source/local-options
new file mode 100644
index 0000000..9cdfca9
--- /dev/null
+++ b/debian/source/local-options
@@ -0,0 +1,2 @@
+unapply-patches
+abort-on-upstream-changes
diff --git a/lib/bundler/vendor/net/http/faster.rb b/lib/bundler/vendor/net/http/faster.rb
deleted file mode 100644
index e5e0908..0000000
--- a/lib/bundler/vendor/net/http/faster.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require 'net/protocol'
-
-##
-# Aaron Patterson's monkeypatch (accepted into 1.9.1) to fix Net::HTTP's speed
-# problems.
-#
-# http://gist.github.com/251244
-
-class Net::BufferedIO #:nodoc:
- alias :old_rbuf_fill :rbuf_fill
-
- def rbuf_fill
- if @io.respond_to? :read_nonblock then
- begin
- @rbuf << @io.read_nonblock(65536)
- rescue Errno::EWOULDBLOCK, Errno::EAGAIN => e
- retry if IO.select [@io], nil, nil, @read_timeout
- raise Timeout::Error, e.message
- end
- else # SSL sockets do not have read_nonblock
- timeout @read_timeout do
- @rbuf << @io.sysread(65536)
- end
- end
- end
-end if RUBY_VERSION < '1.9'
-
diff --git a/lib/bundler/vendor/net/http/persistent.rb b/lib/bundler/vendor/net/http/persistent.rb
deleted file mode 100644
index 3eefc2e..0000000
--- a/lib/bundler/vendor/net/http/persistent.rb
+++ /dev/null
@@ -1,468 +0,0 @@
-require 'net/http'
-require 'net/http/faster'
-require 'uri'
-require 'cgi' # for escaping
-
-##
-# Persistent connections for Net::HTTP
-#
-# Net::HTTP::Persistent maintains persistent connections across all the
-# servers you wish to talk to. For each host:port you communicate with a
-# single persistent connection is created.
-#
-# Multiple Net::HTTP::Persistent objects will share the same set of
-# connections.
-#
-# For each thread you start a new connection will be created. A
-# Net::HTTP::Persistent connection will not be shared across threads.
-#
-# You can shut down the HTTP connections when done by calling #shutdown. You
-# should name your Net::HTTP::Persistent object if you intend to call this
-# method.
-#
-# Example:
-#
-# uri = URI.parse 'http://example.com/awesome/web/service'
-# http = Net::HTTP::Persistent.new
-# stuff = http.request uri # performs a GET
-#
-# # perform a POST
-# post_uri = uri + 'create'
-# post = Net::HTTP::Post.new post_uri.path
-# post.set_form_data 'some' => 'cool data'
-# http.request post_uri, post # URI is always required
-
-class Net::HTTP::Persistent
-
- ##
- # The version of Net::HTTP::Persistent use are using
-
- VERSION = '1.4.1'
-
- ##
- # Error class for errors raised by Net::HTTP::Persistent. Various
- # SystemCallErrors are re-raised with a human-readable message under this
- # class.
-
- class Error < StandardError; end
-
- ##
- # This client's OpenSSL::X509::Certificate
-
- attr_accessor :certificate
-
- ##
- # An SSL certificate authority. Setting this will set verify_mode to
- # VERIFY_PEER.
-
- attr_accessor :ca_file
-
- ##
- # Where this instance's connections live in the thread local variables
-
- attr_reader :connection_key # :nodoc:
-
- ##
- # Sends debug_output to this IO via Net::HTTP#set_debug_output.
- #
- # Never use this method in production code, it causes a serious security
- # hole.
-
- attr_accessor :debug_output
-
- ##
- # Headers that are added to every request
-
- attr_reader :headers
-
- ##
- # Maps host:port to an HTTP version. This allows us to enable version
- # specific features.
-
- attr_reader :http_versions
-
- ##
- # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
- # HTTP/1.1 servers.
- #
- # This may not work correctly for HTTP/1.0 servers
- #
- # This method may be removed in a future version as RFC 2616 does not
- # require this header.
-
- attr_accessor :keep_alive
-
- ##
- # A name for this connection. Allows you to keep your connections apart
- # from everybody else's.
-
- attr_reader :name
-
- ##
- # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
-
- attr_accessor :open_timeout
-
- ##
- # This client's SSL private key
-
- attr_accessor :private_key
-
- ##
- # The URL through which requests will be proxied
-
- attr_reader :proxy_uri
-
- ##
- # Seconds to wait until reading one block. See Net::HTTP#read_timeout
-
- attr_accessor :read_timeout
-
- ##
- # Where this instance's request counts live in the thread local variables
-
- attr_reader :request_key # :nodoc:
-
- ##
- # SSL verification callback. Used when ca_file is set.
-
- attr_accessor :verify_callback
-
- ##
- # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_NONE which ignores
- # certificate problems.
- #
- # You can use +verify_mode+ to override any default values.
-
- attr_accessor :verify_mode
-
- ##
- # Creates a new Net::HTTP::Persistent.
- #
- # Set +name+ to keep your connections apart from everybody else's. Not
- # required currently, but highly recommended. Your library name should be
- # good enough. This parameter will be required in a future version.
- #
- # +proxy+ may be set to a URI::HTTP or :ENV to pick up proxy options from
- # the environment. See proxy_from_env for details.
- #
- # In order to use a URI for the proxy you'll need to do some extra work
- # beyond URI.parse:
- #
- # proxy = URI.parse 'http://proxy.example'
- # proxy.user = 'AzureDiamond'
- # proxy.password = 'hunter2'
-
- def initialize name = nil, proxy = nil
- @name = name
-
- @proxy_uri = case proxy
- when :ENV then proxy_from_env
- when URI::HTTP then proxy
- when nil then # ignore
- else raise ArgumentError, 'proxy must be :ENV or a URI::HTTP'
- end
-
- if @proxy_uri then
- @proxy_args = [
- @proxy_uri.host,
- @proxy_uri.port,
- @proxy_uri.user,
- @proxy_uri.password,
- ]
-
- @proxy_connection_id = [nil, *@proxy_args].join ':'
- end
-
- @debug_output = nil
- @headers = {}
- @http_versions = {}
- @keep_alive = 30
- @open_timeout = nil
- @read_timeout = nil
-
- key = ['net_http_persistent', name, 'connections'].compact.join '_'
- @connection_key = key.intern
- key = ['net_http_persistent', name, 'requests'].compact.join '_'
- @request_key = key.intern
-
- @certificate = nil
- @ca_file = nil
- @private_key = nil
- @verify_callback = nil
- @verify_mode = nil
- end
-
- ##
- # Creates a new connection for +uri+
-
- def connection_for uri
- Thread.current[@connection_key] ||= {}
- Thread.current[@request_key] ||= Hash.new 0
-
- connections = Thread.current[@connection_key]
-
- net_http_args = [uri.host, uri.port]
- connection_id = net_http_args.join ':'
-
- if @proxy_uri then
- connection_id << @proxy_connection_id
- net_http_args.concat @proxy_args
- end
-
- unless connection = connections[connection_id] then
- connections[connection_id] = Net::HTTP.new(*net_http_args)
- connection = connections[connection_id]
- ssl connection if uri.scheme == 'https'
- end
-
- unless connection.started? then
- connection.set_debug_output @debug_output if @debug_output
- connection.open_timeout = @open_timeout if @open_timeout
- connection.read_timeout = @read_timeout if @read_timeout
-
- connection.start
- end
-
- connection
- rescue Errno::ECONNREFUSED
- raise Error, "connection refused: #{connection.address}:#{connection.port}"
- rescue Errno::EHOSTDOWN
- raise Error, "host down: #{connection.address}:#{connection.port}"
- end
-
- ##
- # Returns an error message containing the number of requests performed on
- # this connection
-
- def error_message connection
- requests =
- Thread.current[@request_key][connection.object_id]
-
- "after #{requests} requests on #{connection.object_id}"
- end
-
- ##
- # URI::escape wrapper
-
- def escape str
- CGI.escape str if str
- end
-
- ##
- # Finishes the Net::HTTP +connection+
-
- def finish connection
- Thread.current[@request_key].delete connection.object_id
-
- connection.finish
- rescue IOError
- end
-
- ##
- # Returns the HTTP protocol version for +uri+
-
- def http_version uri
- @http_versions["#{uri.host}:#{uri.port}"]
- end
-
- ##
- # Is +req+ idempotent according to RFC 2616?
-
- def idempotent? req
- case req
- when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
- Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
- true
- end
- end
-
- ##
- # Adds "http://" to the String +uri+ if it is missing.
-
- def normalize_uri uri
- (uri =~ /^https?:/) ? uri : "http://#{uri}"
- end
-
- ##
- # Creates a URI for an HTTP proxy server from ENV variables.
- #
- # If +HTTP_PROXY+ is set a proxy will be returned.
- #
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the URI is given the
- # indicated user and password unless HTTP_PROXY contains either of these in
- # the URI.
- #
- # For Windows users lowercase ENV variables are preferred over uppercase ENV
- # variables.
-
- def proxy_from_env
- env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
-
- return nil if env_proxy.nil? or env_proxy.empty?
-
- uri = URI.parse normalize_uri env_proxy
-
- unless uri.user or uri.password then
- uri.user = escape ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']
- uri.password = escape ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS']
- end
-
- uri
- end
-
- ##
- # Finishes then restarts the Net::HTTP +connection+
-
- def reset connection
- Thread.current[@request_key].delete connection.object_id
-
- finish connection
-
- connection.start
- rescue Errno::ECONNREFUSED
- raise Error, "connection refused: #{connection.address}:#{connection.port}"
- rescue Errno::EHOSTDOWN
- raise Error, "host down: #{connection.address}:#{connection.port}"
- end
-
- ##
- # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
- # against +uri+.
- #
- # If a block is passed #request behaves like Net::HTTP#request (the body of
- # the response will not have been read).
- #
- # +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list).
- #
- # If there is an error and the request is idempontent according to RFC 2616
- # it will be retried automatically.
-
- def request uri, req = nil, &block
- retried = false
- bad_response = false
-
- req = Net::HTTP::Get.new uri.request_uri unless req
-
- headers.each do |pair|
- req.add_field(*pair)
- end
-
- if uri.user or uri.password
- req.basic_auth uri.user, uri.password
- end
-
- req.add_field 'Connection', 'keep-alive'
- req.add_field 'Keep-Alive', @keep_alive
-
- connection = connection_for uri
- connection_id = connection.object_id
-
- begin
- Thread.current[@request_key][connection_id] += 1
- response = connection.request req, &block
-
- rescue Net::HTTPBadResponse => e
- message = error_message connection
-
- finish connection
-
- raise Error, "too many bad responses #{message}" if
- bad_response or not idempotent? req
-
- bad_response = true
- retry
- rescue IOError, EOFError, Timeout::Error,
- Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e
-
- if retried or not idempotent? req
- due_to = "(due to #{e.message} - #{e.class})"
- message = error_message connection
-
- finish connection
-
- raise Error, "too many connection resets #{due_to} #{message}"
- end
-
- reset connection
-
- retried = true
- retry
- end
-
- @http_versions["#{uri.host}:#{uri.port}"] ||= response.http_version
-
- response
- end
-
- ##
- # Shuts down all connections for +thread+.
- #
- # Uses the current thread by default.
- #
- # If you've used Net::HTTP::Persistent across multiple threads you should
- # call this in each thread when you're done making HTTP requests.
- #
- # *NOTE*: Calling shutdown for another thread can be dangerous!
- #
- # If the thread is still using the connection it may cause an error! It is
- # best to call #shutdown in the thread at the appropriate time instead!
-
- def shutdown thread = Thread.current
- connections = thread[@connection_key]
-
- connections.each do |_, connection|
- begin
- connection.finish
- rescue IOError
- end
- end if connections
-
- thread[@connection_key] = nil
- thread[@request_key] = nil
- end
-
- ##
- # Shuts down all connections in all threads
- #
- # *NOTE*: THIS METHOD IS VERY DANGEROUS!
- #
- # Do not call this method if other threads are still using their
- # connections! Call #shutdown at the appropriate time instead!
- #
- # Use this method only as a last resort!
-
- def shutdown_in_all_threads
- Thread.list.each do |thread|
- shutdown thread
- end
-
- nil
- end
-
- ##
- # Enables SSL on +connection+
-
- def ssl connection
- require 'net/https'
- connection.use_ssl = true
-
- # suppress warning but allow override
- connection.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_mode
-
- if @ca_file then
- connection.ca_file = @ca_file
- connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
- connection.verify_callback = @verify_callback if @verify_callback
- end
-
- if @certificate and @private_key then
- connection.cert = @certificate
- connection.key = @private_key
- end
-
- connection.verify_mode = @verify_mode if @verify_mode
- end
-
-end
-
diff --git a/lib/bundler/vendor/thor.rb b/lib/bundler/vendor/thor.rb
deleted file mode 100644
index 225c085..0000000
--- a/lib/bundler/vendor/thor.rb
+++ /dev/null
@@ -1,379 +0,0 @@
-require 'thor/base'
-
-class Thor
- class << self
- # Sets the default task when thor is executed without an explicit task to be called.
- #
- # ==== Parameters
- # meth<Symbol>:: name of the default task
- #
- def default_task(meth=nil)
- case meth
- when :none
- @default_task = 'help'
- when nil
- @default_task ||= from_superclass(:default_task, 'help')
- else
- @default_task = meth.to_s
- end
- end
-
- # Registers another Thor subclass as a command.
- #
- # ==== Parameters
- # klass<Class>:: Thor subclass to register
- # command<String>:: Subcommand name to use
- # usage<String>:: Short usage for the subcommand
- # description<String>:: Description for the subcommand
- def register(klass, subcommand_name, usage, description, options={})
- if klass <= Thor::Group
- desc usage, description, options
- define_method(subcommand_name) { |*args| invoke(klass, args) }
- else
- desc usage, description, options
- subcommand subcommand_name, klass
- end
- end
-
- # Defines the usage and the description of the next task.
- #
- # ==== Parameters
- # usage<String>
- # description<String>
- # options<String>
- #
- def desc(usage, description, options={})
- if options[:for]
- task = find_and_refresh_task(options[:for])
- task.usage = usage if usage
- task.description = description if description
- else
- @usage, @desc, @hide = usage, description, options[:hide] || false
- end
- end
-
- # Defines the long description of the next task.
- #
- # ==== Parameters
- # long description<String>
- #
- def long_desc(long_description, options={})
- if options[:for]
- task = find_and_refresh_task(options[:for])
- task.long_description = long_description if long_description
- else
- @long_desc = long_description
- end
- end
-
- # Maps an input to a task. If you define:
- #
- # map "-T" => "list"
- #
- # Running:
- #
- # thor -T
- #
- # Will invoke the list task.
- #
- # ==== Parameters
- # Hash[String|Array => Symbol]:: Maps the string or the strings in the array to the given task.
- #
- def map(mappings=nil)
- @map ||= from_superclass(:map, {})
-
- if mappings
- mappings.each do |key, value|
- if key.respond_to?(:each)
- key.each {|subkey| @map[subkey] = value}
- else
- @map[key] = value
- end
- end
- end
-
- @map
- end
-
- # Declares the options for the next task to be declared.
- #
- # ==== Parameters
- # Hash[Symbol => Object]:: The hash key is the name of the option and the value
- # is the type of the option. Can be :string, :array, :hash, :boolean, :numeric
- # or :required (string). If you give a value, the type of the value is used.
- #
- def method_options(options=nil)
- @method_options ||= {}
- build_options(options, @method_options) if options
- @method_options
- end
-
- alias options method_options
-
- # Adds an option to the set of method options. If :for is given as option,
- # it allows you to change the options from a previous defined task.
- #
- # def previous_task
- # # magic
- # end
- #
- # method_option :foo => :bar, :for => :previous_task
- #
- # def next_task
- # # magic
- # end
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc - Description for the argument.
- # :required - If the argument is required or not.
- # :default - Default value for this argument. It cannot be required and have default values.
- # :aliases - Aliases for this option.
- # :type - The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
- # :banner - String to show on usage notes.
- # :hide - If you want to hide this option from the help.
- #
- def method_option(name, options={})
- scope = if options[:for]
- find_and_refresh_task(options[:for]).options
- else
- method_options
- end
-
- build_option(name, options, scope)
- end
-
- alias option method_option
-
- # Prints help information for the given task.
- #
- # ==== Parameters
- # shell<Thor::Shell>
- # task_name<String>
- #
- def task_help(shell, task_name)
- meth = normalize_task_name(task_name)
- task = all_tasks[meth]
- handle_no_task_error(meth) unless task
-
- shell.say "Usage:"
- shell.say " #{banner(task)}"
- shell.say
- class_options_help(shell, nil => task.options.map { |_, o| o })
- if task.long_description
- shell.say "Description:"
- shell.print_wrapped(task.long_description, :indent => 2)
- else
- shell.say task.description
- end
- end
-
- # Prints help information for this class.
- #
- # ==== Parameters
- # shell<Thor::Shell>
- #
- def help(shell, subcommand = false)
- list = printable_tasks(true, subcommand)
- Thor::Util.thor_classes_in(self).each do |klass|
- list += klass.printable_tasks(false)
- end
- list.sort!{ |a,b| a[0] <=> b[0] }
-
- shell.say "Tasks:"
- shell.print_table(list, :indent => 2, :truncate => true)
- shell.say
- class_options_help(shell)
- end
-
- # Returns tasks ready to be printed.
- def printable_tasks(all = true, subcommand = false)
- (all ? all_tasks : tasks).map do |_, task|
- next if task.hidden?
- item = []
- item << banner(task, false, subcommand)
- item << (task.description ? "# #{task.description.gsub(/\s+/m,' ')}" : "")
- item
- end.compact
- end
-
- def subcommands
- @subcommands ||= from_superclass(:subcommands, [])
- end
-
- def subcommand(subcommand, subcommand_class)
- self.subcommands << subcommand.to_s
- subcommand_class.subcommand_help subcommand
-
- define_method(subcommand) do |*args|
- args, opts = Thor::Arguments.split(args)
- invoke subcommand_class, args, opts
- end
- end
-
- # Extend check unknown options to accept a hash of conditions.
- #
- # === Parameters
- # options<Hash>: A hash containing :only and/or :except keys
- def check_unknown_options!(options={})
- @check_unknown_options ||= Hash.new
- options.each do |key, value|
- if value
- @check_unknown_options[key] = Array(value)
- else
- @check_unknown_options.delete(key)
- end
- end
- @check_unknown_options
- end
-
- # Overwrite check_unknown_options? to take subcommands and options into account.
- def check_unknown_options?(config) #:nodoc:
- options = check_unknown_options
- return false unless options
-
- task = config[:current_task]
- return true unless task
-
- name = task.name
-
- if subcommands.include?(name)
- false
- elsif options[:except]
- !options[:except].include?(name.to_sym)
- elsif options[:only]
- options[:only].include?(name.to_sym)
- else
- true
- end
- end
-
- protected
-
- # The method responsible for dispatching given the args.
- def dispatch(meth, given_args, given_opts, config) #:nodoc:
- meth ||= retrieve_task_name(given_args)
- task = all_tasks[normalize_task_name(meth)]
-
- if task
- args, opts = Thor::Options.split(given_args)
- else
- args, opts = given_args, nil
- task = Thor::DynamicTask.new(meth)
- end
-
- opts = given_opts || opts || []
- config.merge!(:current_task => task, :task_options => task.options)
-
- instance = new(args, opts, config)
- yield instance if block_given?
- args = instance.args
- trailing = args[Range.new(arguments.size, -1)]
- instance.invoke_task(task, trailing || [])
- end
-
- # The banner for this class. You can customize it if you are invoking the
- # thor class by another ways which is not the Thor::Runner. It receives
- # the task that is going to be invoked and a boolean which indicates if
- # the namespace should be displayed as arguments.
- #
- def banner(task, namespace = nil, subcommand = false)
- "#{basename} #{task.formatted_usage(self, $thor_runner, subcommand)}"
- end
-
- def baseclass #:nodoc:
- Thor
- end
-
- def create_task(meth) #:nodoc:
- if @usage && @desc
- base_class = @hide ? Thor::HiddenTask : Thor::Task
- tasks[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
- @usage, @desc, @long_desc, @method_options, @hide = nil
- true
- elsif self.all_tasks[meth] || meth == "method_missing"
- true
- else
- puts "[WARNING] Attempted to create task #{meth.inspect} without usage or description. " <<
- "Call desc if you want this method to be available as task or declare it inside a " <<
- "no_tasks{} block. Invoked from #{caller[1].inspect}."
- false
- end
- end
-
- def initialize_added #:nodoc:
- class_options.merge!(method_options)
- @method_options = nil
- end
-
- # Retrieve the task name from given args.
- def retrieve_task_name(args) #:nodoc:
- meth = args.first.to_s unless args.empty?
- if meth && (map[meth] || meth !~ /^\-/)
- args.shift
- else
- nil
- end
- end
-
- # receives a (possibly nil) task name and returns a name that is in
- # the tasks hash. In addition to normalizing aliases, this logic
- # will determine if a shortened command is an unambiguous prefix of
- # a task or alias.
- #
- # +normalize_task_name+ also converts names like +animal-prison+
- # into +animal_prison+.
- def normalize_task_name(meth) #:nodoc:
- return default_task.to_s.gsub('-', '_') unless meth
-
- possibilities = find_task_possibilities(meth)
- if possibilities.size > 1
- raise ArgumentError, "Ambiguous task #{meth} matches [#{possibilities.join(', ')}]"
- elsif possibilities.size < 1
- meth = meth || default_task
- elsif map[meth]
- meth = map[meth]
- else
- meth = possibilities.first
- end
-
- meth.to_s.gsub('-','_') # treat foo-bar as foo_bar
- end
-
- # this is the logic that takes the task name passed in by the user
- # and determines whether it is an unambiguous prefix of a task or
- # alias name.
- def find_task_possibilities(meth)
- len = meth.to_s.length
- possibilities = all_tasks.merge(map).keys.select { |n| meth == n[0, len] }.sort
- unique_possibilities = possibilities.map { |k| map[k] || k }.uniq
-
- if possibilities.include?(meth)
- [meth]
- elsif unique_possibilities.size == 1
- unique_possibilities
- else
- possibilities
- end
- end
-
- def subcommand_help(cmd)
- desc "help [COMMAND]", "Describe subcommands or one specific subcommand"
- class_eval <<-RUBY
- def help(task = nil, subcommand = true); super; end
- RUBY
- end
- end
-
- include Thor::Base
-
- map HELP_MAPPINGS => :help
-
- desc "help [TASK]", "Describe available tasks or one specific task"
- def help(task = nil, subcommand = false)
- task ? self.class.task_help(shell, task) : self.class.help(shell, subcommand)
- end
-end
diff --git a/lib/bundler/vendor/thor/actions.rb b/lib/bundler/vendor/thor/actions.rb
deleted file mode 100644
index f9002f5..0000000
--- a/lib/bundler/vendor/thor/actions.rb
+++ /dev/null
@@ -1,318 +0,0 @@
-require 'fileutils'
-require 'uri'
-require 'thor/core_ext/file_binary_read'
-require 'thor/actions/create_file'
-require 'thor/actions/create_link'
-require 'thor/actions/directory'
-require 'thor/actions/empty_directory'
-require 'thor/actions/file_manipulation'
-require 'thor/actions/inject_into_file'
-
-class Thor
- module Actions
- attr_accessor :behavior
-
- def self.included(base) #:nodoc:
- base.extend ClassMethods
- end
-
- module ClassMethods
- # Hold source paths for one Thor instance. source_paths_for_search is the
- # method responsible to gather source_paths from this current class,
- # inherited paths and the source root.
- #
- def source_paths
- @_source_paths ||= []
- end
-
- # Stores and return the source root for this class
- def source_root(path=nil)
- @_source_root = path if path
- @_source_root
- end
-
- # Returns the source paths in the following order:
- #
- # 1) This class source paths
- # 2) Source root
- # 3) Parents source paths
- #
- def source_paths_for_search
- paths = []
- paths += self.source_paths
- paths << self.source_root if self.source_root
- paths += from_superclass(:source_paths, [])
- paths
- end
-
- # Add runtime options that help actions execution.
- #
- def add_runtime_options!
- class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
- :desc => "Overwrite files that already exist"
-
- class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
- :desc => "Run but do not make any changes"
-
- class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
- :desc => "Suppress status output"
-
- class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
- :desc => "Skip files that already exist"
- end
- end
-
- # Extends initializer to add more configuration options.
- #
- # ==== Configuration
- # behavior<Symbol>:: The actions default behavior. Can be :invoke or :revoke.
- # It also accepts :force, :skip and :pretend to set the behavior
- # and the respective option.
- #
- # destination_root<String>:: The root directory needed for some actions.
- #
- def initialize(args=[], options={}, config={})
- self.behavior = case config[:behavior].to_s
- when "force", "skip"
- _cleanup_options_and_set(options, config[:behavior])
- :invoke
- when "revoke"
- :revoke
- else
- :invoke
- end
-
- super
- self.destination_root = config[:destination_root]
- end
-
- # Wraps an action object and call it accordingly to the thor class behavior.
- #
- def action(instance) #:nodoc:
- if behavior == :revoke
- instance.revoke!
- else
- instance.invoke!
- end
- end
-
- # Returns the root for this thor class (also aliased as destination root).
- #
- def destination_root
- @destination_stack.last
- end
-
- # Sets the root for this thor class. Relatives path are added to the
- # directory where the script was invoked and expanded.
- #
- def destination_root=(root)
- @destination_stack ||= []
- @destination_stack[0] = File.expand_path(root || '')
- end
-
- # Returns the given path relative to the absolute root (ie, root where
- # the script started).
- #
- def relative_to_original_destination_root(path, remove_dot=true)
- if path =~ /^#{@destination_stack[0]}/
- path = path.gsub(@destination_stack[0], '.')
- path = remove_dot ? (path[2..-1] || '') : path
- end
-
- path
- end
-
- # Holds source paths in instance so they can be manipulated.
- #
- def source_paths
- @source_paths ||= self.class.source_paths_for_search
- end
-
- # Receives a file or directory and search for it in the source paths.
- #
- def find_in_source_paths(file)
- relative_root = relative_to_original_destination_root(destination_root, false)
-
- source_paths.each do |source|
- source_file = File.expand_path(file, File.join(source, relative_root))
- return source_file if File.exists?(source_file)
- end
-
- message = "Could not find #{file.inspect} in any of your source paths. "
-
- unless self.class.source_root
- message << "Please invoke #{self.class.name}.source_root(PATH) with the PATH containing your templates. "
- end
-
- if source_paths.empty?
- message << "Currently you have no source paths."
- else
- message << "Your current source paths are: \n#{source_paths.join("\n")}"
- end
-
- raise Error, message
- end
-
- # Do something in the root or on a provided subfolder. If a relative path
- # is given it's referenced from the current root. The full path is yielded
- # to the block you provide. The path is set back to the previous path when
- # the method exits.
- #
- # ==== Parameters
- # dir<String>:: the directory to move to.
- # config<Hash>:: give :verbose => true to log and use padding.
- #
- def inside(dir='', config={}, &block)
- verbose = config.fetch(:verbose, false)
- pretend = options[:pretend]
-
- say_status :inside, dir, verbose
- shell.padding += 1 if verbose
- @destination_stack.push File.expand_path(dir, destination_root)
-
- # If the directory doesnt exist and we're not pretending
- if !File.exist?(destination_root) && !pretend
- FileUtils.mkdir_p(destination_root)
- end
-
- if pretend
- # In pretend mode, just yield down to the block
- block.arity == 1 ? yield(destination_root) : yield
- else
- FileUtils.cd(destination_root) { block.arity == 1 ? yield(destination_root) : yield }
- end
-
- @destination_stack.pop
- shell.padding -= 1 if verbose
- end
-
- # Goes to the root and execute the given block.
- #
- def in_root
- inside(@destination_stack.first) { yield }
- end
-
- # Loads an external file and execute it in the instance binding.
- #
- # ==== Parameters
- # path<String>:: The path to the file to execute. Can be a web address or
- # a relative path from the source root.
- #
- # ==== Examples
- #
- # apply "http://gist.github.com/103208"
- #
- # apply "recipes/jquery.rb"
- #
- def apply(path, config={})
- verbose = config.fetch(:verbose, true)
- is_uri = path =~ /^https?\:\/\//
- path = find_in_source_paths(path) unless is_uri
-
- say_status :apply, path, verbose
- shell.padding += 1 if verbose
-
- if is_uri
- contents = open(path, "Accept" => "application/x-thor-template") {|io| io.read }
- else
- contents = open(path) {|io| io.read }
- end
-
- instance_eval(contents, path)
- shell.padding -= 1 if verbose
- end
-
- # Executes a command returning the contents of the command.
- #
- # ==== Parameters
- # command<String>:: the command to be executed.
- # config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output. Specify :with
- # to append an executable to command executation.
- #
- # ==== Example
- #
- # inside('vendor') do
- # run('ln -s ~/edge rails')
- # end
- #
- def run(command, config={})
- return unless behavior == :invoke
-
- destination = relative_to_original_destination_root(destination_root, false)
- desc = "#{command} from #{destination.inspect}"
-
- if config[:with]
- desc = "#{File.basename(config[:with].to_s)} #{desc}"
- command = "#{config[:with]} #{command}"
- end
-
- say_status :run, desc, config.fetch(:verbose, true)
-
- unless options[:pretend]
- config[:capture] ? `#{command}` : system("#{command}")
- end
- end
-
- # Executes a ruby script (taking into account WIN32 platform quirks).
- #
- # ==== Parameters
- # command<String>:: the command to be executed.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- def run_ruby_script(command, config={})
- return unless behavior == :invoke
- run command, config.merge(:with => Thor::Util.ruby_command)
- end
-
- # Run a thor command. A hash of options can be given and it's converted to
- # switches.
- #
- # ==== Parameters
- # task<String>:: the task to be invoked
- # args<Array>:: arguments to the task
- # config<Hash>:: give :verbose => false to not log the status, :capture => true to hide to output.
- # Other options are given as parameter to Thor.
- #
- #
- # ==== Examples
- #
- # thor :install, "http://gist.github.com/103208"
- # #=> thor install http://gist.github.com/103208
- #
- # thor :list, :all => true, :substring => 'rails'
- # #=> thor list --all --substring=rails
- #
- def thor(task, *args)
- config = args.last.is_a?(Hash) ? args.pop : {}
- verbose = config.key?(:verbose) ? config.delete(:verbose) : true
- pretend = config.key?(:pretend) ? config.delete(:pretend) : false
- capture = config.key?(:capture) ? config.delete(:capture) : false
-
- args.unshift task
- args.push Thor::Options.to_switches(config)
- command = args.join(' ').strip
-
- run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
- end
-
- protected
-
- # Allow current root to be shared between invocations.
- #
- def _shared_configuration #:nodoc:
- super.merge!(:destination_root => self.destination_root)
- end
-
- def _cleanup_options_and_set(options, key) #:nodoc:
- case options
- when Array
- %w(--force -f --skip -s).each { |i| options.delete(i) }
- options << "--#{key}"
- when Hash
- [:force, :skip, "force", "skip"].each { |i| options.delete(i) }
- options.merge!(key => true)
- end
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/create_file.rb b/lib/bundler/vendor/thor/actions/create_file.rb
deleted file mode 100644
index ed5973a..0000000
--- a/lib/bundler/vendor/thor/actions/create_file.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-require 'thor/actions/empty_directory'
-
-class Thor
- module Actions
-
- # Create a new file relative to the destination root with the given data,
- # which is the return value of a block or a data string.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # data<String|NilClass>:: the data to append to the file.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # create_file "lib/fun_party.rb" do
- # hostname = ask("What is the virtual hostname I should use?")
- # "vhost.name = #{hostname}"
- # end
- #
- # create_file "config/apache.conf", "your apache config"
- #
- def create_file(destination, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- data = args.first
- action CreateFile.new(self, destination, block || data.to_s, config)
- end
- alias :add_file :create_file
-
- # CreateFile is a subset of Template, which instead of rendering a file with
- # ERB, it gets the content from the user.
- #
- class CreateFile < EmptyDirectory #:nodoc:
- attr_reader :data
-
- def initialize(base, destination, data, config={})
- @data = data
- super(base, destination, config)
- end
-
- # Checks if the content of the file at the destination is identical to the rendered result.
- #
- # ==== Returns
- # Boolean:: true if it is identical, false otherwise.
- #
- def identical?
- exists? && File.binread(destination) == render
- end
-
- # Holds the content to be added to the file.
- #
- def render
- @render ||= if data.is_a?(Proc)
- data.call
- else
- data
- end
- end
-
- def invoke!
- invoke_with_conflict_check do
- FileUtils.mkdir_p(File.dirname(destination))
- File.open(destination, 'wb') { |f| f.write render }
- end
- given_destination
- end
-
- protected
-
- # Now on conflict we check if the file is identical or not.
- #
- def on_conflict_behavior(&block)
- if identical?
- say_status :identical, :blue
- else
- options = base.options.merge(config)
- force_or_skip_or_conflict(options[:force], options[:skip], &block)
- end
- end
-
- # If force is true, run the action, otherwise check if it's not being
- # skipped. If both are false, show the file_collision menu, if the menu
- # returns true, force it, otherwise skip.
- #
- def force_or_skip_or_conflict(force, skip, &block)
- if force
- say_status :force, :yellow
- block.call unless pretend?
- elsif skip
- say_status :skip, :yellow
- else
- say_status :conflict, :red
- force_or_skip_or_conflict(force_on_collision?, true, &block)
- end
- end
-
- # Shows the file collision menu to the user and gets the result.
- #
- def force_on_collision?
- base.shell.file_collision(destination){ render }
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/create_link.rb b/lib/bundler/vendor/thor/actions/create_link.rb
deleted file mode 100644
index 864a1e9..0000000
--- a/lib/bundler/vendor/thor/actions/create_link.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'thor/actions/create_file'
-
-class Thor
- module Actions
-
- # Create a new file relative to the destination root from the given source.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # source<String|NilClass>:: the relative path to the source root.
- # config<Hash>:: give :verbose => false to not log the status.
- # :: give :symbolic => false for hard link.
- #
- # ==== Examples
- #
- # create_link "config/apache.conf", "/etc/apache.conf"
- #
- def create_link(destination, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- source = args.first
- action CreateLink.new(self, destination, source, config)
- end
- alias :add_link :create_link
-
- # CreateLink is a subset of CreateFile, which instead of taking a block of
- # data, just takes a source string from the user.
- #
- class CreateLink < CreateFile #:nodoc:
- attr_reader :data
-
- # Checks if the content of the file at the destination is identical to the rendered result.
- #
- # ==== Returns
- # Boolean:: true if it is identical, false otherwise.
- #
- def identical?
- exists? && File.identical?(render, destination)
- end
-
- def invoke!
- invoke_with_conflict_check do
- FileUtils.mkdir_p(File.dirname(destination))
- # Create a symlink by default
- config[:symbolic] = true if config[:symbolic].nil?
- File.unlink(destination) if exists?
- if config[:symbolic]
- File.symlink(render, destination)
- else
- File.link(render, destination)
- end
- end
- given_destination
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/directory.rb b/lib/bundler/vendor/thor/actions/directory.rb
deleted file mode 100644
index f628347..0000000
--- a/lib/bundler/vendor/thor/actions/directory.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-require 'thor/actions/empty_directory'
-
-class Thor
- module Actions
- # Copies recursively the files from source directory to root directory.
- # If any of the files finishes with .tt, it's considered to be a template
- # and is placed in the destination without the extension .tt. If any
- # empty directory is found, it's copied and all .empty_directory files are
- # ignored. If any file name is wrapped within % signs, the text within
- # the % signs will be executed as a method and replaced with the returned
- # value. Let's suppose a doc directory with the following files:
- #
- # doc/
- # components/.empty_directory
- # README
- # rdoc.rb.tt
- # %app_name%.rb
- #
- # When invoked as:
- #
- # directory "doc"
- #
- # It will create a doc directory in the destination with the following
- # files (assuming that the `app_name` method returns the value "blog"):
- #
- # doc/
- # components/
- # README
- # rdoc.rb
- # blog.rb
- #
- # <b>Encoded path note:</b> Since Thor internals use Object#respond_to? to check if it can
- # expand %something%, this `something` should be a public method in the class calling
- # #directory. If a method is private, Thor stack raises PrivateMethodEncodedError.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- # If :recursive => false, does not look for paths recursively.
- #
- # ==== Examples
- #
- # directory "doc"
- # directory "doc", "docs", :recursive => false
- #
- def directory(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- action Directory.new(self, source, destination || source, config, &block)
- end
-
- class Directory < EmptyDirectory #:nodoc:
- attr_reader :source
-
- def initialize(base, source, destination=nil, config={}, &block)
- @source = File.expand_path(base.find_in_source_paths(source.to_s))
- @block = block
- super(base, destination, { :recursive => true }.merge(config))
- end
-
- def invoke!
- base.empty_directory given_destination, config
- execute!
- end
-
- def revoke!
- execute!
- end
-
- protected
-
- def execute!
- lookup = Util.escape_globs(source)
- lookup = config[:recursive] ? File.join(lookup, '**') : lookup
- lookup = File.join(lookup, '{*,.[a-z]*}')
-
- Dir[lookup].sort.each do |file_source|
- next if File.directory?(file_source)
- file_destination = File.join(given_destination, file_source.gsub(source, '.'))
- file_destination.gsub!('/./', '/')
-
- case file_source
- when /\.empty_directory$/
- dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
- next if dirname == given_destination
- base.empty_directory(dirname, config)
- when /\.tt$/
- destination = base.template(file_source, file_destination[0..-4], config, &@block)
- else
- destination = base.copy_file(file_source, file_destination, config, &@block)
- end
- end
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor/actions/empty_directory.rb
deleted file mode 100644
index 93d3e2a..0000000
--- a/lib/bundler/vendor/thor/actions/empty_directory.rb
+++ /dev/null
@@ -1,153 +0,0 @@
-class Thor
- module Actions
-
- # Creates an empty directory.
- #
- # ==== Parameters
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # empty_directory "doc"
- #
- def empty_directory(destination, config={})
- action EmptyDirectory.new(self, destination, config)
- end
-
- # Class which holds create directory logic. This is the base class for
- # other actions like create_file and directory.
- #
- # This implementation is based in Templater actions, created by Jonas Nicklas
- # and Michael S. Klishin under MIT LICENSE.
- #
- class EmptyDirectory #:nodoc:
- attr_reader :base, :destination, :given_destination, :relative_destination, :config
-
- # Initializes given the source and destination.
- #
- # ==== Parameters
- # base<Thor::Base>:: A Thor::Base instance
- # source<String>:: Relative path to the source of this file
- # destination<String>:: Relative path to the destination of this file
- # config<Hash>:: give :verbose => false to not log the status.
- #
- def initialize(base, destination, config={})
- @base, @config = base, { :verbose => true }.merge(config)
- self.destination = destination
- end
-
- # Checks if the destination file already exists.
- #
- # ==== Returns
- # Boolean:: true if the file exists, false otherwise.
- #
- def exists?
- ::File.exists?(destination)
- end
-
- def invoke!
- invoke_with_conflict_check do
- ::FileUtils.mkdir_p(destination)
- end
- end
-
- def revoke!
- say_status :remove, :red
- ::FileUtils.rm_rf(destination) if !pretend? && exists?
- given_destination
- end
-
- protected
-
- # Shortcut for pretend.
- #
- def pretend?
- base.options[:pretend]
- end
-
- # Sets the absolute destination value from a relative destination value.
- # It also stores the given and relative destination. Let's suppose our
- # script is being executed on "dest", it sets the destination root to
- # "dest". The destination, given_destination and relative_destination
- # are related in the following way:
- #
- # inside "bar" do
- # empty_directory "baz"
- # end
- #
- # destination #=> dest/bar/baz
- # relative_destination #=> bar/baz
- # given_destination #=> baz
- #
- def destination=(destination)
- if destination
- @given_destination = convert_encoded_instructions(destination.to_s)
- @destination = ::File.expand_path(@given_destination, base.destination_root)
- @relative_destination = base.relative_to_original_destination_root(@destination)
- end
- end
-
- # Filenames in the encoded form are converted. If you have a file:
- #
- # %file_name%.rb
- #
- # It calls #file_name from the base and replaces %-string with the
- # return value (should be String) of #file_name:
- #
- # user.rb
- #
- # The method referenced by %-string SHOULD be public. Otherwise you
- # get the exception with the corresponding error message.
- #
- def convert_encoded_instructions(filename)
- filename.gsub(/%(.*?)%/) do |initial_string|
- call_public_method($1.strip) or initial_string
- end
- end
-
- # Calls `base`'s public method `sym`.
- # Returns:: result of `base.sym` or `nil` if `sym` wasn't found in
- # `base`
- # Raises:: Thor::PrivateMethodEncodedError if `sym` references
- # a private method.
- def call_public_method(sym)
- if base.respond_to?(sym)
- base.send(sym)
- elsif base.respond_to?(sym, true)
- raise Thor::PrivateMethodEncodedError,
- "Method #{base.class}##{sym} should be public, not private"
- else
- nil
- end
- end
-
- # Receives a hash of options and just execute the block if some
- # conditions are met.
- #
- def invoke_with_conflict_check(&block)
- if exists?
- on_conflict_behavior(&block)
- else
- say_status :create, :green
- block.call unless pretend?
- end
-
- destination
- end
-
- # What to do when the destination file already exists.
- #
- def on_conflict_behavior(&block)
- say_status :exist, :blue
- end
-
- # Shortcut to say_status shell method.
- #
- def say_status(status, color)
- base.shell.say_status status, relative_destination, color if config[:verbose]
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/actions/file_manipulation.rb
deleted file mode 100644
index 908cdb0..0000000
--- a/lib/bundler/vendor/thor/actions/file_manipulation.rb
+++ /dev/null
@@ -1,308 +0,0 @@
-require 'erb'
-require 'open-uri'
-
-class Thor
- module Actions
-
- # Copies the file from the relative source to the relative destination. If
- # the destination is not given it's assumed to be equal to the source.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # copy_file "README", "doc/README"
- #
- # copy_file "doc/README"
- #
- def copy_file(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- source = File.expand_path(find_in_source_paths(source.to_s))
-
- create_file destination, nil, config do
- content = File.binread(source)
- content = block.call(content) if block
- content
- end
- end
-
- # Links the file from the relative source to the relative destination. If
- # the destination is not given it's assumed to be equal to the source.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # link_file "README", "doc/README"
- #
- # link_file "doc/README"
- #
- def link_file(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source
- source = File.expand_path(find_in_source_paths(source.to_s))
-
- create_link destination, source, config
- end
-
- # Gets the content at the given address and places it at the given relative
- # destination. If a block is given instead of destination, the content of
- # the url is yielded and used as location.
- #
- # ==== Parameters
- # source<String>:: the address of the given content.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # get "http://gist.github.com/103208", "doc/README"
- #
- # get "http://gist.github.com/103208" do |content|
- # content.split("\n").first
- # end
- #
- def get(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first
-
- source = File.expand_path(find_in_source_paths(source.to_s)) unless source =~ /^https?\:\/\//
- render = open(source) {|input| input.binmode.read }
-
- destination ||= if block_given?
- block.arity == 1 ? block.call(render) : block.call
- else
- File.basename(source)
- end
-
- create_file destination, render, config
- end
-
- # Gets an ERB template at the relative source, executes it and makes a copy
- # at the relative destination. If the destination is not given it's assumed
- # to be equal to the source removing .tt from the filename.
- #
- # ==== Parameters
- # source<String>:: the relative path to the source root.
- # destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # template "README", "doc/README"
- #
- # template "doc/README"
- #
- def template(source, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- destination = args.first || source.sub(/\.tt$/, '')
-
- source = File.expand_path(find_in_source_paths(source.to_s))
- context = instance_eval('binding')
-
- create_file destination, nil, config do
- content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
- content = block.call(content) if block
- content
- end
- end
-
- # Changes the mode of the given file or directory.
- #
- # ==== Parameters
- # mode<Integer>:: the file mode
- # path<String>:: the name of the file to change mode
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # chmod "script/*", 0755
- #
- def chmod(path, mode, config={})
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
- say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- FileUtils.chmod_R(mode, path) unless options[:pretend]
- end
-
- # Prepend text to a file. Since it depends on insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # data<String>:: the data to prepend to the file, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # prepend_to_file 'config/environments/test.rb', 'config.gem "rspec"'
- #
- # prepend_to_file 'config/environments/test.rb' do
- # 'config.gem "rspec"'
- # end
- #
- def prepend_to_file(path, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config.merge!(:after => /\A/)
- insert_into_file(path, *(args << config), &block)
- end
- alias_method :prepend_file, :prepend_to_file
-
- # Append text to a file. Since it depends on insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # data<String>:: the data to append to the file, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # append_to_file 'config/environments/test.rb', 'config.gem "rspec"'
- #
- # append_to_file 'config/environments/test.rb' do
- # 'config.gem "rspec"'
- # end
- #
- def append_to_file(path, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config.merge!(:before => /\z/)
- insert_into_file(path, *(args << config), &block)
- end
- alias_method :append_file, :append_to_file
-
- # Injects text right after the class definition. Since it depends on
- # insert_into_file, it's reversible.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # klass<String|Class>:: the class to be manipulated
- # data<String>:: the data to append to the class, can be also given as a block.
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Examples
- #
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController, " filter_parameter :password\n"
- #
- # inject_into_class "app/controllers/application_controller.rb", ApplicationController do
- # " filter_parameter :password\n"
- # end
- #
- def inject_into_class(path, klass, *args, &block)
- config = args.last.is_a?(Hash) ? args.pop : {}
- config.merge!(:after => /class #{klass}\n|class #{klass} .*\n/)
- insert_into_file(path, *(args << config), &block)
- end
-
- # Run a regular expression replacement on a file.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string to be replaced
- # replacement<String>:: the replacement, can be also given as a block
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1'
- #
- # gsub_file 'README', /rake/, :green do |match|
- # match << " no more. Use thor!"
- # end
- #
- def gsub_file(path, flag, *args, &block)
- return unless behavior == :invoke
- config = args.last.is_a?(Hash) ? args.pop : {}
-
- path = File.expand_path(path, destination_root)
- say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
-
- unless options[:pretend]
- content = File.binread(path)
- content.gsub!(flag, *args, &block)
- File.open(path, 'wb') { |file| file.write(content) }
- end
- end
-
- # Uncomment all lines matching a given regex. It will leave the space
- # which existed before the comment hash in tact but will remove any spacing
- # between the comment hash and the beginning of the line.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string used to decide which lines to uncomment
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # uncomment_lines 'config/initializers/session_store.rb', /active_record/
- #
- def uncomment_lines(path, flag, *args)
- flag = flag.respond_to?(:source) ? flag.source : flag
-
- gsub_file(path, /^(\s*)#\s*(.*#{flag})/, '\1\2', *args)
- end
-
- # Comment all lines matching a given regex. It will leave the space
- # which existed before the beginning of the line in tact and will insert
- # a single space after the comment hash.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # flag<Regexp|String>:: the regexp or string used to decide which lines to comment
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # comment_lines 'config/initializers/session_store.rb', /cookie_store/
- #
- def comment_lines(path, flag, *args)
- flag = flag.respond_to?(:source) ? flag.source : flag
-
- gsub_file(path, /^(\s*)([^#|\n]*#{flag})/, '\1# \2', *args)
- end
-
- # Removes a file at the given location.
- #
- # ==== Parameters
- # path<String>:: path of the file to be changed
- # config<Hash>:: give :verbose => false to not log the status.
- #
- # ==== Example
- #
- # remove_file 'README'
- # remove_file 'app/controllers/application_controller.rb'
- #
- def remove_file(path, config={})
- return unless behavior == :invoke
- path = File.expand_path(path, destination_root)
-
- say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
- ::FileUtils.rm_rf(path) if !options[:pretend] && File.exists?(path)
- end
- alias :remove_dir :remove_file
-
- private
- attr_accessor :output_buffer
- def concat(string)
- @output_buffer.concat(string)
- end
-
- def capture(*args, &block)
- with_output_buffer { block.call(*args) }
- end
-
- def with_output_buffer(buf = '') #:nodoc:
- self.output_buffer, old_buffer = buf, output_buffer
- yield
- output_buffer
- ensure
- self.output_buffer = old_buffer
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/actions/inject_into_file.rb
deleted file mode 100644
index c48cfab..0000000
--- a/lib/bundler/vendor/thor/actions/inject_into_file.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-require 'thor/actions/empty_directory'
-
-class Thor
- module Actions
-
- # Injects the given content into a file. Different from gsub_file, this
- # method is reversible.
- #
- # ==== Parameters
- # destination<String>:: Relative path to the destination root
- # data<String>:: Data to add to the file. Can be given as a block.
- # config<Hash>:: give :verbose => false to not log the status and the flag
- # for injection (:after or :before) or :force => true for
- # insert two or more times the same content.
- #
- # ==== Examples
- #
- # insert_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
- #
- # insert_into_file "config/environment.rb", :after => "Rails::Initializer.run do |config|\n" do
- # gems = ask "Which gems would you like to add?"
- # gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
- # end
- #
- def insert_into_file(destination, *args, &block)
- if block_given?
- data, config = block, args.shift
- else
- data, config = args.shift, args.shift
- end
- action InjectIntoFile.new(self, destination, data, config)
- end
- alias_method :inject_into_file, :insert_into_file
-
- class InjectIntoFile < EmptyDirectory #:nodoc:
- attr_reader :replacement, :flag, :behavior
-
- def initialize(base, destination, data, config)
- super(base, destination, { :verbose => true }.merge(config))
-
- @behavior, @flag = if @config.key?(:after)
- [:after, @config.delete(:after)]
- else
- [:before, @config.delete(:before)]
- end
-
- @replacement = data.is_a?(Proc) ? data.call : data
- @flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
- end
-
- def invoke!
- say_status :invoke
-
- content = if @behavior == :after
- '\0' + replacement
- else
- replacement + '\0'
- end
-
- replace!(/#{flag}/, content, config[:force])
- end
-
- def revoke!
- say_status :revoke
-
- regexp = if @behavior == :after
- content = '\1\2'
- /(#{flag})(.*)(#{Regexp.escape(replacement)})/m
- else
- content = '\2\3'
- /(#{Regexp.escape(replacement)})(.*)(#{flag})/m
- end
-
- replace!(regexp, content, true)
- end
-
- protected
-
- def say_status(behavior)
- status = if behavior == :invoke
- if flag == /\A/
- :prepend
- elsif flag == /\z/
- :append
- else
- :insert
- end
- else
- :subtract
- end
-
- super(status, config[:verbose])
- end
-
- # Adds the content to the file.
- #
- def replace!(regexp, string, force)
- unless base.options[:pretend]
- content = File.binread(destination)
- if force || !content.include?(replacement)
- content.gsub!(regexp, string)
- File.open(destination, 'wb') { |file| file.write(content) }
- end
- end
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/base.rb b/lib/bundler/vendor/thor/base.rb
deleted file mode 100644
index a193d2d..0000000
--- a/lib/bundler/vendor/thor/base.rb
+++ /dev/null
@@ -1,617 +0,0 @@
-require 'thor/core_ext/hash_with_indifferent_access'
-require 'thor/core_ext/ordered_hash'
-require 'thor/error'
-require 'thor/shell'
-require 'thor/invocation'
-require 'thor/parser'
-require 'thor/task'
-require 'thor/util'
-
-class Thor
- autoload :Actions, 'thor/actions'
- autoload :RakeCompat, 'thor/rake_compat'
-
- # Shortcuts for help.
- HELP_MAPPINGS = %w(-h -? --help -D)
-
- # Thor methods that should not be overwritten by the user.
- THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
- action add_file create_file in_root inside run run_ruby_script)
-
- module Base
- attr_accessor :options, :parent_options, :args
-
- # It receives arguments in an Array and two hashes, one for options and
- # other for configuration.
- #
- # Notice that it does not check if all required arguments were supplied.
- # It should be done by the parser.
- #
- # ==== Parameters
- # args<Array[Object]>:: An array of objects. The objects are applied to their
- # respective accessors declared with <tt>argument</tt>.
- #
- # options<Hash>:: An options hash that will be available as self.options.
- # The hash given is converted to a hash with indifferent
- # access, magic predicates (options.skip?) and then frozen.
- #
- # config<Hash>:: Configuration for this Thor class.
- #
- def initialize(args=[], options={}, config={})
- parse_options = self.class.class_options
-
- # The start method splits inbound arguments at the first argument
- # that looks like an option (starts with - or --). It then calls
- # new, passing in the two halves of the arguments Array as the
- # first two parameters.
-
- if options.is_a?(Array)
- task_options = config.delete(:task_options) # hook for start
- parse_options = parse_options.merge(task_options) if task_options
- array_options, hash_options = options, {}
- else
- # Handle the case where the class was explicitly instantiated
- # with pre-parsed options.
- array_options, hash_options = [], options
- end
-
- # Let Thor::Options parse the options first, so it can remove
- # declared options from the array. This will leave us with
- # a list of arguments that weren't declared.
- opts = Thor::Options.new(parse_options, hash_options)
- self.options = opts.parse(array_options)
-
- # If unknown options are disallowed, make sure that none of the
- # remaining arguments looks like an option.
- opts.check_unknown! if self.class.check_unknown_options?(config)
-
- # Add the remaining arguments from the options parser to the
- # arguments passed in to initialize. Then remove any positional
- # arguments declared using #argument (this is primarily used
- # by Thor::Group). Tis will leave us with the remaining
- # positional arguments.
- thor_args = Thor::Arguments.new(self.class.arguments)
- thor_args.parse(args + opts.remaining).each { |k,v| send("#{k}=", v) }
- args = thor_args.remaining
-
- @args = args
- end
-
- class << self
- def included(base) #:nodoc:
- base.send :extend, ClassMethods
- base.send :include, Invocation
- base.send :include, Shell
- end
-
- # Returns the classes that inherits from Thor or Thor::Group.
- #
- # ==== Returns
- # Array[Class]
- #
- def subclasses
- @subclasses ||= []
- end
-
- # Returns the files where the subclasses are kept.
- #
- # ==== Returns
- # Hash[path<String> => Class]
- #
- def subclass_files
- @subclass_files ||= Hash.new{ |h,k| h[k] = [] }
- end
-
- # Whenever a class inherits from Thor or Thor::Group, we should track the
- # class and the file on Thor::Base. This is the method responsable for it.
- #
- def register_klass_file(klass) #:nodoc:
- file = caller[1].match(/(.*):\d+/)[1]
- Thor::Base.subclasses << klass unless Thor::Base.subclasses.include?(klass)
-
- file_subclasses = Thor::Base.subclass_files[File.expand_path(file)]
- file_subclasses << klass unless file_subclasses.include?(klass)
- end
- end
-
- module ClassMethods
- def attr_reader(*) #:nodoc:
- no_tasks { super }
- end
-
- def attr_writer(*) #:nodoc:
- no_tasks { super }
- end
-
- def attr_accessor(*) #:nodoc:
- no_tasks { super }
- end
-
- # If you want to raise an error for unknown options, call check_unknown_options!
- # This is disabled by default to allow dynamic invocations.
- def check_unknown_options!
- @check_unknown_options = true
- end
-
- def check_unknown_options #:nodoc:
- @check_unknown_options ||= from_superclass(:check_unknown_options, false)
- end
-
- def check_unknown_options?(config) #:nodoc:
- !!check_unknown_options
- end
-
- # Adds an argument to the class and creates an attr_accessor for it.
- #
- # Arguments are different from options in several aspects. The first one
- # is how they are parsed from the command line, arguments are retrieved
- # from position:
- #
- # thor task NAME
- #
- # Instead of:
- #
- # thor task --name=NAME
- #
- # Besides, arguments are used inside your code as an accessor (self.argument),
- # while options are all kept in a hash (self.options).
- #
- # Finally, arguments cannot have type :default or :boolean but can be
- # optional (supplying :optional => :true or :required => false), although
- # you cannot have a required argument after a non-required argument. If you
- # try it, an error is raised.
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc - Description for the argument.
- # :required - If the argument is required or not.
- # :optional - If the argument is optional or not.
- # :type - The type of the argument, can be :string, :hash, :array, :numeric.
- # :default - Default value for this argument. It cannot be required and have default values.
- # :banner - String to show on usage notes.
- #
- # ==== Errors
- # ArgumentError:: Raised if you supply a required argument after a non required one.
- #
- def argument(name, options={})
- is_thor_reserved_word?(name, :argument)
- no_tasks { attr_accessor name }
-
- required = if options.key?(:optional)
- !options[:optional]
- elsif options.key?(:required)
- options[:required]
- else
- options[:default].nil?
- end
-
- remove_argument name
-
- arguments.each do |argument|
- next if argument.required?
- raise ArgumentError, "You cannot have #{name.to_s.inspect} as required argument after " <<
- "the non-required argument #{argument.human_name.inspect}."
- end if required
-
- arguments << Thor::Argument.new(name, options[:desc], required, options[:type],
- options[:default], options[:banner])
- end
-
- # Returns this class arguments, looking up in the ancestors chain.
- #
- # ==== Returns
- # Array[Thor::Argument]
- #
- def arguments
- @arguments ||= from_superclass(:arguments, [])
- end
-
- # Adds a bunch of options to the set of class options.
- #
- # class_options :foo => false, :bar => :required, :baz => :string
- #
- # If you prefer more detailed declaration, check class_option.
- #
- # ==== Parameters
- # Hash[Symbol => Object]
- #
- def class_options(options=nil)
- @class_options ||= from_superclass(:class_options, {})
- build_options(options, @class_options) if options
- @class_options
- end
-
- # Adds an option to the set of class options
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described below.
- #
- # ==== Options
- # :desc:: -- Description for the argument.
- # :required:: -- If the argument is required or not.
- # :default:: -- Default value for this argument.
- # :group:: -- The group for this options. Use by class options to output options in different levels.
- # :aliases:: -- Aliases for this option. <b>Note:</b> Thor follows a convention of one-dash-one-letter options. Thus aliases like "-something" wouldn't be parsed; use either "\--something" or "-s" instead.
- # :type:: -- The type of the argument, can be :string, :hash, :array, :numeric or :boolean.
- # :banner:: -- String to show on usage notes.
- # :hide:: -- If you want to hide this option from the help.
- #
- def class_option(name, options={})
- build_option(name, options, class_options)
- end
-
- # Removes a previous defined argument. If :undefine is given, undefine
- # accessors as well.
- #
- # ==== Parameters
- # names<Array>:: Arguments to be removed
- #
- # ==== Examples
- #
- # remove_argument :foo
- # remove_argument :foo, :bar, :baz, :undefine => true
- #
- def remove_argument(*names)
- options = names.last.is_a?(Hash) ? names.pop : {}
-
- names.each do |name|
- arguments.delete_if { |a| a.name == name.to_s }
- undef_method name, "#{name}=" if options[:undefine]
- end
- end
-
- # Removes a previous defined class option.
- #
- # ==== Parameters
- # names<Array>:: Class options to be removed
- #
- # ==== Examples
- #
- # remove_class_option :foo
- # remove_class_option :foo, :bar, :baz
- #
- def remove_class_option(*names)
- names.each do |name|
- class_options.delete(name)
- end
- end
-
- # Defines the group. This is used when thor list is invoked so you can specify
- # that only tasks from a pre-defined group will be shown. Defaults to standard.
- #
- # ==== Parameters
- # name<String|Symbol>
- #
- def group(name=nil)
- case name
- when nil
- @group ||= from_superclass(:group, 'standard')
- else
- @group = name.to_s
- end
- end
-
- # Returns the tasks for this Thor class.
- #
- # ==== Returns
- # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task
- # objects as values.
- #
- def tasks
- @tasks ||= Thor::CoreExt::OrderedHash.new
- end
-
- # Returns the tasks for this Thor class and all subclasses.
- #
- # ==== Returns
- # OrderedHash:: An ordered hash with tasks names as keys and Thor::Task
- # objects as values.
- #
- def all_tasks
- @all_tasks ||= from_superclass(:all_tasks, Thor::CoreExt::OrderedHash.new)
- @all_tasks.merge(tasks)
- end
-
- # Removes a given task from this Thor class. This is usually done if you
- # are inheriting from another class and don't want it to be available
- # anymore.
- #
- # By default it only remove the mapping to the task. But you can supply
- # :undefine => true to undefine the method from the class as well.
- #
- # ==== Parameters
- # name<Symbol|String>:: The name of the task to be removed
- # options<Hash>:: You can give :undefine => true if you want tasks the method
- # to be undefined from the class as well.
- #
- def remove_task(*names)
- options = names.last.is_a?(Hash) ? names.pop : {}
-
- names.each do |name|
- tasks.delete(name.to_s)
- all_tasks.delete(name.to_s)
- undef_method name if options[:undefine]
- end
- end
-
- # All methods defined inside the given block are not added as tasks.
- #
- # So you can do:
- #
- # class MyScript < Thor
- # no_tasks do
- # def this_is_not_a_task
- # end
- # end
- # end
- #
- # You can also add the method and remove it from the task list:
- #
- # class MyScript < Thor
- # def this_is_not_a_task
- # end
- # remove_task :this_is_not_a_task
- # end
- #
- def no_tasks
- @no_tasks = true
- yield
- ensure
- @no_tasks = false
- end
-
- # Sets the namespace for the Thor or Thor::Group class. By default the
- # namespace is retrieved from the class name. If your Thor class is named
- # Scripts::MyScript, the help method, for example, will be called as:
- #
- # thor scripts:my_script -h
- #
- # If you change the namespace:
- #
- # namespace :my_scripts
- #
- # You change how your tasks are invoked:
- #
- # thor my_scripts -h
- #
- # Finally, if you change your namespace to default:
- #
- # namespace :default
- #
- # Your tasks can be invoked with a shortcut. Instead of:
- #
- # thor :my_task
- #
- def namespace(name=nil)
- case name
- when nil
- @namespace ||= Thor::Util.namespace_from_thor_class(self)
- else
- @namespace = name.to_s
- end
- end
-
- # Parses the task and options from the given args, instantiate the class
- # and invoke the task. This method is used when the arguments must be parsed
- # from an array. If you are inside Ruby and want to use a Thor class, you
- # can simply initialize it:
- #
- # script = MyScript.new(args, options, config)
- # script.invoke(:task, first_arg, second_arg, third_arg)
- #
- def start(given_args=ARGV, config={})
- config[:shell] ||= Thor::Base.shell.new
- dispatch(nil, given_args.dup, nil, config)
- rescue Thor::Error => e
- ENV["THOR_DEBUG"] == "1" ? (raise e) : config[:shell].error(e.message)
- exit(1) if exit_on_failure?
- rescue Errno::EPIPE
- # This happens if a thor task is piped to something like `head`,
- # which closes the pipe when it's done reading. This will also
- # mean that if the pipe is closed, further unnecessary
- # computation will not occur.
- exit(0)
- end
-
- # Allows to use private methods from parent in child classes as tasks.
- #
- # ==== Parameters
- # names<Array>:: Method names to be used as tasks
- #
- # ==== Examples
- #
- # public_task :foo
- # public_task :foo, :bar, :baz
- #
- def public_task(*names)
- names.each do |name|
- class_eval "def #{name}(*); super end"
- end
- end
-
- def handle_no_task_error(task, has_namespace = $thor_runner) #:nodoc:
- if has_namespace
- raise UndefinedTaskError, "Could not find task #{task.inspect} in #{namespace.inspect} namespace."
- else
- raise UndefinedTaskError, "Could not find task #{task.inspect}."
- end
- end
-
- def handle_argument_error(task, error, arity=nil) #:nodoc:
- msg = "#{basename} #{task.name}"
- if arity
- required = arity < 0 ? (-1 - arity) : arity
- msg << " requires at least #{required} argument"
- msg << "s" if required > 1
- else
- msg = "call #{msg} as"
- end
-
- msg << ": #{self.banner(task).inspect}."
- raise InvocationError, msg
- end
-
- protected
-
- # Prints the class options per group. If an option does not belong to
- # any group, it's printed as Class option.
- #
- def class_options_help(shell, groups={}) #:nodoc:
- # Group options by group
- class_options.each do |_, value|
- groups[value.group] ||= []
- groups[value.group] << value
- end
-
- # Deal with default group
- global_options = groups.delete(nil) || []
- print_options(shell, global_options)
-
- # Print all others
- groups.each do |group_name, options|
- print_options(shell, options, group_name)
- end
- end
-
- # Receives a set of options and print them.
- def print_options(shell, options, group_name=nil)
- return if options.empty?
-
- list = []
- padding = options.collect{ |o| o.aliases.size }.max.to_i * 4
-
- options.each do |option|
- unless option.hide
- item = [ option.usage(padding) ]
- item.push(option.description ? "# #{option.description}" : "")
-
- list << item
- list << [ "", "# Default: #{option.default}" ] if option.show_default?
- end
- end
-
- shell.say(group_name ? "#{group_name} options:" : "Options:")
- shell.print_table(list, :indent => 2)
- shell.say ""
- end
-
- # Raises an error if the word given is a Thor reserved word.
- def is_thor_reserved_word?(word, type) #:nodoc:
- return false unless THOR_RESERVED_WORDS.include?(word.to_s)
- raise "#{word.inspect} is a Thor reserved word and cannot be defined as #{type}"
- end
-
- # Build an option and adds it to the given scope.
- #
- # ==== Parameters
- # name<Symbol>:: The name of the argument.
- # options<Hash>:: Described in both class_option and method_option.
- def build_option(name, options, scope) #:nodoc:
- scope[name] = Thor::Option.new(name, options[:desc], options[:required],
- options[:type], options[:default], options[:banner],
- options[:lazy_default], options[:group], options[:aliases], options[:hide])
- end
-
- # Receives a hash of options, parse them and add to the scope. This is a
- # fast way to set a bunch of options:
- #
- # build_options :foo => true, :bar => :required, :baz => :string
- #
- # ==== Parameters
- # Hash[Symbol => Object]
- def build_options(options, scope) #:nodoc:
- options.each do |key, value|
- scope[key] = Thor::Option.parse(key, value)
- end
- end
-
- # Finds a task with the given name. If the task belongs to the current
- # class, just return it, otherwise dup it and add the fresh copy to the
- # current task hash.
- def find_and_refresh_task(name) #:nodoc:
- task = if task = tasks[name.to_s]
- task
- elsif task = all_tasks[name.to_s]
- tasks[name.to_s] = task.clone
- else
- raise ArgumentError, "You supplied :for => #{name.inspect}, but the task #{name.inspect} could not be found."
- end
- end
-
- # Everytime someone inherits from a Thor class, register the klass
- # and file into baseclass.
- def inherited(klass)
- Thor::Base.register_klass_file(klass)
- klass.instance_variable_set(:@no_tasks, false)
- end
-
- # Fire this callback whenever a method is added. Added methods are
- # tracked as tasks by invoking the create_task method.
- def method_added(meth)
- meth = meth.to_s
-
- if meth == "initialize"
- initialize_added
- return
- end
-
- # Return if it's not a public instance method
- return unless public_instance_methods.include?(meth) ||
- public_instance_methods.include?(meth.to_sym)
-
- return if @no_tasks || !create_task(meth)
-
- is_thor_reserved_word?(meth, :task)
- Thor::Base.register_klass_file(self)
- end
-
- # Retrieves a value from superclass. If it reaches the baseclass,
- # returns default.
- def from_superclass(method, default=nil)
- if self == baseclass || !superclass.respond_to?(method, true)
- default
- else
- value = superclass.send(method)
- value.dup if value
- end
- end
-
- # A flag that makes the process exit with status 1 if any error happens.
- def exit_on_failure?
- false
- end
-
- #
- # The basename of the program invoking the thor class.
- #
- def basename
- File.basename($0).split(' ').first
- end
-
- # SIGNATURE: Sets the baseclass. This is where the superclass lookup
- # finishes.
- def baseclass #:nodoc:
- end
-
- # SIGNATURE: Creates a new task if valid_task? is true. This method is
- # called when a new method is added to the class.
- def create_task(meth) #:nodoc:
- end
-
- # SIGNATURE: Defines behavior when the initialize method is added to the
- # class.
- def initialize_added #:nodoc:
- end
-
- # SIGNATURE: The hook invoked by start.
- def dispatch(task, given_args, given_opts, config) #:nodoc:
- raise NotImplementedError
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/core_ext/dir_escape.rb b/lib/bundler/vendor/thor/core_ext/dir_escape.rb
deleted file mode 100644
index e69de29..0000000
diff --git a/lib/bundler/vendor/thor/core_ext/file_binary_read.rb b/lib/bundler/vendor/thor/core_ext/file_binary_read.rb
deleted file mode 100644
index d6af7e4..0000000
--- a/lib/bundler/vendor/thor/core_ext/file_binary_read.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class File #:nodoc:
-
- unless File.respond_to?(:binread)
- def self.binread(file)
- File.open(file, 'rb') { |f| f.read }
- end
- end
-
-end
diff --git a/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb
deleted file mode 100644
index 40d201d..0000000
--- a/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-class Thor
- module CoreExt #:nodoc:
-
- # A hash with indifferent access and magic predicates.
- #
- # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true
- #
- # hash[:foo] #=> 'bar'
- # hash['foo'] #=> 'bar'
- # hash.foo? #=> true
- #
- class HashWithIndifferentAccess < ::Hash #:nodoc:
-
- def initialize(hash={})
- super()
- hash.each do |key, value|
- self[convert_key(key)] = value
- end
- end
-
- def [](key)
- super(convert_key(key))
- end
-
- def []=(key, value)
- super(convert_key(key), value)
- end
-
- def delete(key)
- super(convert_key(key))
- end
-
- def values_at(*indices)
- indices.collect { |key| self[convert_key(key)] }
- end
-
- def merge(other)
- dup.merge!(other)
- end
-
- def merge!(other)
- other.each do |key, value|
- self[convert_key(key)] = value
- end
- self
- end
-
- protected
-
- def convert_key(key)
- key.is_a?(Symbol) ? key.to_s : key
- end
-
- # Magic predicates. For instance:
- #
- # options.force? # => !!options['force']
- # options.shebang # => "/usr/lib/local/ruby"
- # options.test_framework?(:rspec) # => options[:test_framework] == :rspec
- #
- def method_missing(method, *args, &block)
- method = method.to_s
- if method =~ /^(\w+)\?$/
- if args.empty?
- !!self[$1]
- else
- self[$1] == args.first
- end
- else
- self[method]
- end
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/core_ext/ordered_hash.rb b/lib/bundler/vendor/thor/core_ext/ordered_hash.rb
deleted file mode 100644
index 27fea5b..0000000
--- a/lib/bundler/vendor/thor/core_ext/ordered_hash.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-class Thor
- module CoreExt #:nodoc:
-
- if RUBY_VERSION >= '1.9'
- class OrderedHash < ::Hash
- end
- else
- # This class is based on the Ruby 1.9 ordered hashes.
- #
- # It keeps the semantics and most of the efficiency of normal hashes
- # while also keeping track of the order in which elements were set.
- #
- class OrderedHash #:nodoc:
- include Enumerable
-
- Node = Struct.new(:key, :value, :next, :prev)
-
- def initialize
- @hash = {}
- end
-
- def [](key)
- @hash[key] && @hash[key].value
- end
-
- def []=(key, value)
- if node = @hash[key]
- node.value = value
- else
- node = Node.new(key, value)
-
- if @first.nil?
- @first = @last = node
- else
- node.prev = @last
- @last.next = node
- @last = node
- end
- end
-
- @hash[key] = node
- value
- end
-
- def delete(key)
- if node = @hash[key]
- prev_node = node.prev
- next_node = node.next
-
- next_node.prev = prev_node if next_node
- prev_node.next = next_node if prev_node
-
- @first = next_node if @first == node
- @last = prev_node if @last == node
-
- value = node.value
- end
-
- @hash.delete(key)
- value
- end
-
- def keys
- self.map { |k, v| k }
- end
-
- def values
- self.map { |k, v| v }
- end
-
- def each
- return unless @first
- yield [@first.key, @first.value]
- node = @first
- yield [node.key, node.value] while node = node.next
- self
- end
-
- def merge(other)
- hash = self.class.new
-
- self.each do |key, value|
- hash[key] = value
- end
-
- other.each do |key, value|
- hash[key] = value
- end
-
- hash
- end
-
- def empty?
- @hash.empty?
- end
- end
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/error.rb b/lib/bundler/vendor/thor/error.rb
deleted file mode 100644
index 532db46..0000000
--- a/lib/bundler/vendor/thor/error.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-class Thor
- # Thor::Error is raised when it's caused by wrong usage of thor classes. Those
- # errors have their backtrace suppressed and are nicely shown to the user.
- #
- # Errors that are caused by the developer, like declaring a method which
- # overwrites a thor keyword, it SHOULD NOT raise a Thor::Error. This way, we
- # ensure that developer errors are shown with full backtrace.
- #
- class Error < StandardError
- end
-
- # Raised when a task was not found.
- #
- class UndefinedTaskError < Error
- end
-
- # Raised when a task was found, but not invoked properly.
- #
- class InvocationError < Error
- end
-
- class UnknownArgumentError < Error
- end
-
- class RequiredArgumentMissingError < InvocationError
- end
-
- class MalformattedArgumentError < InvocationError
- end
-
- # Raised when a user tries to call a private method encoded in templated filename.
- #
- class PrivateMethodEncodedError < Error
- end
-end
diff --git a/lib/bundler/vendor/thor/group.rb b/lib/bundler/vendor/thor/group.rb
deleted file mode 100644
index 874ac47..0000000
--- a/lib/bundler/vendor/thor/group.rb
+++ /dev/null
@@ -1,285 +0,0 @@
-require 'thor/base'
-
-# Thor has a special class called Thor::Group. The main difference to Thor class
-# is that it invokes all tasks at once. It also include some methods that allows
-# invocations to be done at the class method, which are not available to Thor
-# tasks.
-class Thor::Group
- class << self
- # The description for this Thor::Group. If none is provided, but a source root
- # exists, tries to find the USAGE one folder above it, otherwise searches
- # in the superclass.
- #
- # ==== Parameters
- # description<String>:: The description for this Thor::Group.
- #
- def desc(description=nil)
- case description
- when nil
- @desc ||= from_superclass(:desc, nil)
- else
- @desc = description
- end
- end
-
- # Prints help information.
- #
- # ==== Options
- # short:: When true, shows only usage.
- #
- def help(shell)
- shell.say "Usage:"
- shell.say " #{banner}\n"
- shell.say
- class_options_help(shell)
- shell.say self.desc if self.desc
- end
-
- # Stores invocations for this class merging with superclass values.
- #
- def invocations #:nodoc:
- @invocations ||= from_superclass(:invocations, {})
- end
-
- # Stores invocation blocks used on invoke_from_option.
- #
- def invocation_blocks #:nodoc:
- @invocation_blocks ||= from_superclass(:invocation_blocks, {})
- end
-
- # Invoke the given namespace or class given. It adds an instance
- # method that will invoke the klass and task. You can give a block to
- # configure how it will be invoked.
- #
- # The namespace/class given will have its options showed on the help
- # usage. Check invoke_from_option for more information.
- #
- def invoke(*names, &block)
- options = names.last.is_a?(Hash) ? names.pop : {}
- verbose = options.fetch(:verbose, true)
-
- names.each do |name|
- invocations[name] = false
- invocation_blocks[name] = block if block_given?
-
- class_eval <<-METHOD, __FILE__, __LINE__
- def _invoke_#{name.to_s.gsub(/\W/, '_')}
- klass, task = self.class.prepare_for_invocation(nil, #{name.inspect})
-
- if klass
- say_status :invoke, #{name.inspect}, #{verbose.inspect}
- block = self.class.invocation_blocks[#{name.inspect}]
- _invoke_for_class_method klass, task, &block
- else
- say_status :error, %(#{name.inspect} [not found]), :red
- end
- end
- METHOD
- end
- end
-
- # Invoke a thor class based on the value supplied by the user to the
- # given option named "name". A class option must be created before this
- # method is invoked for each name given.
- #
- # ==== Examples
- #
- # class GemGenerator < Thor::Group
- # class_option :test_framework, :type => :string
- # invoke_from_option :test_framework
- # end
- #
- # ==== Boolean options
- #
- # In some cases, you want to invoke a thor class if some option is true or
- # false. This is automatically handled by invoke_from_option. Then the
- # option name is used to invoke the generator.
- #
- # ==== Preparing for invocation
- #
- # In some cases you want to customize how a specified hook is going to be
- # invoked. You can do that by overwriting the class method
- # prepare_for_invocation. The class method must necessarily return a klass
- # and an optional task.
- #
- # ==== Custom invocations
- #
- # You can also supply a block to customize how the option is going to be
- # invoked. The block receives two parameters, an instance of the current
- # class and the klass to be invoked.
- #
- def invoke_from_option(*names, &block)
- options = names.last.is_a?(Hash) ? names.pop : {}
- verbose = options.fetch(:verbose, :white)
-
- names.each do |name|
- unless class_options.key?(name)
- raise ArgumentError, "You have to define the option #{name.inspect} " <<
- "before setting invoke_from_option."
- end
-
- invocations[name] = true
- invocation_blocks[name] = block if block_given?
-
- class_eval <<-METHOD, __FILE__, __LINE__
- def _invoke_from_option_#{name.to_s.gsub(/\W/, '_')}
- return unless options[#{name.inspect}]
-
- value = options[#{name.inspect}]
- value = #{name.inspect} if TrueClass === value
- klass, task = self.class.prepare_for_invocation(#{name.inspect}, value)
-
- if klass
- say_status :invoke, value, #{verbose.inspect}
- block = self.class.invocation_blocks[#{name.inspect}]
- _invoke_for_class_method klass, task, &block
- else
- say_status :error, %(\#{value} [not found]), :red
- end
- end
- METHOD
- end
- end
-
- # Remove a previously added invocation.
- #
- # ==== Examples
- #
- # remove_invocation :test_framework
- #
- def remove_invocation(*names)
- names.each do |name|
- remove_task(name)
- remove_class_option(name)
- invocations.delete(name)
- invocation_blocks.delete(name)
- end
- end
-
- # Overwrite class options help to allow invoked generators options to be
- # shown recursively when invoking a generator.
- #
- def class_options_help(shell, groups={}) #:nodoc:
- get_options_from_invocations(groups, class_options) do |klass|
- klass.send(:get_options_from_invocations, groups, class_options)
- end
- super(shell, groups)
- end
-
- # Get invocations array and merge options from invocations. Those
- # options are added to group_options hash. Options that already exists
- # in base_options are not added twice.
- #
- def get_options_from_invocations(group_options, base_options) #:nodoc:
- invocations.each do |name, from_option|
- value = if from_option
- option = class_options[name]
- option.type == :boolean ? name : option.default
- else
- name
- end
- next unless value
-
- klass, _ = prepare_for_invocation(name, value)
- next unless klass && klass.respond_to?(:class_options)
-
- value = value.to_s
- human_name = value.respond_to?(:classify) ? value.classify : value
-
- group_options[human_name] ||= []
- group_options[human_name] += klass.class_options.values.select do |class_option|
- base_options[class_option.name.to_sym].nil? && class_option.group.nil? &&
- !group_options.values.flatten.any? { |i| i.name == class_option.name }
- end
-
- yield klass if block_given?
- end
- end
-
- # Returns tasks ready to be printed.
- def printable_tasks(*)
- item = []
- item << banner
- item << (desc ? "# #{desc.gsub(/\s+/m,' ')}" : "")
- [item]
- end
-
- def handle_argument_error(task, error, arity=nil) #:nodoc:
- if arity > 0
- msg = "#{basename} #{task.name} takes #{arity} argument"
- msg << "s" if arity > 1
- msg << ", but it should not."
- else
- msg = "You should not pass arguments to #{basename} #{task.name}."
- end
-
- raise error, msg
- end
-
- protected
-
- # The method responsible for dispatching given the args.
- def dispatch(task, given_args, given_opts, config) #:nodoc:
- if Thor::HELP_MAPPINGS.include?(given_args.first)
- help(config[:shell])
- return
- end
-
- args, opts = Thor::Options.split(given_args)
- opts = given_opts || opts
-
- instance = new(args, opts, config)
- yield instance if block_given?
- args = instance.args
-
- if task
- instance.invoke_task(all_tasks[task])
- else
- instance.invoke_all
- end
- end
-
- # The banner for this class. You can customize it if you are invoking the
- # thor class by another ways which is not the Thor::Runner.
- def banner
- "#{basename} #{self_task.formatted_usage(self, false)}"
- end
-
- # Represents the whole class as a task.
- def self_task #:nodoc:
- Thor::DynamicTask.new(self.namespace, class_options)
- end
-
- def baseclass #:nodoc:
- Thor::Group
- end
-
- def create_task(meth) #:nodoc:
- tasks[meth.to_s] = Thor::Task.new(meth, nil, nil, nil, nil)
- true
- end
- end
-
- include Thor::Base
-
- protected
-
- # Shortcut to invoke with padding and block handling. Use internally by
- # invoke and invoke_from_option class methods.
- def _invoke_for_class_method(klass, task=nil, *args, &block) #:nodoc:
- with_padding do
- if block
- case block.arity
- when 3
- block.call(self, klass, task)
- when 2
- block.call(self, klass)
- when 1
- instance_exec(klass, &block)
- end
- else
- invoke klass, task, *args
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/invocation.rb b/lib/bundler/vendor/thor/invocation.rb
deleted file mode 100644
index 71db7c8..0000000
--- a/lib/bundler/vendor/thor/invocation.rb
+++ /dev/null
@@ -1,170 +0,0 @@
-class Thor
- module Invocation
- def self.included(base) #:nodoc:
- base.extend ClassMethods
- end
-
- module ClassMethods
- # This method is responsible for receiving a name and find the proper
- # class and task for it. The key is an optional parameter which is
- # available only in class methods invocations (i.e. in Thor::Group).
- def prepare_for_invocation(key, name) #:nodoc:
- case name
- when Symbol, String
- Thor::Util.find_class_and_task_by_namespace(name.to_s, !key)
- else
- name
- end
- end
- end
-
- # Make initializer aware of invocations and the initialization args.
- def initialize(args=[], options={}, config={}, &block) #:nodoc:
- @_invocations = config[:invocations] || Hash.new { |h,k| h[k] = [] }
- @_initializer = [ args, options, config ]
- super
- end
-
- # Receives a name and invokes it. The name can be a string (either "task" or
- # "namespace:task"), a Thor::Task, a Class or a Thor instance. If the task
- # cannot be guessed by name, it can also be supplied as second argument.
- #
- # You can also supply the arguments, options and configuration values for
- # the task to be invoked, if none is given, the same values used to
- # initialize the invoker are used to initialize the invoked.
- #
- # When no name is given, it will invoke the default task of the current class.
- #
- # ==== Examples
- #
- # class A < Thor
- # def foo
- # invoke :bar
- # invoke "b:hello", ["José"]
- # end
- #
- # def bar
- # invoke "b:hello", ["José"]
- # end
- # end
- #
- # class B < Thor
- # def hello(name)
- # puts "hello #{name}"
- # end
- # end
- #
- # You can notice that the method "foo" above invokes two tasks: "bar",
- # which belongs to the same class and "hello" which belongs to the class B.
- #
- # By using an invocation system you ensure that a task is invoked only once.
- # In the example above, invoking "foo" will invoke "b:hello" just once, even
- # if it's invoked later by "bar" method.
- #
- # When class A invokes class B, all arguments used on A initialization are
- # supplied to B. This allows lazy parse of options. Let's suppose you have
- # some rspec tasks:
- #
- # class Rspec < Thor::Group
- # class_option :mock_framework, :type => :string, :default => :rr
- #
- # def invoke_mock_framework
- # invoke "rspec:#{options[:mock_framework]}"
- # end
- # end
- #
- # As you noticed, it invokes the given mock framework, which might have its
- # own options:
- #
- # class Rspec::RR < Thor::Group
- # class_option :style, :type => :string, :default => :mock
- # end
- #
- # Since it's not rspec concern to parse mock framework options, when RR
- # is invoked all options are parsed again, so RR can extract only the options
- # that it's going to use.
- #
- # If you want Rspec::RR to be initialized with its own set of options, you
- # have to do that explicitly:
- #
- # invoke "rspec:rr", [], :style => :foo
- #
- # Besides giving an instance, you can also give a class to invoke:
- #
- # invoke Rspec::RR, [], :style => :foo
- #
- def invoke(name=nil, *args)
- if name.nil?
- warn "[Thor] Calling invoke() without argument is deprecated. Please use invoke_all instead.\n#{caller.join("\n")}"
- return invoke_all
- end
-
- args.unshift(nil) if Array === args.first || NilClass === args.first
- task, args, opts, config = args
-
- klass, task = _retrieve_class_and_task(name, task)
- raise "Expected Thor class, got #{klass}" unless klass <= Thor::Base
-
- args, opts, config = _parse_initialization_options(args, opts, config)
- klass.send(:dispatch, task, args, opts, config) do |instance|
- instance.parent_options = options
- end
- end
-
- # Invoke the given task if the given args.
- def invoke_task(task, *args) #:nodoc:
- current = @_invocations[self.class]
-
- unless current.include?(task.name)
- current << task.name
- task.run(self, *args)
- end
- end
-
- # Invoke all tasks for the current instance.
- def invoke_all #:nodoc:
- self.class.all_tasks.map { |_, task| invoke_task(task) }
- end
-
- # Invokes using shell padding.
- def invoke_with_padding(*args)
- with_padding { invoke(*args) }
- end
-
- protected
-
- # Configuration values that are shared between invocations.
- def _shared_configuration #:nodoc:
- { :invocations => @_invocations }
- end
-
- # This method simply retrieves the class and task to be invoked.
- # If the name is nil or the given name is a task in the current class,
- # use the given name and return self as class. Otherwise, call
- # prepare_for_invocation in the current class.
- def _retrieve_class_and_task(name, sent_task=nil) #:nodoc:
- case
- when name.nil?
- [self.class, nil]
- when self.class.all_tasks[name.to_s]
- [self.class, name.to_s]
- else
- klass, task = self.class.prepare_for_invocation(nil, name)
- [klass, task || sent_task]
- end
- end
-
- # Initialize klass using values stored in the @_initializer.
- def _parse_initialization_options(args, opts, config) #:nodoc:
- stored_args, stored_opts, stored_config = @_initializer
-
- args ||= stored_args.dup
- opts ||= stored_opts.dup
-
- config ||= {}
- config = stored_config.merge(_shared_configuration).merge!(config)
-
- [ args, opts, config ]
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/parser.rb b/lib/bundler/vendor/thor/parser.rb
deleted file mode 100644
index 57a3f6e..0000000
--- a/lib/bundler/vendor/thor/parser.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'thor/parser/argument'
-require 'thor/parser/arguments'
-require 'thor/parser/option'
-require 'thor/parser/options'
diff --git a/lib/bundler/vendor/thor/parser/argument.rb b/lib/bundler/vendor/thor/parser/argument.rb
deleted file mode 100644
index 68c2e08..0000000
--- a/lib/bundler/vendor/thor/parser/argument.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-class Thor
- class Argument #:nodoc:
- VALID_TYPES = [ :numeric, :hash, :array, :string ]
-
- attr_reader :name, :description, :required, :type, :default, :banner
- alias :human_name :name
-
- def initialize(name, description=nil, required=true, type=:string, default=nil, banner=nil)
- class_name = self.class.name.split("::").last
-
- raise ArgumentError, "#{class_name} name can't be nil." if name.nil?
- raise ArgumentError, "Type :#{type} is not valid for #{class_name.downcase}s." if type && !valid_type?(type)
-
- @name = name.to_s
- @description = description
- @required = required || false
- @type = (type || :string).to_sym
- @default = default
- @banner = banner || default_banner
-
- validate! # Trigger specific validations
- end
-
- def usage
- required? ? banner : "[#{banner}]"
- end
-
- def required?
- required
- end
-
- def show_default?
- case default
- when Array, String, Hash
- !default.empty?
- else
- default
- end
- end
-
- protected
-
- def validate!
- raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
- end
-
- def valid_type?(type)
- self.class::VALID_TYPES.include?(type.to_sym)
- end
-
- def default_banner
- case type
- when :boolean
- nil
- when :string, :default
- human_name.upcase
- when :numeric
- "N"
- when :hash
- "key:value"
- when :array
- "one two three"
- end
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/parser/arguments.rb b/lib/bundler/vendor/thor/parser/arguments.rb
deleted file mode 100644
index 12db2b2..0000000
--- a/lib/bundler/vendor/thor/parser/arguments.rb
+++ /dev/null
@@ -1,165 +0,0 @@
-class Thor
- class Arguments #:nodoc:
- NUMERIC = /(\d*\.\d+|\d+)/
-
- # Receives an array of args and returns two arrays, one with arguments
- # and one with switches.
- #
- def self.split(args)
- arguments = []
-
- args.each do |item|
- break if item =~ /^-/
- arguments << item
- end
-
- return arguments, args[Range.new(arguments.size, -1)]
- end
-
- def self.parse(*args)
- to_parse = args.pop
- new(*args).parse(to_parse)
- end
-
- # Takes an array of Thor::Argument objects.
- #
- def initialize(arguments=[])
- @assigns, @non_assigned_required = {}, []
- @switches = arguments
-
- arguments.each do |argument|
- if argument.default != nil
- @assigns[argument.human_name] = argument.default
- elsif argument.required?
- @non_assigned_required << argument
- end
- end
- end
-
- def parse(args)
- @pile = args.dup
-
- @switches.each do |argument|
- break unless peek
- @non_assigned_required.delete(argument)
- @assigns[argument.human_name] = send(:"parse_#{argument.type}", argument.human_name)
- end
-
- check_requirement!
- @assigns
- end
-
- def remaining
- @pile
- end
-
- private
-
- def no_or_skip?(arg)
- arg =~ /^--(no|skip)-([-\w]+)$/
- $2
- end
-
- def last?
- @pile.empty?
- end
-
- def peek
- @pile.first
- end
-
- def shift
- @pile.shift
- end
-
- def unshift(arg)
- unless arg.kind_of?(Array)
- @pile.unshift(arg)
- else
- @pile = arg + @pile
- end
- end
-
- def current_is_value?
- peek && peek.to_s !~ /^-/
- end
-
- # Runs through the argument array getting strings that contains ":" and
- # mark it as a hash:
- #
- # [ "name:string", "age:integer" ]
- #
- # Becomes:
- #
- # { "name" => "string", "age" => "integer" }
- #
- def parse_hash(name)
- return shift if peek.is_a?(Hash)
- hash = {}
-
- while current_is_value? && peek.include?(?:)
- key, value = shift.split(':',2)
- hash[key] = value
- end
- hash
- end
-
- # Runs through the argument array getting all strings until no string is
- # found or a switch is found.
- #
- # ["a", "b", "c"]
- #
- # And returns it as an array:
- #
- # ["a", "b", "c"]
- #
- def parse_array(name)
- return shift if peek.is_a?(Array)
- array = []
-
- while current_is_value?
- array << shift
- end
- array
- end
-
- # Check if the peek is numeric format and return a Float or Integer.
- # Otherwise raises an error.
- #
- def parse_numeric(name)
- return shift if peek.is_a?(Numeric)
-
- unless peek =~ NUMERIC && $& == peek
- raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
- end
-
- $&.index('.') ? shift.to_f : shift.to_i
- end
-
- # Parse string:
- # for --string-arg, just return the current value in the pile
- # for --no-string-arg, nil
- #
- def parse_string(name)
- if no_or_skip?(name)
- nil
- else
- shift
- end
- end
-
- # Raises an error if @non_assigned_required array is not empty.
- #
- def check_requirement!
- unless @non_assigned_required.empty?
- names = @non_assigned_required.map do |o|
- o.respond_to?(:switch_name) ? o.switch_name : o.human_name
- end.join("', '")
-
- class_name = self.class.name.split('::').last.downcase
- raise RequiredArgumentMissingError, "No value provided for required #{class_name} '#{names}'"
- end
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/parser/option.rb b/lib/bundler/vendor/thor/parser/option.rb
deleted file mode 100644
index 26da9d6..0000000
--- a/lib/bundler/vendor/thor/parser/option.rb
+++ /dev/null
@@ -1,121 +0,0 @@
-class Thor
- class Option < Argument #:nodoc:
- attr_reader :aliases, :group, :lazy_default, :hide
-
- VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
-
- def initialize(name, description=nil, required=nil, type=nil, default=nil, banner=nil, lazy_default=nil, group=nil, aliases=nil, hide=nil)
- super(name, description, required, type, default, banner)
- @lazy_default = lazy_default
- @group = group.to_s.capitalize if group
- @aliases = [*aliases].compact
- @hide = hide
- end
-
- # This parse quick options given as method_options. It makes several
- # assumptions, but you can be more specific using the option method.
- #
- # parse :foo => "bar"
- # #=> Option foo with default value bar
- #
- # parse [:foo, :baz] => "bar"
- # #=> Option foo with default value bar and alias :baz
- #
- # parse :foo => :required
- # #=> Required option foo without default value
- #
- # parse :foo => 2
- # #=> Option foo with default value 2 and type numeric
- #
- # parse :foo => :numeric
- # #=> Option foo without default value and type numeric
- #
- # parse :foo => true
- # #=> Option foo with default value true and type boolean
- #
- # The valid types are :boolean, :numeric, :hash, :array and :string. If none
- # is given a default type is assumed. This default type accepts arguments as
- # string (--foo=value) or booleans (just --foo).
- #
- # By default all options are optional, unless :required is given.
- #
- def self.parse(key, value)
- if key.is_a?(Array)
- name, *aliases = key
- else
- name, aliases = key, []
- end
-
- name = name.to_s
- default = value
-
- type = case value
- when Symbol
- default = nil
- if VALID_TYPES.include?(value)
- value
- elsif required = (value == :required)
- :string
- end
- when TrueClass, FalseClass
- :boolean
- when Numeric
- :numeric
- when Hash, Array, String
- value.class.name.downcase.to_sym
- end
-
- self.new(name.to_s, nil, required, type, default, nil, nil, nil, aliases)
- end
-
- def switch_name
- @switch_name ||= dasherized? ? name : dasherize(name)
- end
-
- def human_name
- @human_name ||= dasherized? ? undasherize(name) : name
- end
-
- def usage(padding=0)
- sample = if banner && !banner.to_s.empty?
- "#{switch_name}=#{banner}"
- else
- switch_name
- end
-
- sample = "[#{sample}]" unless required?
-
- if aliases.empty?
- (" " * padding) << sample
- else
- "#{aliases.join(', ')}, #{sample}"
- end
- end
-
- VALID_TYPES.each do |type|
- class_eval <<-RUBY, __FILE__, __LINE__ + 1
- def #{type}?
- self.type == #{type.inspect}
- end
- RUBY
- end
-
- protected
-
- def validate!
- raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
- end
-
- def dasherized?
- name.index('-') == 0
- end
-
- def undasherize(str)
- str.sub(/^-{1,2}/, '')
- end
-
- def dasherize(str)
- (str.length > 1 ? "--" : "-") + str.gsub('_', '-')
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/parser/options.rb b/lib/bundler/vendor/thor/parser/options.rb
deleted file mode 100644
index 81b671d..0000000
--- a/lib/bundler/vendor/thor/parser/options.rb
+++ /dev/null
@@ -1,178 +0,0 @@
-class Thor
- class Options < Arguments #:nodoc:
- LONG_RE = /^(--\w+(?:-\w+)*)$/
- SHORT_RE = /^(-[a-z])$/i
- EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
- SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args
- SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i
-
- # Receives a hash and makes it switches.
- def self.to_switches(options)
- options.map do |key, value|
- case value
- when true
- "--#{key}"
- when Array
- "--#{key} #{value.map{ |v| v.inspect }.join(' ')}"
- when Hash
- "--#{key} #{value.map{ |k,v| "#{k}:#{v}" }.join(' ')}"
- when nil, false
- ""
- else
- "--#{key} #{value.inspect}"
- end
- end.join(" ")
- end
-
- # Takes a hash of Thor::Option and a hash with defaults.
- def initialize(hash_options={}, defaults={})
- options = hash_options.values
- super(options)
-
- # Add defaults
- defaults.each do |key, value|
- @assigns[key.to_s] = value
- @non_assigned_required.delete(hash_options[key])
- end
-
- @shorts, @switches, @extra = {}, {}, []
-
- options.each do |option|
- @switches[option.switch_name] = option
-
- option.aliases.each do |short|
- @shorts[short.to_s] ||= option.switch_name
- end
- end
- end
-
- def remaining
- @extra
- end
-
- def parse(args)
- @pile = args.dup
-
- while peek
- match, is_switch = current_is_switch?
- shifted = shift
-
- if is_switch
- case shifted
- when SHORT_SQ_RE
- unshift($1.split('').map { |f| "-#{f}" })
- next
- when EQ_RE, SHORT_NUM
- unshift($2)
- switch = $1
- when LONG_RE, SHORT_RE
- switch = $1
- end
-
- switch = normalize_switch(switch)
- option = switch_option(switch)
- @assigns[option.human_name] = parse_peek(switch, option)
- elsif match
- @extra << shifted
- @extra << shift while peek && peek !~ /^-/
- else
- @extra << shifted
- end
- end
-
- check_requirement!
-
- assigns = Thor::CoreExt::HashWithIndifferentAccess.new(@assigns)
- assigns.freeze
- assigns
- end
-
- def check_unknown!
- # an unknown option starts with - or -- and has no more --'s afterward.
- unknown = @extra.select { |str| str =~ /^--?(?:(?!--).)*$/ }
- raise UnknownArgumentError, "Unknown switches '#{unknown.join(', ')}'" unless unknown.empty?
- end
-
- protected
-
- # Returns true if the current value in peek is a registered switch.
- #
- def current_is_switch?
- case peek
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM
- [true, switch?($1)]
- when SHORT_SQ_RE
- [true, $1.split('').any? { |f| switch?("-#{f}") }]
- else
- [false, false]
- end
- end
-
- def current_is_switch_formatted?
- case peek
- when LONG_RE, SHORT_RE, EQ_RE, SHORT_NUM, SHORT_SQ_RE
- true
- else
- false
- end
- end
-
- def switch?(arg)
- switch_option(normalize_switch(arg))
- end
-
- def switch_option(arg)
- if match = no_or_skip?(arg)
- @switches[arg] || @switches["--#{match}"]
- else
- @switches[arg]
- end
- end
-
- # Check if the given argument is actually a shortcut.
- #
- def normalize_switch(arg)
- (@shorts[arg] || arg).tr('_', '-')
- end
-
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
- #
- def parse_boolean(switch)
- if current_is_value?
- if ["true", "TRUE", "t", "T", true].include?(peek)
- shift
- true
- elsif ["false", "FALSE", "f", "F", false].include?(peek)
- shift
- false
- else
- true
- end
- else
- @switches.key?(switch) || !no_or_skip?(switch)
- end
- end
-
- # Parse the value at the peek analyzing if it requires an input or not.
- #
- def parse_peek(switch, option)
- if current_is_switch_formatted? || last?
- if option.boolean?
- # No problem for boolean types
- elsif no_or_skip?(switch)
- return nil # User set value to nil
- elsif option.string? && !option.required?
- # Return the default if there is one, else the human name
- return option.lazy_default || option.default || option.human_name
- elsif option.lazy_default
- return option.lazy_default
- else
- raise MalformattedArgumentError, "No value provided for option '#{switch}'"
- end
- end
-
- @non_assigned_required.delete(option)
- send(:"parse_#{option.type}", switch)
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/rake_compat.rb b/lib/bundler/vendor/thor/rake_compat.rb
deleted file mode 100644
index c86e840..0000000
--- a/lib/bundler/vendor/thor/rake_compat.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-require 'rake'
-require 'rake/dsl_definition'
-
-class Thor
- # Adds a compatibility layer to your Thor classes which allows you to use
- # rake package tasks. For example, to use rspec rake tasks, one can do:
- #
- # require 'thor/rake_compat'
- #
- # class Default < Thor
- # include Thor::RakeCompat
- #
- # Spec::Rake::SpecTask.new(:spec) do |t|
- # t.spec_opts = ['--options', "spec/spec.opts"]
- # t.spec_files = FileList['spec/**/*_spec.rb']
- # end
- # end
- #
- module RakeCompat
- include Rake::DSL if defined?(Rake::DSL)
-
- def self.rake_classes
- @rake_classes ||= []
- end
-
- def self.included(base)
- # Hack. Make rakefile point to invoker, so rdoc task is generated properly.
- rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
- Rake.application.instance_variable_set(:@rakefile, rakefile)
- self.rake_classes << base
- end
- end
-end
-
-# override task on (main), for compatibility with Rake 0.9
-self.instance_eval do
- alias rake_namespace namespace
-
- def task(*)
- task = super
-
- if klass = Thor::RakeCompat.rake_classes.last
- non_namespaced_name = task.name.split(':').last
-
- description = non_namespaced_name
- description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
- description.strip!
-
- klass.desc description, Rake.application.last_description || non_namespaced_name
- Rake.application.last_description = nil
- klass.send :define_method, non_namespaced_name do |*args|
- Rake::Task[task.name.to_sym].invoke(*args)
- end
- end
-
- task
- end
-
- def namespace(name)
- if klass = Thor::RakeCompat.rake_classes.last
- const_name = Thor::Util.camel_case(name.to_s).to_sym
- klass.const_set(const_name, Class.new(Thor))
- new_klass = klass.const_get(const_name)
- Thor::RakeCompat.rake_classes << new_klass
- end
-
- super
- Thor::RakeCompat.rake_classes.pop
- end
-end
-
diff --git a/lib/bundler/vendor/thor/runner.rb b/lib/bundler/vendor/thor/runner.rb
deleted file mode 100644
index d69fba1..0000000
--- a/lib/bundler/vendor/thor/runner.rb
+++ /dev/null
@@ -1,321 +0,0 @@
-require 'thor'
-require 'thor/group'
-require 'thor/core_ext/file_binary_read'
-
-require 'fileutils'
-require 'open-uri'
-require 'yaml'
-require 'digest/md5'
-require 'pathname'
-
-class Thor::Runner < Thor #:nodoc:
- map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
-
- # Override Thor#help so it can give information about any class and any method.
- #
- def help(meth = nil)
- if meth && !self.respond_to?(meth)
- initialize_thorfiles(meth)
- klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
- self.class.handle_no_task_error(task, false) if klass.nil?
- klass.start(["-h", task].compact, :shell => self.shell)
- else
- super
- end
- end
-
- # If a task is not found on Thor::Runner, method missing is invoked and
- # Thor::Runner is then responsable for finding the task in all classes.
- #
- def method_missing(meth, *args)
- meth = meth.to_s
- initialize_thorfiles(meth)
- klass, task = Thor::Util.find_class_and_task_by_namespace(meth)
- self.class.handle_no_task_error(task, false) if klass.nil?
- args.unshift(task) if task
- klass.start(args, :shell => self.shell)
- end
-
- desc "install NAME", "Install an optionally named Thor file into your system tasks"
- method_options :as => :string, :relative => :boolean, :force => :boolean
- def install(name)
- initialize_thorfiles
-
- # If a directory name is provided as the argument, look for a 'main.thor'
- # task in said directory.
- begin
- if File.directory?(File.expand_path(name))
- base, package = File.join(name, "main.thor"), :directory
- contents = open(base) {|input| input.read }
- else
- base, package = name, :file
- contents = open(name) {|input| input.read }
- end
- rescue OpenURI::HTTPError
- raise Error, "Error opening URI '#{name}'"
- rescue Errno::ENOENT
- raise Error, "Error opening file '#{name}'"
- end
-
- say "Your Thorfile contains:"
- say contents
-
- unless options["force"]
- return false if no?("Do you wish to continue [y/N]?")
- end
-
- as = options["as"] || begin
- first_line = contents.split("\n")[0]
- (match = first_line.match(/\s*#\s*module:\s*([^\n]*)/)) ? match[1].strip : nil
- end
-
- unless as
- basename = File.basename(name)
- as = ask("Please specify a name for #{name} in the system repository [#{basename}]:")
- as = basename if as.empty?
- end
-
- location = if options[:relative] || name =~ /^https?:\/\//
- name
- else
- File.expand_path(name)
- end
-
- thor_yaml[as] = {
- :filename => Digest::MD5.hexdigest(name + as),
- :location => location,
- :namespaces => Thor::Util.namespaces_in_content(contents, base)
- }
-
- save_yaml(thor_yaml)
- say "Storing thor file in your system repository"
- destination = File.join(thor_root, thor_yaml[as][:filename])
-
- if package == :file
- File.open(destination, "w") { |f| f.puts contents }
- else
- FileUtils.cp_r(name, destination)
- end
-
- thor_yaml[as][:filename] # Indicate success
- end
-
- desc "version", "Show Thor version"
- def version
- require 'thor/version'
- say "Thor #{Thor::VERSION}"
- end
-
- desc "uninstall NAME", "Uninstall a named Thor module"
- def uninstall(name)
- raise Error, "Can't find module '#{name}'" unless thor_yaml[name]
- say "Uninstalling #{name}."
- FileUtils.rm_rf(File.join(thor_root, "#{thor_yaml[name][:filename]}"))
-
- thor_yaml.delete(name)
- save_yaml(thor_yaml)
-
- puts "Done."
- end
-
- desc "update NAME", "Update a Thor file from its original location"
- def update(name)
- raise Error, "Can't find module '#{name}'" if !thor_yaml[name] || !thor_yaml[name][:location]
-
- say "Updating '#{name}' from #{thor_yaml[name][:location]}"
-
- old_filename = thor_yaml[name][:filename]
- self.options = self.options.merge("as" => name)
-
- if File.directory? File.expand_path(name)
- FileUtils.rm_rf(File.join(thor_root, old_filename))
-
- thor_yaml.delete(old_filename)
- save_yaml(thor_yaml)
-
- filename = install(name)
- else
- filename = install(thor_yaml[name][:location])
- end
-
- unless filename == old_filename
- File.delete(File.join(thor_root, old_filename))
- end
- end
-
- desc "installed", "List the installed Thor modules and tasks"
- method_options :internal => :boolean
- def installed
- initialize_thorfiles(nil, true)
- display_klasses(true, options["internal"])
- end
-
- desc "list [SEARCH]", "List the available thor tasks (--substring means .*SEARCH)"
- method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
- def list(search="")
- initialize_thorfiles
-
- search = ".*#{search}" if options["substring"]
- search = /^#{search}.*/i
- group = options[:group] || "standard"
-
- klasses = Thor::Base.subclasses.select do |k|
- (options[:all] || k.group == group) && k.namespace =~ search
- end
-
- display_klasses(false, false, klasses)
- end
-
- private
-
- def self.banner(task, all = false, subcommand = false)
- "thor " + task.formatted_usage(self, all, subcommand)
- end
-
- def thor_root
- Thor::Util.thor_root
- end
-
- def thor_yaml
- @thor_yaml ||= begin
- yaml_file = File.join(thor_root, "thor.yml")
- yaml = YAML.load_file(yaml_file) if File.exists?(yaml_file)
- yaml || {}
- end
- end
-
- # Save the yaml file. If none exists in thor root, creates one.
- #
- def save_yaml(yaml)
- yaml_file = File.join(thor_root, "thor.yml")
-
- unless File.exists?(yaml_file)
- FileUtils.mkdir_p(thor_root)
- yaml_file = File.join(thor_root, "thor.yml")
- FileUtils.touch(yaml_file)
- end
-
- File.open(yaml_file, "w") { |f| f.puts yaml.to_yaml }
- end
-
- def self.exit_on_failure?
- true
- end
-
- # Load the Thorfiles. If relevant_to is supplied, looks for specific files
- # in the thor_root instead of loading them all.
- #
- # By default, it also traverses the current path until find Thor files, as
- # described in thorfiles. This look up can be skipped by suppliying
- # skip_lookup true.
- #
- def initialize_thorfiles(relevant_to=nil, skip_lookup=false)
- thorfiles(relevant_to, skip_lookup).each do |f|
- Thor::Util.load_thorfile(f, nil, options[:debug]) unless Thor::Base.subclass_files.keys.include?(File.expand_path(f))
- end
- end
-
- # Finds Thorfiles by traversing from your current directory down to the root
- # directory of your system. If at any time we find a Thor file, we stop.
- #
- # We also ensure that system-wide Thorfiles are loaded first, so local
- # Thorfiles can override them.
- #
- # ==== Example
- #
- # If we start at /Users/wycats/dev/thor ...
- #
- # 1. /Users/wycats/dev/thor
- # 2. /Users/wycats/dev
- # 3. /Users/wycats <-- we find a Thorfile here, so we stop
- #
- # Suppose we start at c:\Documents and Settings\james\dev\thor ...
- #
- # 1. c:\Documents and Settings\james\dev\thor
- # 2. c:\Documents and Settings\james\dev
- # 3. c:\Documents and Settings\james
- # 4. c:\Documents and Settings
- # 5. c:\ <-- no Thorfiles found!
- #
- def thorfiles(relevant_to=nil, skip_lookup=false)
- thorfiles = []
-
- unless skip_lookup
- Pathname.pwd.ascend do |path|
- thorfiles = Thor::Util.globs_for(path).map { |g| Dir[g] }.flatten
- break unless thorfiles.empty?
- end
- end
-
- files = (relevant_to ? thorfiles_relevant_to(relevant_to) : Thor::Util.thor_root_glob)
- files += thorfiles
- files -= ["#{thor_root}/thor.yml"]
-
- files.map! do |file|
- File.directory?(file) ? File.join(file, "main.thor") : file
- end
- end
-
- # Load Thorfiles relevant to the given method. If you provide "foo:bar" it
- # will load all thor files in the thor.yaml that has "foo" e "foo:bar"
- # namespaces registered.
- #
- def thorfiles_relevant_to(meth)
- lookup = [ meth, meth.split(":")[0...-1].join(":") ]
-
- files = thor_yaml.select do |k, v|
- v[:namespaces] && !(v[:namespaces] & lookup).empty?
- end
-
- files.map { |k, v| File.join(thor_root, "#{v[:filename]}") }
- end
-
- # Display information about the given klasses. If with_module is given,
- # it shows a table with information extracted from the yaml file.
- #
- def display_klasses(with_modules=false, show_internal=false, klasses=Thor::Base.subclasses)
- klasses -= [Thor, Thor::Runner, Thor::Group] unless show_internal
-
- raise Error, "No Thor tasks available" if klasses.empty?
- show_modules if with_modules && !thor_yaml.empty?
-
- list = Hash.new { |h,k| h[k] = [] }
- groups = klasses.select { |k| k.ancestors.include?(Thor::Group) }
-
- # Get classes which inherit from Thor
- (klasses - groups).each { |k| list[k.namespace.split(":").first] += k.printable_tasks(false) }
-
- # Get classes which inherit from Thor::Base
- groups.map! { |k| k.printable_tasks(false).first }
- list["root"] = groups
-
- # Order namespaces with default coming first
- list = list.sort{ |a,b| a[0].sub(/^default/, '') <=> b[0].sub(/^default/, '') }
- list.each { |n, tasks| display_tasks(n, tasks) unless tasks.empty? }
- end
-
- def display_tasks(namespace, list) #:nodoc:
- list.sort!{ |a,b| a[0] <=> b[0] }
-
- say shell.set_color(namespace, :blue, true)
- say "-" * namespace.size
-
- print_table(list, :truncate => true)
- say
- end
-
- def show_modules #:nodoc:
- info = []
- labels = ["Modules", "Namespaces"]
-
- info << labels
- info << [ "-" * labels[0].size, "-" * labels[1].size ]
-
- thor_yaml.each do |name, hash|
- info << [ name, hash[:namespaces].join(", ") ]
- end
-
- print_table info
- say ""
- end
-end
diff --git a/lib/bundler/vendor/thor/shell.rb b/lib/bundler/vendor/thor/shell.rb
deleted file mode 100644
index a718c53..0000000
--- a/lib/bundler/vendor/thor/shell.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-require 'rbconfig'
-
-class Thor
- module Base
- # Returns the shell used in all Thor classes. If you are in a Unix platform
- # it will use a colored log, otherwise it will use a basic one without color.
- #
- def self.shell
- @shell ||= if ENV['THOR_SHELL'] && ENV['THOR_SHELL'].size > 0
- Thor::Shell.const_get(ENV['THOR_SHELL'])
- elsif ((RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) && !(ENV['ANSICON']))
- Thor::Shell::Basic
- else
- Thor::Shell::Color
- end
- end
-
- # Sets the shell used in all Thor classes.
- #
- def self.shell=(klass)
- @shell = klass
- end
- end
-
- module Shell
- SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
-
- autoload :Basic, 'thor/shell/basic'
- autoload :Color, 'thor/shell/color'
- autoload :HTML, 'thor/shell/html'
-
- # Add shell to initialize config values.
- #
- # ==== Configuration
- # shell<Object>:: An instance of the shell to be used.
- #
- # ==== Examples
- #
- # class MyScript < Thor
- # argument :first, :type => :numeric
- # end
- #
- # MyScript.new [1.0], { :foo => :bar }, :shell => Thor::Shell::Basic.new
- #
- def initialize(args=[], options={}, config={})
- super
- self.shell = config[:shell]
- self.shell.base ||= self if self.shell.respond_to?(:base)
- end
-
- # Holds the shell for the given Thor instance. If no shell is given,
- # it gets a default shell from Thor::Base.shell.
- def shell
- @shell ||= Thor::Base.shell.new
- end
-
- # Sets the shell for this thor class.
- def shell=(shell)
- @shell = shell
- end
-
- # Common methods that are delegated to the shell.
- SHELL_DELEGATED_METHODS.each do |method|
- module_eval <<-METHOD, __FILE__, __LINE__
- def #{method}(*args,&block)
- shell.#{method}(*args,&block)
- end
- METHOD
- end
-
- # Yields the given block with padding.
- def with_padding
- shell.padding += 1
- yield
- ensure
- shell.padding -= 1
- end
-
- protected
-
- # Allow shell to be shared between invocations.
- #
- def _shared_configuration #:nodoc:
- super.merge!(:shell => self.shell)
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/shell/basic.rb b/lib/bundler/vendor/thor/shell/basic.rb
deleted file mode 100644
index 3c5904b..0000000
--- a/lib/bundler/vendor/thor/shell/basic.rb
+++ /dev/null
@@ -1,389 +0,0 @@
-require 'tempfile'
-
-class Thor
- module Shell
- class Basic
- attr_accessor :base
- attr_reader :padding
-
- # Initialize base, mute and padding to nil.
- #
- def initialize #:nodoc:
- @base, @mute, @padding = nil, false, 0
- end
-
- # Mute everything that's inside given block
- #
- def mute
- @mute = true
- yield
- ensure
- @mute = false
- end
-
- # Check if base is muted
- #
- def mute?
- @mute
- end
-
- # Sets the output padding, not allowing less than zero values.
- #
- def padding=(value)
- @padding = [0, value].max
- end
-
- # Asks something to the user and receives a response.
- #
- # If asked to limit the correct responses, you can pass in an
- # array of acceptable answers. If one of those is not supplied,
- # they will be shown a message stating that one of those answers
- # must be given and re-asked the question.
- #
- # ==== Example
- # ask("What is your name?")
- #
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
- #
- def ask(statement, *args)
- options = args.last.is_a?(Hash) ? args.pop : {}
-
- options[:limited_to] ? ask_filtered(statement, options[:limited_to], *args) : ask_simply(statement, *args)
- end
-
- # Say (print) something to the user. If the sentence ends with a whitespace
- # or tab character, a new line is not appended (print + flush). Otherwise
- # are passed straight to puts (behavior got from Highline).
- #
- # ==== Example
- # say("I know you knew that.")
- #
- def say(message="", color=nil, force_new_line=(message.to_s !~ /( |\t)$/))
- message = message.to_s
-
- message = set_color(message, *color) if color
-
- spaces = " " * padding
-
- if force_new_line
- stdout.puts(spaces + message)
- else
- stdout.print(spaces + message)
- end
- stdout.flush
- end
-
- # Say a status with the given color and appends the message. Since this
- # method is used frequently by actions, it allows nil or false to be given
- # in log_status, avoiding the message from being shown. If a Symbol is
- # given in log_status, it's used as the color.
- #
- def say_status(status, message, log_status=true)
- return if quiet? || log_status == false
- spaces = " " * (padding + 1)
- color = log_status.is_a?(Symbol) ? log_status : :green
-
- status = status.to_s.rjust(12)
- status = set_color status, color, true if color
-
- stdout.puts "#{status}#{spaces}#{message}"
- stdout.flush
- end
-
- # Make a question the to user and returns true if the user replies "y" or
- # "yes".
- #
- def yes?(statement, color=nil)
- !!(ask(statement, color) =~ is?(:yes))
- end
-
- # Make a question the to user and returns true if the user replies "n" or
- # "no".
- #
- def no?(statement, color=nil)
- !yes?(statement, color)
- end
-
- # Prints values in columns
- #
- # ==== Parameters
- # Array[String, String, ...]
- #
- def print_in_columns(array)
- return if array.empty?
- colwidth = (array.map{|el| el.to_s.size}.max || 0) + 2
- array.each_with_index do |value, index|
- # Don't output trailing spaces when printing the last column
- if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
- stdout.puts value
- else
- stdout.printf("%-#{colwidth}s", value)
- end
- end
- end
-
- # Prints a table.
- #
- # ==== Parameters
- # Array[Array[String, String, ...]]
- #
- # ==== Options
- # indent<Integer>:: Indent the first column by indent value.
- # colwidth<Integer>:: Force the first column to colwidth spaces wide.
- #
- def print_table(array, options={})
- return if array.empty?
-
- formats, indent, colwidth = [], options[:indent].to_i, options[:colwidth]
- options[:truncate] = terminal_width if options[:truncate] == true
-
- formats << "%-#{colwidth + 2}s" if colwidth
- start = colwidth ? 1 : 0
-
- colcount = array.max{|a,b| a.size <=> b.size }.size
-
- maximas = []
-
- start.upto(colcount - 1) do |index|
- maxima = array.map {|row| row[index] ? row[index].to_s.size : 0 }.max
- maximas << maxima
- if index == colcount - 1
- # Don't output 2 trailing spaces when printing the last column
- formats << "%-s"
- else
- formats << "%-#{maxima + 2}s"
- end
- end
-
- formats[0] = formats[0].insert(0, " " * indent)
- formats << "%s"
-
- array.each do |row|
- sentence = ""
-
- row.each_with_index do |column, index|
- maxima = maximas[index]
-
- if column.is_a?(Numeric)
- if index == row.size - 1
- # Don't output 2 trailing spaces when printing the last column
- f = "%#{maxima}s"
- else
- f = "%#{maxima}s "
- end
- else
- f = formats[index]
- end
- sentence << f % column.to_s
- end
-
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
- stdout.puts sentence
- end
- end
-
- # Prints a long string, word-wrapping the text to the current width of the
- # terminal display. Ideal for printing heredocs.
- #
- # ==== Parameters
- # String
- #
- # ==== Options
- # indent<Integer>:: Indent each line of the printed paragraph by indent value.
- #
- def print_wrapped(message, options={})
- indent = options[:indent] || 0
- width = terminal_width - indent
- paras = message.split("\n\n")
-
- paras.map! do |unwrapped|
- unwrapped.strip.gsub(/\n/, " ").squeeze(" ").
- gsub(/.{1,#{width}}(?:\s|\Z)/){($& + 5.chr).
- gsub(/\n\005/,"\n").gsub(/\005/,"\n")}
- end
-
- paras.each do |para|
- para.split("\n").each do |line|
- stdout.puts line.insert(0, " " * indent)
- end
- stdout.puts unless para == paras.last
- end
- end
-
- # Deals with file collision and returns true if the file should be
- # overwritten and false otherwise. If a block is given, it uses the block
- # response as the content for the diff.
- #
- # ==== Parameters
- # destination<String>:: the destination file to solve conflicts
- # block<Proc>:: an optional block that returns the value to be used in diff
- #
- def file_collision(destination)
- return true if @always_force
- options = block_given? ? "[Ynaqdh]" : "[Ynaqh]"
-
- while true
- answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}]
-
- case answer
- when is?(:yes), is?(:force), ""
- return true
- when is?(:no), is?(:skip)
- return false
- when is?(:always)
- return @always_force = true
- when is?(:quit)
- say 'Aborting...'
- raise SystemExit
- when is?(:diff)
- show_diff(destination, yield) if block_given?
- say 'Retrying...'
- else
- say file_collision_help
- end
- end
- end
-
- # This code was copied from Rake, available under MIT-LICENSE
- # Copyright (c) 2003, 2004 Jim Weirich
- def terminal_width
- if ENV['THOR_COLUMNS']
- result = ENV['THOR_COLUMNS'].to_i
- else
- result = unix? ? dynamic_width : 80
- end
- (result < 10) ? 80 : result
- rescue
- 80
- end
-
- # Called if something goes wrong during the execution. This is used by Thor
- # internally and should not be used inside your scripts. If something went
- # wrong, you can always raise an exception. If you raise a Thor::Error, it
- # will be rescued and wrapped in the method below.
- #
- def error(statement)
- stderr.puts statement
- end
-
- # Apply color to the given string with optional bold. Disabled in the
- # Thor::Shell::Basic class.
- #
- def set_color(string, *args) #:nodoc:
- string
- end
-
- protected
-
- def lookup_color(color)
- return color unless color.is_a?(Symbol)
- self.class.const_get(color.to_s.upcase)
- end
-
- def stdout
- $stdout
- end
-
- def stdin
- $stdin
- end
-
- def stderr
- $stderr
- end
-
- def is?(value) #:nodoc:
- value = value.to_s
-
- if value.size == 1
- /\A#{value}\z/i
- else
- /\A(#{value}|#{value[0,1]})\z/i
- end
- end
-
- def file_collision_help #:nodoc:
-<<HELP
-Y - yes, overwrite
-n - no, do not overwrite
-a - all, overwrite this and all others
-q - quit, abort
-d - diff, show the differences between the old and the new
-h - help, show this help
-HELP
- end
-
- def show_diff(destination, content) #:nodoc:
- diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
-
- Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
- temp.write content
- temp.rewind
- system %(#{diff_cmd} "#{destination}" "#{temp.path}")
- end
- end
-
- def quiet? #:nodoc:
- mute? || (base && base.options[:quiet])
- end
-
- # Calculate the dynamic width of the terminal
- def dynamic_width
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
- end
-
- def dynamic_width_stty
- %x{stty size 2>/dev/null}.split[1].to_i
- end
-
- def dynamic_width_tput
- %x{tput cols 2>/dev/null}.to_i
- end
-
- def unix?
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
- end
-
- def truncate(string, width)
- as_unicode do
- chars = string.chars.to_a
- if chars.length <= width
- chars.join
- else
- ( chars[0, width-3].join ) + "..."
- end
- end
- end
-
- if "".respond_to?(:encode)
- def as_unicode
- yield
- end
- else
- def as_unicode
- old, $KCODE = $KCODE, "U"
- yield
- ensure
- $KCODE = old
- end
- end
-
- def ask_simply(statement, color=nil)
- say("#{statement} ", color)
- stdin.gets.strip
- end
-
- def ask_filtered(statement, answer_set, *args)
- correct_answer = nil
- until correct_answer
- answer = ask_simply("#{statement} #{answer_set.inspect}", *args)
- correct_answer = answer_set.include?(answer) ? answer : nil
- answers = answer_set.map(&:inspect).join(", ")
- say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
- end
- correct_answer
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/shell/color.rb b/lib/bundler/vendor/thor/shell/color.rb
deleted file mode 100644
index f24ab6c..0000000
--- a/lib/bundler/vendor/thor/shell/color.rb
+++ /dev/null
@@ -1,144 +0,0 @@
-require 'thor/shell/basic'
-
-class Thor
- module Shell
- # Inherit from Thor::Shell::Basic and add set_color behavior. Check
- # Thor::Shell::Basic to see all available methods.
- #
- class Color < Basic
- # Embed in a String to clear all previous ANSI sequences.
- CLEAR = "\e[0m"
- # The start of an ANSI bold sequence.
- BOLD = "\e[1m"
-
- # Set the terminal's foreground ANSI color to black.
- BLACK = "\e[30m"
- # Set the terminal's foreground ANSI color to red.
- RED = "\e[31m"
- # Set the terminal's foreground ANSI color to green.
- GREEN = "\e[32m"
- # Set the terminal's foreground ANSI color to yellow.
- YELLOW = "\e[33m"
- # Set the terminal's foreground ANSI color to blue.
- BLUE = "\e[34m"
- # Set the terminal's foreground ANSI color to magenta.
- MAGENTA = "\e[35m"
- # Set the terminal's foreground ANSI color to cyan.
- CYAN = "\e[36m"
- # Set the terminal's foreground ANSI color to white.
- WHITE = "\e[37m"
-
- # Set the terminal's background ANSI color to black.
- ON_BLACK = "\e[40m"
- # Set the terminal's background ANSI color to red.
- ON_RED = "\e[41m"
- # Set the terminal's background ANSI color to green.
- ON_GREEN = "\e[42m"
- # Set the terminal's background ANSI color to yellow.
- ON_YELLOW = "\e[43m"
- # Set the terminal's background ANSI color to blue.
- ON_BLUE = "\e[44m"
- # Set the terminal's background ANSI color to magenta.
- ON_MAGENTA = "\e[45m"
- # Set the terminal's background ANSI color to cyan.
- ON_CYAN = "\e[46m"
- # Set the terminal's background ANSI color to white.
- ON_WHITE = "\e[47m"
-
- # Set color by using a string or one of the defined constants. If a third
- # option is set to true, it also adds bold to the string. This is based
- # on Highline implementation and it automatically appends CLEAR to the end
- # of the returned String.
- #
- # Pass foreground, background and bold options to this method as
- # symbols.
- #
- # Example:
- #
- # set_color "Hi!", :red, :on_white, :bold
- #
- # The available colors are:
- #
- # :bold
- # :black
- # :red
- # :green
- # :yellow
- # :blue
- # :magenta
- # :cyan
- # :white
- # :on_black
- # :on_red
- # :on_green
- # :on_yellow
- # :on_blue
- # :on_magenta
- # :on_cyan
- # :on_white
- def set_color(string, *colors)
- if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
- ansi_colors = colors.map { |color| lookup_color(color) }
- "#{ansi_colors.join}#{string}#{CLEAR}"
- else
- # The old API was `set_color(color, bold=boolean)`. We
- # continue to support the old API because you should never
- # break old APIs unnecessarily :P
- foreground, bold = colors
- foreground = self.class.const_get(foreground.to_s.upcase) if foreground.is_a?(Symbol)
-
- bold = bold ? BOLD : ""
- "#{bold}#{foreground}#{string}#{CLEAR}"
- end
- end
-
- protected
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when '-'
- say "- #{diff.old_element.chomp}", :red, true
- when '+'
- say "+ #{diff.new_element.chomp}", :green, true
- when '!'
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require 'diff/lcs'
- true
- rescue LoadError
- false
- end
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/shell/html.rb b/lib/bundler/vendor/thor/shell/html.rb
deleted file mode 100644
index 678bc89..0000000
--- a/lib/bundler/vendor/thor/shell/html.rb
+++ /dev/null
@@ -1,123 +0,0 @@
-require 'thor/shell/basic'
-
-class Thor
- module Shell
- # Inherit from Thor::Shell::Basic and add set_color behavior. Check
- # Thor::Shell::Basic to see all available methods.
- #
- class HTML < Basic
- # The start of an HTML bold sequence.
- BOLD = "font-weight: bold"
-
- # Set the terminal's foreground HTML color to black.
- BLACK = 'color: black'
- # Set the terminal's foreground HTML color to red.
- RED = 'color: red'
- # Set the terminal's foreground HTML color to green.
- GREEN = 'color: green'
- # Set the terminal's foreground HTML color to yellow.
- YELLOW = 'color: yellow'
- # Set the terminal's foreground HTML color to blue.
- BLUE = 'color: blue'
- # Set the terminal's foreground HTML color to magenta.
- MAGENTA = 'color: magenta'
- # Set the terminal's foreground HTML color to cyan.
- CYAN = 'color: cyan'
- # Set the terminal's foreground HTML color to white.
- WHITE = 'color: white'
-
- # Set the terminal's background HTML color to black.
- ON_BLACK = 'background-color: black'
- # Set the terminal's background HTML color to red.
- ON_RED = 'background-color: red'
- # Set the terminal's background HTML color to green.
- ON_GREEN = 'background-color: green'
- # Set the terminal's background HTML color to yellow.
- ON_YELLOW = 'background-color: yellow'
- # Set the terminal's background HTML color to blue.
- ON_BLUE = 'background-color: blue'
- # Set the terminal's background HTML color to magenta.
- ON_MAGENTA = 'background-color: magenta'
- # Set the terminal's background HTML color to cyan.
- ON_CYAN = 'background-color: cyan'
- # Set the terminal's background HTML color to white.
- ON_WHITE = 'background-color: white'
-
- # Set color by using a string or one of the defined constants. If a third
- # option is set to true, it also adds bold to the string. This is based
- # on Highline implementation and it automatically appends CLEAR to the end
- # of the returned String.
- #
- def set_color(string, *colors)
- if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
- html_colors = colors.map { |color| lookup_color(color) }
- "<span style=\"#{html_colors.join("; ")};\">#{string}</span>"
- else
- color, bold = colors
- html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
- styles = [html_color]
- styles << BOLD if bold
- "<span style=\"#{styles.join("; ")};\">#{string}</span>"
- end
- end
-
- # Ask something to the user and receives a response.
- #
- # ==== Example
- # ask("What is your name?")
- #
- # TODO: Implement #ask for Thor::Shell::HTML
- def ask(statement, color=nil)
- raise NotImplementedError, "Implement #ask for Thor::Shell::HTML"
- end
-
- protected
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV['THOR_DIFF'].nil? && ENV['RAILS_DIFF'].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when '-'
- say "- #{diff.old_element.chomp}", :red, true
- when '+'
- say "+ #{diff.new_element.chomp}", :green, true
- when '!'
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require 'diff/lcs'
- true
- rescue LoadError
- false
- end
- end
-
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/task.rb b/lib/bundler/vendor/thor/task.rb
deleted file mode 100644
index 02daa1a..0000000
--- a/lib/bundler/vendor/thor/task.rb
+++ /dev/null
@@ -1,132 +0,0 @@
-class Thor
- class Task < Struct.new(:name, :description, :long_description, :usage, :options)
- FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
-
- def initialize(name, description, long_description, usage, options=nil)
- super(name.to_s, description, long_description, usage, options || {})
- end
-
- def initialize_copy(other) #:nodoc:
- super(other)
- self.options = other.options.dup if other.options
- end
-
- def hidden?
- false
- end
-
- # By default, a task invokes a method in the thor class. You can change this
- # implementation to create custom tasks.
- def run(instance, args=[])
- arity = nil
-
- if private_method?(instance)
- instance.class.handle_no_task_error(name)
- elsif public_method?(instance)
- arity = instance.method(name).arity
- instance.send(name, *args)
- elsif local_method?(instance, :method_missing)
- instance.send(:method_missing, name.to_sym, *args)
- else
- instance.class.handle_no_task_error(name)
- end
- rescue ArgumentError => e
- handle_argument_error?(instance, e, caller) ?
- instance.class.handle_argument_error(self, e, arity) : (raise e)
- rescue NoMethodError => e
- handle_no_method_error?(instance, e, caller) ?
- instance.class.handle_no_task_error(name) : (raise e)
- end
-
- # Returns the formatted usage by injecting given required arguments
- # and required options into the given usage.
- def formatted_usage(klass, namespace = true, subcommand = false)
- if namespace
- namespace = klass.namespace
- formatted = "#{namespace.gsub(/^(default)/,'')}:"
- end
- formatted = "#{klass.namespace.split(':').last} " if subcommand
-
- formatted ||= ""
-
- # Add usage with required arguments
- formatted << if klass && !klass.arguments.empty?
- usage.to_s.gsub(/^#{name}/) do |match|
- match << " " << klass.arguments.map{ |a| a.usage }.compact.join(' ')
- end
- else
- usage.to_s
- end
-
- # Add required options
- formatted << " #{required_options}"
-
- # Strip and go!
- formatted.strip
- end
-
- protected
-
- def not_debugging?(instance)
- !(instance.class.respond_to?(:debugging) && instance.class.debugging)
- end
-
- def required_options
- @required_options ||= options.map{ |_, o| o.usage if o.required? }.compact.sort.join(" ")
- end
-
- # Given a target, checks if this class name is a public method.
- def public_method?(instance) #:nodoc:
- !(instance.public_methods & [name.to_s, name.to_sym]).empty?
- end
-
- def private_method?(instance)
- !(instance.private_methods & [name.to_s, name.to_sym]).empty?
- end
-
- def local_method?(instance, name)
- methods = instance.public_methods(false) + instance.private_methods(false) + instance.protected_methods(false)
- !(methods & [name.to_s, name.to_sym]).empty?
- end
-
- def sans_backtrace(backtrace, caller) #:nodoc:
- saned = backtrace.reject { |frame| frame =~ FILE_REGEXP || (frame =~ /\.java:/ && RUBY_PLATFORM =~ /java/) }
- saned -= caller
- end
-
- def handle_argument_error?(instance, error, caller)
- not_debugging?(instance) && error.message =~ /wrong number of arguments/ && begin
- saned = sans_backtrace(error.backtrace, caller)
- # Ruby 1.9 always include the called method in the backtrace
- saned.empty? || (saned.size == 1 && RUBY_VERSION >= "1.9")
- end
- end
-
- def handle_no_method_error?(instance, error, caller)
- not_debugging?(instance) &&
- error.message =~ /^undefined method `#{name}' for #{Regexp.escape(instance.to_s)}$/
- end
- end
-
- # A task that is hidden in help messages but still invocable.
- class HiddenTask < Task
- def hidden?
- true
- end
- end
-
- # A dynamic task that handles method missing scenarios.
- class DynamicTask < Task
- def initialize(name, options=nil)
- super(name.to_s, "A dynamically-generated task", name.to_s, name.to_s, options)
- end
-
- def run(instance, args=[])
- if (instance.methods & [name.to_s, name.to_sym]).empty?
- super
- else
- instance.class.handle_no_task_error(name)
- end
- end
- end
-end
diff --git a/lib/bundler/vendor/thor/util.rb b/lib/bundler/vendor/thor/util.rb
deleted file mode 100644
index d45843d..0000000
--- a/lib/bundler/vendor/thor/util.rb
+++ /dev/null
@@ -1,266 +0,0 @@
-require 'rbconfig'
-
-class Thor
- module Sandbox #:nodoc:
- end
-
- # This module holds several utilities:
- #
- # 1) Methods to convert thor namespaces to constants and vice-versa.
- #
- # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz"
- #
- # 2) Loading thor files and sandboxing:
- #
- # Thor::Util.load_thorfile("~/.thor/foo")
- #
- module Util
-
- # Receives a namespace and search for it in the Thor::Base subclasses.
- #
- # ==== Parameters
- # namespace<String>:: The namespace to search for.
- #
- def self.find_by_namespace(namespace)
- namespace = "default#{namespace}" if namespace.empty? || namespace =~ /^:/
- Thor::Base.subclasses.find { |klass| klass.namespace == namespace }
- end
-
- # Receives a constant and converts it to a Thor namespace. Since Thor tasks
- # can be added to a sandbox, this method is also responsable for removing
- # the sandbox namespace.
- #
- # This method should not be used in general because it's used to deal with
- # older versions of Thor. On current versions, if you need to get the
- # namespace from a class, just call namespace on it.
- #
- # ==== Parameters
- # constant<Object>:: The constant to be converted to the thor path.
- #
- # ==== Returns
- # String:: If we receive Foo::Bar::Baz it returns "foo:bar:baz"
- #
- def self.namespace_from_thor_class(constant)
- constant = constant.to_s.gsub(/^Thor::Sandbox::/, "")
- constant = snake_case(constant).squeeze(":")
- constant
- end
-
- # Given the contents, evaluate it inside the sandbox and returns the
- # namespaces defined in the sandbox.
- #
- # ==== Parameters
- # contents<String>
- #
- # ==== Returns
- # Array[Object]
- #
- def self.namespaces_in_content(contents, file=__FILE__)
- old_constants = Thor::Base.subclasses.dup
- Thor::Base.subclasses.clear
-
- load_thorfile(file, contents)
-
- new_constants = Thor::Base.subclasses.dup
- Thor::Base.subclasses.replace(old_constants)
-
- new_constants.map!{ |c| c.namespace }
- new_constants.compact!
- new_constants
- end
-
- # Returns the thor classes declared inside the given class.
- #
- def self.thor_classes_in(klass)
- stringfied_constants = klass.constants.map { |c| c.to_s }
- Thor::Base.subclasses.select do |subclass|
- next unless subclass.name
- stringfied_constants.include?(subclass.name.gsub("#{klass.name}::", ''))
- end
- end
-
- # Receives a string and convert it to snake case. SnakeCase returns snake_case.
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def self.snake_case(str)
- return str.downcase if str =~ /^[A-Z_]+$/
- str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/
- return $+.downcase
- end
-
- # Receives a string and convert it to camel case. camel_case returns CamelCase.
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def self.camel_case(str)
- return str if str !~ /_/ && str =~ /[A-Z]+.*/
- str.split('_').map { |i| i.capitalize }.join
- end
-
- # Receives a namespace and tries to retrieve a Thor or Thor::Group class
- # from it. It first searches for a class using the all the given namespace,
- # if it's not found, removes the highest entry and searches for the class
- # again. If found, returns the highest entry as the class name.
- #
- # ==== Examples
- #
- # class Foo::Bar < Thor
- # def baz
- # end
- # end
- #
- # class Baz::Foo < Thor::Group
- # end
- #
- # Thor::Util.namespace_to_thor_class("foo:bar") #=> Foo::Bar, nil # will invoke default task
- # Thor::Util.namespace_to_thor_class("baz:foo") #=> Baz::Foo, nil
- # Thor::Util.namespace_to_thor_class("foo:bar:baz") #=> Foo::Bar, "baz"
- #
- # ==== Parameters
- # namespace<String>
- #
- def self.find_class_and_task_by_namespace(namespace, fallback = true)
- if namespace.include?(?:) # look for a namespaced task
- pieces = namespace.split(":")
- task = pieces.pop
- klass = Thor::Util.find_by_namespace(pieces.join(":"))
- end
- unless klass # look for a Thor::Group with the right name
- klass, task = Thor::Util.find_by_namespace(namespace), nil
- end
- if !klass && fallback # try a task in the default namespace
- task = namespace
- klass = Thor::Util.find_by_namespace('')
- end
- return klass, task
- end
-
- # Receives a path and load the thor file in the path. The file is evaluated
- # inside the sandbox to avoid namespacing conflicts.
- #
- def self.load_thorfile(path, content=nil, debug=false)
- content ||= File.binread(path)
-
- begin
- Thor::Sandbox.class_eval(content, path)
- rescue Exception => e
- $stderr.puts("WARNING: unable to load thorfile #{path.inspect}: #{e.message}")
- if debug
- $stderr.puts(*e.backtrace)
- else
- $stderr.puts(e.backtrace.first)
- end
- end
- end
-
- def self.user_home
- @@user_home ||= if ENV["HOME"]
- ENV["HOME"]
- elsif ENV["USERPROFILE"]
- ENV["USERPROFILE"]
- elsif ENV["HOMEDRIVE"] && ENV["HOMEPATH"]
- File.join(ENV["HOMEDRIVE"], ENV["HOMEPATH"])
- elsif ENV["APPDATA"]
- ENV["APPDATA"]
- else
- begin
- File.expand_path("~")
- rescue
- if File::ALT_SEPARATOR
- "C:/"
- else
- "/"
- end
- end
- end
- end
-
- # Returns the root where thor files are located, depending on the OS.
- #
- def self.thor_root
- File.join(user_home, ".thor").gsub(/\\/, '/')
- end
-
- # Returns the files in the thor root. On Windows thor_root will be something
- # like this:
- #
- # C:\Documents and Settings\james\.thor
- #
- # If we don't #gsub the \ character, Dir.glob will fail.
- #
- def self.thor_root_glob
- files = Dir["#{escape_globs(thor_root)}/*"]
-
- files.map! do |file|
- File.directory?(file) ? File.join(file, "main.thor") : file
- end
- end
-
- # Where to look for Thor files.
- #
- def self.globs_for(path)
- path = escape_globs(path)
- ["#{path}/Thorfile", "#{path}/*.thor", "#{path}/tasks/*.thor", "#{path}/lib/tasks/*.thor"]
- end
-
- # Return the path to the ruby interpreter taking into account multiple
- # installations and windows extensions.
- #
- def self.ruby_command
- @ruby_command ||= begin
- ruby_name = RbConfig::CONFIG['ruby_install_name']
- ruby = File.join(RbConfig::CONFIG['bindir'], ruby_name)
- ruby << RbConfig::CONFIG['EXEEXT']
-
- # avoid using different name than ruby (on platforms supporting links)
- if ruby_name != 'ruby' && File.respond_to?(:readlink)
- begin
- alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
- alternate_ruby << RbConfig::CONFIG['EXEEXT']
-
- # ruby is a symlink
- if File.symlink? alternate_ruby
- linked_ruby = File.readlink alternate_ruby
-
- # symlink points to 'ruby_install_name'
- ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
- end
- rescue NotImplementedError
- # just ignore on windows
- end
- end
-
- # escape string in case path to ruby executable contain spaces.
- ruby.sub!(/.*\s.*/m, '"\&"')
- ruby
- end
- end
-
- # Returns a string that has had any glob characters escaped.
- # The glob characters are `* ? { } [ ]`.
- #
- # ==== Examples
- #
- # Thor::Util.escape_globs('[apps]') # => '\[apps\]'
- #
- # ==== Parameters
- # String
- #
- # ==== Returns
- # String
- #
- def self.escape_globs(path)
- path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
- end
-
- end
-end
diff --git a/lib/bundler/vendor/thor/version.rb b/lib/bundler/vendor/thor/version.rb
deleted file mode 100644
index 7e888f8..0000000
--- a/lib/bundler/vendor/thor/version.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Thor
- VERSION = "0.15.2"
-end
--
bundler.git
More information about the Pkg-ruby-extras-commits
mailing list