module Guard::Jasmine::Inspector

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

Public Class Methods

clean(paths, options) click to toggle source

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

@param [Array<String>] paths the changed paths @param [Hash] options the options for the Guard @option options [String] :spec_dir the directory with the Jasmine specs @return [Array<String>] the valid spec files

# File lib/guard/jasmine/inspector.rb, line 20
def clean(paths, options)
  paths.uniq!
  paths.compact!
  paths = if paths.include?(options[:spec_dir])
            [options[:spec_dir]]
          else
            paths.select { |p| jasmine_spec?(p) }
          end

  paths
end

Private Class Methods

jasmine_spec?(path) click to toggle source

Tests if the file is valid.

@param [String] path the file @return [Boolean] when the file valid

# File lib/guard/jasmine/inspector.rb, line 39
def jasmine_spec?(path)
  path =~ /(?:_s|S)pec\.(js|coffee|js\.coffee|cjsx|js\.cjsx)$/ && File.exist?(path)
end