./lib/lux_assets/base.rb in lux_assets-0.2.2 vs ./lib/lux_assets/base.rb in lux_assets-0.2.4

- old
+ new

@@ -16,15 +16,10 @@ def relative_root name=nil @relative_root = name if name @relative_root end - def die text - puts text.try(:red) - exit - end - def asset name @name = name.to_s yield end @@ -71,11 +66,11 @@ files = files.select { |it| File.file?(it) } if files[0] add_local_files files else - die 'No files found in "%s -> :%s" (%s)'.red % [@ext, @name, added] + LuxAssets::Cli.die 'No files found in "%s -> :%s" (%s)'.red % [@ext, @name, added] end end end # get list of files in the resource @@ -104,22 +99,22 @@ end # gzip if needed files = Dir['./public/assets/*.css'] + Dir['./public/assets/*.js'] files.each do |file| - LuxAssets.run 'gzip -k %s' % file unless File.exist?('%s.gz' % file) + LuxAssets::Cli.run 'gzip -k %s' % 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 } end # get all files as a hash def to_h unless @assets_loaded - die 'Assets file not found in %s' % CONFIG_PATH unless CONFIG_PATH.exist? + LuxAssets::Cli.die 'Assets rb config file not found in %s' % CONFIG_PATH unless CONFIG_PATH.exist? @assets_loaded = true eval CONFIG_PATH.read end @assets @@ -146,29 +141,9 @@ end total = '%s kB in total' % (total/1024.to_f).round(1).to_s puts total.rjust(20) end - end - end - - def run what, cache_file=nil - puts what.yellow - - stdin, stdout, stderr, wait_thread = Open3.popen3(what) - - error = stderr.gets - while line = stderr.gets do - error += line - end - - # node-sass prints to stderror on complete - error = nil if error && error.index('Rendering Complete, saving .css file...') - - if error - cache_file.unlink if cache_file && cache_file.exist? - - puts error.red end end private \ No newline at end of file