./lib/lux_assets/base.rb in lux_assets-0.2.4 vs ./lib/lux_assets/base.rb in lux_assets-0.2.9
- old
+ new
@@ -1,11 +1,11 @@
# Main assets module
module LuxAssets
extend self
- CONFIG_PATH = Pathname.new ENV.fetch('ASSETS_CONFIG') { './config/assets.rb' }
+ CONFIG_PATH ||= Pathname.new ENV.fetch('ASSETS_CONFIG') { './config/assets.rb' }
ASSET_TYPES ||= {
js: ['js', 'coffee', 'ts'],
css: ['css', 'scss']
}
@@ -74,20 +74,17 @@
end
# get list of files in the resource
def files ext, name=nil
ext, name = ext.split('/', 2) unless name
- ext = ext.to_sym
-
- raise ArgumentError.new('name not deinfed') if name.empty?
-
- to_h[ext][name.to_s]
+ Asset.new(ext, name).files
end
# compile single asset
- def compile path
- LuxAssets::Element.new(path).compile
+ def compile path, opts={}
+ opts[:production] = false if opts[:production].nil?
+ LuxAssets::Element.new(path).send :compile, opts
end
# compile all assets
def compile_all
# generate master file for every resource
@@ -99,10 +96,10 @@
end
# gzip if needed
files = Dir['./public/assets/*.css'] + Dir['./public/assets/*.js']
files.each do |file|
- LuxAssets::Cli.run 'gzip -k %s' % file unless File.exist?('%s.gz' % file)
+ LuxAssets::Cli.run('gzip -k %s' % file, message: "Gzip: #{file}") unless File.exist?('%s.gz' % file)
end
# touch all files and reset the timestamp
Dir['./public/assets/*']
.each { |file| system 'touch -t 201001010101 %s' % file }
\ No newline at end of file