Sha256: 0bab90ec1852e26c93d9baf76c2f2c9f5306b785380666b965274cb29a0c562d
Contents?: true
Size: 1.4 KB
Versions: 4
Compression:
Stored size: 1.4 KB
Contents
require 'guard/dsl' module Guard # The DslDescriber overrides methods to create an internal structure # of the Guardfile that is used in some inspection utility methods # like the CLI commands `show` and `list`. # # @see Guard::Dsl # @see Guard::CLI # class DslDescriber < Dsl @@guardfile_structure = [ { :guards => [] } ] class << self # Get the Guardfile structure. # # @return [Array<Hash>] the structure # def guardfile_structure @@guardfile_structure end end private # Declares a group of guards. # # @param [String] name the group's name called from the CLI # @yield a block where you can declare several guards # # @see Guard::Dsl#group # def group(name) @@guardfile_structure << { :group => name.to_sym, :guards => [] } @group = true yield if block_given? @group = false end # Declares a Guard. # # @param [String] name the Guard name # @param [Hash] options the options accepted by the Guard # @yield a block where you can declare several watch patterns and actions # # @see Guard::Dsl#guard # def guard(name, options = {}) node = (@group ? @@guardfile_structure.last : @@guardfile_structure.first) node[:guards] << { :name => name, :options => options } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
guard-0.8.4 | lib/guard/dsl_describer.rb |
guard-0.8.3 | lib/guard/dsl_describer.rb |
guard-0.8.2 | lib/guard/dsl_describer.rb |
guard-0.8.0 | lib/guard/dsl_describer.rb |