Sha256: ee2036f5ec26d91a980fbdaaba60522f2b22d96cba367443f0d123a31fe65ede

Contents?: true

Size: 1.21 KB

Versions: 36

Compression:

Stored size: 1.21 KB

Contents

module Sprockets
  class SourceFile
    attr_reader :environment, :pathname
    attr_accessor :interpolate_constants

    def initialize(environment, pathname)
      @environment = environment
      @pathname = pathname
      @interpolate_constants = true
    end

    def source_lines
      @lines ||= begin
        lines = []

        comments = []
        File.open(pathname.absolute_location) do |file|
          file.each do |line|
            lines << line = SourceLine.new(self, line, file.lineno)

            if line.begins_pdoc_comment? || comments.any?
              comments << line
            end

            if line.ends_multiline_comment?
              if line.ends_pdoc_comment?
                comments.each { |l| l.comment! }
              end
              comments.clear
            end
          end
        end

        lines
      end
    end

    def each_source_line(&block)
      source_lines.each(&block)
    end

    def find(location, kind = :file)
      pathname.parent_pathname.find(location, kind)
    end
    
    def ==(source_file)
      pathname == source_file.pathname
    end
    
    def mtime
      File.mtime(pathname.absolute_location)
    rescue Errno::ENOENT
      Time.now
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
architecture-js-0.6.3 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.6.2 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.6.1 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.6.0 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.8 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.7 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.6 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.5 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.4 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.3 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.2 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.1 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.5.0 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.4.0 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.3.8 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.3.7 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.3.6 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.3.5 lib/sprockets/lib/sprockets/source_file.rb
architecture-js-0.3.4 lib/sprockets/lib/sprockets/source_file.rb
ninjs-0.16.8 lib/sprockets/lib/sprockets/source_file.rb