Module: Qbuild::Jshandler

Defined in:
lib/qbuild/jshandler.rb

Class Method Summary collapse

Class Method Details

.minify_jsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/qbuild/jshandler.rb', line 7

def self.minify_js
  js_paths = Qbuild::Config.js_paths
  min_js_path = Qbuild::Config.minified_js_path
  Qbuild::Config.create_target_directory(min_js_path)
  js_paths.each do |js_path|
    Dir["#{js_path}/*.js"].each do |file|
      unless file.include? '.min.js'
        jsmin = Uglifier.new.compile(File.read(file))
        File.write("#{min_js_path}/#{name_min_file(file)}", jsmin)
      end
    end
  end
end

.name_min_file(file) ⇒ Object



21
22
23
24
# File 'lib/qbuild/jshandler.rb', line 21

def self.name_min_file(file)
  file = File.basename file
  file.gsub(/(.*)(.js)(.*)/, '\1.min.js\3')
end