Sha256: 5231d0121bb8365a620121f337b95a79161ee06d6815b1fcd2d3bca3e1587d3b

Contents?: true

Size: 728 Bytes

Versions: 54

Compression:

Stored size: 728 Bytes

Contents

module Sprockets
  class Concatenation
    attr_reader :source_lines
    
    def initialize
      @source_lines = []
      @source_file_mtimes = {}
    end
    
    def record(source_line)
      source_lines << source_line
      record_mtime_for(source_line.source_file)
      source_line
    end
    
    def to_s
      source_lines.join
    end

    def mtime
      @source_file_mtimes.values.max
    end
    
    def save_to(filename)
      timestamp = mtime
      File.open(filename, "w") { |file| file.write(to_s) }
      File.utime(timestamp, timestamp, filename)
      true
    end

    protected
      def record_mtime_for(source_file)
        @source_file_mtimes[source_file] ||= source_file.mtime
      end
  end
end

Version data entries

54 entries across 53 versions & 6 rubygems

Version Path
architecture-js-0.3.4 lib/sprockets/lib/sprockets/concatenation.rb
ninjs-0.16.8 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.3.3 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.3.2 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.3.1 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.3.0 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.2.3 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.2.2 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.2.1 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.2.0 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.1.17 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.1.16 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.1.15 lib/sprockets/lib/sprockets/concatenation.rb
architecture-js-0.1.14 lib/sprockets/lib/sprockets/concatenation.rb
ninjs-0.16.7 lib/sprockets/lib/sprockets/concatenation.rb
ninjs-0.16.6 lib/sprockets/lib/sprockets/concatenation.rb
ninjs-0.16.5 lib/sprockets/lib/sprockets/concatenation.rb
ninjs-0.16.4 lib/sprockets/lib/sprockets/concatenation.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/sprockets-1.0.2/lib/sprockets/concatenation.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/sprockets-1.0.2/lib/sprockets/concatenation.rb