Sha256: 815d01c5483a7ad2b34c30af449191da4e26f9079f64c8a7d98b1318936c950b

Contents?: true

Size: 916 Bytes

Versions: 2

Compression:

Stored size: 916 Bytes

Contents

module Sprockets
  class Pathname
    attr_reader :environment, :absolute_location
    
    def initialize(environment, absolute_location)
      @environment = environment
      @absolute_location = File.expand_path(absolute_location)
    end

    # Returns a Pathname for the location relative to this pathname's absolute location.
    def find(location)
      location = File.join(absolute_location, location)
      File.file?(location) ? Pathname.new(environment, location) : nil
    end

    def parent_pathname
      Pathname.new(environment, File.dirname(absolute_location))
    end

    def source_file
      SourceFile.new(environment, self)
    end
    
    def contents
      IO.read(absolute_location)
    end
    
    def ==(pathname)
      environment == pathname.environment &&
        absolute_location == pathname.absolute_location
    end
    
    def to_s
      absolute_location
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sstephenson-sprockets-0.3.0 lib/sprockets/pathname.rb
sstephenson-sprockets-0.4.0 lib/sprockets/pathname.rb