1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/generators
Nick Wolf 7cc2b57b8d
Refactor railsrc file location to be xdg compliant (#39411)
* Refactor railsrc file location to be xdg compliant

The XDG Base Directory Specification (which is currently used by
FOSS projects such as Git, Tmux, Pry, Rspec) provides a default
location for various file formats, including config/rc files.

This comment refactors app_generator.rb to load railsrc from
XDG_CONFIG_HOME if both XDG_CONFIG_HOME is set and rails/railrc
exists within the XDG_CONFIG_HOME location.

To maintain backwards compatibility it defaults back to ~/.railsrc
if either XDG_CONFIG_HOME is not set or there is no rails/railsrc.

* Refactor default_rc_file based on jonathanhefner PR feedback

* Update generators/rails/app/USAGE to explain railsrc XDG compliance

* Refactor default_rc_file based on sinsoku PR feedback

* Add test for ARGVScrubber.default_rc_file method

fileutils is required because tmpdir does not allow you to create a new
temp directory with a set title 'inside' another temporary directory, a
file is created for railsrc because tempfile creates a custom and unique
name preventing the specification of a file called 'railsrc'

Currently this test is failing because the ARGVScrubber class seems to
be loading directly from the gem (which still has the previous code)
rather than from the file itself. (loading the code in a pry session
and using show-method ARGVScrubber.default_rc_file reveals it is coming
from
gems/railties-6.0.3.3/lib/rails/generators/rails/app/app_generator.rb:536
instead of
railties/lib/rails/generators/rails/app/app_generator.rb

* Switch to double quote strings

* Add file deletion for argv_scrubber test

* Refactor test_xdg_config_no_custom_rc with jonathanhefner feedback

* Add Changelog for railsrc xdg-specification compliance

* Apply backtick and whitespace refactoring suggestsions from jonathanhefner

* Apply jonathanhefner suggested Changelog refactoring

[Rafael Mendonça França + Nick Wolf + Jonathan Hefner]
2020-10-21 01:21:07 -04:00
..
actions Add config.generators.after_generate for processing to generated files 2020-05-08 21:06:04 +09:00
css [Railties] require_relative => require 2017-10-21 22:48:26 +09:00
erb Document on ActiveModel::Errors changes 2020-01-14 23:55:09 +08:00
rails Refactor railsrc file location to be xdg compliant (#39411) 2020-10-21 01:21:07 -04:00
test_unit Address to false negative for Performance/DeletePrefix,DeleteSuffix 2020-06-14 13:04:47 +09:00
testing Address to false negative for Performance/DeletePrefix,DeleteSuffix 2020-06-14 13:04:47 +09:00
actions.rb Rails::Command.invoke wants kwargs, so give it kwargs 2020-03-12 10:04:56 -07:00
active_model.rb Adding frozen_string_literal pragma to Railties. 2017-08-14 19:08:09 +02:00
app_base.rb If it respond_to a method, the method should be public_sendable 2020-10-07 11:25:26 +09:00
app_name.rb Don't normalize original_app_name 2019-04-03 17:56:04 +09:00
base.rb [ci skip] Correct engine generator docs 2020-07-27 10:22:29 -04:00
database.rb Update pg gem required version to 1.1 2020-04-27 16:27:40 +09:00
erb.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
generated_attribute.rb Address to false negative for Performance/DeletePrefix,DeleteSuffix 2020-06-14 13:04:47 +09:00
migration.rb Add config.generators.after_generate for processing to generated files 2020-05-08 21:06:04 +09:00
model_helpers.rb Emit warning for unknown inflection rule when generating model. 2018-08-31 15:47:35 +09:00
named_base.rb Add config.generators.after_generate for processing to generated files 2020-05-08 21:06:04 +09:00
resource_helpers.rb Rails 6 requires Ruby 2.3+ 2018-02-17 10:03:37 -08:00
test_case.rb update from PR #36222 2020-02-12 13:31:43 -05:00
test_unit.rb [Railties] require_relative => require 2017-10-21 22:48:26 +09:00