Class: Guard::Internals::Groups

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/internals/groups.rb

Constant Summary collapse

DEFAULT_GROUPS =
[:common, :default]

Instance Method Summary collapse

Constructor Details

#initializeGroups

Returns a new instance of Groups.



9
10
11
# File 'lib/guard/internals/groups.rb', line 9

def initialize
  @groups = DEFAULT_GROUPS.map { |name| Group.new(name) }
end

Instance Method Details

#add(name, options = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/guard/internals/groups.rb', line 19

def add(name, options = {})
  all(name).first || Group.new(name, options).tap do |group|
    fail if name == :specs && options.empty?
    @groups << group
  end
end

#all(filter = nil) ⇒ Object



13
14
15
16
17
# File 'lib/guard/internals/groups.rb', line 13

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