Class: CSSminify2
- Inherits:
-
Object
- Object
- CSSminify2
- Defined in:
- lib/cssminify2.rb,
lib/cssminify2/version.rb
Constant Summary collapse
- VERSION =
"2.1.0"
Class Method Summary collapse
-
.compress(source, length = 5000) ⇒ String
Compress CSS with YUI (Original API - Unchanged).
-
.compress_enhanced(source, options = {}) ⇒ String
Enhanced compression with additional features (New, Optional).
-
.compress_with_stats(source, options = {}) ⇒ Hash
Enhanced compression with statistics (New, Optional).
Instance Method Summary collapse
-
#compress(source = '', length = 5000) ⇒ String
Compress CSS with YUI (Original API - Unchanged).
-
#initialize ⇒ CSSminify2
constructor
A new instance of CSSminify2.
Constructor Details
#initialize ⇒ CSSminify2
Returns a new instance of CSSminify2.
15 16 |
# File 'lib/cssminify2.rb', line 15 def initialize end |
Class Method Details
.compress(source, length = 5000) ⇒ String
Compress CSS with YUI (Original API - Unchanged)
24 25 26 |
# File 'lib/cssminify2.rb', line 24 def self.compress(source, length = 5000) self.new.compress(source, length) end |
.compress_enhanced(source, options = {}) ⇒ String
Enhanced compression with additional features (New, Optional)
50 51 52 53 54 55 56 57 |
# File 'lib/cssminify2.rb', line 50 def self.compress_enhanced(source, = {}) if defined?(CSSminify2Enhanced) CSSminify2Enhanced.compress(source, ) else # Fallback to original compression if enhanced features not available compress(source, [:linebreakpos] || 5000) end end |
.compress_with_stats(source, options = {}) ⇒ Hash
Enhanced compression with statistics (New, Optional)
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cssminify2.rb', line 65 def self.compress_with_stats(source, = {}) if defined?(CSSminify2Enhanced) CSSminify2Enhanced.compress_with_stats(source, ) else # Fallback with basic stats original = source.respond_to?(:read) ? source.read : source.to_s compressed = compress(original, [:linebreakpos] || 5000) { compressed_css: compressed, statistics: { original_size: original.length, compressed_size: compressed.length, compression_ratio: ((original.length - compressed.length).to_f / original.length * 100).round(2), enhanced_features_used: false } } end end |
Instance Method Details
#compress(source = '', length = 5000) ⇒ String
Compress CSS with YUI (Original API - Unchanged)
34 35 36 37 38 |
# File 'lib/cssminify2.rb', line 34 def compress(source = '', length = 5000) source = source.respond_to?(:read) ? source.read : source.to_s CssCompressor.compress(source, length) end |