Sha256: 7e53457a270cf95d5779897b6359f2c1ecc026f3344ce3bae6ecf05b3a1090de

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

module Sprockets
  class SourceFile
    attr_reader :environment, :pathname

    def initialize(environment, pathname)
      @environment = environment
      @pathname = pathname
    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

13 entries across 12 versions & 3 rubygems

Version Path
amiel-sprockets-1.0.5 lib/sprockets/source_file.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.10.17 vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.10.16 vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.10.15 vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
middleman-0.10.14 vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb
sprockets-1.0.2 lib/sprockets/source_file.rb