Sha256: 1008d74f6e63f89d94f97722ac08cff610f812f2b4b7e3645effd0f1f0828d1e
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
module Spinebox module Compiler require "digest" # Compiles the assets and the views into the public folder def self.compile Spinebox.config.concatenate = true create_directories compile_javascripts compile_stylesheets compile_views copy_images end private def self.create_directories Dir.mkdir "public" unless File.directory?("public") Dir.mkdir "public/assets" unless File.directory?("public/assets") end def self.compile_javascripts asset = Spinebox.assets["application.js"] path = File.join("public/assets", asset.logical_path) write_asset!(asset, path) if asset_updated?(asset, path) end def self.compile_stylesheets asset = Spinebox.assets["application.css"] path = File.join("public/assets", asset.logical_path) write_asset!(asset, path) if asset_updated?(asset, path) end def self.compile_views Spinebox.views.each_logical_path do |logical_path| next if logical_path.start_with?("_") asset = Spinebox.views[logical_path] path = File.join("public", asset.logical_path) write_asset!(asset, path) if asset_updated?(asset, path) end end def self.copy_images FileUtils.cp_r "app/assets/images/.", "public/assets", :preserve => true end def self.asset_updated?(asset, path) return true unless File.exists?(path) Digest::SHA2.file(path).hexdigest != Digest::SHA2.hexdigest(asset.to_s) end def self.write_asset!(asset, path) asset.write_to(path) time = Time.now File.utime(time, time, path) puts path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spinebox-0.0.15 | lib/spinebox/compiler.rb |