Permalink
Browse files

Update vendored thor and ensure that content is completely modified b…

…efore checking file collisions.

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 74be700 commit 28657e4f418c84dad08ae1f541d24df2d91d93aa @josevalim josevalim committed with jeremy Dec 2, 2009
Showing with 38 additions and 36 deletions.
  1. +1 −1 railties/lib/rails/generators.rb
  2. +3 −3 railties/lib/rails/generators/rails/app/app_generator.rb
  3. +0 −3 railties/lib/rails/vendor/thor-0.12.0/lib/thor/version.rb
  4. +2 −2 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/CHANGELOG.rdoc
  5. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/LICENSE
  6. +10 −10 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/README.rdoc
  7. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/Thorfile
  8. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor.rb
  9. +2 −2 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions.rb
  10. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions/create_file.rb
  11. +2 −4 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions/directory.rb
  12. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions/empty_directory.rb
  13. +8 −4 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions/file_manipulation.rb
  14. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/actions/inject_into_file.rb
  15. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/base.rb
  16. +1 −1 ...es/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/core_ext/hash_with_indifferent_access.rb
  17. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/core_ext/ordered_hash.rb
  18. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/error.rb
  19. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/group.rb
  20. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/invocation.rb
  21. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/parser.rb
  22. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/parser/argument.rb
  23. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/parser/arguments.rb
  24. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/parser/option.rb
  25. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/parser/options.rb
  26. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/rake_compat.rb
  27. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/runner.rb
  28. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/shell.rb
  29. +1 −1 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/shell/basic.rb
  30. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/shell/color.rb
  31. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/task.rb
  32. 0 railties/lib/rails/vendor/{thor-0.12.0 → thor-0.12.1}/lib/thor/util.rb
  33. +3 −0 railties/lib/rails/vendor/thor-0.12.1/lib/thor/version.rb
@@ -9,7 +9,7 @@
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 @@ def create_prototype_files
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 @@ 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.
+ # 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 @@ def run_ruby_script(command, config={})
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 @@ def execute!
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 @@ module Actions
#
# 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 @@ def get(source, destination=nil, config={}, &block)
#
# 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 @@ module Actions
# 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 @@ def method_missing(method, *args, &block)
else
self[$1] == args.first
end
- else
+ else
self[method]
end
end
@@ -132,7 +132,7 @@ def invoke_from_option(*names, &block)
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 @@ def initialize(name, description=nil, required=nil, type=nil, default=nil, banne
# 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 @@ def method_missing(meth, *args)
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 @@ def file_collision(destination)
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
@@ -0,0 +1,3 @@
+class Thor
+ VERSION = "0.12.1".freeze
+end

0 comments on commit 28657e4

Please sign in to comment.