class Guard::HamlLint
This class is Guard
plugin
Constants
- DEFAULT_OPTIONS
Attributes
Public Class Methods
Initializes a Guard
plugin. Don't do any work here, especially as Guard
plugins get initialized even if they are not in an active group!
@param [Hash] options the custom Guard
plugin options @option options [Array<Guard::Watcher>] watchers the Guard
plugin file watchers @option options [Symbol] group the group this Guard
plugin belongs to @option options [Boolean] any_return allow any object to be returned from a watcher
# File lib/guard/haml_lint.rb, line 25 def initialize(options = {}) super default_options = DEFAULT_OPTIONS.dup @options = default_options.merge!(haml_dires: default_haml_dirs).merge!(options) end
Public Instance Methods
Called when `reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/…
@return [nil]
# File lib/guard/haml_lint.rb, line 46 def reload; end
Called when just `enter` is pressed This method should be principally used for long action like running all specs/tests/…
@raise [:task_has_failed] when run_all
has failed @return [Object] the task result
# File lib/guard/haml_lint.rb, line 54 def run_all run end
Called on file(s) additions that the Guard
plugin watches.
@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_additions
has failed @return [Object] the task result
# File lib/guard/haml_lint.rb, line 64 def run_on_additions(paths) run(paths) end
Called on file(s) modifications that the Guard
plugin watches.
@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_modifications
has failed @return [Object] the task result
# File lib/guard/haml_lint.rb, line 74 def run_on_modifications(paths) run(paths) end
Called on file(s) removals that the Guard
plugin watches.
@return [nil]
# File lib/guard/haml_lint.rb, line 82 def run_on_removals(paths); end
Called once when Guard
starts. Please override initialize method to init stuff.
@raise [:task_has_failed] when start has failed @return [Object] the task result
# File lib/guard/haml_lint.rb, line 36 def start run if @options[:all_on_start] end
Private Instance Methods
@param [String] commands
# File lib/guard/haml_lint.rb, line 107 def build_cli_command(commands) case commands when String then commands.shellsplit when NilClass then [] else raise ArgumentError, 'Please specify only String for :cli option' end end
@return [Array<String>] haml directory paths
# File lib/guard/haml_lint.rb, line 117 def default_haml_dirs File.exist?('app/views') ? ['app/views'] : ['.'] end
@param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_additions
has failed @return [Object] the task result
# File lib/guard/haml_lint.rb, line 90 def run(paths = []) command = ['haml-lint'] command.concat build_cli_command(@options[:cli]) if paths.empty? Guard::Compat::UI.info 'Running HAML-Lint for all haml files' command.concat @options[:haml_dires] else Guard::Compat::UI.info "Running HAML-Lint for some of the haml files: #{paths.join('\n')}" command.concat paths end throw :task_has_failed unless system(*command) end