lib/linner/asset.rb in linner-0.1.0 vs lib/linner/asset.rb in linner-0.1.1
- old
+ new
@@ -3,41 +3,29 @@
attr_accessor :path, :content
def initialize(path)
@path = path
- if path =~ /#{Linner.root.to_path}\/public/
- @content = ""
- else
- @content = Linner::Template.new(path).render
- end
+ @content ||= File.exist?(path) ? Tilt.new(path).render : ""
end
- def type
- @type ||= if @path =~ /\.(js|coffee)$/
- "script"
- elsif @path =~ /\.(css|sass|scss)/
- "style"
- end
- end
-
def wrap
- Linner::Wrapper.wrap(logical_path.chomp(File.extname logical_path), @content)
+ Wrapper.wrap(logical_path.chomp(File.extname logical_path), @content)
end
def wrappable?
- !!(!@path.include? Linner.root.join("vendor").to_path and type == "script")
+ !!(@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.open @path, "w" do |file|
file.write @content
end
end
def compress
- @content = Linner::Compressor.compress(self)
+ @content = Compressor.compress(self)
end
def logical_path
@logical_path ||= @path.gsub(/#{Linner.root}\/app\/\w*\//, "")
end