class Blade::Assets::Builder
Attributes
environment[RW]
Public Class Methods
new(environment)
click to toggle source
# File lib/blade/assets/builder.rb, line 4 def initialize(environment) @environment = environment end
Public Instance Methods
build()
click to toggle source
# File lib/blade/assets/builder.rb, line 8 def build puts "Building assets…" clean compile clean_dist_path create_dist_path install end
Private Instance Methods
clean()
click to toggle source
# File lib/blade/assets/builder.rb, line 39 def clean compile_path.rmtree if compile_path.exist? compile_path.mkpath end
clean_dist_path()
click to toggle source
# File lib/blade/assets/builder.rb, line 52 def clean_dist_path if clean_dist_path? children = dist_path.children dist_path.rmtree children.each do |child| puts "[removed] #{child}" end end end
clean_dist_path?()
click to toggle source
# File lib/blade/assets/builder.rb, line 62 def clean_dist_path? Blade.config.build.clean && dist_path.exist? end
compile()
click to toggle source
# File lib/blade/assets/builder.rb, line 19 def compile environment.js_compressor = Blade.config.build.js_compressor.try(:to_sym) environment.css_compressor = Blade.config.build.css_compressor.try(:to_sym) manifest.compile(logical_paths) end
compile_path()
click to toggle source
# File lib/blade/assets/builder.rb, line 70 def compile_path @compile_path ||= Blade.tmp_path.join("compile") end
create_dist_path()
click to toggle source
# File lib/blade/assets/builder.rb, line 48 def create_dist_path dist_path.mkpath unless dist_path.exist? end
dist_path()
click to toggle source
# File lib/blade/assets/builder.rb, line 66 def dist_path @dist_path ||= Pathname.new(Blade.config.build.path) end
install()
click to toggle source
# File lib/blade/assets/builder.rb, line 25 def install logical_paths.each do |logical_path| fingerprint_path = manifest.assets[logical_path] source_path = compile_path.join(fingerprint_path) destination_path = dist_path.join(logical_path) FileUtils.cp(source_path, destination_path) puts "[created] #{destination_path}" end end
logical_paths()
click to toggle source
# File lib/blade/assets/builder.rb, line 44 def logical_paths Blade.config.build.logical_paths end
manifest()
click to toggle source
# File lib/blade/assets/builder.rb, line 35 def manifest @manifest ||= Sprockets::Manifest.new(environment.index, compile_path) end