Sha256: de69ffa106bc9fd377db7bad297eacce4492bdee0fbc9d06d8e5bce4e63e5eda

Contents?: true

Size: 987 Bytes

Versions: 13

Compression:

Stored size: 987 Bytes

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 str
      PostProcessor::POST_PROCESSORS[target_class.outputs].each do |processor|
        p = processor.new(str)
        str.replace(p.process)
      end
      
      str
    end
    
    def code_for_dependency d
      post_process(d.code)
    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

13 entries across 13 versions & 1 rubygems

Version Path
assette-0.0.13 lib/assette/compiled_file.rb
assette-0.0.12 lib/assette/compiled_file.rb
assette-0.0.11 lib/assette/compiled_file.rb
assette-0.0.10 lib/assette/compiled_file.rb
assette-0.0.9 lib/assette/compiled_file.rb
assette-0.0.8 lib/assette/compiled_file.rb
assette-0.0.7 lib/assette/compiled_file.rb
assette-0.0.6 lib/assette/compiled_file.rb
assette-0.0.5 lib/assette/compiled_file.rb
assette-0.0.4 lib/assette/compiled_file.rb
assette-0.0.3 lib/assette/compiled_file.rb
assette-0.0.2 lib/assette/compiled_file.rb
assette-0.0.1 lib/assette/compiled_file.rb