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.

Options Hash (options):

  • :spec_dir (String)

    the directory with the Jasmine specs



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

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.



37
38
39
# File 'lib/guard/jasmine/inspector.rb', line 37

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