mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix rake dev and update vendored Thor.
Signed-off-by: Yehuda Katz <wycats@gmail.com>
This commit is contained in:
parent
b30294b54a
commit
c28a45ad8b
34 changed files with 88 additions and 110 deletions
|
@ -6,7 +6,8 @@ require 'rake/gempackagetask'
|
|||
require 'date'
|
||||
require 'rbconfig'
|
||||
|
||||
require File.join(File.dirname(__FILE__), 'lib/rails', 'version')
|
||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
|
||||
require 'rails'
|
||||
|
||||
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
||||
PKG_NAME = ENV['PKG_NAME'] || 'rails'
|
||||
|
@ -81,7 +82,6 @@ end
|
|||
# Run application generator -------------------------------------------------------------
|
||||
|
||||
task :create_rails do
|
||||
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
|
||||
require 'rails/generators'
|
||||
require 'rails/generators/rails/app/app_generator'
|
||||
Rails::Generators::AppGenerator.start [ File.basename(PKG_DESTINATION), "--quiet" ],
|
||||
|
|
|
@ -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.6/lib")
|
||||
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/vendor/thor-0.11.8/lib")
|
||||
require 'rails/generators/base'
|
||||
require 'rails/generators/named_base'
|
||||
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'ruby2ruby'
|
||||
require 'parse_tree'
|
||||
if Ruby2Ruby::VERSION >= "1.2.0"
|
||||
require 'parse_tree_extensions'
|
||||
end
|
||||
require 'rake'
|
||||
|
||||
input = ARGV[0] || 'Rakefile'
|
||||
output = ARGV[1] || 'Thorfile'
|
||||
|
||||
$requires = []
|
||||
|
||||
module Kernel
|
||||
def require_with_record(file)
|
||||
$requires << file if caller[1] =~ /rake2thor:/
|
||||
require_without_record file
|
||||
end
|
||||
alias_method :require_without_record, :require
|
||||
alias_method :require, :require_with_record
|
||||
end
|
||||
|
||||
load input
|
||||
|
||||
@private_methods = []
|
||||
|
||||
def file_task_name(name)
|
||||
"compile_" + name.gsub('/', '_slash_').gsub('.', '_dot_').gsub(/\W/, '_')
|
||||
end
|
||||
|
||||
def method_for_task(task)
|
||||
file_task = task.is_a?(Rake::FileTask)
|
||||
comment = task.instance_variable_get('@comment')
|
||||
prereqs = task.instance_variable_get('@prerequisites').select(&Rake::Task.method(:task_defined?))
|
||||
actions = task.instance_variable_get('@actions')
|
||||
name = task.name.gsub(/^([^:]+:)+/, '')
|
||||
name = file_task_name(name) if file_task
|
||||
meth = ''
|
||||
|
||||
meth << "desc #{name.inspect}, #{comment.inspect}\n" if comment
|
||||
meth << "def #{name}\n"
|
||||
|
||||
meth << prereqs.map do |pre|
|
||||
pre = pre.to_s
|
||||
pre = file_task_name(pre) if Rake::Task[pre].is_a?(Rake::FileTask)
|
||||
' ' + pre
|
||||
end.join("\n")
|
||||
|
||||
meth << "\n\n" unless prereqs.empty? || actions.empty?
|
||||
|
||||
meth << actions.map do |act|
|
||||
act = act.to_ruby
|
||||
unless act.gsub!(/^proc \{ \|(\w+)\|\n/,
|
||||
" \\1 = Struct.new(:name).new(#{name.inspect}) # A crude mock Rake::Task object\n")
|
||||
act.gsub!(/^proc \{\n/, '')
|
||||
end
|
||||
act.gsub(/\n\}$/, '')
|
||||
end.join("\n")
|
||||
|
||||
meth << "\nend"
|
||||
|
||||
if file_task
|
||||
@private_methods << meth
|
||||
return
|
||||
end
|
||||
|
||||
meth
|
||||
end
|
||||
|
||||
body = Rake::Task.tasks.map(&method(:method_for_task)).compact.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
|
||||
|
||||
unless @private_methods.empty?
|
||||
body << "\n\n private\n\n"
|
||||
body << @private_methods.map { |meth| meth.gsub(/^/, ' ') }.join("\n\n")
|
||||
end
|
||||
|
||||
requires = $requires.map { |r| "require #{r.inspect}" }.join("\n")
|
||||
|
||||
File.open(output, 'w') { |f| f.write(<<END.lstrip) }
|
||||
#{requires}
|
||||
|
||||
class Default < Thor
|
||||
#{body}
|
||||
end
|
||||
END
|
|
@ -1,7 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
# -*- mode: ruby -*-
|
||||
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'thor')
|
||||
require 'thor/runner'
|
||||
|
||||
Thor::Runner.start
|
63
railties/lib/rails/vendor/thor-0.11.8/Thorfile
vendored
Normal file
63
railties/lib/rails/vendor/thor-0.11.8/Thorfile
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
# enconding: utf-8
|
||||
|
||||
require File.join(File.dirname(__FILE__), "lib", "thor", "version")
|
||||
require 'thor/rake_compat'
|
||||
require 'spec/rake/spectask'
|
||||
require 'rdoc/task'
|
||||
|
||||
GEM_NAME = 'thor'
|
||||
EXTRA_RDOC_FILES = ["README.rdoc", "LICENSE", "CHANGELOG.rdoc", "VERSION", "Thorfile"]
|
||||
|
||||
class Default < Thor
|
||||
include Thor::RakeCompat
|
||||
|
||||
Spec::Rake::SpecTask.new(:spec) do |t|
|
||||
t.libs << 'lib'
|
||||
t.spec_opts = ['--options', "spec/spec.opts"]
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
||||
|
||||
Spec::Rake::SpecTask.new(:rcov) do |t|
|
||||
t.libs << 'lib'
|
||||
t.spec_opts = ['--options', "spec/spec.opts"]
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
t.rcov = true
|
||||
t.rcov_dir = "rcov"
|
||||
end
|
||||
|
||||
RDoc::Task.new do |rdoc|
|
||||
rdoc.main = "README.rdoc"
|
||||
rdoc.rdoc_dir = "rdoc"
|
||||
rdoc.title = GEM_NAME
|
||||
rdoc.rdoc_files.include(*EXTRA_RDOC_FILES)
|
||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
||||
rdoc.options << '--line-numbers' << '--inline-source'
|
||||
end
|
||||
|
||||
begin
|
||||
require 'jeweler'
|
||||
Jeweler::Tasks.new do |s|
|
||||
s.name = GEM_NAME
|
||||
s.version = Thor::VERSION
|
||||
s.rubyforge_project = "textmate"
|
||||
s.platform = Gem::Platform::RUBY
|
||||
s.summary = "A scripting framework that replaces rake, sake and rubigen"
|
||||
s.email = "ruby-thor@googlegroups.com"
|
||||
s.homepage = "http://yehudakatz.com"
|
||||
s.description = "A scripting framework that replaces rake, sake and rubigen"
|
||||
s.authors = ['Yehuda Katz', 'José Valim']
|
||||
s.has_rdoc = true
|
||||
s.extra_rdoc_files = EXTRA_RDOC_FILES
|
||||
s.require_path = 'lib'
|
||||
s.bindir = "bin"
|
||||
s.executables = %w( thor rake2thor )
|
||||
s.files = s.extra_rdoc_files + Dir.glob("{bin,lib}/**/*")
|
||||
s.files.exclude 'spec/sandbox/**/*'
|
||||
s.test_files.exclude 'spec/sandbox/**/*'
|
||||
end
|
||||
|
||||
Jeweler::RubyforgeTasks.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
|
||||
end
|
|
@ -1,4 +1,3 @@
|
|||
$:.unshift File.expand_path(File.dirname(__FILE__))
|
||||
require 'thor/base'
|
||||
require 'thor/group'
|
||||
require 'thor/actions'
|
|
@ -73,7 +73,9 @@ class Thor
|
|||
|
||||
case file_source
|
||||
when /\.empty_directory$/
|
||||
base.empty_directory(File.dirname(file_destination), config)
|
||||
dirname = File.dirname(file_destination).gsub(/\/\.$/, '')
|
||||
next if dirname == given_destination
|
||||
base.empty_directory(dirname, config)
|
||||
when /\.tt$/
|
||||
base.template(file_source, file_destination[0..-4], config)
|
||||
else
|
|
@ -22,7 +22,8 @@ class Thor
|
|||
|
||||
def self.included(base)
|
||||
# Hack. Make rakefile point to invoker, so rdoc task is generated properly.
|
||||
Rake.application.instance_variable_set(:@rakefile, caller[0].match(/(.*):\d+/)[1])
|
||||
rakefile = File.basename(caller[0].match(/(.*):\d+/)[1])
|
||||
Rake.application.instance_variable_set(:@rakefile, rakefile)
|
||||
self.rake_classes << base
|
||||
end
|
||||
end
|
||||
|
@ -43,11 +44,9 @@ class Object #:nodoc:
|
|||
description.strip!
|
||||
|
||||
klass.desc description, task.comment || non_namespaced_name
|
||||
klass.class_eval <<-METHOD
|
||||
def #{non_namespaced_name}(#{task.arg_names.join(', ')})
|
||||
Rake::Task[#{task.name.to_sym.inspect}].invoke(#{task.arg_names.join(', ')})
|
||||
end
|
||||
METHOD
|
||||
klass.send :define_method, non_namespaced_name do |*args|
|
||||
Rake::Task[task.name.to_sym].invoke(*args)
|
||||
end
|
||||
end
|
||||
|
||||
task
|
|
@ -215,7 +215,7 @@ class Thor::Runner < Thor #:nodoc:
|
|||
# 5. c:\ <-- no Thorfiles found!
|
||||
#
|
||||
def thorfiles(relevant_to=nil, skip_lookup=false)
|
||||
# Deal with deprecated thor when :namespaces: is available as constants
|
||||
# TODO Remove this dealing with deprecated thor when :namespaces: is available as constants
|
||||
save_yaml(thor_yaml) if Thor::Util.convert_constants_to_namespaces(thor_yaml)
|
||||
|
||||
thorfiles = []
|
|
@ -1,11 +1,17 @@
|
|||
require 'rbconfig'
|
||||
require 'thor/shell/color'
|
||||
|
||||
class Thor
|
||||
module Base
|
||||
# Returns the shell used in all Thor classes. Default to color one.
|
||||
# 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 ||= Thor::Shell::Color
|
||||
@shell ||= if Config::CONFIG['host_os'] =~ /mswin|mingw/
|
||||
Thor::Shell::Basic
|
||||
else
|
||||
Thor::Shell::Color
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the shell used in all Thor classes.
|
|
@ -209,7 +209,7 @@ class Thor
|
|||
# Returns the root where thor files are located, dependending on the OS.
|
||||
#
|
||||
def self.thor_root
|
||||
File.join(user_home, ".thor")
|
||||
File.join(user_home, ".thor").gsub(/\\/, '/')
|
||||
end
|
||||
|
||||
# Returns the files in the thor root. On Windows thor_root will be something
|
||||
|
@ -220,7 +220,7 @@ class Thor
|
|||
# If we don't #gsub the \ character, Dir.glob will fail.
|
||||
#
|
||||
def self.thor_root_glob
|
||||
files = Dir["#{thor_root.gsub(/\\/, '/')}/*"]
|
||||
files = Dir["#{thor_root}/*"]
|
||||
|
||||
files.map! do |file|
|
||||
File.directory?(file) ? File.join(file, "main.thor") : file
|
3
railties/lib/rails/vendor/thor-0.11.8/lib/thor/version.rb
vendored
Normal file
3
railties/lib/rails/vendor/thor-0.11.8/lib/thor/version.rb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
class Thor
|
||||
VERSION = "0.11.8".freeze
|
||||
end
|
Loading…
Reference in a new issue