Update Rails Generators to use Thor 0.12.0.
Signed-off-by: Yehuda Katz <wycats@mobile-166-129-219-135.mycingular.net>
This commit is contained in:
parent
103b29831e
commit
216e8c6bfa
|
@ -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.11.8/lib")
|
||||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.12.0/lib")
|
||||
require 'rails/generators/base'
|
||||
require 'rails/generators/named_base'
|
||||
|
||||
|
|
|
@ -212,6 +212,10 @@ module Rails
|
|||
def self.inherited(base) #:nodoc:
|
||||
super
|
||||
|
||||
# Cache source root, we need to do this, since __FILE__ is a relative value
|
||||
# and can point to wrong directions when inside an specified directory.
|
||||
base.source_root
|
||||
|
||||
if base.name && base.name !~ /Base$/ && defined?(Rails.root) && Rails.root
|
||||
path = File.expand_path(File.join(Rails.root, 'lib', 'templates'))
|
||||
if base.name.include?('::')
|
||||
|
|
|
@ -2,7 +2,12 @@
|
|||
|
||||
* Improve spec coverage for Thor::Runner
|
||||
|
||||
== 0.11.x, released 2009-07-01
|
||||
== 0.12, released 2009-11-06
|
||||
|
||||
* [#7] Do not force white color on status
|
||||
* [#8] Yield a block with the filename on directory
|
||||
|
||||
== 0.11, released 2009-07-01
|
||||
|
||||
* Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
|
||||
Thor classes.
|
|
@ -60,6 +60,7 @@ class Thor
|
|||
FileUtils.mkdir_p(File.dirname(destination))
|
||||
File.open(destination, 'w'){ |f| f.write render }
|
||||
end
|
||||
given_destination
|
||||
end
|
||||
|
||||
protected
|
|
@ -40,15 +40,16 @@ class Thor
|
|||
# directory "doc"
|
||||
# directory "doc", "docs", :recursive => false
|
||||
#
|
||||
def directory(source, destination=nil, config={})
|
||||
action Directory.new(self, source, destination || source, config)
|
||||
def directory(source, destination=nil, config={}, &block)
|
||||
action Directory.new(self, source, destination || source, config, &block)
|
||||
end
|
||||
|
||||
class Directory < EmptyDirectory #:nodoc:
|
||||
attr_reader :source
|
||||
|
||||
def initialize(base, source, destination=nil, config={})
|
||||
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
|
||||
|
||||
|
@ -70,6 +71,7 @@ class Thor
|
|||
Dir[lookup].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$/
|
||||
|
@ -77,9 +79,11 @@ class Thor
|
|||
next if dirname == given_destination
|
||||
base.empty_directory(dirname, config)
|
||||
when /\.tt$/
|
||||
base.template(file_source, file_destination[0..-4], config)
|
||||
destination = base.template(file_source, file_destination[0..-4], config)
|
||||
@block.call(destination) if @block
|
||||
else
|
||||
base.copy_file(file_source, file_destination, config)
|
||||
destination = base.copy_file(file_source, file_destination, config)
|
||||
@block.call(destination) if @block
|
||||
end
|
||||
end
|
||||
end
|
|
@ -55,6 +55,7 @@ class Thor
|
|||
def revoke!
|
||||
say_status :remove, :red
|
||||
::FileUtils.rm_rf(destination) if !pretend? && exists?
|
||||
given_destination
|
||||
end
|
||||
|
||||
protected
|
|
@ -74,7 +74,7 @@ class Thor::Group
|
|||
#
|
||||
def invoke(*names, &block)
|
||||
options = names.last.is_a?(Hash) ? names.pop : {}
|
||||
verbose = options.fetch(:verbose, :white)
|
||||
verbose = options.fetch(:verbose, true)
|
||||
|
||||
names.each do |name|
|
||||
invocations[name] = false
|
Loading…
Reference in New Issue