From 1a81f156bd81990a50ecf13986b2131dbd20a62b Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Apr 2008 08:32:05 -0500 Subject: Change all databases.rake adapter 'when' statements to use regexes. This is more friendly to JRuby/JDBC adapters (with names like 'jdbcmysql') and leaves the door open to alternate implementations of adapters in the future. --- railties/lib/tasks/databases.rake | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 21c81b3fb5..08294a6853 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -32,7 +32,7 @@ namespace :db do ActiveRecord::Base.connection rescue case config['adapter'] - when 'mysql' + when /mysql/ @charset = ENV['CHARSET'] || 'utf8' @collation = ENV['COLLATION'] || 'utf8_general_ci' begin @@ -42,7 +42,7 @@ namespace :db do rescue $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)" end - when 'postgresql' + when /postgresql/ @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) @@ -52,9 +52,9 @@ namespace :db do $stderr.puts $!, *($!.backtrace) $stderr.puts "Couldn't create database for #{config.inspect}" end - when 'sqlite' + when /sqlite$/ `sqlite "#{config['database']}"` - when 'sqlite3' + when /sqlite3$/ `sqlite3 "#{config['database']}"` end else @@ -239,7 +239,7 @@ namespace :db do task :dump => :environment do abcs = ActiveRecord::Base.configurations case abcs[RAILS_ENV]["adapter"] - when "mysql", "oci", "oracle" + when /mysql/, /oci/, /oracle/ ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } when "postgresql" @@ -250,13 +250,13 @@ namespace :db do search_path = "--schema=#{search_path}" if search_path `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` raise "Error dumping database" if $?.exitstatus == 1 - when "sqlite", "sqlite3" + when /sqlite/ dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql` - when "sqlserver" + when /sqlserver/ `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r` `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` - when "firebird" + when /firebird/ set_firebird_env(abcs[RAILS_ENV]) db_string = firebird_db_string(abcs[RAILS_ENV]) sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql" @@ -285,13 +285,13 @@ namespace :db do task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do abcs = ActiveRecord::Base.configurations case abcs["test"]["adapter"] - when "mysql" + when /mysql/ ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| ActiveRecord::Base.connection.execute(table) end - when "postgresql" + when /postgresql/ ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] @@ -301,12 +301,12 @@ namespace :db do `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql` when "sqlserver" `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" + when /oci/, /oracle/ ActiveRecord::Base.establish_connection(:test) IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl| ActiveRecord::Base.connection.execute(ddl) end - when "firebird" + when /firebird/ set_firebird_env(abcs["test"]) db_string = firebird_db_string(abcs["test"]) sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}" @@ -319,7 +319,7 @@ namespace :db do task :purge => :environment do abcs = ActiveRecord::Base.configurations case abcs["test"]["adapter"] - when "mysql" + when /mysql/ ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"]) when "postgresql" @@ -329,16 +329,16 @@ namespace :db do when "sqlite","sqlite3" dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] File.delete(dbfile) if File.exist?(dbfile) - when "sqlserver" + when /sqlserver/ dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when "oci", "oracle" + when /oci/, /oracle/ ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| ActiveRecord::Base.connection.execute(ddl) end - when "firebird" + when /firebird/ ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.recreate_database! else @@ -372,9 +372,9 @@ end def drop_database(config) case config['adapter'] - when 'mysql' + when /mysql/ ActiveRecord::Base.connection.drop_database config['database'] - when /^sqlite/ + when /sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) when 'postgresql' ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) -- cgit v1.2.3 From 3151d96663874ac65bc49dd645b24605cd4817e0 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Thu, 8 May 2008 20:01:57 -0700 Subject: Revert "Change all databases.rake adapter 'when' statements to use regexes." This reverts commit 3d2512d38d2e28b3ea669139f7c7b0307522aa72. --- railties/lib/tasks/databases.rake | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 08294a6853..21c81b3fb5 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -32,7 +32,7 @@ namespace :db do ActiveRecord::Base.connection rescue case config['adapter'] - when /mysql/ + when 'mysql' @charset = ENV['CHARSET'] || 'utf8' @collation = ENV['COLLATION'] || 'utf8_general_ci' begin @@ -42,7 +42,7 @@ namespace :db do rescue $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config['charset'] || @charset}, collation: #{config['collation'] || @collation} (if you set the charset manually, make sure you have a matching collation)" end - when /postgresql/ + when 'postgresql' @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) @@ -52,9 +52,9 @@ namespace :db do $stderr.puts $!, *($!.backtrace) $stderr.puts "Couldn't create database for #{config.inspect}" end - when /sqlite$/ + when 'sqlite' `sqlite "#{config['database']}"` - when /sqlite3$/ + when 'sqlite3' `sqlite3 "#{config['database']}"` end else @@ -239,7 +239,7 @@ namespace :db do task :dump => :environment do abcs = ActiveRecord::Base.configurations case abcs[RAILS_ENV]["adapter"] - when /mysql/, /oci/, /oracle/ + when "mysql", "oci", "oracle" ActiveRecord::Base.establish_connection(abcs[RAILS_ENV]) File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump } when "postgresql" @@ -250,13 +250,13 @@ namespace :db do search_path = "--schema=#{search_path}" if search_path `pg_dump -i -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{search_path} #{abcs[RAILS_ENV]["database"]}` raise "Error dumping database" if $?.exitstatus == 1 - when /sqlite/ + when "sqlite", "sqlite3" dbfile = abcs[RAILS_ENV]["database"] || abcs[RAILS_ENV]["dbfile"] `#{abcs[RAILS_ENV]["adapter"]} #{dbfile} .schema > db/#{RAILS_ENV}_structure.sql` - when /sqlserver/ + when "sqlserver" `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r` `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r` - when /firebird/ + when "firebird" set_firebird_env(abcs[RAILS_ENV]) db_string = firebird_db_string(abcs[RAILS_ENV]) sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql" @@ -285,13 +285,13 @@ namespace :db do task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do abcs = ActiveRecord::Base.configurations case abcs["test"]["adapter"] - when /mysql/ + when "mysql" ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table| ActiveRecord::Base.connection.execute(table) end - when /postgresql/ + when "postgresql" ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"] ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"] ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"] @@ -301,12 +301,12 @@ namespace :db do `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql` when "sqlserver" `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when /oci/, /oracle/ + when "oci", "oracle" ActiveRecord::Base.establish_connection(:test) IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl| ActiveRecord::Base.connection.execute(ddl) end - when /firebird/ + when "firebird" set_firebird_env(abcs["test"]) db_string = firebird_db_string(abcs["test"]) sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}" @@ -319,7 +319,7 @@ namespace :db do task :purge => :environment do abcs = ActiveRecord::Base.configurations case abcs["test"]["adapter"] - when /mysql/ + when "mysql" ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"]) when "postgresql" @@ -329,16 +329,16 @@ namespace :db do when "sqlite","sqlite3" dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"] File.delete(dbfile) if File.exist?(dbfile) - when /sqlserver/ + when "sqlserver" dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-') `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}` `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql` - when /oci/, /oracle/ + when "oci", "oracle" ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.structure_drop.split(";\n\n").each do |ddl| ActiveRecord::Base.connection.execute(ddl) end - when /firebird/ + when "firebird" ActiveRecord::Base.establish_connection(:test) ActiveRecord::Base.connection.recreate_database! else @@ -372,9 +372,9 @@ end def drop_database(config) case config['adapter'] - when /mysql/ + when 'mysql' ActiveRecord::Base.connection.drop_database config['database'] - when /sqlite/ + when /^sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) when 'postgresql' ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) -- cgit v1.2.3 From c1b949869c3de8fc62f8ab072bbd77542b1d3605 Mon Sep 17 00:00:00 2001 From: Nick Sieger Date: Fri, 22 Aug 2008 15:44:59 -0500 Subject: Remove call to active_record.allow_concurrency since it's deprecated --- railties/lib/initializer.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 008f1de8fa..4c1f96d505 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -784,7 +784,6 @@ Run `rake gems:install` to install the missing gems. def threadsafe! self.cache_classes = true self.dependency_loading = false - self.active_record.allow_concurrency = true self.action_controller.allow_concurrency = true self end -- cgit v1.2.3 From efa6620a2a7b8ae7b42664ab81faef7df1368939 Mon Sep 17 00:00:00 2001 From: Nathaniel Bibler Date: Fri, 29 Aug 2008 23:36:16 -0400 Subject: Added optional rake doc:app TITLE environment parameter [#939 state:resolved] Signed-off-by: Jeremy Kemper --- railties/lib/tasks/documentation.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/lib') diff --git a/railties/lib/tasks/documentation.rake b/railties/lib/tasks/documentation.rake index f4927a0ef1..4ef838626a 100644 --- a/railties/lib/tasks/documentation.rake +++ b/railties/lib/tasks/documentation.rake @@ -1,9 +1,9 @@ namespace :doc do - desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb" + desc "Generate documentation for the application. Set custom template with TEMPLATE=/path/to/rdoc/template.rb or title with TITLE=\"Custom Title\"" Rake::RDocTask.new("app") { |rdoc| rdoc.rdoc_dir = 'doc/app' rdoc.template = ENV['template'] if ENV['template'] - rdoc.title = "Rails Application Documentation" + rdoc.title = ENV['title'] || "Rails Application Documentation" rdoc.options << '--line-numbers' << '--inline-source' rdoc.options << '--charset' << 'utf-8' rdoc.rdoc_files.include('doc/README_FOR_APP') -- cgit v1.2.3 From a1eb4e11c2cccb91483fa15f1a1a0b2ae518d2cf Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 31 Aug 2008 13:15:26 -0700 Subject: Get rid of 'Object#send!'. It was originally added because it's in Ruby 1.9, but it has since been removed from 1.9. Signed-off-by: Jeremy Kemper Conflicts: actionpack/test/controller/layout_test.rb --- railties/lib/initializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/lib') diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 008f1de8fa..0e2c7b827f 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -488,7 +488,7 @@ Run `rake gems:install` to install the missing gems. # If assigned value cannot be matched to a TimeZone, an exception will be raised. def initialize_time_zone if configuration.time_zone - zone_default = Time.send!(:get_zone, configuration.time_zone) + zone_default = Time.__send__(:get_zone, configuration.time_zone) unless zone_default raise %{Value assigned to config.time_zone not recognized. Run "rake -D time" for a list of tasks for finding appropriate time zone names.} end -- cgit v1.2.3