Class: ViewAssets::Packager::Packager

Inherits:
Object
  • Object
show all
Defined in:
lib/view_assets/packager/packager.rb

Direct Known Subclasses

CssPackager, JsPackager

Instance Method Summary collapse

Instance Method Details

#package(targets = {}, options = {}) ⇒ Object

targets = { :controller => [:action1, :action2], … } options:

:verbal => false
:compress => true
:compress_engine => 'yui-compressor'
:manifest => true


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/view_assets/packager/packager.rb', line 17

def package(targets = {}, options = {})
  options = { :verbal => false, :compress => true, :manifest => true, :compress_engine => 'yui-compressor' }.update(options)
  targets = actions_map.retrieve if targets.empty?

  # Preparing Envs
  FileUtils.mkdir_p("#{root}/assets/#{CSS_PATH}")
  FileUtils.mkdir_p("#{root}/assets/#{JS_PATH}")

  # Packaging
  @manifest = {}
  meta_package('', '', options)

  targets.each do |controller, actions|
    meta_package(controller, '', options)

    actions.map do |action|
      meta_package(controller, action, options)
    end
  end

  File.open("#{root}/assets/#{asset_path}/manifest.yml", 'w') { |file| YAML.dump(@manifest, file) } if options[:manifest]

  @manifest
end

#rootObject



42
43
44
# File 'lib/view_assets/packager/packager.rb', line 42

def root
  Rails.public_path
end