Class: WebResourceBundler::Filters::BundleFilter::ResourcePackager

Inherits:
Object
  • Object
show all
Defined in:
lib/web_resource_bundler/filters/bundle_filter/resource_packager.rb

Constant Summary collapse

IMPORT_PTR =
/\@import ['|"](.*?)['|"];/i

Instance Method Summary collapse

Constructor Details

#initialize(settings, file_manager) ⇒ ResourcePackager

Returns a new instance of ResourcePackager.



5
6
7
8
# File 'lib/web_resource_bundler/filters/bundle_filter/resource_packager.rb', line 5

def initialize(settings, file_manager)
  @settings     = settings
  @file_manager = file_manager 
end

Instance Method Details

#bundle_files(files) ⇒ Object

recursively iterates through all files and imported files



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/web_resource_bundler/filters/bundle_filter/resource_packager.rb', line 11

def bundle_files(files)
  output = ""
  files.select { |f| !f.content.empty? }.each do |file|
    content = file.content
    path    = file.path
    output  << bundled_file_header(path) 
    output  << include_imported_files(content, path) if file.type[:ext] == 'css'
    content << javascript_fix                        if file.type[:ext] == '.js' 
    output  << content
    output  << bundled_file_footer(path)
  end
  output
end