Sha256: 75973a7b6e2577a6ff69754b484dd0e4ee72a872f43ccca71d3da9d336ef80f9
Contents?: true
Size: 1.82 KB
Versions: 67
Compression:
Stored size: 1.82 KB
Contents
module Startback module Web class MagicAssets class RakeTasks DEFAULT_OPTIONS = { :namespace => :assets } def initialize(rake, options) @rake = rake @options = DEFAULT_OPTIONS.merge(options) install end attr_reader :rake, :options private def install require 'securerandom' ns = options[:namespace] target_folder = options[:target] assets = options[:assets] assets = MagicAssets.new(assets) if assets.is_a?(Hash) version = SecureRandom.urlsafe_base64 rake.instance_exec do namespace(ns) do desc 'Cleans generated assets' task :clean do FileUtils.rm_rf target_folder end task :prepare do FileUtils.mkdir_p target_folder (target_folder/"VERSION").write(version) end desc 'compile javascript assets' task :compile_js do assets['vendor.js'].write_to(target_folder/"vendor-#{version}.min.js") assets['app.js'].write_to(target_folder/"app-#{version}.min.js") puts "successfully compiled js assets" end desc 'compile css assets' task :compile_css do assets['vendor.css'].write_to(target_folder/"vendor-#{version}.min.css") assets['app.css'].write_to(target_folder/"app-#{version}.min.css") puts "successfully compiled css assets" end desc 'compile assets' task :compile => [:clean, :prepare, :compile_js, :compile_css] end end end end end # class MagicAssets end # module Web end # module Startback
Version data entries
67 entries across 67 versions & 4 rubygems