Class: Guard::RSpectacle::Reloader

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/rspectacle/reloader.rb

Overview

The reloader class handles reloading of changed files.

Class Method Summary collapse

Class Method Details

.reload_file(file) ⇒ Boolean

Reloads the given file.

Parameters:

  • file (String)

    the changed file

Returns:

  • (Boolean)

    the load status

Raises:

  • (:task_has_failed)

    when run_on_change has failed



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/guard/rspectacle/reloader.rb', line 16

def reload_file(file)
  return false unless file =~ /\.rb$/

  if File.exists?(file)
    Formatter.info "Reload #{ file }"
    load file

  else
    false
  end

rescue Exception => e
  Formatter.error "Error reloading file #{ file }: #{ e.message }"

  throw :task_has_failed
end