Class: Guard::DslDescriber
Overview
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.
Class Method Summary collapse
-
.evaluate_guardfile(options = {}) ⇒ Object
Evaluate the DSL methods in the
Guardfile. -
.list(options) ⇒ Object
List the Guards that are available for use in your system and marks those that are currently used in your
Guardfile. -
.show(options) ⇒ Object
Shows all Guards and their options that are defined in the
Guardfile.
Methods inherited from Dsl
#callback, fetch_guardfile_contents, guardfile_contents, guardfile_contents_usable?, guardfile_contents_with_user_config, guardfile_default_path, guardfile_include?, guardfile_path, #ignore_paths, instance_eval_guardfile, read_guardfile, reevaluate_guardfile, #watch
Class Method Details
.evaluate_guardfile(options = {}) ⇒ Object
Evaluate the DSL methods in the Guardfile.
25 26 27 28 |
# File 'lib/guard/dsl_describer.rb', line 25 def evaluate_guardfile( = {}) @@guardfile_structure = [{ :guards => [] }] super end |
.list(options) ⇒ Object
List the Guards that are available for use in your system and marks
those that are currently used in your Guardfile.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/guard/dsl_describer.rb', line 47 def list() evaluate_guardfile() installed = guardfile_structure.inject([]) do |installed, group| group[:guards].each { |guard| installed << guard[:name] } if group[:guards] installed end UI.info 'Available guards:' ::Guard.guard_gem_names.sort.uniq.each do |name| UI.info " #{ name }#{ installed.include?(name) ? '*' : '' }" end UI.info '' UI.info 'See also https://github.com/guard/guard/wiki/List-of-available-Guards' UI.info '* denotes ones already in your Guardfile' end |
.show(options) ⇒ Object
Shows all Guards and their options that are defined in
the Guardfile.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/guard/dsl_describer.rb', line 79 def show() evaluate_guardfile() guardfile_structure.each do |group| unless group[:guards].empty? if group[:group] UI.info "Group #{ group[:group] }:" else UI.info '(global):' end group[:guards].each do |guard| line = " #{ guard[:name] }" unless guard[:options].empty? line += ": #{ guard[:options].sort.collect { |k, v| "#{ k } => #{ v.inspect }" }.join(', ') }" end UI.info line end end end UI.info '' end |