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

+ (Array<String>) clean(paths, options)

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
31
# 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

+ (Boolean) jasmine_spec?(path) (private)

Tests if the file is valid.

Parameters:

  • path (String)

    the file

Returns:

  • (Boolean)

    when the file valid



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

def jasmine_spec?(path)
  path =~ /_spec\.(js|coffee|js\.coffee)$/ && File.exists?(path)
end