Sha256: 0fe28b42a40f4d515d950c657bcd32b2b7c08afe5a4268b3f2af50abb2c29eef

Contents?: true

Size: 572 Bytes

Versions: 4

Compression:

Stored size: 572 Bytes

Contents

module Jasmine
  class PathExpander

    def self.expand(base_directory, patterns, globber = Dir.method(:glob))
      negative, positive = patterns.partition {|pattern| /^!/ =~ pattern}
      chosen, negated = [positive, negative].collect do |patterns|
        patterns.map do |path|
          files = globber.call(File.join(base_directory, path.gsub(/^!/, '')))
          if files.empty? && !(path =~ /\*|^\!/)
            files = [File.join(base_directory, path)]
          end
          files
        end.flatten.uniq
      end
      chosen - negated
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
jasmine-multi_json-1.3.2.1 lib/jasmine/path_expander.rb
jasmine-1.3.2 lib/jasmine/path_expander.rb
jasmine-multi_json-1.3.1.1 lib/jasmine/path_expander.rb
jasmine-1.3.1 lib/jasmine/path_expander.rb