Sha256: a4146600e12f23fe84b5b05e2a6a8ebd238b4977a1df5292ec85e57f37a4884e

Contents?: true

Size: 726 Bytes

Versions: 1

Compression:

Stored size: 726 Bytes

Contents

module Linner
  class Asset

    attr_accessor :path, :content

    def initialize(path)
      @path = path
      @content ||= File.exist?(path) ? Tilt.new(path).render : ""
    end

    def wrap
      Wrapper.wrap(logical_path.chomp(File.extname logical_path), @content)
    end

    def wrappable?
      !!(@path.include? Linner.root.join("app").to_path and Template.template_for_script?(@path))
    end

    def write
      FileUtils.mkdir_p File.dirname(@path)
      File.open @path, "w" do |file|
        file.write @content
      end
    end

    def compress
      @content = Compressor.compress(self)
    end

    def logical_path
      @logical_path ||= @path.gsub(/#{Linner.root}\/app\/\w*\//, "")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
linner-0.1.1 lib/linner/asset.rb