Class: GithubbishAssets::Packer

Inherits:
Object
  • Object
show all
Defined in:
lib/githubbish_assets/packer.rb

Defined Under Namespace

Classes: MultiFile

Class Method Summary collapse

Class Method Details

.cssObject



33
34
35
36
37
# File 'lib/githubbish_assets/packer.rb', line 33

def self.css
  pack(Rails.root + 'public/stylesheets', '.css') do |target, files|
    compress_with_yui(YUI::CssCompressor.new(:line_break => 0), files, target)
  end
end

.jsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/githubbish_assets/packer.rb', line 5

def self.js
  case GithubbishAssets.js_compressor
  when :jsmin
    require 'vendor/js_minimizer'
  when :closure
    require 'closure-compiler'
  end

  pack(Rails.root + 'public/javascripts', '.js') do |target, files|
    case GithubbishAssets.js_compressor
    when :closure
      opts = { :js_output_file => target, :js => files }

      if GithubbishAssets.closure_source_map
        opts[:create_source_map] = "#{target}.map"
      end

      Closure::Compiler.new(opts).compile('')
    when :yui
      compress_with_yui(YUI::JavaScriptCompressor.new, files, target)
    else
      File.open(target, 'w+') do |f|
        f.puts GithubbishAssets::JSMinimizer.minimize_files(*files)
      end
    end
  end
end