Sha256: a0f16bfcf1e30b5c304cd02b4b464e30195051d557ee9f7f2b3f9372db71860a

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

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.relative_path( path, prefix, options = {} )
      return path if prefix.nil?
      m = path.match( /^#{ prefix }\/?/ )
      if ! m.nil?
        if options[ :initial_dot_slash ]
          "./#{ m.post_match }"
        else
          m.post_match
        end
      else
        path
      end
    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rake-builder-0.7.0 lib/rake/path.rb
rake-builder-0.0.19 lib/rake/path.rb
rake-builder-0.0.18 lib/rake/path.rb
rake-builder-0.0.17 lib/rake/path.rb
rake-builder-0.0.16 lib/rake/path.rb
rake-builder-0.0.15 lib/rake/path.rb