Skip to content

Upgrading to Guard 3.0

Rémy Coutable edited this page Jul 22, 2022 · 3 revisions

Guard 3.0 is a major update and removes a lot of API methods to reduce the API surface needed to be kept back-compatible over time. Most of what was possible with the removed APIs can still be done via CLI. Following is the exhaustive list of these changes (mostly useful for Guard plugins authors).

Removed APIs

Guard

  1. Remove support for plugins that inherited from Guard:
    • Guard.guards, Guard.plugins, Guard.plugin, Guard.add_guard, Guard.add_plugin.
    • Guard.groups, Guard.group, Guard.add_group.
    • Guard.scope.
    • Guard.state.session.plugins.all, Guard.state.session.plugins.add (internal API only).
    • Guard.state.session.groups.all, Guard.state.session.groups.add (internal API only).
    • Guard.state.scope, Guard.state.scope= (internal API only).
    • Guard.get_guard_class, Guard.locate_guard, Guard.guard_gem_names.
    • Guard::PluginUtil#plugin_class, Guard::PluginUtil#plugin_location, Guard::PluginUtil.plugin_names (internal API only).
    • Guard.running, Guard.lock, Guard.listener=, Guard.evaluator, Guard.reset_evaluator, Guard.runner, Guard.evaluate_guardfile, Guard.options.
  2. Remove support for plugins that inherited from Guard.
  3. Remove Guard::Watcher#match_guardfile?.
  4. Remove Guard::Guardfile::Evaluator#evaluate_guardfile in favor of Guard::Guardfile::Evaluator#evaluate.
  5. Remove Guard::Guardfile::Evaluator#reevaluate_guardfile.
  6. Remove Guard::Dsl.evaluate_guardfile(options) in favor of Guard::Guardfile::Evaluator.new(options).evaluate_guardfile.
  7. Remove Guard::Dsl#filter in favor of Guard::Dsl#ignore.
  8. Remove Guard::Dsl#filter! in favor of Guard::Dsl#ignore!.
  9. Remove support for Regexps as strings in `Guard::Dsl#watch.
  10. Remove Guard::Guardfile.create_guardfile in favor of Guard::Guardfile::Generator#create_guardfile.
  11. Remove Guard::Guardfile.initialize_template in favor of Guard::Guardfile::Generator#initialize_template.
  12. Remove Guard::Guardfile.initialize_all_templates in favor of Guard::Guardfile::Generator#initialize_all_templates.

Other breaking changes

  • Drop support for Ruby 2.4 (support for it has ended on 2020-03-31: https://www.ruby-lang.org/en/news/2020/04/05/support-of-ruby-2-4-has-ended/). While Guard could have kept the support for this Ruby version, we think it's a good opportunity to move forward, and given how stable Guard has been in the last years, users can keep using Guard 2.x if they're using Ruby 2.4, since Guard 3.0 is mostly refactors and APIs removal.

Internal improvements

  1. Introduce Guard::Engine and move away from the singleton approach (https://github.com/guard/guard/pull/982).