module Bunto::Compressor

Public Instance Methods

exclude?(dest, dest_path) click to toggle source
# File lib/bunto-press.rb, line 9
def exclude?(dest, dest_path)
  res = false
  file_name = dest_path.slice(dest.length+1..dest_path.length)
  exclude = @site.config['bunto-press'] && @site.config['bunto-press']['exclude']
  if exclude
    if exclude.is_a? String
      exclude = [exclude]
    end
    exclude.each do |e|
      if e == file_name || File.fnmatch(e, file_name)
        res = true
        break
      end
    end
  end
  res
end
output_css(path, content) click to toggle source
# File lib/bunto-press.rb, line 46
def output_css(path, content)
  output_file(path, MultiCss.min(content, @site.config['bunto-press'] && @site.config['bunto-press']['css_options'] || {}))
rescue MultiCss::ParseError => e
  warn "Warning: parse error in #{path}. Don't panic - copying initial file"
  warn "Details: #{e.message.strip}"
  output_file(path, content)
end
output_file(dest, content) click to toggle source
# File lib/bunto-press.rb, line 27
def output_file(dest, content)
  FileUtils.mkdir_p(File.dirname(dest))
  File.open(dest, 'w') do |f|
    f.write(content)
  end
end
output_html(path, content) click to toggle source
# File lib/bunto-press.rb, line 34
def output_html(path, content)
  output_file(path, HtmlPress.press(content, @site.config['bunto-press'] && @site.config['bunto-press']['html_options'] || {}))
end
output_js(path, content) click to toggle source
# File lib/bunto-press.rb, line 38
def output_js(path, content)
  output_file(path, MultiJs.compile(content, @site.config['bunto-press'] && @site.config['bunto-press']['js_options'] || {}))
rescue MultiJs::ParseError => e
  warn "Warning: parse error in #{path}. Don't panic - copying initial file"
  warn "Details: #{e.message.strip}"
  output_file(path, content)
end