Skip to content

Commit

Permalink
Remove deprecated methods and options. Fixes #425.
Browse files Browse the repository at this point in the history
  • Loading branch information
rymai committed Sep 9, 2013
1 parent 019741c commit a5162d2
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 208 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
### Removals & deprecations

- Remove `Guard::Guardfile.duplicate_definitions?`. ([@rymai][])
- Remove the deprecated `watch_all_modifications` start option. ([@rymai][])
- Remove the deprecated `no_vendor` start option. ([@rymai][])
- Remove the deprecated `reset_color` UI method. ([@rymai][])
- Remove the deprecated `match_file?` Watcher method. ([@rymai][])
- Remove the deprecated `ignore_paths` DSL method. ([@rymai][])
- Remove the deprecation warning for the `interactor` DSL method. ([@rymai][])
- Remove the deprecation warning for when a plugin defines the `run_on_change` method. ([@rymai][])
- Remove the deprecation warning for when a plugin defines the `run_on_deletion` method. ([@rymai][])
- Deprecate `Guard.guards(filter)` in favor of `Guard.plugins(filter)`. ([@rymai][])
- Deprecate `Guard.add_guard(name, options = {})` in favor of `Guard.add_plugin(name, options = {})`. ([@rymai][])
- Deprecate `Guard.get_guard_class(name, fail_gracefully)` in favor of `Guard::PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)`. ([@rymai][])
Expand Down
14 changes: 0 additions & 14 deletions lib/guard/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,6 @@ class CLI < Thor
aliases: '-G',
banner: 'Specify a Guardfile'

# DEPRECATED
method_option :no_vendor,
type: :boolean,
default: false,
aliases: '-I',
banner: 'DEPRECATED: Ignore vendored dependencies'

# DEPRECATED
method_option :watch_all_modifications,
type: :boolean,
default: false,
aliases: '-A',
banner: 'DEPRECATED: Watch for all file modifications including moves and deletions'

method_option :no_interactions,
type: :boolean,
default: false,
Expand Down
66 changes: 0 additions & 66 deletions lib/guard/deprecator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,71 +103,5 @@ class Deprecator
#{MORE_INFO_ON_UPGRADING_TO_GUARD_2}
EOS

# Deprecator message for the `watch_all_modifications` start option
WATCH_ALL_MODIFICATIONS_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.1 the 'watch_all_modifications' option is removed
and is now always on.
EOS

# Deprecator message for the `no_vendor` start option
NO_VENDOR_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.1 the 'no_vendor' option is removed because the
monitoring gems are now part of a new gem called Listen.
(https://github.com/guard/listen)
You can specify a custom version of any monitoring gem directly in your
Gemfile if you want to overwrite Listen's default monitoring gems.
EOS

# Deprecator message for the `run_on_change` method
RUN_ON_CHANGE_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.1 the use of the 'run_on_change' method in the '%s' guard is deprecated.
Please consider replacing that method-call with 'run_on_changes' if the type of change
is not important for your usecase or using either 'run_on_modifications' or 'run_on_additions'
based on the type of the changes you want to handle.
#{MORE_INFO_ON_UPGRADING_TO_GUARD_1_1}
EOS

# Deprecator message for the `run_on_deletion` method
RUN_ON_DELETION_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.1 the use of the 'run_on_deletion' method in the '%s' guard is deprecated.
Please consider replacing that method-call with 'run_on_removals' for future proofing your code.
#{MORE_INFO_ON_UPGRADING_TO_GUARD_1_1}
EOS

# Deprecator message for the `interactor` method
DSL_METHOD_INTERACTOR_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.4 the use of the 'interactor' Guardfile DSL method is only used to
disable or pass options to the Pry interactor. All other usages are deprecated.
EOS

# Deprecator message for the `ignore_paths` method
DSL_METHOD_IGNORE_PATHS_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
Starting with Guard 1.1 the use of the 'ignore_paths' Guardfile DSL method is deprecated.
Please replace that method with the better 'ignore' or/and 'filter' methods.
Documentation on the README: https://github.com/guard/guard#ignore
EOS

# Displays a warning for each deprecated options used when starting Guard.
#
def self.deprecated_options_warning(options)
::Guard::UI.deprecation(WATCH_ALL_MODIFICATIONS_DEPRECATION) if options.watch_all_modifications
::Guard::UI.deprecation(NO_VENDOR_DEPRECATION) if options.no_vendor
end

# Displays a warning for each deprecated method used is any registered Guard plugin.
#
def self.deprecated_plugin_methods_warning
::Guard.plugins.each do |plugin|
::Guard::UI.deprecation(RUN_ON_CHANGE_DEPRECATION % plugin.class.name) if plugin.respond_to?(:run_on_change)
::Guard::UI.deprecation(RUN_ON_DELETION_DEPRECATION % plugin.class.name) if plugin.respond_to?(:run_on_deletion)
end
end

end
end
20 changes: 3 additions & 17 deletions lib/guard/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ def notification(notifier, options = {})
# options
#
def interactor(options)
if options == :off
case options
when :off
::Guard::Interactor.enabled = false

elsif options.is_a?(Hash)
when Hash
::Guard::Interactor.options = options

else
::Guard::UI.deprecation(::Guard::Deprecator::DSL_METHOD_INTERACTOR_DEPRECATION)
end
end

Expand Down Expand Up @@ -216,17 +213,6 @@ def callback(*args, &block)
@callbacks << { events: events, listener: block }
end

# @deprecated Use `ignore` or `ignore!` instead.
#
# @example Ignore some paths
# ignore_paths '.git', '.svn'
#
# @param [Array] paths the list of paths to ignore
#
def ignore_paths(*paths)
::Guard::UI.deprecation(::Guard::Deprecator::DSL_METHOD_IGNORE_PATHS_DEPRECATION)
end

# Ignores certain paths globally.
#
# @example Ignore some paths
Expand Down
5 changes: 0 additions & 5 deletions lib/guard/setuper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ module Setuper
# @option options [Array<String>] group the list of groups to start
# @option options [Array<String>] watchdir the directories to watch
# @option options [String] guardfile the path to the Guardfile
# @option options [Boolean] watch_all_modifications **[deprecated]** watches all file modifications if true
# @option options [Boolean] no_vendor **[deprecated]** ignore vendored dependencies
#
# @return [Guard] the Guard singleton
#
Expand Down Expand Up @@ -65,9 +63,6 @@ def setup(opts = {})

setup_scope(groups: options.group, plugins: options.plugin)

::Guard::Deprecator.deprecated_options_warning(options)
::Guard::Deprecator.deprecated_plugin_methods_warning

_setup_notifier
_setup_interactor

Expand Down
9 changes: 0 additions & 9 deletions lib/guard/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,6 @@ def calling_plugin_name(depth = 2)
name ? name[1].split('/').map { |part| part.split(/[^a-z0-9]/i).map { |word| word.capitalize }.join }.join('::') : 'Guard'
end

# @deprecated Reset a color sequence.
#
# @param [String] text the text
#
def reset_color(text)
deprecation("UI.reset_color(text) is deprecated, please use color(text, ' ') instead.")
color(text, '')
end

# Checks if color output can be enabled.
#
# @return [Boolean] whether color is enabled or not
Expand Down
7 changes: 0 additions & 7 deletions lib/guard/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ def match(file)
end
end

# @deprecated Use {#match} instead
#
def match_file?(file)
::Guard::UI.deprecation 'Guard::Watcher.match_file? is deprecated, please use Guard::Watcher.match instead.'
match(file)
end

# Executes a watcher action.
#
# @param [String, MatchData] matches the matched path or the match from the
Expand Down
66 changes: 0 additions & 66 deletions spec/guard/deprecator_spec.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/guard/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ def self.disable_user_config
end
end

describe '#ignore_paths' do
disable_user_config

it 'adds the paths to the listener\'s ignore_paths' do
::Guard::UI.should_receive(:deprecation).with(Guard::Deprecator::DSL_METHOD_IGNORE_PATHS_DEPRECATION)

described_class.evaluate_guardfile(guardfile_contents: 'ignore_paths \'foo\', \'bar\'')
end
end

describe '#ignore' do
disable_user_config
let(:listener) { double }
Expand Down Expand Up @@ -115,18 +105,11 @@ def self.disable_user_config
disable_user_config

it 'disables the interactions with :off' do
::Guard::UI.should_not_receive(:deprecation).with(Guard::Deprecator::DSL_METHOD_INTERACTOR_DEPRECATION)
described_class.evaluate_guardfile(guardfile_contents: 'interactor :off')
Guard::Interactor.enabled.should be_false
end

it 'shows a deprecation for symbols other than :off' do
::Guard::UI.should_receive(:deprecation).with(Guard::Deprecator::DSL_METHOD_INTERACTOR_DEPRECATION)
described_class.evaluate_guardfile(guardfile_contents: 'interactor :coolline')
end

it 'passes the options to the interactor' do
::Guard::UI.should_not_receive(:deprecation).with(Guard::Deprecator::DSL_METHOD_INTERACTOR_DEPRECATION)
described_class.evaluate_guardfile(guardfile_contents: 'interactor option1: \'a\', option2: 123')
Guard::Interactor.options.should include({ option1: 'a', option2: 123 })
end
Expand Down
7 changes: 0 additions & 7 deletions spec/guard/setuper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@
subject
end

it 'show the deprecations' do
Guard::Deprecator.should_receive(:deprecated_options_warning)
Guard::Deprecator.should_receive(:deprecated_plugin_methods_warning)

subject
end

context 'without the group or plugin option' do
it "initializes the empty scope" do
subject.scope.should eq({ groups: [], plugins: [] })
Expand Down

0 comments on commit a5162d2

Please sign in to comment.