Module: Guard::Jasmine::Inspector

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

Overview

The inspector verifies if the changed paths are valid for Guard::Jasmine. Please note that request to Inspector.clean paths keeps the current valid files cached until clear is called.

Class Method Summary collapse

Class Method Details

.clean(paths, options) ⇒ Array<String>

Clean the changed paths and return only valid Jasmine specs in either JavaScript or CoffeeScript.

Parameters:

  • paths (Array<String>)

    the changed paths

  • options (Hash)

    the options for the Guard

Options Hash (options):

  • :spec_dir (String)

    the directory with the Jasmine specs

Returns:

  • (Array<String>)

    the valid spec files



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/guard/jasmine/inspector.rb', line 20

def clean(paths, options)
  paths.uniq!
  paths.compact!
  if paths.include?(options[:spec_dir])
    paths = [options[:spec_dir]]
  else
    paths = paths.select { |p| jasmine_spec?(p) }
  end

  paths
end

.jasmine_spec?(path) ⇒ Boolean (private)

Tests if the file is valid.

Parameters:

  • path (String)

    the file

Returns:

  • (Boolean)

    when the file valid



39
40
41
# File 'lib/guard/jasmine/inspector.rb', line 39

def jasmine_spec?(path)
  path =~ /(?:_s|S)pec\.(js|coffee|js\.coffee)$/ && File.exists?(path)
end