Class: Mack::Assets::PackageCollection

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/mack-asset_packager/package_collection.rb

Overview

:nodoc:

Constant Summary collapse

ASSET_LOAD_TIME =
Time.now

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bundle_processedObject

Returns the value of attribute bundle_processed.



7
8
9
# File 'lib/mack-asset_packager/package_collection.rb', line 7

def bundle_processed
  @bundle_processed
end

Instance Method Details

#compress_bundlesObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mack-asset_packager/package_collection.rb', line 32

def compress_bundles
  if !self.bundle_processed and merge?
    self.bundle_processed = true
    assets_mgr.groups_by_asset_type(:javascripts).each do |group|
      compress(group, :javascripts)
    end
    
    assets_mgr.groups_by_asset_type(:stylesheets).each do |group|
      compress(group, :stylesheets)
    end
  end
end

#destroy_compressed_bundlesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mack-asset_packager/package_collection.rb', line 17

def destroy_compressed_bundles
  assets_mgr.groups_by_asset_type(:javascripts).each do |group|
    path = Mack::Paths.javascripts(group + ".js")
    if File.exists?(path)
      FileUtils.rm(path)
    end
  end
  assets_mgr.groups_by_asset_type(:stylesheets).each do |group|
    path = Mack::Paths.stylesheets(group + ".css")
    if File.exists?(path)
      FileUtils.rm(path)
    end
  end
end

#extension(asset_type) ⇒ Object



45
46
47
48
49
# File 'lib/mack-asset_packager/package_collection.rb', line 45

def extension(asset_type)
  return "js" if asset_type.to_s == "javascripts"
  return "css" if asset_type.to_s == "stylesheets"
  return ""
end

#initializedObject



13
14
15
# File 'lib/mack-asset_packager/package_collection.rb', line 13

def initialized
  self.bundle_processed = false
end

#merge?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/mack-asset_packager/package_collection.rb', line 9

def merge?
  return configatron.mack.assets.enable_bundle_merge
end