mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update vendored thor and ensure that content is completely modified before checking file collisions.
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
This commit is contained in:
parent
74be70039f
commit
28657e4f41
33 changed files with 38 additions and 36 deletions
|
@ -9,7 +9,7 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|||
require 'active_support/core_ext/string/inflections'
|
||||
|
||||
# TODO: Do not always push on vendored thor
|
||||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.12.0/lib")
|
||||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.12.1/lib")
|
||||
require 'rails/generators/base'
|
||||
require 'rails/generators/named_base'
|
||||
|
||||
|
|
|
@ -123,10 +123,10 @@ module Rails::Generators
|
|||
end
|
||||
|
||||
def create_script_files
|
||||
directory "script" do |file|
|
||||
prepend_file file, "#{shebang}\n", :verbose => false
|
||||
chmod file, 0755, :verbose => false
|
||||
directory "script" do |content|
|
||||
"#{shebang}\n" + content
|
||||
end
|
||||
chmod "script", 0755, :verbose => false
|
||||
end
|
||||
|
||||
def create_test_files
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
class Thor
|
||||
VERSION = "0.11.8".freeze
|
||||
end
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
* thor help now show information about any class/task. All those calls are
|
||||
possible:
|
||||
|
||||
|
||||
thor help describe
|
||||
thor help describe:amazing
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
|||
are in the 'standard' group. Running 'thor -T' will only show the standard
|
||||
tasks - adding --all will show all tasks. You can also filter on a specific
|
||||
group using the --group option: thor -T --group advanced
|
||||
|
||||
|
||||
== 0.9.6, released 2008-09-13
|
||||
|
||||
* Generic improvements
|
|
@ -7,7 +7,7 @@ Example:
|
|||
|
||||
class App < Thor # [1]
|
||||
map "-L" => :list # [2]
|
||||
|
||||
|
||||
desc "install APP_NAME", "install one of the available apps" # [3]
|
||||
method_options :force => :boolean, :alias => :string # [4]
|
||||
def install(name)
|
||||
|
@ -17,7 +17,7 @@ Example:
|
|||
end
|
||||
# other code
|
||||
end
|
||||
|
||||
|
||||
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
|
||||
def list(search="")
|
||||
# list everything
|
||||
|
@ -126,13 +126,13 @@ invoked only once. For example:
|
|||
invoke :two
|
||||
invoke :three
|
||||
end
|
||||
|
||||
|
||||
desc "two", "Prints 2, 3"
|
||||
def two
|
||||
puts 2
|
||||
invoke :three
|
||||
end
|
||||
|
||||
|
||||
desc "three", "Prints 3"
|
||||
def three
|
||||
puts 3
|
||||
|
@ -155,15 +155,15 @@ Thor::Group as this:
|
|||
|
||||
class Counter < Thor::Group
|
||||
desc "Prints 1, 2, 3"
|
||||
|
||||
|
||||
def one
|
||||
puts 1
|
||||
end
|
||||
|
||||
|
||||
def two
|
||||
puts 2
|
||||
end
|
||||
|
||||
|
||||
def three
|
||||
puts 3
|
||||
end
|
||||
|
@ -184,15 +184,15 @@ Besides, Thor::Group can parse arguments and options as Thor tasks:
|
|||
# number will be available as attr_accessor
|
||||
argument :number, :type => :numeric, :desc => "The number to start counting"
|
||||
desc "Prints the 'number' given upto 'number+2'"
|
||||
|
||||
|
||||
def one
|
||||
puts number + 0
|
||||
end
|
||||
|
||||
|
||||
def two
|
||||
puts number + 1
|
||||
end
|
||||
|
||||
|
||||
def three
|
||||
puts number + 2
|
||||
end
|
|
@ -56,7 +56,7 @@ class Default < Thor
|
|||
s.test_files.exclude 'spec/sandbox/**/*'
|
||||
end
|
||||
|
||||
Jeweler::RubyforgeTasks.new
|
||||
Jeweler::GemcutterTasks.new
|
||||
rescue LoadError
|
||||
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
||||
end
|
|
@ -114,7 +114,7 @@ class Thor
|
|||
@source_paths ||= self.class.source_paths_for_search
|
||||
end
|
||||
|
||||
# Receives a file or directory and search for it in the source paths.
|
||||
# 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)
|
||||
|
@ -222,7 +222,7 @@ class Thor
|
|||
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
|
||||
# Run a thor command. A hash of options can be given and it's converted to
|
||||
# switches.
|
||||
#
|
||||
# ==== Parameters
|
|
@ -79,11 +79,9 @@ class Thor
|
|||
next if dirname == given_destination
|
||||
base.empty_directory(dirname, config)
|
||||
when /\.tt$/
|
||||
destination = base.template(file_source, file_destination[0..-4], config)
|
||||
@block.call(destination) if @block
|
||||
destination = base.template(file_source, file_destination[0..-4], config, &@block)
|
||||
else
|
||||
destination = base.copy_file(file_source, file_destination, config)
|
||||
@block.call(destination) if @block
|
||||
destination = base.copy_file(file_source, file_destination, config, &@block)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -18,12 +18,14 @@ class Thor
|
|||
#
|
||||
# copy_file "doc/README"
|
||||
#
|
||||
def copy_file(source, destination=nil, config={})
|
||||
def copy_file(source, destination=nil, config={}, &block)
|
||||
destination ||= source
|
||||
source = File.expand_path(find_in_source_paths(source.to_s))
|
||||
|
||||
create_file destination, nil, config do
|
||||
File.read(source)
|
||||
content = File.read(source)
|
||||
content = block.call(content) if block
|
||||
content
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -72,13 +74,15 @@ class Thor
|
|||
#
|
||||
# template "doc/README"
|
||||
#
|
||||
def template(source, destination=nil, config={})
|
||||
def template(source, destination=nil, config={}, &block)
|
||||
destination ||= source
|
||||
source = File.expand_path(find_in_source_paths(source.to_s))
|
||||
context = instance_eval('binding')
|
||||
|
||||
create_file destination, nil, config do
|
||||
ERB.new(::File.read(source), nil, '-').result(context)
|
||||
content = ERB.new(::File.read(source), nil, '-').result(context)
|
||||
content = block.call(content) if block
|
||||
content
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@ class Thor
|
|||
# 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).
|
||||
#
|
||||
#
|
||||
# ==== Examples
|
||||
#
|
||||
# inject_into_file "config/environment.rb", "config.gem :thor", :after => "Rails::Initializer.run do |config|\n"
|
|
@ -65,7 +65,7 @@ class Thor
|
|||
else
|
||||
self[$1] == args.first
|
||||
end
|
||||
else
|
||||
else
|
||||
self[method]
|
||||
end
|
||||
end
|
|
@ -132,7 +132,7 @@ class Thor::Group
|
|||
|
||||
names.each do |name|
|
||||
unless class_options.key?(name)
|
||||
raise ArgumentError, "You have to define the option #{name.inspect} " <<
|
||||
raise ArgumentError, "You have to define the option #{name.inspect} " <<
|
||||
"before setting invoke_from_option."
|
||||
end
|
||||
|
|
@ -36,7 +36,7 @@ class Thor
|
|||
# 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
|
|
@ -36,7 +36,7 @@ class Thor::Runner < Thor #:nodoc:
|
|||
def install(name)
|
||||
initialize_thorfiles
|
||||
|
||||
# If a directory name is provided as the argument, look for a 'main.thor'
|
||||
# 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))
|
|
@ -143,7 +143,7 @@ class Thor
|
|||
answer = ask %[Overwrite #{destination}? (enter "h" for help) #{options}]
|
||||
|
||||
case answer
|
||||
when is?(:yes), is?(:force)
|
||||
when is?(:yes), is?(:force), ""
|
||||
return true
|
||||
when is?(:no), is?(:skip)
|
||||
return false
|
3
railties/lib/rails/vendor/thor-0.12.1/lib/thor/version.rb
vendored
Normal file
3
railties/lib/rails/vendor/thor-0.12.1/lib/thor/version.rb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Thor
|
||||
VERSION = "0.12.1".freeze
|
||||
end
|
Loading…
Reference in a new issue