File: group.rb

package info (click to toggle)
ruby-guard 2.18.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,344 kB
  • sloc: ruby: 9,256; makefile: 6
file content (64 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
module Guard
  # 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.
  #
  # @example 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 Guard::CLI
  #
  class Group
    attr_accessor :name, :options

    # Initializes a Group.
    #
    # @param [String] name the name of the group
    # @param [Hash] options the group options
    # @option options [Boolean] halt_on_fail if a task execution
    #   should be halted for all Guard plugins in this group if a Guard plugin
    #   throws `:task_has_failed`
    #
    def initialize(name, options = {})
      @name = name.to_sym
      @options = options
    end

    # Returns the group title.
    #
    # @example Title for a group named 'backend'
    #   > Guard::Group.new('backend').title
    #   => "Backend"
    #
    # @return [String]
    #
    def title
      @title ||= name.to_s.capitalize
    end

    # String representation of the group.
    #
    # @example String representation of a group named 'backend'
    #   > Guard::Group.new('backend').to_s
    #   => "#<Guard::Group @name=backend @options={}>"
    #
    # @return [String] the string representation
    #
    def to_s
      "#<#{self.class} @name=#{name} @options=#{options}>"
    end
  end
end