Skip to content
  • Nick Wolf's avatar
    7cc2b57b
    Refactor railsrc file location to be xdg compliant (#39411) · 7cc2b57b
    Nick Wolf authored
    * 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]
    7cc2b57b
    Refactor railsrc file location to be xdg compliant (#39411)
    Nick Wolf authored
    * 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]
Loading