aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/initializer.rb3
-rw-r--r--railties/lib/rails/backtrace_cleaner.rb6
-rw-r--r--railties/lib/rails_generator/generators/applications/app/app_generator.rb2
-rw-r--r--railties/lib/rails_generator/generators/applications/app/template_runner.rb33
-rw-r--r--railties/lib/tasks/databases.rake2
-rw-r--r--railties/lib/tasks/framework.rake6
6 files changed, 34 insertions, 18 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 4bb1e480b7..06a3332c42 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -569,7 +569,7 @@ Run `rake gems:install` to install the missing gems.
def load_application_initializers
if gems_dependencies_loaded
Dir["#{configuration.root_path}/config/initializers/**/*.rb"].sort.each do |initializer|
- load initializer.sub(/^#{Regexp.escape(configuration.root_path)}\//, '')
+ load(initializer)
end
end
end
@@ -927,7 +927,6 @@ Run `rake gems:install` to install the missing gems.
app/controllers
app/helpers
app/services
- config
lib
vendor
).map { |dir| "#{root_path}/#{dir}" }.select { |dir| File.directory?(dir) }
diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb
index d8626aaf14..f344c6477d 100644
--- a/railties/lib/rails/backtrace_cleaner.rb
+++ b/railties/lib/rails/backtrace_cleaner.rb
@@ -3,7 +3,9 @@ module Rails
ERB_METHOD_SIG = /:in `_run_erb_.*/
VENDOR_DIRS = %w( vendor/plugins vendor/gems vendor/rails )
- SERVER_DIRS = %w( lib/mongrel bin/mongrel lib/rack )
+ SERVER_DIRS = %w( lib/mongrel bin/mongrel
+ lib/passenger bin/passenger-spawn-server
+ lib/rack )
RAILS_NOISE = %w( script/server )
RUBY_NOISE = %w( rubygems/custom_require benchmark.rb )
@@ -30,4 +32,4 @@ module Rails
Rails.backtrace_cleaner.clean(backtrace)
end
end
-end \ No newline at end of file
+end
diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
index 4a191578cf..795a0d7653 100644
--- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb
+++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb
@@ -40,7 +40,7 @@ class AppGenerator < Rails::Generator::Base
def after_generate
if options[:template]
- Rails::TemplateRunner.new(@destination_root, options[:template])
+ Rails::TemplateRunner.new(options[:template], @destination_root)
end
end
diff --git a/railties/lib/rails_generator/generators/applications/app/template_runner.rb b/railties/lib/rails_generator/generators/applications/app/template_runner.rb
index 0083e0d5a5..c6113648e6 100644
--- a/railties/lib/rails_generator/generators/applications/app/template_runner.rb
+++ b/railties/lib/rails_generator/generators/applications/app/template_runner.rb
@@ -7,10 +7,10 @@ require 'fileutils'
module Rails
class TemplateRunner
- attr_reader :behavior, :description, :root
+ attr_reader :root
- def initialize(root, template) # :nodoc:
- @root = Dir.pwd + "/" + root
+ def initialize(template, root = '') # :nodoc:
+ @root = File.join(Dir.pwd, root)
puts "applying template: #{template}"
@@ -57,16 +57,22 @@ module Rails
end
# Install a plugin. You must provide either a Subversion url or Git url.
+ # For a Git-hosted plugin, you can specify if it should be added as a submodule instead of cloned.
#
# ==== Examples
#
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
+ # plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk'
#
def plugin(name, options)
puts "installing plugin #{name}"
- if options[:git] || options[:svn]
+ if options[:git] && options[:submodule]
+ in_root do
+ Git.run("submodule add #{options[:git]} vendor/plugins/#{name}")
+ end
+ elsif options[:git] || options[:svn]
in_root do
`script/plugin install #{options[:svn] || options[:git]}`
end
@@ -103,13 +109,13 @@ module Rails
# git :add => "onefile.rb", :rm => "badfile.cxx"
#
def git(command = {})
- puts "running git #{command}"
-
in_root do
if command.is_a?(Symbol)
+ puts "running git #{command}"
Git.run(command.to_s)
else
command.each do |command, options|
+ puts "running git #{command} #{options}"
Git.run("#{command} #{options}")
end
end
@@ -233,11 +239,11 @@ module Rails
#
# generate(:authenticated, "user session")
#
- def generate(what, args = nil)
+ def generate(what, *args)
puts "generating #{what}"
- args = args.join(" ") if args.class == Array
+ argument = args.map(&:to_s).flatten.join(" ")
- in_root { `#{root}/script/generate #{what} #{args}` }
+ in_root { `#{root}/script/generate #{what} #{argument}` }
end
# Executes a command
@@ -258,11 +264,14 @@ module Rails
# ==== Example
#
# rake("db:migrate")
- # rake("db:migrate", "production")
+ # rake("db:migrate", :env => "production")
+ # rake("gems:install", :sudo => true)
#
- def rake(command, env = 'development')
+ def rake(command, options = {})
puts "running rake task #{command}"
- in_root { `rake #{command} RAILS_ENV=#{env}` }
+ env = options[:env] || 'development'
+ sudo = options[:sudo] ? 'sudo ' : ''
+ in_root { `#{sudo}rake #{command} RAILS_ENV=#{env}` }
end
# Just run the capify command in root
diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake
index a90c1d4a77..3a576063fa 100644
--- a/railties/lib/tasks/databases.rake
+++ b/railties/lib/tasks/databases.rake
@@ -110,7 +110,7 @@ namespace :db do
end
- desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
+ desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
task :migrate => :environment do
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
diff --git a/railties/lib/tasks/framework.rake b/railties/lib/tasks/framework.rake
index d639214ffe..191c9361ff 100644
--- a/railties/lib/tasks/framework.rake
+++ b/railties/lib/tasks/framework.rake
@@ -80,6 +80,12 @@ namespace :rails do
desc "Update both configs, scripts and public/javascripts from Rails"
task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
+ desc "Applies the template supplied by LOCATION=/path/to/template"
+ task :template do
+ require 'rails_generator/generators/applications/app/template_runner'
+ Rails::TemplateRunner.new(ENV["LOCATION"])
+ end
+
namespace :update do
desc "Add new scripts to the application script/ directory"
task :scripts do