Class: Guard::ErbLint

Inherits:
Plugin
  • Object
show all
Defined in:
lib/guard/erb_lint.rb,
lib/guard/erb_lint/options.rb

Defined Under Namespace

Modules: Options

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ErbLint

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!

Parameters:

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

    the custom Guard plugin options

Options Hash (options):

  • watchers (Array<Guard::Watcher>)

    the Guard plugin file watchers

  • group (Symbol)

    the group this Guard plugin belongs to

  • any_return (Boolean)

    allow any object to be returned from a watcher



19
20
21
22
# File 'lib/guard/erb_lint.rb', line 19

def initialize(options = {})
  @options = Guard::ErbLint::Options.with_defaults(options).with_indifferent_access
  super
end

Instance Method Details

#run(*args) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/guard/erb_lint.rb', line 68

def run(*args)
  cli = ERBLint::CLI.new

  Compat::UI.info("Running ERBLint with args #{args.join(", ")}")

  cli.run(args)
end

#run_allObject

Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/…

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_all has failed



42
43
44
45
46
# File 'lib/guard/erb_lint.rb', line 42

def run_all
  run("--lint-all")
rescue StandardError
  throw(:task_has_failed)
end

#run_on_additions(paths) ⇒ Object

Called on file(s) additions that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_additions has failed



54
55
56
# File 'lib/guard/erb_lint.rb', line 54

def run_on_additions(paths)
  run_all_or_block { run(*paths) }
end

#run_on_modifications(paths) ⇒ Object

Called on file(s) modifications that the Guard plugin watches.

Parameters:

  • paths (Array<String>)

    the changes files or paths

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when run_on_modifications has failed



64
65
66
# File 'lib/guard/erb_lint.rb', line 64

def run_on_modifications(paths)
  run_all_or_block { run(*paths) }
end

#startObject

Called once when Guard starts. Please override initialize method to init stuff.

Returns:

  • (Object)

    the task result

Raises:

  • (:task_has_failed)

    when start has failed



29
30
31
32
33
34
# File 'lib/guard/erb_lint.rb', line 29

def start
  Compat::UI.info("Guard::ERBLint initialized")
  run_all if @options[:all_on_start]
rescue StandardError
  throw(:task_has_failed)
end