aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/vendor
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-07-15 20:16:37 +0200
committerJosé Valim <jose.valim@gmail.com>2009-07-15 20:16:37 +0200
commitb4ef958de6b16294094de28d00ba25fe2f48accc (patch)
tree89ccd25109c5095125faeab8d5fcc318fa94ceb2 /railties/lib/vendor
parentbaa4781ac7174e527c2471b4c86ea51c0f65cf6b (diff)
downloadrails-b4ef958de6b16294094de28d00ba25fe2f48accc.tar.gz
rails-b4ef958de6b16294094de28d00ba25fe2f48accc.tar.bz2
rails-b4ef958de6b16294094de28d00ba25fe2f48accc.zip
Change false to :verbose => false as in new Thor version.
Diffstat (limited to 'railties/lib/vendor')
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions.rb70
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/copy_file.rb10
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/create_file.rb10
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/directory.rb31
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/empty_directory.rb10
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/get.rb10
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/inject_into_file.rb24
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/template.rb10
-rw-r--r--railties/lib/vendor/thor-0.11.1/lib/thor/actions/templater.rb13
9 files changed, 88 insertions, 100 deletions
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions.rb
index 83d082382c..939339088a 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions.rb
@@ -164,8 +164,8 @@ class Thor
# Same as inside, but log status and use padding.
#
- def inside_with_padding(dir='', log_status=true, &block)
- say_status :inside, dir, log_status
+ def inside_with_padding(dir='', config={}, &block)
+ say_status :inside, dir, config.fetch(:verbose, true)
shell.padding += 1
inside(dir, &block)
shell.padding -= 1
@@ -182,17 +182,16 @@ class Thor
# ==== Parameters
# mode<Integer>:: the file mode
# path<String>:: the name of the file to change mode
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Example
#
# chmod "script/*", 0755
#
- def chmod(path, mode, log_status=true)
+ 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), log_status
+ say_status :chmod, relative_to_original_destination_root(path), config.fetch(:verbose, true)
FileUtils.chmod_R(mode, path) unless options[:pretend]
end
@@ -200,8 +199,7 @@ class Thor
#
# ==== Parameters
# command<String>:: the command to be executed.
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Example
#
@@ -209,9 +207,10 @@ class Thor
# run('ln -s ~/edge rails')
# end
#
- def run(command, log_status=true)
+ def run(command, config={})
return unless behavior == :invoke
- say_status :run, "\"#{command}\" from #{relative_to_original_destination_root(destination_root, false)}", log_status
+ description = "#{command.inspect} from #{relative_to_original_destination_root(destination_root, false)}"
+ say_status :run, description, config.fetch(:verbose, true)
`#{command}` unless options[:pretend]
end
@@ -219,12 +218,11 @@ class Thor
#
# ==== Parameters
# command<String>:: the command to be executed.
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
- def run_ruby_script(command, log_status=true)
+ def run_ruby_script(command, config={})
return unless behavior == :invoke
- say_status File.basename(Thor::Util.ruby_command), command, log_status
+ say_status File.basename(Thor::Util.ruby_command), command, config.fetch(:verbose, true)
`#{Thor::Util.ruby_command} #{command}` unless options[:pretend]
end
@@ -234,9 +232,8 @@ class Thor
# ==== Parameters
# task<String>:: the task to be invoked
# args<Array>:: arguments to the task
- # options<Hash>:: a hash with options used on invocation
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # options<Hash>:: give :verbose => false to not log the status. Other options
+ # are given as parameter to Thor.
#
# ==== Examples
#
@@ -247,35 +244,33 @@ class Thor
# #=> thor list --all --substring=rails
#
def thor(task, *args)
- log_status = args.last.is_a?(Symbol) || [true, false].include?(args.last) ? args.pop : true
- options = args.last.is_a?(Hash) ? args.pop : {}
+ config = args.last.is_a?(Hash) ? args.pop : {}
+ verbose = config.key?(:verbose) ? config.delete(:verbose) : true
args.unshift task
- args.push Thor::Options.to_switches(options)
+ args.push Thor::Options.to_switches(config)
command = args.join(' ').strip
- say_status :thor, command, log_status
- run "thor #{command}", false
+ say_status :thor, command, verbose
+ run "thor #{command}", :verbose => false
end
# Removes a file at the given location.
#
# ==== Parameters
# path<String>:: path of the file to be changed
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # 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, log_status=true)
+ def remove_file(path, config={})
return unless behavior == :invoke
path = File.expand_path(path, destination_root)
- color = log_status.is_a?(Symbol) ? log_status : :red
- say_status :remove, relative_to_original_destination_root(path), log_status
+ say_status :remove, relative_to_original_destination_root(path), config.fetch(:verbose, true)
::FileUtils.rm_rf(path) if !options[:pretend] && File.exists?(path)
end
@@ -285,8 +280,7 @@ class Thor
# 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
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Example
#
@@ -298,10 +292,10 @@ class Thor
#
def gsub_file(path, flag, *args, &block)
return unless behavior == :invoke
- log_status = args.last.is_a?(Symbol) || [ true, false ].include?(args.last) ? args.pop : true
+ config = args.last.is_a?(Hash) ? args.pop : {}
path = File.expand_path(path, destination_root)
- say_status :gsub, relative_to_original_destination_root(path), log_status
+ say_status :gsub, relative_to_original_destination_root(path), config.fetch(:verbose, true)
unless options[:pretend]
content = File.read(path)
@@ -315,17 +309,16 @@ class Thor
# ==== 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.
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Example
#
# append_file 'config/environments/test.rb', 'config.gem "rspec"'
#
- def append_file(path, data=nil, log_status=true, &block)
+ def append_file(path, data=nil, config={}, &block)
return unless behavior == :invoke
path = File.expand_path(path, destination_root)
- say_status :append, relative_to_original_destination_root(path), log_status
+ say_status :append, relative_to_original_destination_root(path), config.fetch(:verbose, true)
File.open(path, 'ab') { |file| file.write(data || block.call) } unless options[:pretend]
end
@@ -334,17 +327,16 @@ class Thor
# ==== 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.
- # log_status<Boolean>:: if false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Example
#
# prepend_file 'config/environments/test.rb', 'config.gem "rspec"'
#
- def prepend_file(path, data=nil, log_status=true, &block)
+ def prepend_file(path, data=nil, config={}, &block)
return unless behavior == :invoke
path = File.expand_path(path, destination_root)
- say_status :prepend, relative_to_original_destination_root(path), log_status
+ say_status :prepend, relative_to_original_destination_root(path), config.fetch(:verbose, true)
unless options[:pretend]
content = data || block.call
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/copy_file.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/copy_file.rb
index b9d2e9e0a7..bfbc38a367 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/copy_file.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/copy_file.rb
@@ -7,9 +7,9 @@ class Thor
# 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
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # 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
#
@@ -17,8 +17,8 @@ class Thor
#
# copy_file "doc/README"
#
- def copy_file(source, destination=nil, log_status=true)
- action CopyFile.new(self, source, destination || source, log_status)
+ def copy_file(source, destination=nil, config={})
+ action CopyFile.new(self, source, destination || source, config)
end
class CopyFile < Templater #:nodoc:
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/create_file.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/create_file.rb
index 2f3732247e..72bf34c0a3 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/create_file.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/create_file.rb
@@ -9,7 +9,7 @@ class Thor
# ==== Parameters
# destination<String>:: the relative path to the destination root.
# data<String|NilClass>:: the data to append to the file.
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # config<Hash>:: give :verbose => false to not log the status.
#
# ==== Examples
#
@@ -20,8 +20,8 @@ class Thor
#
# create_file "config/apach.conf", "your apache config"
#
- def create_file(destination, data=nil, log_status=true, &block)
- action CreateFile.new(self, destination, block || data.to_s, log_status)
+ def create_file(destination, data=nil, config={}, &block)
+ action CreateFile.new(self, destination, block || data.to_s, config)
end
alias :add_file :create_file
@@ -31,8 +31,8 @@ class Thor
class CreateFile < Templater #:nodoc:
attr_reader :data
- def initialize(base, destination, data, log_status)
- super(base, nil, destination, log_status)
+ def initialize(base, destination, data, config={})
+ super(base, nil, destination, config)
@data = data
end
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/directory.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/directory.rb
index 134f13d1b7..2c6d2bc59b 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/directory.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/directory.rb
@@ -30,30 +30,27 @@ class Thor
# blog.rb
#
# ==== Parameters
- # source<String>:: the relative path to the source root
- # destination<String>:: the relative path to the destination root
- # recursive<Boolean>:: if the directory must be copied recursively, true by default
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # 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", false
+ # directory "doc", "docs", :recursive => false
#
- def directory(source, destination=nil, recursive=true, log_status=true)
- action Directory.new(self, source, destination || source, recursive, log_status)
+ def directory(source, destination=nil, config={})
+ action Directory.new(self, source, destination || source, config)
end
class Directory < Templater #:nodoc:
- attr_reader :recursive
-
- def initialize(base, source, destination=nil, recursive=true, log_status=true)
- @recursive = recursive
- super(base, source, destination, log_status)
+ def initialize(base, source, destination=nil, config={})
+ super(base, source, destination, { :recursive => true }.merge(config))
end
def invoke!
- base.empty_directory given_destination, @log_status
+ base.empty_directory given_destination, config
execute!
end
@@ -64,7 +61,7 @@ class Thor
protected
def execute!
- lookup = recursive ? File.join(source, '**') : source
+ lookup = config[:recursive] ? File.join(source, '**') : source
lookup = File.join(lookup, '{*,.[a-z]*}')
Dir[lookup].each do |file_source|
@@ -73,11 +70,11 @@ class Thor
case file_source
when /\.empty_directory$/
- base.empty_directory(File.dirname(file_destination), @log_status)
+ base.empty_directory(File.dirname(file_destination), config)
when /\.tt$/
- base.template(file_source, file_destination[0..-4], @log_status)
+ base.template(file_source, file_destination[0..-4], config)
else
- base.copy_file(file_source, file_destination, @log_status)
+ base.copy_file(file_source, file_destination, config)
end
end
end
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/empty_directory.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/empty_directory.rb
index 3f29d52362..04f9817212 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/empty_directory.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/empty_directory.rb
@@ -6,21 +6,21 @@ class Thor
# Creates an empty directory.
#
# ==== Parameters
- # destination<String>:: the relative path to the destination root
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # 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, log_status=true)
- action EmptyDirectory.new(self, nil, destination, log_status)
+ def empty_directory(destination, config={})
+ action EmptyDirectory.new(self, nil, destination, config)
end
class EmptyDirectory < Templater #:nodoc:
def invoke!
- invoke_with_options!(base.options) do
+ invoke_with_options!(base.options.merge(config)) do
::FileUtils.mkdir_p(destination)
end
end
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/get.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/get.rb
index a0d12b8370..bd8deb8194 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/get.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/get.rb
@@ -9,9 +9,9 @@ class Thor
# 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
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # 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
#
@@ -21,8 +21,8 @@ class Thor
# content.split("\n").first
# end
#
- def get(source, destination=nil, log_status=true, &block)
- action Get.new(self, source, block || destination, log_status)
+ def get(source, destination=nil, config={}, &block)
+ action Get.new(self, source, block || destination, config)
end
class Get < Templater #:nodoc:
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/inject_into_file.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/inject_into_file.rb
index c91bd96098..6bd0100a12 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/inject_into_file.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/inject_into_file.rb
@@ -9,9 +9,8 @@ class Thor
# ==== Parameters
# destination<String>:: Relative path to the destination root
# data<String>:: Data to add to the file. Can be given as a block.
- # flag<String>:: Flag of where to add the changes.
- # log_status<Boolean>:: If false, does not log the status. True by default.
- # If a symbol is given, uses it as the output color.
+ # config<Hash>:: give :verbose => false to not log the status and the flag
+ # for injection (:after or :before).
#
# ==== Examples
#
@@ -24,28 +23,29 @@ class Thor
#
def inject_into_file(destination, *args, &block)
if block_given?
- data, flag = block, args.shift
+ data, config = block, args.shift
else
- data, flag = args.shift, args.shift
+ data, config = args.shift, args.shift
end
log_status = args.empty? || args.pop
- action InjectIntoFile.new(self, destination, data, flag, log_status)
+ action InjectIntoFile.new(self, destination, data, config)
end
class InjectIntoFile #:nodoc:
- attr_reader :base, :destination, :relative_destination, :flag, :replacement
+ attr_reader :base, :destination, :relative_destination, :flag, :replacement, :config
- def initialize(base, destination, data, flag, log_status=true)
- @base, @log_status = base, log_status
- behavior, @flag = flag.keys.first, flag.values.first
+ def initialize(base, destination, data, config)
+ @base, @config = base, { :verbose => true }.merge(config)
self.destination = destination
data = data.call if data.is_a?(Proc)
- @replacement = if behavior == :after
+ @replacement = if @config.key?(:after)
+ @flag = @config.delete(:after)
@flag + data
else
+ @flag = @config.delete(:before)
data + @flag
end
end
@@ -75,7 +75,7 @@ class Thor
# Shortcut to say_status shell method.
#
def say_status(status)
- base.shell.say_status status, relative_destination, @log_status
+ base.shell.say_status status, relative_destination, config[:verbose]
end
# Adds the content to the file.
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/template.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/template.rb
index 6b2e50b8c5..95e2412514 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/template.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/template.rb
@@ -9,9 +9,9 @@ class Thor
# 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
- # log_status<Boolean>:: if false, does not log the status. True by default.
+ # 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
#
@@ -19,9 +19,9 @@ class Thor
#
# template "doc/README"
#
- def template(source, destination=nil, log_status=true)
+ def template(source, destination=nil, config={})
destination ||= source.gsub(/.tt$/, '')
- action Template.new(self, source, destination, log_status)
+ action Template.new(self, source, destination, config)
end
class Template < Templater #:nodoc:
diff --git a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/templater.rb b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/templater.rb
index b4b7bae3af..455178c6e8 100644
--- a/railties/lib/vendor/thor-0.11.1/lib/thor/actions/templater.rb
+++ b/railties/lib/vendor/thor-0.11.1/lib/thor/actions/templater.rb
@@ -8,7 +8,7 @@ class Thor
# by Jonas Nicklas and Michael S. Klishin under MIT LICENSE.
#
class Templater #:nodoc:
- attr_reader :base, :source, :destination, :given_destination, :relative_destination
+ attr_reader :base, :source, :destination, :given_destination, :relative_destination, :config
# Initializes given the source and destination.
#
@@ -16,11 +16,10 @@ class Thor
# 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
- # log_status<Boolean>:: If false, does not log the status. True by default.
- # Templater log status does not accept color.
+ # config<Hash>:: give :verbose => false to not log the status.
#
- def initialize(base, source, destination, log_status=true)
- @base, @log_status = base, log_status
+ def initialize(base, source, destination, config={})
+ @base, @config = base, { :verbose => true }.merge(config)
self.source = source
self.destination = destination
end
@@ -56,7 +55,7 @@ class Thor
# but you can modify in the subclass.
#
def invoke!
- invoke_with_options!(base.options) do
+ invoke_with_options!(base.options.merge(config)) do
::FileUtils.mkdir_p(::File.dirname(destination))
::File.open(destination, 'w'){ |f| f.write render }
end
@@ -187,7 +186,7 @@ class Thor
# Shortcut to say_status shell method.
#
def say_status(status, color)
- base.shell.say_status status, relative_destination, color if @log_status
+ base.shell.say_status status, relative_destination, color if config[:verbose]
end
end