From b1ce7e4d4ada3eedc361d90b637ca06274a0ac3d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 10 Dec 2007 05:54:46 +0000 Subject: [PATCH] Ruby 1.9 compat: File.exists\? -> File.exist\? en masse. References #1689 [Pratik Naik] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8365 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_controller/caching.rb | 4 ++-- actionpack/lib/action_controller/rescue.rb | 2 +- .../test/template/asset_tag_helper_test.rb | 18 ++++++++--------- activerecord/test/aaa_create_tables_test.rb | 4 ++-- activerecord/test/associations_test.rb | 2 +- activesupport/test/multibyte_conformance.rb | 4 ++-- railties/builtin/rails_info/rails/info.rb | 2 +- railties/environments/boot.rb | 1 + railties/lib/commands/plugin.rb | 4 ++-- railties/lib/commands/runner.rb | 2 +- railties/lib/rails_generator/commands.rb | 8 ++++---- .../applications/app/app_generator.rb | 2 +- .../rails_generator/secret_key_generator.rb | 2 +- .../test/generators/generator_test_helper.rb | 4 ++-- .../generators/rails_model_generator_test.rb | 20 +++++++++---------- .../rails_resource_generator_test.rb | 20 +++++++++---------- .../rails_scaffold_generator_test.rb | 20 +++++++++---------- 17 files changed, 60 insertions(+), 59 deletions(-) diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index bf4e7799c7..e3e48f660b 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -81,7 +81,7 @@ module ActionController #:nodoc: return unless perform_caching benchmark "Expired page: #{page_cache_file(path)}" do - File.delete(page_cache_path(path)) if File.exists?(page_cache_path(path)) + File.delete(page_cache_path(path)) if File.exist?(page_cache_path(path)) end end @@ -552,7 +552,7 @@ module ActionController #:nodoc: end def ensure_cache_path(path) - FileUtils.makedirs(path) unless File.exists?(path) + FileUtils.makedirs(path) unless File.exist?(path) end def search_dir(dir, &callback) diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 46611b7c00..b91115a93c 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -154,7 +154,7 @@ module ActionController #:nodoc: def render_optional_error_file(status_code) status = interpret_status(status_code) path = "#{RAILS_ROOT}/public/#{status[0,3]}.html" - if File.exists?(path) + if File.exist?(path) render :file => path, :status => status else head status diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb index a27a597e98..502c54e57f 100644 --- a/actionpack/test/template/asset_tag_helper_test.rb +++ b/actionpack/test/template/asset_tag_helper_test.rb @@ -234,14 +234,14 @@ class AssetTagHelperTest < Test::Unit::TestCase javascript_include_tag(:all, :cache => true) ) - assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) assert_dom_equal( %(), javascript_include_tag(:all, :cache => "money") ) - assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) ensure File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) @@ -258,7 +258,7 @@ class AssetTagHelperTest < Test::Unit::TestCase javascript_include_tag(:all, :cache => "cache/money") ) - assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) ensure File.delete(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'cache', 'money.js')) end @@ -272,14 +272,14 @@ class AssetTagHelperTest < Test::Unit::TestCase javascript_include_tag(:all, :cache => true) ) - assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) + assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'all.js')) assert_dom_equal( %(\n\n), javascript_include_tag(:all, :cache => "money") ) - assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) + assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::JAVASCRIPTS_DIR, 'money.js')) end def test_caching_stylesheet_link_tag_when_caching_on @@ -292,14 +292,14 @@ class AssetTagHelperTest < Test::Unit::TestCase stylesheet_link_tag(:all, :cache => true) ) - assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) assert_dom_equal( %(), stylesheet_link_tag(:all, :cache => "money") ) - assert File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) + assert File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) ensure File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) File.delete(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) @@ -314,14 +314,14 @@ class AssetTagHelperTest < Test::Unit::TestCase stylesheet_link_tag(:all, :cache => true) ) - assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) + assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'all.css')) assert_dom_equal( %(\n), stylesheet_link_tag(:all, :cache => "money") ) - assert !File.exists?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) + assert !File.exist?(File.join(ActionView::Helpers::AssetTagHelper::STYLESHEETS_DIR, 'money.css')) end end diff --git a/activerecord/test/aaa_create_tables_test.rb b/activerecord/test/aaa_create_tables_test.rb index 3db6cb52d0..7703c76a35 100644 --- a/activerecord/test/aaa_create_tables_test.rb +++ b/activerecord/test/aaa_create_tables_test.rb @@ -33,12 +33,12 @@ class AAACreateTablesTest < Test::Unit::TestCase private def use_migrations? unittest_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + ".sql" - not File.exists? "#{@base_path}/#{unittest_sql_filename}" + not File.exist? "#{@base_path}/#{unittest_sql_filename}" end def use_migrations_for_courses? unittest2_sql_filename = ActiveRecord::Base.connection.adapter_name.downcase + "2.sql" - not File.exists? "#{@base_path}/#{unittest2_sql_filename}" + not File.exist? "#{@base_path}/#{unittest2_sql_filename}" end def recreate(base, suffix = nil) diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb index 64dc34066a..e35233a1b8 100755 --- a/activerecord/test/associations_test.rb +++ b/activerecord/test/associations_test.rb @@ -55,7 +55,7 @@ class AssociationsTest < Test::Unit::TestCase def test_storing_in_pstore require "tmpdir" store_filename = File.join(Dir.tmpdir, "ar-pstore-association-test") - File.delete(store_filename) if File.exists?(store_filename) + File.delete(store_filename) if File.exist?(store_filename) require "pstore" apple = Firm.create("name" => "Apple") natural = Client.new("name" => "Natural Company") diff --git a/activesupport/test/multibyte_conformance.rb b/activesupport/test/multibyte_conformance.rb index dfd77bd6e1..dede3e561d 100644 --- a/activesupport/test/multibyte_conformance.rb +++ b/activesupport/test/multibyte_conformance.rb @@ -10,7 +10,7 @@ class Downloader def self.download(from, to) unless File.exist?(to) $stderr.puts "Downloading #{from} to #{to}" - unless File.exists?(File.dirname(to)) + unless File.exist?(File.dirname(to)) system "mkdir -p #{File.dirname(to)}" end open(from) do |source| @@ -31,7 +31,7 @@ class String end unless ''.respond_to?(:ui) end -Dir.mkdir(CACHE_DIR) unless File.exists?(CACHE_DIR) +Dir.mkdir(CACHE_DIR) unless File.exist?(CACHE_DIR) Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE) module ConformanceTest diff --git a/railties/builtin/rails_info/rails/info.rb b/railties/builtin/rails_info/rails/info.rb index 176abfc0f8..b73cc13409 100644 --- a/railties/builtin/rails_info/rails/info.rb +++ b/railties/builtin/rails_info/rails/info.rb @@ -32,7 +32,7 @@ module Rails end def freeze_edge_version - if File.exists?(rails_vendor_root) + if File.exist?(rails_vendor_root) begin Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first rescue diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb index 1e9f1b109d..5697cc1bc3 100644 --- a/railties/environments/boot.rb +++ b/railties/environments/boot.rb @@ -24,6 +24,7 @@ module Rails File.exist?("#{RAILS_ROOT}/vendor/rails") end + # FIXME : Ruby 1.9 def preinitialize load(preinitializer_path) if File.exists?(preinitializer_path) end diff --git a/railties/lib/commands/plugin.rb b/railties/lib/commands/plugin.rb index ecef450ff4..a26f747dfb 100644 --- a/railties/lib/commands/plugin.rb +++ b/railties/lib/commands/plugin.rb @@ -214,12 +214,12 @@ class Plugin def run_install_hook install_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/install.rb" - load install_hook_file if File.exists? install_hook_file + load install_hook_file if File.exist? install_hook_file end def run_uninstall_hook uninstall_hook_file = "#{rails_env.root}/vendor/plugins/#{name}/uninstall.rb" - load uninstall_hook_file if File.exists? uninstall_hook_file + load uninstall_hook_file if File.exist? uninstall_hook_file end def install_using_export(options = {}) diff --git a/railties/lib/commands/runner.rb b/railties/lib/commands/runner.rb index 62db8b75e1..926bc26344 100644 --- a/railties/lib/commands/runner.rb +++ b/railties/lib/commands/runner.rb @@ -41,7 +41,7 @@ require RAILS_ROOT + '/config/environment' if code_or_file.nil? $stderr.puts "Run '#{$0} -h' for help." exit 1 -elsif File.exists?(code_or_file) +elsif File.exist?(code_or_file) eval(File.read(code_or_file)) else eval(code_or_file) diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 98531d9771..6f90a44b8a 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -207,7 +207,7 @@ HELP # Determine full paths for source and destination files. source = source_path(relative_source) destination = destination_path(relative_destination) - destination_exists = File.exists?(destination) + destination_exists = File.exist?(destination) # If source and destination are identical then we're done. if destination_exists and identical?(source, destination, &block) @@ -306,7 +306,7 @@ HELP # Always directories which exist. def directory(relative_path) path = destination_path(relative_path) - if File.exists?(path) + if File.exist?(path) logger.exists relative_path else logger.create relative_path @@ -415,7 +415,7 @@ end_message # Remove a file if it exists and is a file. def file(relative_source, relative_destination, file_options = {}) destination = destination_path(relative_destination) - if File.exists?(destination) + if File.exist?(destination) logger.rm relative_destination unless options[:pretend] if options[:svn] @@ -450,7 +450,7 @@ end_message until parts.empty? partial = File.join(parts) path = destination_path(partial) - if File.exists?(path) + if File.exist?(path) if Dir[File.join(path, '*')].empty? logger.rmdir partial unless options[:pretend] 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 02d9b0fb88..915b15317f 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -128,7 +128,7 @@ class AppGenerator < Rails::Generator::Base end def mysql_socket_location - MYSQL_SOCKET_LOCATIONS.find { |f| File.exists?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ + MYSQL_SOCKET_LOCATIONS.find { |f| File.exist?(f) } unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ end diff --git a/railties/lib/rails_generator/secret_key_generator.rb b/railties/lib/rails_generator/secret_key_generator.rb index f488f96f32..497df72ce9 100644 --- a/railties/lib/rails_generator/secret_key_generator.rb +++ b/railties/lib/rails_generator/secret_key_generator.rb @@ -141,7 +141,7 @@ module Rails end def self.supports_urandom? - File.exists?('/dev/urandom') + File.exist?('/dev/urandom') end def self.supports_openssl? diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb index 63780b3dfb..3af5886a01 100644 --- a/railties/test/generators/generator_test_helper.rb +++ b/railties/test/generators/generator_test_helper.rb @@ -77,7 +77,7 @@ module GeneratorTestHelper # asserts that the given file exists def assert_file_exists(path) - assert File.exists?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist" + assert File.exist?("#{RAILS_ROOT}/#{path}"),"The file '#{path}' should exist" end # asserts that the given class source file was generated. @@ -158,7 +158,7 @@ module GeneratorTestHelper # It takes the name of the migration as a parameter. def assert_skipped_migration(name) migration_file = "#{RAILS_ROOT}/db/migrate/001_#{name.to_s.underscore}.rb" - assert !File.exists?(migration_file), "should not create migration #{migration_file}" + assert !File.exist?(migration_file), "should not create migration #{migration_file}" end # asserts that the given resource was added to the routes. diff --git a/railties/test/generators/rails_model_generator_test.rb b/railties/test/generators/rails_model_generator_test.rb index 81d57607d6..a1637c4cda 100644 --- a/railties/test/generators/rails_model_generator_test.rb +++ b/railties/test/generators/rails_model_generator_test.rb @@ -46,7 +46,7 @@ if defined?(RAILS_ROOT) else RAILS_ROOT=tmp_dir end -Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) +Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" require 'rails_generator' @@ -57,15 +57,15 @@ class RailsModelGeneratorTest < Test::Unit::TestCase def setup ActiveRecord::Base.pluralize_table_names = true - Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") - Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") - Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") - Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") - Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") - Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") - Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") - Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") - Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets") + Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") + Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") + Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") + Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") + Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") + Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") + Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") + Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") + Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" end diff --git a/railties/test/generators/rails_resource_generator_test.rb b/railties/test/generators/rails_resource_generator_test.rb index 7aa06b645d..63cd284d35 100644 --- a/railties/test/generators/rails_resource_generator_test.rb +++ b/railties/test/generators/rails_resource_generator_test.rb @@ -46,7 +46,7 @@ if defined?(RAILS_ROOT) else RAILS_ROOT=tmp_dir end -Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) +Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" require 'rails_generator' @@ -57,15 +57,15 @@ class RailsResourceGeneratorTest < Test::Unit::TestCase def setup ActiveRecord::Base.pluralize_table_names = true - Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") - Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") - Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") - Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") - Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") - Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") - Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") - Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") - Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets") + Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") + Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") + Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") + Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") + Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") + Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") + Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") + Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") + Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" end diff --git a/railties/test/generators/rails_scaffold_generator_test.rb b/railties/test/generators/rails_scaffold_generator_test.rb index 4de175b45e..16588affab 100644 --- a/railties/test/generators/rails_scaffold_generator_test.rb +++ b/railties/test/generators/rails_scaffold_generator_test.rb @@ -48,7 +48,7 @@ if defined?(RAILS_ROOT) else RAILS_ROOT=tmp_dir end -Dir.mkdir(RAILS_ROOT) unless File.exists?(RAILS_ROOT) +Dir.mkdir(RAILS_ROOT) unless File.exist?(RAILS_ROOT) $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../lib" require 'rails_generator' @@ -60,15 +60,15 @@ class RailsScaffoldGeneratorTest < Test::Unit::TestCase def setup ActiveRecord::Base.pluralize_table_names = true - Dir.mkdir("#{RAILS_ROOT}/app") unless File.exists?("#{RAILS_ROOT}/app") - Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exists?("#{RAILS_ROOT}/app/views") - Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exists?("#{RAILS_ROOT}/app/views/layouts") - Dir.mkdir("#{RAILS_ROOT}/config") unless File.exists?("#{RAILS_ROOT}/config") - Dir.mkdir("#{RAILS_ROOT}/db") unless File.exists?("#{RAILS_ROOT}/db") - Dir.mkdir("#{RAILS_ROOT}/test") unless File.exists?("#{RAILS_ROOT}/test") - Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exists?("#{RAILS_ROOT}/test/fixtures") - Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") - Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets") + Dir.mkdir("#{RAILS_ROOT}/app") unless File.exist?("#{RAILS_ROOT}/app") + Dir.mkdir("#{RAILS_ROOT}/app/views") unless File.exist?("#{RAILS_ROOT}/app/views") + Dir.mkdir("#{RAILS_ROOT}/app/views/layouts") unless File.exist?("#{RAILS_ROOT}/app/views/layouts") + Dir.mkdir("#{RAILS_ROOT}/config") unless File.exist?("#{RAILS_ROOT}/config") + Dir.mkdir("#{RAILS_ROOT}/db") unless File.exist?("#{RAILS_ROOT}/db") + Dir.mkdir("#{RAILS_ROOT}/test") unless File.exist?("#{RAILS_ROOT}/test") + Dir.mkdir("#{RAILS_ROOT}/test/fixtures") unless File.exist?("#{RAILS_ROOT}/test/fixtures") + Dir.mkdir("#{RAILS_ROOT}/public") unless File.exist?("#{RAILS_ROOT}/public") + Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exist?("#{RAILS_ROOT}/public/stylesheets") File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" end