Class: Guard::Group

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

Overview

A group of Guard plugins. There are two reasons why you want to group your Guard plugins:

  • You can start only certain groups from the command line by passing the ‘–group` option to `guard start`.

  • Abort task execution chain on failure within a group with the ‘:halt_on_fail` option.

Examples:

Group that aborts on failure


group :frontend, halt_on_fail: true do
  guard 'coffeescript', input: 'spec/coffeescripts',
    output: 'spec/javascripts'
  guard 'jasmine-headless-webkit' do
    watch(%r{^spec/javascripts/(.*)\..*}) do |m|
    newest_js_file("spec/javascripts/#{m[1]}_spec")
  end
  end
end

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Group

Initializes a Group.

Parameters:

  • name (String)

    the name of the group

  • options (Hash) (defaults to: {})

    the group options

Options Hash (options):

  • halt_on_fail (Boolean)

    if a task execution should be halted for all Guard plugins in this group if a Guard plugin throws ‘:task_has_failed`



35
36
37
38
# File 'lib/guard/group.rb', line 35

def initialize(name, options = {})
  @name = name.to_sym
  @options = options
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



25
26
27
# File 'lib/guard/group.rb', line 25

def name
  @name
end

#optionsObject

Returns the value of attribute options.



25
26
27
# File 'lib/guard/group.rb', line 25

def options
  @options
end

Instance Method Details

#titleString

Returns the group title.

Examples:

Title for a group named ‘backend’

> Guard::Group.new('backend').title
=> "Backend"

Returns:

  • (String)


48
49
50
# File 'lib/guard/group.rb', line 48

def title
  @title ||= name.to_s.capitalize
end

#to_sString

String representation of the group.

Examples:

String representation of a group named ‘backend’

> Guard::Group.new('backend').to_s
=> "#<Guard::Group @name=backend @options={}>"

Returns:

  • (String)

    the string representation



60
61
62
# File 'lib/guard/group.rb', line 60

def to_s
  "#<#{self.class} @name=#{name} @options=#{options}>"
end