Sha256: ab134c069c87eb5c05d629b4733b3069d0f11afc6f918701cc5e7eb9cb6e173d

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

module Guard
  class Jasmine

    # 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.
    #
    module Inspector
      class << self

        # Clean the changed paths and return only valid
        # Jasmine specs in either JavaScript or CoffeeScript.
        #
        # @param [Array<String>] paths the changed paths
        # @return [Array<String>] the valid spec files
        #
        def clean(paths)
          paths.uniq!
          paths.compact!

          if paths.include?('spec/javascripts')
            paths = ['spec/javascripts']
          else
            paths = paths.select { |p| jasmine_spec?(p) }
          end

          paths
        end

        private

        # Tests if the file is valid.
        #
        # @param [String] file the file
        # @return [Boolean] when the file valid
        #
        def jasmine_spec?(path)
          path =~ /_spec\.(js|coffee|js\.coffee)$/ && File.exists?(path)
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
guard-jasmine-0.9.13 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.12 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.11 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.10 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.9 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.8 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.7 lib/guard/jasmine/inspector.rb
guard-jasmine-0.9.6 lib/guard/jasmine/inspector.rb