Module: Guard::CoffeeScript::Inspector

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

Overview

The inspector verifies of the changed paths are valid for Guard::CoffeeScript.

Class Method Summary (collapse)

Class Method Details

+ (Array<String>) clean(paths, options = {})

Clean the changed paths and return only valid CoffeeScript files.

Parameters:

  • paths (Array<String>)

    the changed paths

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

    the clean options

Options Hash (options):

  • :missing_ok (String)

    don't remove missing files from list

Returns:

  • (Array<String>)

    the valid spec files



18
19
20
21
22
# File 'lib/guard/coffeescript/inspector.rb', line 18

def clean(paths, options = {})
  paths.uniq!
  paths.compact!
  paths.select { |p| coffee_file?(p, options) }
end

+ (Boolean) coffee_file?(path, options) (private)

Tests if the file is valid.

Parameters:

  • path (String)

    the file

  • options (Hash)

    the clean options

Options Hash (options):

  • :missing_ok (String)

    don't remove missing files from list

Returns:

  • (Boolean)

    when the file valid



33
34
35
# File 'lib/guard/coffeescript/inspector.rb', line 33

def coffee_file?(path, options)
  path =~ /\.(?:coffee|coffee\.md|litcoffee)$/ && (options[:missing_ok] || File.exists?(path))
end