Skip to content

Simplify rake task hierarchy#477

Merged
n-rodriguez merged 1 commit intokjvarga:masterfrom
jasonkarns:rake-task-env
Mar 20, 2026
Merged

Simplify rake task hierarchy#477
n-rodriguez merged 1 commit intokjvarga:masterfrom
jasonkarns:rake-task-env

Conversation

@jasonkarns
Copy link
Copy Markdown

The require structure (both for loading the sitemap_generator gem, and for booting the Rails :environment), is legacy remainder from Rails plugins (pre Rails 4).

As the gem now only supports Rails 6+, we can simplify the task dependency tree quite a bit.

  1. reduce the sitemap:require task down to only requiring the 'sitemap_generator' gem.

This may be necessary in an app, where these tasks are loaded directly from the user's Rakefile via require 'sitemap_generator/tasks'.

  1. Enhance this base sitemap:require task to boot the rails environment, but only if Rails is defined. (ie, in a Rails app) With :environment added as a pre-req, it will run before the sitemap:require task. If in a Rails environment, and after the environment is booted, it is unlikely that we even need a require. (In most cases, the gem will already have been required by Rails using Bundler.require.) However, we cannot assume this is the case, as user's may omit the sitemap_generator gem from auto-requiring.

  2. Simplify all pre-req references to depend on the base sitemap:require task (which would be conditionally enhanced if in a Rails app).

@n-rodriguez n-rodriguez merged commit b9f20a4 into kjvarga:master Mar 20, 2026
77 checks passed
jasonkarns added a commit to jasonkarns/sitemap_generator that referenced this pull request Mar 21, 2026
* upstream/master:
  Enhance Rails railtie to respect existing rails configuration (kjvarga#478)
  Improve Sitemap method-missing implementation (kjvarga#473)
  Fix broken specs (kjvarga#476)
  Simplify rake task hierarchy (kjvarga#477)
  Fix AWS upload deprecation (kjvarga#464)
@jasonkarns jasonkarns deleted the rake-task-env branch March 21, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants