Class: Guard::Maven

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/maven.rb

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ Maven

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:

  • watchers (Array<Guard::Watcher>) (defaults to: [])

    the Guard plugin file watchers

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

    the custom Guard plugin options

Options Hash (options):

  • group (Symbol)

    the group this Guard plugin belongs to

  • any_return (Boolean)

    allow any object to be returned from a watcher



15
16
17
18
# File 'lib/guard/maven.rb', line 15

def initialize(watchers = [], options = {})
  super
  @options = options
end

Instance Method Details

#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



35
36
37
# File 'lib/guard/maven.rb', line 35

def run_all
  run_maven_tests
end

#run_on_changes(paths) ⇒ Object

Default behaviour on file(s) changes 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_change has failed



44
45
46
47
48
49
50
51
# File 'lib/guard/maven.rb', line 44

def run_on_changes(paths)
  # for now run all
  if paths.include? 'all'
    run_all
  else
    run_maven_tests :classes => paths
  end
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



25
26
27
# File 'lib/guard/maven.rb', line 25

def start
  run_all if @options[:all_on_start]
end