Class: AssetFormat::Js

Inherits:
AssetFormat show all
Defined in:
app/models/asset_format/js.rb

Constant Summary collapse

CONTENT_TYPE =
'text/javascript'
IMPORT =
/[\/\*]{0,2}\s*@import[ "'\(]+([^\s"'\);]+)[\s"'\);]*[\*\/]{0,2}/
IMPORT_COFFEE =
/# *@import[ "'\(]+([^\s"'\);]+)[ "'\)]*/
EXTEND_FORMATS =
[:coffee]

Instance Method Summary collapse

Methods inherited from AssetFormat

#content_type, #log, #status, #text

Instance Method Details

#coffee(text) ⇒ Object



11
12
13
14
15
16
# File 'app/models/asset_format/js.rb', line 11

def coffee text
  text = text.gsub(IMPORT_COFFEE){ |s|
    "\n### @import #{IMPORT_COFFEE.match(s)[1]}\n###\n"
  }
  ::CoffeeScript.compile text
end

#minify(text) ⇒ Object



7
8
9
# File 'app/models/asset_format/js.rb', line 7

def minify text
  ::Uglifier.compile text, copyright: false
end