class Guard::Internals::Plugins

def add(name, options)

configs or groups)
TODO: should it allow duplicates? (probably yes because of different
def add(name, options)
  @plugins << PluginUtil.new(name).initialize_plugin(options)
end

def all(filter = nil)

def all(filter = nil)
  return @plugins if filter.nil?
  matcher = matcher_for(filter)
  @plugins.select { |plugin| matcher.call(plugin) }
end

def initialize

def initialize
  @plugins = []
end

def matcher_for(filter)

def matcher_for(filter)
  case filter
  when String, Symbol
    shortname = filter.to_s.downcase.delete("-")
    ->(plugin) { plugin.name == shortname }
  when Regexp
    ->(plugin) { plugin.name =~ filter }
  when Hash
    lambda do |plugin|
      filter.all? do |k, v|
        case k
        when :name
          plugin.name == v.to_s.downcase.delete("-")
        when :group
          plugin.group.name == v.to_sym
        end
      end
    end
  end
end

def remove(plugin)

def remove(plugin)
  @plugins.delete(plugin)
end