From e6ab70c439301d533f14b3387ee181d843a86b30 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 19:28:46 +0200 Subject: [PATCH] applies new string literal convention to the rest of the project The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default. --- Rakefile | 24 ++++----- actioncable/Rakefile | 12 ++--- actionmailer/Rakefile | 6 +-- actionpack/Rakefile | 14 ++--- actionview/Rakefile | 18 +++---- activejob/Rakefile | 32 ++++++------ activemodel/Rakefile | 4 +- activerecord/Rakefile | 76 ++++++++++++++-------------- activerecord/bin/test | 2 +- activerecord/examples/performance.rb | 48 +++++++++--------- activerecord/examples/simple.rb | 6 +-- activesupport/Rakefile | 8 +-- activesupport/bin/generate_tables | 30 +++++------ railties/Rakefile | 14 ++--- railties/exe/rails | 4 +- 15 files changed, 149 insertions(+), 149 deletions(-) diff --git a/Rakefile b/Rakefile index 1d70ce96ea..02e9e5997c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,8 @@ -require 'net/http' +require "net/http" -$:.unshift File.expand_path('..', __FILE__) +$:.unshift File.expand_path("..", __FILE__) require "tasks/release" -require 'railties/lib/rails/api/task' +require "railties/lib/rails/api/task" desc "Build gem files for all projects" task :build => "all:build" @@ -13,7 +13,7 @@ task :prep_release => "all:prep_release" desc "Release all gems to rubygems and create a tag" task :release => "all:release" -desc 'Run all tests by default' +desc "Run all tests by default" task :default => %w(test test:isolated) %w(test test:isolated package gem).each do |task_name| @@ -24,7 +24,7 @@ task :default => %w(test test:isolated) system(%(cd #{project} && #{$0} #{task_name} --trace)) || errors << project end if task_name =~ /test/ - system(%(cd actioncable && env FAYE=1 #{$0} #{task_name} --trace)) || errors << 'actioncable-faye' + system(%(cd actioncable && env FAYE=1 #{$0} #{task_name} --trace)) || errors << "actioncable-faye" end fail("Errors in #{errors.join(', ')}") unless errors.empty? end @@ -43,13 +43,13 @@ desc "Install gems for all projects." task :install => "all:install" desc "Generate documentation for the Rails framework" -if ENV['EDGE'] - Rails::API::EdgeTask.new('rdoc') +if ENV["EDGE"] + Rails::API::EdgeTask.new("rdoc") else - Rails::API::StableTask.new('rdoc') + Rails::API::StableTask.new("rdoc") end -desc 'Bump all versions to match RAILS_VERSION' +desc "Bump all versions to match RAILS_VERSION" task :update_versions => "all:update_versions" # We have a webhook configured in GitHub that gets invoked after pushes. @@ -61,10 +61,10 @@ task :update_versions => "all:update_versions" # * if there's a new stable tag, generates and publishes stable docs # # Everything is automated and you do NOT need to run this task normally. -desc 'Publishes docs, run this AFTER a new stable tag has been pushed' +desc "Publishes docs, run this AFTER a new stable tag has been pushed" task :publish_docs do - Net::HTTP.new('api.rubyonrails.org', 8080).start do |http| - request = Net::HTTP::Post.new('/rails-master-hook') + Net::HTTP.new("api.rubyonrails.org", 8080).start do |http| + request = Net::HTTP::Post.new("/rails-master-hook") response = http.request(request) puts response.body end diff --git a/actioncable/Rakefile b/actioncable/Rakefile index a72142deb5..4419eb1738 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -1,7 +1,7 @@ -require 'rake/testtask' -require 'pathname' -require 'action_cable' -require 'blade' +require "rake/testtask" +require "pathname" +require "action_cable" +require "blade" dir = File.dirname(__FILE__) @@ -20,12 +20,12 @@ end namespace :test do task :isolated do Dir.glob("test/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', '-Ilib:test', file) + sh(Gem.ruby, "-w", "-Ilib:test", file) end or raise "Failures" end task :integration do - if ENV['CI'] + if ENV["CI"] Blade.start(interface: :ci) else Blade.start(interface: :runner) diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 416c9ee33a..059d98fb28 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -1,4 +1,4 @@ -require 'rake/testtask' +require "rake/testtask" desc "Default Task" task default: [ :test ] @@ -8,7 +8,7 @@ task :package # Run the unit tests Rake::TestTask.new { |t| t.libs << "test" - t.pattern = 'test/**/*_test.rb' + t.pattern = "test/**/*_test.rb" t.warning = true t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) @@ -17,7 +17,7 @@ Rake::TestTask.new { |t| namespace :test do task :isolated do Dir.glob("test/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', '-Ilib:test', file) + sh(Gem.ruby, "-w", "-Ilib:test", file) end or raise "Failures" end end diff --git a/actionpack/Rakefile b/actionpack/Rakefile index 4a05c067a9..b8e62bf428 100644 --- a/actionpack/Rakefile +++ b/actionpack/Rakefile @@ -1,6 +1,6 @@ -require 'rake/testtask' +require "rake/testtask" -test_files = Dir.glob('test/**/*_test.rb') +test_files = Dir.glob("test/**/*_test.rb") desc "Default Task" task :default => :test @@ -9,7 +9,7 @@ task :package # Run the unit tests Rake::TestTask.new do |t| - t.libs << 'test' + t.libs << "test" t.test_files = test_files t.warning = true @@ -20,19 +20,19 @@ end namespace :test do task :isolated do test_files.all? do |file| - sh(Gem.ruby, '-w', '-Ilib:test', file) + sh(Gem.ruby, "-w", "-Ilib:test", file) end or raise "Failures" end end task :lines do - load File.expand_path('..', File.dirname(__FILE__)) + '/tools/line_statistics' + load File.expand_path("..", File.dirname(__FILE__)) + "/tools/line_statistics" files = FileList["lib/**/*.rb"] CodeTools::LineStatistics.new(files).print_loc end -rule '.rb' => '.y' do |t| +rule ".rb" => ".y" do |t| sh "racc -l -o #{t.name} #{t.source}" end -task compile: 'lib/action_dispatch/journey/parser.rb' +task compile: "lib/action_dispatch/journey/parser.rb" diff --git a/actionview/Rakefile b/actionview/Rakefile index f0f9bda3e4..936620e6e6 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -1,4 +1,4 @@ -require 'rake/testtask' +require "rake/testtask" desc "Default Task" task :default => :test @@ -13,31 +13,31 @@ task :test => ["test:template", "test:integration:action_pack", "test:integratio namespace :test do task :isolated do Dir.glob("test/{actionpack,activerecord,template}/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', '-Ilib:test', file) + sh(Gem.ruby, "-w", "-Ilib:test", file) end or raise "Failures" end Rake::TestTask.new(:template) do |t| - t.libs << 'test' - t.test_files = Dir.glob('test/template/**/*_test.rb') + t.libs << "test" + t.test_files = Dir.glob("test/template/**/*_test.rb") t.warning = true t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) end namespace :integration do - desc 'ActiveRecord Integration Tests' + desc "ActiveRecord Integration Tests" Rake::TestTask.new(:active_record) do |t| - t.libs << 'test' + t.libs << "test" t.test_files = Dir.glob("test/activerecord/*_test.rb") t.warning = true t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) end - desc 'ActionPack Integration Tests' + desc "ActionPack Integration Tests" Rake::TestTask.new(:action_pack) do |t| - t.libs << 'test' + t.libs << "test" t.test_files = Dir.glob("test/actionpack/**/*_test.rb") t.warning = true t.verbose = true @@ -47,7 +47,7 @@ namespace :test do end task :lines do - load File.expand_path('..', File.dirname(__FILE__)) + '/tools/line_statistics' + load File.expand_path("..", File.dirname(__FILE__)) + "/tools/line_statistics" files = FileList["lib/**/*.rb"] CodeTools::LineStatistics.new(files).print_loc end diff --git a/activejob/Rakefile b/activejob/Rakefile index e47f17b740..da153c8a49 100644 --- a/activejob/Rakefile +++ b/activejob/Rakefile @@ -1,41 +1,41 @@ -require 'rake/testtask' +require "rake/testtask" #TODO: add qu back to the list after it support Rails 5.1 ACTIVEJOB_ADAPTERS = %w(async inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch backburner test) ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION) task default: :test -task test: 'test:default' +task test: "test:default" task :package namespace :test do - desc 'Run all adapter tests' + desc "Run all adapter tests" task :default do run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:#{a}" } end - desc 'Run all adapter tests in isolation' + desc "Run all adapter tests in isolation" task :isolated do run_without_aborting ACTIVEJOB_ADAPTERS.map { |a| "test:isolated:#{a}" } end - desc 'Run integration tests for all adapters' + desc "Run integration tests for all adapters" task :integration do - run_without_aborting (ACTIVEJOB_ADAPTERS - ['test']).map { |a| "test:integration:#{a}" } + run_without_aborting (ACTIVEJOB_ADAPTERS - ["test"]).map { |a| "test:integration:#{a}" } end - task 'env:integration' do - ENV['AJ_INTEGRATION_TESTS'] = "1" + task "env:integration" do + ENV["AJ_INTEGRATION_TESTS"] = "1" end ACTIVEJOB_ADAPTERS.each do |adapter| - task("env:#{adapter}") { ENV['AJ_ADAPTER'] = adapter } + task("env:#{adapter}") { ENV["AJ_ADAPTER"] = adapter } Rake::TestTask.new(adapter => "test:env:#{adapter}") do |t| t.description = "Run adapter tests for #{adapter}" - t.libs << 'test' - t.test_files = FileList['test/cases/**/*_test.rb'] + t.libs << "test" + t.test_files = FileList["test/cases/**/*_test.rb"] t.verbose = true t.warning = false t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) @@ -45,16 +45,16 @@ namespace :test do task adapter => "test:env:#{adapter}" do dir = File.dirname(__FILE__) Dir.glob("#{dir}/test/cases/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', "-I#{dir}/lib", "-I#{dir}/test", file) - end or raise 'Failures' + sh(Gem.ruby, "-w", "-I#{dir}/lib", "-I#{dir}/test", file) + end or raise "Failures" end end namespace :integration do - Rake::TestTask.new(adapter => ["test:env:#{adapter}", 'test:env:integration']) do |t| + Rake::TestTask.new(adapter => ["test:env:#{adapter}", "test:env:integration"]) do |t| t.description = "Run integration tests for #{adapter}" - t.libs << 'test' - t.test_files = FileList['test/integration/**/*_test.rb'] + t.libs << "test" + t.test_files = FileList["test/integration/**/*_test.rb"] t.verbose = true t.warning = false t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 036815a987..d94f857614 100644 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -1,4 +1,4 @@ -require 'rake/testtask' +require "rake/testtask" dir = File.dirname(__FILE__) @@ -17,7 +17,7 @@ end namespace :test do task :isolated do Dir.glob("#{dir}/test/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', "-I#{dir}/lib", "-I#{dir}/test", file) + sh(Gem.ruby, "-w", "-I#{dir}/lib", "-I#{dir}/test", file) end or raise "Failures" end end diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 8fbea61335..5bf1c843af 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -1,4 +1,4 @@ -require 'rake/testtask' +require "rake/testtask" require File.expand_path(File.dirname(__FILE__)) + "/test/config" require File.expand_path(File.dirname(__FILE__)) + "/test/support/config" @@ -17,12 +17,12 @@ def run_without_aborting(*tasks) abort "Errors running #{errors.join(', ')}" if errors.any? end -desc 'Run mysql2, sqlite, and postgresql tests by default' +desc "Run mysql2, sqlite, and postgresql tests by default" task :default => :test task :package -desc 'Run mysql2, sqlite, and postgresql tests' +desc "Run mysql2, sqlite, and postgresql tests" task :test do tasks = defined?(JRUBY_VERSION) ? %w(test_jdbcmysql test_jdbcsqlite3 test_jdbcpostgresql) : @@ -39,19 +39,19 @@ namespace :test do end end -desc 'Build MySQL and PostgreSQL test databases' +desc "Build MySQL and PostgreSQL test databases" namespace :db do - task :create => ['db:mysql:build', 'db:postgresql:build'] - task :drop => ['db:mysql:drop', 'db:postgresql:drop'] + task :create => ["db:mysql:build", "db:postgresql:build"] + task :drop => ["db:mysql:drop", "db:postgresql:drop"] end %w( mysql2 postgresql sqlite3 sqlite3_mem db2 oracle jdbcmysql jdbcpostgresql jdbcsqlite3 jdbcderby jdbch2 jdbchsqldb ).each do |adapter| namespace :test do Rake::TestTask.new(adapter => "#{adapter}:env") { |t| - adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/] - t.libs << 'test' + adapter_short = adapter == "db2" ? adapter : adapter[/^[a-z0-9]+/] + t.libs << "test" t.test_files = (Dir.glob( "test/cases/**/*_test.rb" ).reject { - |x| x.include?('/adapters/') + |x| x.include?("/adapters/") } + Dir.glob("test/cases/adapters/#{adapter_short}/**/*_test.rb")) t.warning = true @@ -61,12 +61,12 @@ end namespace :isolated do task adapter => "#{adapter}:env" do - adapter_short = adapter == 'db2' ? adapter : adapter[/^[a-z0-9]+/] + adapter_short = adapter == "db2" ? adapter : adapter[/^[a-z0-9]+/] puts [adapter, adapter_short].inspect (Dir["test/cases/**/*_test.rb"].reject { - |x| x.include?('/adapters/') + |x| x.include?("/adapters/") } + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file| - sh(Gem.ruby, '-w' ,"-Itest", file) + sh(Gem.ruby, "-w" ,"-Itest", file) end or raise "Failures" end end @@ -77,7 +77,7 @@ end task :isolated_test => "isolated_test_#{adapter}" # Set the connection environment for the adapter - task(:env) { ENV['ARCONN'] = adapter } + task(:env) { ENV["ARCONN"] = adapter } end # Make sure the adapter test evaluates the env setting task @@ -87,30 +87,30 @@ end namespace :db do namespace :mysql do - desc 'Build the MySQL test databases' + desc "Build the MySQL test databases" task :build do - config = ARTest.config['connections']['mysql2'] - %x( mysql --user=#{config['arunit']['username']} --password=#{config['arunit']['password']} -e "create DATABASE #{config['arunit']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") - %x( mysql --user=#{config['arunit2']['username']} --password=#{config['arunit2']['password']} -e "create DATABASE #{config['arunit2']['database']} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") + config = ARTest.config["connections"]["mysql2"] + %x( mysql --user=#{config["arunit"]["username"]} --password=#{config["arunit"]["password"]} -e "create DATABASE #{config["arunit"]["database"]} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") + %x( mysql --user=#{config["arunit2"]["username"]} --password=#{config["arunit2"]["password"]} -e "create DATABASE #{config["arunit2"]["database"]} DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci ") end - desc 'Drop the MySQL test databases' + desc "Drop the MySQL test databases" task :drop do - config = ARTest.config['connections']['mysql2'] - %x( mysqladmin --user=#{config['arunit']['username']} --password=#{config['arunit']['password']} -f drop #{config['arunit']['database']} ) - %x( mysqladmin --user=#{config['arunit2']['username']} --password=#{config['arunit2']['password']} -f drop #{config['arunit2']['database']} ) + config = ARTest.config["connections"]["mysql2"] + %x( mysqladmin --user=#{config["arunit"]["username"]} --password=#{config["arunit"]["password"]} -f drop #{config["arunit"]["database"]} ) + %x( mysqladmin --user=#{config["arunit2"]["username"]} --password=#{config["arunit2"]["password"]} -f drop #{config["arunit2"]["database"]} ) end - desc 'Rebuild the MySQL test databases' + desc "Rebuild the MySQL test databases" task :rebuild => [:drop, :build] end namespace :postgresql do - desc 'Build the PostgreSQL test databases' + desc "Build the PostgreSQL test databases" task :build do - config = ARTest.config['connections']['postgresql'] - %x( createdb -E UTF8 -T template0 #{config['arunit']['database']} ) - %x( createdb -E UTF8 -T template0 #{config['arunit2']['database']} ) + config = ARTest.config["connections"]["postgresql"] + %x( createdb -E UTF8 -T template0 #{config["arunit"]["database"]} ) + %x( createdb -E UTF8 -T template0 #{config["arunit2"]["database"]} ) # prepare hstore if %x( createdb --version ).strip.gsub(/(.*)(\d\.\d\.\d)$/, "\\2") < "9.1.0" @@ -118,28 +118,28 @@ namespace :db do end end - desc 'Drop the PostgreSQL test databases' + desc "Drop the PostgreSQL test databases" task :drop do - config = ARTest.config['connections']['postgresql'] - %x( dropdb #{config['arunit']['database']} ) - %x( dropdb #{config['arunit2']['database']} ) + config = ARTest.config["connections"]["postgresql"] + %x( dropdb #{config["arunit"]["database"]} ) + %x( dropdb #{config["arunit2"]["database"]} ) end - desc 'Rebuild the PostgreSQL test databases' + desc "Rebuild the PostgreSQL test databases" task :rebuild => [:drop, :build] end end -task :build_mysql_databases => 'db:mysql:build' -task :drop_mysql_databases => 'db:mysql:drop' -task :rebuild_mysql_databases => 'db:mysql:rebuild' +task :build_mysql_databases => "db:mysql:build" +task :drop_mysql_databases => "db:mysql:drop" +task :rebuild_mysql_databases => "db:mysql:rebuild" -task :build_postgresql_databases => 'db:postgresql:build' -task :drop_postgresql_databases => 'db:postgresql:drop' -task :rebuild_postgresql_databases => 'db:postgresql:rebuild' +task :build_postgresql_databases => "db:postgresql:build" +task :drop_postgresql_databases => "db:postgresql:drop" +task :rebuild_postgresql_databases => "db:postgresql:rebuild" task :lines do - load File.expand_path('..', File.dirname(__FILE__)) + '/tools/line_statistics' + load File.expand_path("..", File.dirname(__FILE__)) + "/tools/line_statistics" files = FileList["lib/active_record/**/*.rb"] CodeTools::LineStatistics.new(files).print_loc end diff --git a/activerecord/bin/test b/activerecord/bin/test index 7417b068bf..822e303ad8 100755 --- a/activerecord/bin/test +++ b/activerecord/bin/test @@ -14,6 +14,6 @@ module Minitest end end -Minitest.extensions.unshift 'active_record' +Minitest.extensions.unshift "active_record" exit Minitest.run(ARGV) diff --git a/activerecord/examples/performance.rb b/activerecord/examples/performance.rb index c3c46c19c5..cb9ee58f59 100644 --- a/activerecord/examples/performance.rb +++ b/activerecord/examples/performance.rb @@ -1,10 +1,10 @@ require "active_record" -require 'benchmark/ips' +require "benchmark/ips" -TIME = (ENV['BENCHMARK_TIME'] || 20).to_i -RECORDS = (ENV['BENCHMARK_RECORDS'] || TIME*1000).to_i +TIME = (ENV["BENCHMARK_TIME"] || 20).to_i +RECORDS = (ENV["BENCHMARK_RECORDS"] || TIME*1000).to_i -conn = { adapter: 'sqlite3', database: ':memory:' } +conn = { adapter: "sqlite3", database: ":memory:" } ActiveRecord::Base.establish_connection(conn) @@ -44,7 +44,7 @@ end def progress_bar(int); print "." if (int%100).zero? ; end -puts 'Generating data...' +puts "Generating data..." module ActiveRecord class Faker @@ -57,11 +57,11 @@ module ActiveRecord Praesent varius tincidunt commodo}.split def self.name - LOREM.grep(/^\w*$/).sort_by { rand }.first(2).join ' ' + LOREM.grep(/^\w*$/).sort_by { rand }.first(2).join " " end def self.email - LOREM.grep(/^\w*$/).sort_by { rand }.first(2).join('@') + ".com" + LOREM.grep(/^\w*$/).sort_by { rand }.first(2).join("@") + ".com" end end end @@ -72,7 +72,7 @@ end # Using the same paragraph for all exhibits because it is very slow # to generate unique paragraphs for all exhibits. -notes = ActiveRecord::Faker::LOREM.join ' ' +notes = ActiveRecord::Faker::LOREM.join " " today = Date.today puts "Inserting #{RECORDS} users and exhibits..." @@ -95,9 +95,9 @@ puts "Done!\n" Benchmark.ips(TIME) do |x| ar_obj = Exhibit.find(1) - attrs = { name: 'sam' } - attrs_first = { name: 'sam' } - attrs_second = { name: 'tom' } + attrs = { name: "sam" } + attrs_first = { name: "sam" } + attrs_second = { name: "tom" } exhibit = { name: ActiveRecord::Faker.name, notes: notes, @@ -108,19 +108,19 @@ Benchmark.ips(TIME) do |x| ar_obj.id end - x.report 'Model.new (instantiation)' do + x.report "Model.new (instantiation)" do Exhibit.new end - x.report 'Model.new (setting attributes)' do + x.report "Model.new (setting attributes)" do Exhibit.new(attrs) end - x.report 'Model.first' do + x.report "Model.first" do Exhibit.first.look end - x.report 'Model.take' do + x.report "Model.take" do Exhibit.take end @@ -140,36 +140,36 @@ Benchmark.ips(TIME) do |x| Exhibit.look Exhibit.limit(10000) end - x.report 'Model.named_scope' do + x.report "Model.named_scope" do Exhibit.limit(10).with_name.with_notes end - x.report 'Model.create' do + x.report "Model.create" do Exhibit.create(exhibit) end - x.report 'Resource#attributes=' do + x.report "Resource#attributes=" do e = Exhibit.new(attrs_first) e.attributes = attrs_second end - x.report 'Resource#update' do - Exhibit.first.update(name: 'bob') + x.report "Resource#update" do + Exhibit.first.update(name: "bob") end - x.report 'Resource#destroy' do + x.report "Resource#destroy" do Exhibit.first.destroy end - x.report 'Model.transaction' do + x.report "Model.transaction" do Exhibit.transaction { Exhibit.new } end - x.report 'Model.find(id)' do + x.report "Model.find(id)" do User.find(1) end - x.report 'Model.find_by_sql' do + x.report "Model.find_by_sql" do Exhibit.find_by_sql("SELECT * FROM exhibits WHERE id = #{(rand * 1000 + 1).to_i}").first end diff --git a/activerecord/examples/simple.rb b/activerecord/examples/simple.rb index 5a041e8417..c3648fee48 100644 --- a/activerecord/examples/simple.rb +++ b/activerecord/examples/simple.rb @@ -1,13 +1,13 @@ -require 'active_record' +require "active_record" class Person < ActiveRecord::Base - establish_connection adapter: 'sqlite3', database: 'foobar.db' + establish_connection adapter: "sqlite3", database: "foobar.db" connection.create_table table_name, force: true do |t| t.string :name end end -bob = Person.create!(name: 'bob') +bob = Person.create!(name: "bob") puts Person.all.inspect bob.destroy puts Person.all.inspect diff --git a/activesupport/Rakefile b/activesupport/Rakefile index 7b56e36abf..de3467529d 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -1,12 +1,12 @@ -require 'rake/testtask' +require "rake/testtask" task :default => :test task :package Rake::TestTask.new do |t| - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' + t.libs << "test" + t.pattern = "test/**/*_test.rb" t.warning = true t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) @@ -15,7 +15,7 @@ end namespace :test do task :isolated do Dir.glob("test/**/*_test.rb").all? do |file| - sh(Gem.ruby, '-w', '-Ilib:test', file) + sh(Gem.ruby, "-w", "-Ilib:test", file) end or raise "Failures" end end diff --git a/activesupport/bin/generate_tables b/activesupport/bin/generate_tables index 2193533588..c5ed991d94 100755 --- a/activesupport/bin/generate_tables +++ b/activesupport/bin/generate_tables @@ -1,13 +1,13 @@ #!/usr/bin/env ruby begin - $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib')) - require 'active_support' + $:.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) + require "active_support" rescue IOError end -require 'open-uri' -require 'tmpdir' +require "open-uri" +require "tmpdir" module ActiveSupport module Multibyte @@ -20,10 +20,10 @@ module ActiveSupport class DatabaseGenerator BASE_URI = "http://www.unicode.org/Public/#{UNICODE_VERSION}/ucd/" SOURCES = { - :codepoints => BASE_URI + 'UnicodeData.txt', - :composition_exclusion => BASE_URI + 'CompositionExclusions.txt', - :grapheme_break_property => BASE_URI + 'auxiliary/GraphemeBreakProperty.txt', - :cp1252 => 'http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT' + :codepoints => BASE_URI + "UnicodeData.txt", + :composition_exclusion => BASE_URI + "CompositionExclusions.txt", + :grapheme_break_property => BASE_URI + "auxiliary/GraphemeBreakProperty.txt", + :cp1252 => "http://unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT" } def initialize @@ -52,9 +52,9 @@ module ActiveSupport codepoint.code = $1.hex codepoint.combining_class = Integer($4) codepoint.decomp_type = $7 - codepoint.decomp_mapping = ($8=='') ? nil : $8.split.collect(&:hex) - codepoint.uppercase_mapping = ($16=='') ? 0 : $16.hex - codepoint.lowercase_mapping = ($17=='') ? 0 : $17.hex + codepoint.decomp_mapping = ($8=="") ? nil : $8.split.collect(&:hex) + codepoint.uppercase_mapping = ($16=="") ? 0 : $16.hex + codepoint.lowercase_mapping = ($17=="") ? 0 : $17.hex @ucd.codepoints[codepoint.code] = codepoint end @@ -62,8 +62,8 @@ module ActiveSupport if line =~ /^([0-9A-F.]+)\s*;\s*([\w]+)\s*#/ type = $2.downcase.intern @ucd.boundary[type] ||= [] - if $1.include? '..' - parts = $1.split '..' + if $1.include? ".." + parts = $1.split ".." @ucd.boundary[type] << (parts[0].hex..parts[1].hex) else @ucd.boundary[type] << $1.hex @@ -105,7 +105,7 @@ module ActiveSupport filename = File.join(Dir.tmpdir, "#{url.split('/').last}") unless File.exist?(filename) $stderr.puts "Downloading #{url.split('/').last}" - File.open(filename, 'wb') do |target| + File.open(filename, "wb") do |target| open(url) do |source| source.each_line { |line| target.write line } end @@ -120,7 +120,7 @@ module ActiveSupport end def dump_to(filename) - File.open(filename, 'wb') do |f| + File.open(filename, "wb") do |f| f.write Marshal.dump([@ucd.codepoints, @ucd.composition_exclusion, @ucd.composition_map, @ucd.boundary, @ucd.cp1252]) end end diff --git a/railties/Rakefile b/railties/Rakefile index db23bbabaa..edc405f605 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,11 +1,11 @@ -require 'rake/testtask' +require "rake/testtask" task :default => :test task :package desc "Run all unit tests" -task :test => 'test:isolated' +task :test => "test:isolated" namespace :test do task :isolated do @@ -14,8 +14,8 @@ namespace :test do Dir[*test_files].each do |file| next true if file.include?("fixtures") dash_i = [ - 'test', - 'lib', + "test", + "lib", "#{File.dirname(__FILE__)}/../activesupport/lib", "#{File.dirname(__FILE__)}/../actionpack/lib", "#{File.dirname(__FILE__)}/../activemodel/lib" @@ -25,9 +25,9 @@ namespace :test do end end -Rake::TestTask.new('test:regular') do |t| - t.libs << 'test' << "#{File.dirname(__FILE__)}/../activesupport/lib" - t.pattern = 'test/**/*_test.rb' +Rake::TestTask.new("test:regular") do |t| + t.libs << "test" << "#{File.dirname(__FILE__)}/../activesupport/lib" + t.pattern = "test/**/*_test.rb" t.warning = false t.verbose = true t.ruby_opts = ["--dev"] if defined?(JRUBY_VERSION) diff --git a/railties/exe/rails b/railties/exe/rails index 82c17cabce..7e791c1f99 100755 --- a/railties/exe/rails +++ b/railties/exe/rails @@ -1,9 +1,9 @@ #!/usr/bin/env ruby -git_path = File.expand_path('../../../.git', __FILE__) +git_path = File.expand_path("../../../.git", __FILE__) if File.exist?(git_path) - railties_path = File.expand_path('../../lib', __FILE__) + railties_path = File.expand_path("../../lib", __FILE__) $:.unshift(railties_path) end require "rails/cli"