Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require, require_relative, load by double quotes #38841

Merged
merged 4 commits into from Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/Rakefile
@@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
4 changes: 2 additions & 2 deletions actionmailbox/test/dummy/bin/rails
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
require_relative "../config/boot"
require "rails/commands"
4 changes: 2 additions & 2 deletions actionmailbox/test/dummy/bin/rake
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/bin/setup
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
require "fileutils"
include FileUtils

# path to your application root.
Expand Down
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/bin/update
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
require "fileutils"
include FileUtils

# path to your application root.
Expand Down
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config.ru
@@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
require_relative "config/environment"

run Rails.application
4 changes: 2 additions & 2 deletions actionmailbox/test/dummy/config/application.rb
@@ -1,6 +1,6 @@
require_relative 'boot'
require_relative "boot"

require 'rails/all'
require "rails/all"

Bundler.require(*Rails.groups)

Expand Down
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/boot.rb
@@ -1,5 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/environment.rb
@@ -1,5 +1,5 @@
# Load the Rails application.
require_relative 'application'
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
2 changes: 1 addition & 1 deletion actionmailbox/test/dummy/config/environments/production.rb
Expand Up @@ -80,7 +80,7 @@
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
Expand Down
Expand Up @@ -136,7 +136,7 @@ def authentication_request(controller, realm, message)
#
# === Simple \Digest example
#
# require 'digest/md5'
# require "digest/md5"
# class PostsController < ApplicationController
# REALM = "SuperSecret"
# USERS = {"dhh" => "secret", #plain text password
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/journey/parser.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/system_test_case.rb
Expand Up @@ -27,7 +27,7 @@ module ActionDispatch
#
# Here is an example system test:
#
# require 'application_system_test_case'
# require "application_system_test_case"
#
# class Users::CreateTest < ApplicationSystemTestCase
# test "adding a new user" do
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/testing/integration.rb
Expand Up @@ -513,7 +513,7 @@ def method_missing(method, *args, &block)
#
# A simple integration test that exercises multiple controllers:
#
# require 'test_helper'
# require "test_helper"
#
# class UserFlowsTest < ActionDispatch::IntegrationTest
# test "login and browse site" do
Expand Down Expand Up @@ -542,7 +542,7 @@ def method_missing(method, *args, &block)
#
# Here's an example of multiple sessions and custom DSL in an integration test
#
# require 'test_helper'
# require "test_helper"
#
# class UserFlowsTest < ActionDispatch::IntegrationTest
# test "login and browse site" do
Expand Down
2 changes: 1 addition & 1 deletion actiontext/test/dummy/Rakefile
@@ -1,6 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
4 changes: 2 additions & 2 deletions actiontext/test/dummy/bin/rails
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
require 'rails/commands'
require_relative "../config/boot"
require "rails/commands"
4 changes: 2 additions & 2 deletions actiontext/test/dummy/bin/rake
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
2 changes: 1 addition & 1 deletion actiontext/test/dummy/bin/setup
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
require "fileutils"
include FileUtils

# path to your application root.
Expand Down
2 changes: 1 addition & 1 deletion actiontext/test/dummy/bin/update
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
require 'fileutils'
require "fileutils"
include FileUtils

# path to your application root.
Expand Down
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config.ru
@@ -1,5 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'
require_relative "config/environment"

run Rails.application
4 changes: 2 additions & 2 deletions actiontext/test/dummy/config/application.rb
@@ -1,6 +1,6 @@
require_relative 'boot'
require_relative "boot"

require 'rails/all'
require "rails/all"

Bundler.require(*Rails.groups)
require "action_text"
Expand Down
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/boot.rb
@@ -1,5 +1,5 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/environment.rb
@@ -1,5 +1,5 @@
# Load the Rails application.
require_relative 'application'
require_relative "application"

# Initialize the Rails application.
Rails.application.initialize!
2 changes: 1 addition & 1 deletion actiontext/test/dummy/config/environments/production.rb
Expand Up @@ -82,7 +82,7 @@
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/fixtures.rb
Expand Up @@ -59,7 +59,7 @@ class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc:
# Since fixtures are a testing construct, we use them in our unit and functional tests. There
# are two ways to use the fixtures, but first let's take a look at a sample unit test:
#
# require 'test_helper'
# require "test_helper"
#
# class WebSiteTest < ActiveSupport::TestCase
# test "web_site_count" do
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/migration.rb
Expand Up @@ -691,7 +691,7 @@ def initialize(name = self.class.name, version = nil)
# Or equivalently, if +TenderloveMigration+ is defined as in the
# documentation for Migration:
#
# require_relative '20121212123456_tenderlove_migration'
# require_relative "20121212123456_tenderlove_migration"
#
# class FixupTLMigration < ActiveRecord::Migration[6.0]
# def change
Expand Down
2 changes: 1 addition & 1 deletion activestorage/test/dummy/config/environments/production.rb
Expand Up @@ -69,7 +69,7 @@
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
# require "syslog/logger"
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')

if ENV["RAILS_LOG_TO_STDOUT"].present?
Expand Down
4 changes: 2 additions & 2 deletions activesupport/lib/active_support/concern.rb
Expand Up @@ -19,7 +19,7 @@ module ActiveSupport
# By using <tt>ActiveSupport::Concern</tt> the above module could instead be
# written as:
#
# require 'active_support/concern'
# require "active_support/concern"
#
# module M
# extend ActiveSupport::Concern
Expand Down Expand Up @@ -76,7 +76,7 @@ module ActiveSupport
# is the +Bar+ module, not the +Host+ class. With <tt>ActiveSupport::Concern</tt>,
# module dependencies are properly resolved:
#
# require 'active_support/concern'
# require "active_support/concern"
#
# module Foo
# extend ActiveSupport::Concern
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/configurable.rb
Expand Up @@ -126,7 +126,7 @@ def config_accessor(*names, instance_reader: true, instance_writer: true, instan

# Reads and writes attributes from a configuration <tt>OrderedHash</tt>.
#
# require 'active_support/configurable'
# require "active_support/configurable"
#
# class User
# include ActiveSupport::Configurable
Expand Down
4 changes: 2 additions & 2 deletions guides/source/3_2_release_notes.md
Expand Up @@ -64,8 +64,8 @@ Replace the code beneath the comment in `script/rails` with the following conten
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/your_engine_name/engine', __FILE__)

require 'rails/all'
require 'rails/engine/commands'
require "rails/all"
require "rails/engine/commands"
```

Creating a Rails 3.2 application
Expand Down
2 changes: 1 addition & 1 deletion guides/source/action_cable_overview.md
Expand Up @@ -799,7 +799,7 @@ basic setup is as follows:

```ruby
# cable/config.ru
require_relative '../config/environment'
require_relative "../config/environment"
Rails.application.eager_load!

run ActionCable.server
Expand Down
2 changes: 1 addition & 1 deletion guides/source/active_model_basics.md
Expand Up @@ -425,7 +425,7 @@ the Active Model API.
* `test/models/person_test.rb`

```ruby
require 'test_helper'
require "test_helper"

class PersonTest < ActiveSupport::TestCase
include ActiveModel::Lint::Tests
Expand Down
2 changes: 1 addition & 1 deletion guides/source/active_record_migrations.md
Expand Up @@ -672,7 +672,7 @@ can't be done.
You can use Active Record's ability to rollback migrations using the `revert` method:

```ruby
require_relative '20121212123456_example_migration'
require_relative "20121212123456_example_migration"

class FixupExampleMigration < ActiveRecord::Migration[6.0]
def change
Expand Down
16 changes: 8 additions & 8 deletions guides/source/active_support_core_extensions.md
Expand Up @@ -26,7 +26,7 @@ In order to have a near-zero default footprint, Active Support does not load any
Thus, after a simple require like:

```ruby
require 'active_support'
require "active_support"
```

objects do not even respond to `blank?`. Let's see how to load its definition.
Expand All @@ -42,8 +42,8 @@ NOTE: Defined in `active_support/core_ext/object/blank.rb`.
That means that you can require it like this:

```ruby
require 'active_support'
require 'active_support/core_ext/object/blank'
require "active_support"
require "active_support/core_ext/object/blank"
```

Active Support has been carefully revised so that cherry-picking a file loads only strictly needed dependencies, if any.
Expand All @@ -55,25 +55,25 @@ The next level is to simply load all extensions to `Object`. As a rule of thumb,
Thus, to load all extensions to `Object` (including `blank?`):

```ruby
require 'active_support'
require 'active_support/core_ext/object'
require "active_support"
require "active_support/core_ext/object"
```

#### Loading All Core Extensions

You may prefer just to load all core extensions, there is a file for that:

```ruby
require 'active_support'
require 'active_support/core_ext'
require "active_support"
require "active_support/core_ext"
```

#### Loading All Active Support

And finally, if you want to have all Active Support available just issue:

```ruby
require 'active_support/all'
require "active_support/all"
```

That does not even put the entire Active Support in memory upfront indeed, some stuff is configured via `autoload`, so it is only loaded if used.
Expand Down
Expand Up @@ -27,8 +27,8 @@ Ruby on Rails allows applications to be written as if their code was preloaded.
In a normal Ruby program classes need to load their dependencies:

```ruby
require 'application_controller'
require 'post'
require "application_controller"
require "post"

class PostsController < ApplicationController
def index
Expand Down Expand Up @@ -440,7 +440,7 @@ autoload_paths and eager_load_paths
As you probably know, when `require` gets a relative file name:

```ruby
require 'erb'
require "erb"
```

Ruby looks for the file in the directories listed in `$LOAD_PATH`. That is, Ruby
Expand Down Expand Up @@ -1030,7 +1030,7 @@ have to know all its descendants.
Files defining constants to be autoloaded should never be `require`d:

```ruby
require 'user' # DO NOT DO THIS
require "user" # DO NOT DO THIS

class UsersController < ApplicationController
...
Expand Down
2 changes: 1 addition & 1 deletion guides/source/configuring.md
Expand Up @@ -25,7 +25,7 @@ Rails offers four standard spots to place initialization code:
Running Code Before Rails
-------------------------

In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to `require 'rails/all'` in `config/application.rb`.
In the rare event that your application needs to run some code before Rails itself is loaded, put it above the call to `require "rails/all"` in `config/application.rb`.

Configuring Rails Components
----------------------------
Expand Down
4 changes: 2 additions & 2 deletions guides/source/engines.md
Expand Up @@ -1417,8 +1417,8 @@ required, you should require them before the engine's initialization. For
example:

```ruby
require 'other_engine/engine'
require 'yet_another_engine/engine'
require "other_engine/engine"
require "yet_another_engine/engine"

module MyEngine
class Engine < ::Rails::Engine
Expand Down