Sha256: f3dc8a0bd69383de01408eaa76af93f8a9713d462cb079b02b12d8a2449de0b5

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module Assette
  class CompiledFile < Array
    
    attr_reader :file

    def initialize(file)
      @file = file
    end

    def add_dependency d
      c = []
      c << "\n"
      c << file.comment_str % "Start: #{d.path}"
      c << code_for_dependency(d)
      c << file.comment_str % "End: #{d.path}"
      
      self << c.join("\n")
    end
    
    def post_process file
      str = file.code
      PostProcessor::POST_PROCESSORS[target_class.outputs].each do |processor|
        p = processor.new(file, str, :parent => @file)

        str.replace(p.process)
      end
      
      str
    end
    
    def code_for_dependency d
      post_process(d)
    end

    def content_type
      return mime_type.content_type if mime_type

      case file.target_class.outputs
      when :js
        'text/javascript'
      when :css
        'text/css'
      else
        'text/plain'
      end
    end

    def mime_type
      target_class.mime_type
    end
    
    def target_class
      file.target_class
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
assette-0.1.8 lib/assette/compiled_file.rb
assette-0.1.7 lib/assette/compiled_file.rb
assette-0.1.6 lib/assette/compiled_file.rb
assette-0.1.5 lib/assette/compiled_file.rb