Sha256: 39d1857080c8755e554132ef93a2ff51d25d40974a44af4718e84303d046e5a8

Contents?: true

Size: 971 Bytes

Versions: 4

Compression:

Stored size: 971 Bytes

Contents

require 'rubygems' if RUBY_VERSION < '1.9'

module Rake

  module Path

    def self.find_files( paths, extension )
      files = paths.reduce( [] ) do | memo, path |
        case
        when File.file?( path )
          files = FileList[ path ]
        when ( path =~ /[\*\?]/ )
          files = FileList[ path ]
        else
          files = FileList[ path + '/*.' + extension ]
        end
        memo + files
      end
    end

    # Expand path to an absolute path relative to the supplied root
    def self.expand_with_root( path, root )
      if path =~ /^\//
        File.expand_path( path )
      else
        File.expand_path( root + '/' + path )
      end
    end

    # Expand an array of paths to absolute paths relative to the supplied root
    def self.expand_all_with_root( paths, root )
      paths.map{ |path| expand_with_root( path, root ) }
    end

    def self.subtract_prefix( prefix, path )
      path[ prefix.size .. -1 ]
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rake-builder-0.0.14 lib/rake/path.rb
rake-builder-0.0.13 lib/rake/path.rb
rake-builder-0.0.12 lib/rake/path.rb
rake-builder-0.0.11 lib/rake/path.rb