Class: Guard::Internals::Groups
- Inherits:
-
Object
- Object
- Guard::Internals::Groups
- Defined in:
- lib/guard/internals/groups.rb
Constant Summary collapse
- DEFAULT_GROUPS =
[:common, :default]
Instance Method Summary collapse
- #add(name, options = {}) ⇒ Object
- #all(filter = nil) ⇒ Object
-
#initialize ⇒ Groups
constructor
A new instance of Groups.
Constructor Details
#initialize ⇒ Groups
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, = {}) all(name).first || Group.new(name, ).tap do |group| fail if name == :specs && .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 |