lib/linner.rb in linner-0.6.3 vs lib/linner.rb in linner-0.6.4

- old
+ new

@@ -116,39 +116,48 @@ private def concat(config) config["concat"].each_with_index do |pair, index| dest, pattern, order = pair.first, pair.last, config["order"]||[] matches = Dir.glob(pattern).sort_by(&:downcase).order_by(order) - next if matches.select {|p| cache.miss? p}.empty? + next if matches.select {|path| cache.miss?(dest, path)}.empty? write_asset(dest, matches) end end def copy(config) config["copy"].each do |dest, pattern| Dir.glob(pattern).each do |path| - next if not cache.miss?(path) - logical_path = Asset.new(path).logical_path - dest_path = File.join(env.public_folder, dest, logical_path) - FileUtils.mkdir_p File.dirname(dest_path) - FileUtils.cp_r path, dest_path + next if not cache.miss?(dest, path) + asset = Asset.new(path) + dest_path = File.join(env.public_folder, dest, asset.logical_path) + if asset.javascript? or asset.stylesheet? + asset.content + asset.compress if compile? + dest_path = dest_path.sub(/[^.]+\z/,"js") if asset.javascript? + dest_path = dest_path.sub(/[^.]+\z/,"css") if asset.stylesheet? + asset.path = dest_path + asset.write + else + FileUtils.mkdir_p File.dirname(dest_path) + FileUtils.cp_r path, dest_path + end end end end def precompile(config) config["precompile"].each do |dest, pattern| matches = Dir.glob(pattern).sort_by(&:downcase) - next if matches.select { |p| cache.miss? p }.empty? + next if matches.select { |path| cache.miss?(dest, path) }.empty? write_template(dest, matches) end end def sprite(config) config["sprite"].each do |dest, pattern| matches = Dir.glob(pattern).sort_by(&:downcase) - next if matches.select { |p| cache.miss? p }.empty? + next if matches.select { |path| cache.miss?(dest, path) }.empty? paint_sprite(dest, matches) end end def revision @@ -181,19 +190,19 @@ asset.write end def write_template(dest, child_assets) asset = Asset.new(File.join env.public_folder, dest) - content = child_assets.inject("") {|s, m| s << cache[m].content} + content = child_assets.inject("") {|s, m| s << cache["#{dest}:#{m}"].content} asset.content = Wrapper::Template.definition(content) asset.compress if compile? asset.write end def write_asset(dest, child_assets) asset = Asset.new(File.join env.public_folder, dest) definition = (asset.path == env.definition ? Wrapper::Module.definition : "") - asset.content = child_assets.inject(definition) {|s, m| s << cache[m].content} + asset.content = child_assets.inject(definition) {|s, m| s << cache["#{dest}:#{m}"].content} asset.compress if compile? asset.write end def replace_attributes file