module Guard::Deprecated::Guard::ClassMethods

Constants

ADD_GROUP
ADD_GUARD

@deprecated Use ‘Guard.add_plugin(name, options = {})` instead.

@see github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to

upgrade for Guard 2.0
ADD_PLUGIN
EVALUATE_GUARDFILE
EVALUATOR
GET_GUARD_CLASS

@deprecated Use

`Guard::PluginUtil.new(name).plugin_class(fail_gracefully:
fail_gracefully)` instead.

@see github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to

upgrade for Guard 2.0
GROUP
GROUPS
GUARDS

@deprecated Use ‘Guard.plugins(filter)` instead.

@see github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to

upgrade for Guard 2.0
GUARD_GEM_NAMES

@deprecated Use ‘Guard::PluginUtil.plugin_names` instead.

@see github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to

upgrade for Guard 2.0

Deprecator message for the ‘Guard.guard_gem_names` method

LISTENER_ASSIGN
LOCATE_GUARD

@deprecated Use ‘Guard::PluginUtil.new(name).plugin_location` instead.

@see github.com/guard/guard/wiki/Upgrading-to-Guard-2.0 How to

upgrade for Guard 2.0
LOCK
MORE_INFO_ON_UPGRADING_TO_GUARD_2
OPTIONS
PLUGIN
PLUGINS
RESET_EVALUATOR
RUNNER
RUNNING
SCOPE
SCOPE_ASSIGN

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/guard/deprecated/guard.rb, line 199
def initialize
  super(to_hash)
end

Public Instance Methods

[]=(key, value) click to toggle source
# File lib/guard/deprecated/guard.rb, line 224
def []=(key, value)
  case key
  when :clear
    ::Guard.state.session.clearing(value)
  else
    msg = "Oops! Guard.option[%s]= is unhandled or unsupported." \
      "Please file an issue if you rely on this option working."
    fail NotImplementedError, format(msg, key)
  end
end
add_group(name, options = {}) click to toggle source
# File lib/guard/deprecated/guard.rb, line 251
def add_group(name, options = {})
  UI.deprecation(ADD_GROUP)
  ::Guard.state.session.groups.add(name, options)
end
add_guard(*args) click to toggle source
# File lib/guard/deprecated/guard.rb, line 57
def add_guard(*args)
  ::Guard::UI.deprecation(ADD_GUARD)
  add_plugin(*args)
end
add_plugin(name, options = {}) click to toggle source
# File lib/guard/deprecated/guard.rb, line 261
def add_plugin(name, options = {})
  UI.deprecation(ADD_PLUGIN)
  ::Guard.state.session.plugins.add(name, options)
end
evaluate_guardfile() click to toggle source
# File lib/guard/deprecated/guard.rb, line 179
def evaluate_guardfile
  UI.deprecation(EVALUATE_GUARDFILE)
  options = ::Guard.state.session.evaluator_options
  evaluator = ::Guard::Guardfile::Evaluator.new(options)
  evaluator.evaluate
  msg = "No plugins found in Guardfile, please add at least one."
  ::Guard::UI.error msg if _pluginless_guardfile?
end
evaluator() click to toggle source
# File lib/guard/deprecated/guard.rb, line 152
def evaluator
  UI.deprecation(EVALUATOR)
  options = ::Guard.state.session.evaluator_options
  ::Guard::Guardfile::Evaluator.new(options)
end
fetch(key, *args) click to toggle source
# File lib/guard/deprecated/guard.rb, line 218
def fetch(key, *args)
  hash = to_hash
  verify_key!(hash, key)
  hash.fetch(key, *args)
end
get_guard_class(name, fail_gracefully = false) click to toggle source
# File lib/guard/deprecated/guard.rb, line 79
def get_guard_class(name, fail_gracefully = false)
  UI.deprecation(GET_GUARD_CLASS)
  PluginUtil.new(name).plugin_class(fail_gracefully: fail_gracefully)
end
group(filter) click to toggle source
# File lib/guard/deprecated/guard.rb, line 271
def group(filter)
  UI.deprecation(GROUP)
  ::Guard.state.session.groups.all(filter).first
end
groups(filter) click to toggle source
# File lib/guard/deprecated/guard.rb, line 291
def groups(filter)
  UI.deprecation(GROUPS)
  ::Guard.state.session.groups.all(filter)
end
guard_gem_names() click to toggle source
# File lib/guard/deprecated/guard.rb, line 116
def guard_gem_names
  UI.deprecation(GUARD_GEM_NAMES)
  PluginUtil.plugin_names
end
guards(filter = nil) click to toggle source
# File lib/guard/deprecated/guard.rb, line 38
def guards(filter = nil)
  ::Guard::UI.deprecation(GUARDS)
  ::Guard.state.session.plugins.all(filter)
end
listener=(_) click to toggle source
# File lib/guard/deprecated/guard.rb, line 143
def listener=(_)
  UI.deprecation(LISTENER_ASSIGN)
  ::Guard.listener
end
locate_guard(name) click to toggle source
# File lib/guard/deprecated/guard.rb, line 97
def locate_guard(name)
  UI.deprecation(LOCATE_GUARD)
  PluginUtil.new(name).plugin_location
end
lock() click to toggle source
# File lib/guard/deprecated/guard.rb, line 135
def lock
  UI.deprecation(LOCK)
end
options() click to toggle source
# File lib/guard/deprecated/guard.rb, line 195
def options
  UI.deprecation(OPTIONS)

  Class.new(Hash) do
    def initialize
      super(to_hash)
    end

    def to_hash
      session = ::Guard.state.session
      {
        clear: session.clearing?,
        debug: session.debug?,
        watchdir: Array(session.watchdirs).map(&:to_s),
        notify: session.notify_options[:notify],
        no_interactions: (session.interactor_name == :sleep)
      }
    end

    extend Forwardable
    delegate [:to_a, :keys] => :to_hash
    delegate [:include?] => :keys

    def fetch(key, *args)
      hash = to_hash
      verify_key!(hash, key)
      hash.fetch(key, *args)
    end

    def []=(key, value)
      case key
      when :clear
        ::Guard.state.session.clearing(value)
      else
        msg = "Oops! Guard.option[%s]= is unhandled or unsupported." \
          "Please file an issue if you rely on this option working."
        fail NotImplementedError, format(msg, key)
      end
    end

    private

    def verify_key!(hash, key)
      return if hash.key?(key)
      msg = "Oops! Guard.option[%s] is unhandled or unsupported." \
        "Please file an issue if you rely on this option working."
      fail NotImplementedError, format(msg, key)
    end
  end.new
end
plugin(filter) click to toggle source
# File lib/guard/deprecated/guard.rb, line 281
def plugin(filter)
  UI.deprecation(PLUGIN)
  ::Guard.state.session.plugins.all(filter).first
end
plugins(filter) click to toggle source
# File lib/guard/deprecated/guard.rb, line 301
def plugins(filter)
  UI.deprecation(PLUGINS)
  ::Guard.state.session.plugins.all(filter)
end
reset_evaluator(_options) click to toggle source
# File lib/guard/deprecated/guard.rb, line 162
def reset_evaluator(_options)
  UI.deprecation(RESET_EVALUATOR)
end
runner() click to toggle source
# File lib/guard/deprecated/guard.rb, line 170
def runner
  UI.deprecation(RUNNER)
  ::Guard::Runner.new
end
running() click to toggle source
# File lib/guard/deprecated/guard.rb, line 126
def running
  UI.deprecation(RUNNING)
  nil
end
scope() click to toggle source
# File lib/guard/deprecated/guard.rb, line 311
def scope
  UI.deprecation(SCOPE)
  ::Guard.state.scope.to_hash
end
scope=(scope) click to toggle source
# File lib/guard/deprecated/guard.rb, line 321
def scope=(scope)
  UI.deprecation(SCOPE_ASSIGN)
  ::Guard.state.scope.from_interactor(scope)
end
to_hash() click to toggle source
# File lib/guard/deprecated/guard.rb, line 203
def to_hash
  session = ::Guard.state.session
  {
    clear: session.clearing?,
    debug: session.debug?,
    watchdir: Array(session.watchdirs).map(&:to_s),
    notify: session.notify_options[:notify],
    no_interactions: (session.interactor_name == :sleep)
  }
end
verify_key!(hash, key) click to toggle source
# File lib/guard/deprecated/guard.rb, line 237
def verify_key!(hash, key)
  return if hash.key?(key)
  msg = "Oops! Guard.option[%s] is unhandled or unsupported." \
    "Please file an issue if you rely on this option working."
  fail NotImplementedError, format(msg, key)
end