Guard 2.0 is a major update and comes with several API changes. Most of these changes are actually new methods (the old methods are deprecated). Following is the exhaustive list of these changes (mostly useful for Guard plugins authors).
Changes in Guard
New methods
Guard.plugin(filter)
: Allows to return the first plugin matching the given filter. Filtering works exactly as forGuard.plugins(filter = nil)
.Guard.group(filter)
: Allows to return the first group matching the given filter. Filtering works exactly as forGuard.groups(filter = nil)
.
Deprecated methods
Guard.guards(filter = nil)
is deprecated and replaced byGuard.plugins(filter = nil)
Guard.add_guard(name, options = {})
is deprecated and replaced byGuard.add_plugin(name, options = {})
Guard.get_guard_class(name, fail_gracefully = false)
is deprecated and replaced byGuard::PluginUtil.new(name).plugin_class(:fail_gracefully => fail_gracefully)
Guard.locate_guard(name)
is deprecated and replaced byGuard::PluginUtil.new(name).plugin_location
Guard.guard_gem_names
is deprecated and replaced byGuard::PluginUtil.plugin_names
Changes in Guard::Guard
Guard::Guard
deprecated in favor of Guard::Plugin
To remove the confusion between Guard and its many plugins (guard-rspec, guard-pow, guard-livereload etc.), Guard::Guard
is renamed Guard::Plugin
. Guard::Guard
is deprecated so if you're a plugin maintainer, in your next (major) release that will depend on Guard ~> 2.0 you must make your plugin inherit from Guard::Plugin
instead of Guard::Guard
.
Also, please be sure to change the #initialize
signature from #initialize(watchers = [], options = {})
to #initialize(options = {})
(watchers are now passed in the options
argument directly).
For instance, for guard-rspec:
module Guard
class RSpec < Guard
def initialize(watchers = [], options = {})
super
# rest of the implementation...
end
end
end
should become:
module Guard
class RSpec < Plugin
def initialize(options = {})
super
# you can still access the watchers with options[:watchers]
# rest of the implementation...
end
end
end
Changes in Guard::Dsl
Deprecated methods
Guard::Dsl.evaluate_guardfile(options)
is deprecated and replaced byGuard::Guardfile::Evaluator.new(options).evaluate_guardfile
Changes in Guard::Guardfile
Deprecated methods
Guard::Guardfile.create_guardfile(options)
is deprecated and replaced byGuard::Guardfile::Generator.new(options).create_guardfile
Guard::Guardfile.initialize_template(plugin_name)
is deprecated and replaced byGuard::Guardfile::Generator.new.initialize_template(plugin_name)
Guard::Guardfile.initialize_all_templates
is deprecated and replaced byGuard::Guardfile::Generator.new.initialize_all_templates
Removed methods
Guard::Guardfile.duplicate_definitions?
has been removed and replaced byGuard::Guardfile::Evaluator#guardfile_include?(plugin_name)
New notifiers system
Notifiers are now classes with a common interface inherited from Guard::Notifier::Base
:
- [required]
#notify(message, opts = {})
- [optional]
.supported_hosts
- [optional]
.available?(opts = {})
- [optional]
.gem_name
Breaking change: The signature of #notify
in the notifiers has changed from #notify(type, title, message, image, options = {})
to notify(message, opts = {})
(:type
, :title
and :image
must now be passed in the opts
hash.
Even though the notifiers system (including the notifiers #notify
methods signature) has been completely rewritten, this shouldn't create any issues since individual notifiers' interface shouldn't be called directly. You should always use the Guard::Notifier.notify
method instead.
Intro
Installation
- System Notifications
- Terminal Colors on Windows
- Add Readline support to Ruby on Mac OS X
- Which Growl library should I use
- Efficient Filesystem Handling
Getting Started
- List of Guard Commands
- Command Line Options for Guard
- List of available Guards
- Guardfile examples
- Run Guard within RubyMine
- Guardfile-DSL / Configuring-Guard
- Configuration Files
- Interacting with Guard
- Guard Signals
Troubleshooting
Advanced use of Guard
Cookbooks
Development
This wiki and the Guard README document contains a lot of information, please take your time and read these instructions carefully.
If you run into any trouble, you may start by understanding how Guard works.
We provide detailed changes for each Guard release.
Be sure to read the CONTRIBUTING guidelines before reporting a new Guard issue or open a pull request.
If you have any questions about the Guard usage or want to share some information with the Guard community, please go to one of the following places:
- Google+ community
- Google group
- StackOverflow
- IRC channel
#guard
(irc.freenode.net) for chatting