Commit Graph

86 Commits

Author SHA1 Message Date
Simon Perepelitsa 1911673e67 Add benchmark method that can be called from anywhere 2020-12-04 15:52:10 +03:00
Charles Oliver Nutter 09e0372532
Use optimized subclass of StringInquirer for Rails.env
This adds a StringInquirer subclass EnvironmentInquirer that
predefines the three default environments as query methods, in
order to avoid dispatching through `method_missing` for every call
to those methods. The original StringInquirer was not modified due
to the side effects of having new env-related methods on it. This
new class was not implemented using lazy method definition to
avoid the open-ended possibility of defining a new method for all
query calls. The three default environments should cover a high
percentage of real-world uses, and users with custom environments
could add their own to this class.

Fixes #37803.
2020-03-05 14:57:27 -06:00
Aaron Patterson 227ff44e36
Revert "Merge pull request #37808 from headius/optimize_string_inquirer"
This reverts commit 9e5c6c4c84, reversing
changes made to 3aacd855cd.
2020-03-05 11:12:14 -08:00
Charles Oliver Nutter 516b8a5f69
Use optimized subclass of StringInquirer for Rails.env
This adds a StringInquirer subclass EnvironmentInquirer that
predefines the three default environments as query methods, in
order to avoid dispatching through `method_missing` for every call
to those methods. The original StringInquirer was not modified due
to the side effects of having new env-related methods on it. This
new class was not implemented using lazy method definition to
avoid the open-ended possibility of defining a new method for all
query calls. The three default environments should cover a high
percentage of real-world uses, and users with custom environments
could add their own to this class.

Fixes #37803.
2019-11-26 17:18:40 -06:00
yuuji.yaginuma 1ccc407e9d Fix document formatting of `Rails.group` [ci skip] 2019-09-05 19:00:20 +09:00
Akira Matsuda 84e21165a8 active_support/dependencies/autoload is already required via active_support.rb 2019-07-12 18:30:58 +09:00
Xavier Noria b686b67191 moves a require to the file that needs it 2019-03-08 09:04:12 -08:00
Jean Boussier 6d624f2de9 Allow autoloader inflectors to be swaped out 2019-03-08 17:31:29 +01:00
Xavier Noria 870377915a Replace autoloader accessors with Rails.autoloaders.{main,once}
Rails.autoloader and Rails.once_autoloader was just tentative API good
enough for a first patch. Rails.autoloader is singular and does not
convey in its name that there is another autoloader. That might be
confusing, for example if you set a logger and miss traces. On the other
hand, the name `once_autoloader` is very close to being horrible.

Rails.autoloaders.main and Rails.autoloaders.once read better for my
taste, and have a nice symmetry. Also, both "main" and "once" are four
letters long, short and same length.

They are tagged as "rails.main" and "rails.once", respectively.

References #35235.
2019-02-14 22:34:16 -08:00
Xavier Noria 821d6c694c Zeitwerk integration 2019-02-12 02:28:04 -08:00
Akira Matsuda 6a728491b6 [Railties] require_relative => require
This basically reverts 618268b4b9
2017-10-21 22:48:26 +09:00
Pat Allan acea68de02 Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
Akira Matsuda 618268b4b9 [Railties] require => require_relative 2017-07-01 18:35:43 +09:00
Ryunosuke Sato bc76ecf655 Fix the example code for `Rails.groups` [ci skip]
`Rails.groups` contains `Rails.env` that is inspected as String.
2017-03-30 01:13:27 +09:00
Daniel Deng 498370c05b Rails.env falls back to dev mode when env var is empty 2017-01-04 15:03:30 +11:00
bogdanvlviv 5faa9a235c Add missing `+` around a some literals.
Mainly around `nil`

[ci skip]
2016-10-27 00:27:47 +03:00
Santosh Wadghule c3fe596a4a AS => Active Support [ci skip] 2016-09-25 00:09:16 +05:30
Xavier Noria 69ab3eb57e applies new string literal convention in railties/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:15:47 +02:00
Santosh Wadghule d8575289a2 rails -> Rails [ci skip] 2016-07-12 12:21:36 +05:30
Travis Yoder b0b4b176b0 better docs for Rails.root and Rails.public_path 2015-05-07 10:54:26 -06:00
Jeremy Kemper 5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b8, reversing
changes made to 45786be516.
2015-03-20 08:14:11 -07:00
Damien Mathieu d578cbfb5c don't fallback to RACK_ENV when RAILS_ENV is not present 2015-03-19 10:06:28 +01:00
Rafael Mendonça França 21f02f3485 Remove some comments about Ruby 1.9 behaviors 2015-01-04 15:55:28 -03:00
claudiob a770d7e404 Add docs for `Rails.env` and `Rails.env=`
[ci skip]
2014-12-22 03:44:37 +01:00
Aaron Patterson d25fe31c40 lazily instantiate application subclasses
this means we can meaningfully override methods in the subclass
2014-08-06 18:27:16 -07:00
Prem Sichanugrist 2dd2fcf896
Introduce `Rails.gem_version`
This method return `Gem::Version.new(Rails.version)`, suggesting a more
reliable way to perform version comparison.

Example:

    Rails.version #=> "4.1.2"
    Rails.gem_version #=> #<Gem::Version "4.1.2">

    Rails.version > "4.1.10" #=> false
    Rails.gem_version > Gem::Version.new("4.1.10") #=> true
    Gem::Requirement.new("~> 4.1.2") =~ Rails.gem_version #=> true

This was originally introduced as `.version` by @charliesome in #8501
but got reverted in #10002 since it was not backward compatible.

Also, updating template for `rake update_versions`.
2014-03-05 12:37:38 -05:00
Andrew White d6dec7fcb6 Add mailer previews feature based on mail_view gem 2013-12-17 03:58:35 +00:00
Paul Nikitochkin 419f257b73 Removed unused deprecation requires. 2013-07-03 23:21:23 +03:00
Genadi Samokovarov 50be56dcde Refactor of ::Rails module
1. Used ActiveSupport::Autoload to dry-up the autoload definitions.
2. Used ActiveSupport's delegate to dry up the application proxied
   attributes.
3. Did a little white space change on Rails.groups.
2013-06-12 11:42:36 +03:00
Charlie Somerville ceb3b8717b reverts changes to Rails.version made in #8501 2013-03-30 14:16:46 +11:00
Charlie Somerville f0e6ab59f6 remove references to *::VERSION, replace with *.version 2013-03-21 19:56:07 +11:00
Jeremy Kemper f9da785d0b Move background jobs to the 'jobs' branch until fully baked. Not shipping with Rails 4.0. 2012-12-21 16:29:47 -08:00
Andy Lindeman 33b3fa67c4 Revert "Make sure that RAILS_ENV is set when accessing Rails.env"
This reverts commit b3125c89f4.

* It is not desirable to set `ENV['RAILS_ENV']`; otherwise, it will leak
  through to rake tasks such as `rake test` or `rake spec`. See #7175
  for more details.
2012-12-21 17:22:57 -05:00
schneems baea5d69be Use Rails to Render Default Index Page
This is an alternative implementation to #7771 thanks to the advice of @spastorino

Rails is a dynamic framework that serves a static index.html by default. One of my first questions ever on IRC was solved by simply deleting my public/index.html file. This file is a source of confusion when starting as it over-rides any set "root" in the routes yet it itself is not listed in the routes. By making the page dynamic by default we can eliminate this confusion.

This PR moves the static index page to an internal controller/route/view similar to `rails/info`. When someone starts a rails server, if no root is defined, this route will take over and the "dynamic" index page from rails/welcome_controller will be rendered. These routes are only added in development. If a developer defines a root in their routes, it automatically takes precedence over this route and will be rendered, with no deleting of files required. 

In addition to removing this source of confusion for new devs, we can now use Rails view helpers to build and render this page. While not the primary intent, the added value of "dogfooding" should not be under-estimated.

The prior PR #7771 had push-back since it introduced developer facing files. This PR solves all of the same problems, but does not have any new developer facing files (it actually removes one). 

cc/ @wsouto, @dickeyxxx, @tyre, @ryanb, @josevalim, @maxim, @subdigital, @steveklabnik

ATP Railties and Actionpack.
2012-12-10 16:15:04 -08:00
Bjørn Arild Mæland b9d1d2cdda Use attr_accessor for Rails.{application,cache,logger} 2012-12-01 21:41:54 +01:00
Steve Klabnik b3125c89f4 Make sure that RAILS_ENV is set when accessing Rails.env
Fixes #8025
2012-10-31 17:05:26 -07:00
Robin Dupret 5ad7f8ab41 Use Ruby 1.9 Hash syntax in railties 2012-10-14 18:26:58 +02:00
Prem Sichanugrist 26fe77b27d Make Rails.public_path return a Pathname 2012-10-02 20:44:02 -04:00
Santiago Pastorino 8577687fcb Move queue classes to ActiveSupport 2012-09-14 14:10:00 -07:00
Francesco Rodriguez 17059a4868 Removing ==Examples and last blank lines of docs from railties 2012-05-14 10:50:59 -05:00
Yehuda Katz adff4a706a Initial queue implementation 2012-04-26 21:38:27 -07:00
Roman V. Babenko 1e36e02df3 Class variables has been fixed to Singleton instance variables at Rails module 2012-04-06 07:59:57 +03:00
Franck Verrot 4882271f6b Rails.initialized? can be called at any time without raising an exception [Closes #2507]
Changes:

* `Rails.initialized=` has been removed
* `Rails.initialized?` and `Rails.application.initialized?` are now
* delegating to `MyApp::Application.initialized?`
2012-03-28 00:42:59 +02:00
kennyj 6f8159c421 Deprecate RAILS_CACHE constant. 2012-01-18 01:53:09 +09:00
José Valim 51095be1b0 Get rid of more 1.8.x dead code 2011-12-20 17:59:26 +01:00
Aaron Patterson 572c3d5178 * BufferedLogger is deprecated. Use ActiveSupport::Logger, or the logger
from Ruby stdlib.
2011-12-19 18:41:37 -08:00
Aaron Patterson 3096629d29 we are *sure* we want to set the encoding, so silence warnings around it 2011-08-24 16:23:38 -07:00
Oemuer Oezkir 71d18ce48e Changed a few instances of of words in the API docs written in British English to
American English(according to Weber)
2011-07-24 10:21:42 +00:00
José Valim 60076de1d4 Make Rails.groups accept arrays. 2011-07-10 08:36:08 -03:00
José Valim a803aec00d Add Rails.groups to encapsulate available groups for require. 2011-06-21 11:24:05 -03:00