Module: Guard::CoffeeScript::Runner

Defined in:
lib/guard/coffeescript/runner.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.last_run_failedObject

Returns the value of attribute last_run_failed.



8
9
10
# File 'lib/guard/coffeescript/runner.rb', line 8

def last_run_failed
  @last_run_failed
end

Class Method Details

.remove(files, watchers, options = { }) ⇒ Object

The remove function deals with CoffeeScript file removal by locating the output javascript file and removing it.

Parameters:

  • files (Array<String>)

    the spec files or directories

  • watchers (Array<Guard::Watcher>)

    the Guard watchers in the block

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

    the options for the removal

Options Hash (options):

  • :output (String)

    the output directory

  • :shallow (Boolean)

    do not create nested directories



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/guard/coffeescript/runner.rb', line 43

def remove(files, watchers, options = { })
  removed_files = []
  directories   = detect_nested_directories(watchers, files, options)

  directories.each do |directory, scripts|
    scripts.each do |file|
      javascript = javascript_file_name(file, directory)
      if File.exists?(javascript)
        FileUtils.remove_file(javascript)
        removed_files << javascript
      end
    end
  end

  if removed_files.length > 0
    message = "Removed #{ removed_files.join(', ') }"
    Formatter.success(message)
    Formatter.notify(message, :title => 'CoffeeScript results')
  end
end

.run(files, watchers, options = { }) ⇒ Array<Array<String>, Boolean>

The CoffeeScript runner handles the CoffeeScript compilation, creates nested directories and the output file, writes the result to the console and triggers optional system notifications.

Parameters:

  • files (Array<String>)

    the spec files or directories

  • watchers (Array<Guard::Watcher>)

    the Guard watchers in the block

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

    the options for the execution

Options Hash (options):

  • :input (String)

    the input directory

  • :output (String)

    the output directory

  • :bare (Boolean)

    do not wrap the output in a top level function

  • :shallow (Boolean)

    do not create nested directories

  • :hide_success (Boolean)

    hide success message notification

  • :noop (Boolean)

    do not generate an output file

  • :source_map (Boolean)

    generate the source map files

Returns:

  • (Array<Array<String>, Boolean>)

    the result for the compilation run



26
27
28
29
30
31
32
# File 'lib/guard/coffeescript/runner.rb', line 26

def run(files, watchers, options = { })
  notify_start(files, options)
  changed_files, errors = compile_files(files, watchers, options)
  notify_result(changed_files, errors, options)

  [changed_files, errors.empty?]
end