Class: Sinatra::Minify::Compressor
- Inherits:
-
Object
- Object
- Sinatra::Minify::Compressor
- Defined in:
- lib/sinatra/minify/compressor.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#build ⇒ Object
Rebuilds the minified .min.* files.
-
#clean ⇒ Object
Deletes all minified files.
-
#initialize(type, file, package) ⇒ Compressor
constructor
A new instance of Compressor.
Constructor Details
#initialize(type, file, package) ⇒ Compressor
Returns a new instance of Compressor.
11 12 13 14 15 16 17 18 19 |
# File 'lib/sinatra/minify/compressor.rb', line 11 def initialize(type, file, package) @type = type.to_s @file = file @package = package @command = :"minify_#{@type}" @host = ENV["MINIFY_SITE_URL"] || "http://localhost:4567" raise ArgumentError if not ['js', 'css'].include?(type) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
9 10 11 |
# File 'lib/sinatra/minify/compressor.rb', line 9 def file @file end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
8 9 10 |
# File 'lib/sinatra/minify/compressor.rb', line 8 def package @package end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/sinatra/minify/compressor.rb', line 7 def type @type end |
Instance Method Details
#build ⇒ Object
Rebuilds the minified .min.* files.
22 23 24 25 26 |
# File 'lib/sinatra/minify/compressor.rb', line 22 def build FileUtils.mkdir_p(File.dirname(file)) File.open(file, 'w') { |f| f.write minify(concatenated) } file end |
#clean ⇒ Object
Deletes all minified files.
29 30 31 |
# File 'lib/sinatra/minify/compressor.rb', line 29 def clean File.unlink(file) if File.exists?(file) end |