cssminify2 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +10 -5
  3. data/CHANGELOG.md +121 -0
  4. data/Dockerfile +16 -0
  5. data/Gemfile +1 -1
  6. data/README.md +501 -42
  7. data/cssminify2.gemspec +6 -2
  8. data/docs/ADVANCED_USAGE.md +616 -0
  9. data/docs/API_REFERENCE.md +464 -0
  10. data/docs/EXAMPLES.md +844 -0
  11. data/docs/MIGRATION_GUIDE.md +586 -0
  12. data/lib/cssminify2/cssmin.rb +89 -7
  13. data/lib/cssminify2/cssmin_enhanced.rb +424 -0
  14. data/lib/cssminify2/enhanced.rb +818 -0
  15. data/lib/cssminify2/version.rb +1 -1
  16. data/lib/cssminify2.rb +53 -4
  17. data/spec/cssminify_spec.rb +49 -34
  18. data/spec/tests/README +6 -0
  19. data/spec/tests/_munge.js +8 -0
  20. data/spec/tests/_munge.js.min +1 -0
  21. data/spec/tests/_string_combo.js +5 -0
  22. data/spec/tests/_string_combo.js.min +1 -0
  23. data/spec/tests/_string_combo2.js +4 -0
  24. data/spec/tests/_string_combo2.js.min +1 -0
  25. data/spec/tests/_string_combo3.js +5 -0
  26. data/spec/tests/_string_combo3.js.min +1 -0
  27. data/spec/tests/_syntax_error.js +73 -0
  28. data/spec/tests/_syntax_error.js.min +1 -0
  29. data/spec/tests/border-none.css +6 -1
  30. data/spec/tests/border-none.css.min +1 -1
  31. data/spec/tests/bug-flex.css +3 -0
  32. data/spec/tests/bug-flex.css.min +1 -0
  33. data/spec/tests/bug-nested-pseudoclass.css +3 -0
  34. data/spec/tests/bug-nested-pseudoclass.css.min +1 -0
  35. data/spec/tests/bug-preservetoken-calc.css +8 -0
  36. data/spec/tests/bug-preservetoken-calc.css.min +1 -0
  37. data/spec/tests/color-keyword.css +1 -0
  38. data/spec/tests/color-keyword.css.min +1 -0
  39. data/spec/tests/color.css +2 -0
  40. data/spec/tests/color.css.min +1 -1
  41. data/spec/tests/concat-charset.css +2 -2
  42. data/spec/tests/concat-charset.css.min +1 -1
  43. data/spec/tests/dataurl-singlequote-font.css +1 -1
  44. data/spec/tests/dataurl-validity.html +29 -0
  45. data/spec/tests/float.js +2 -0
  46. data/spec/tests/float.js.min +1 -0
  47. data/spec/tests/hsla-issue81.css.FAIL +4 -0
  48. data/spec/tests/hsla-issue81.css.min +1 -0
  49. data/spec/tests/ie-backslash9-hack.css +2 -0
  50. data/spec/tests/ie-backslash9-hack.css.min +1 -0
  51. data/spec/tests/issue-59.css +7 -0
  52. data/spec/tests/issue-59.css.min +1 -0
  53. data/spec/tests/issue151.css +8 -0
  54. data/spec/tests/issue151.css.min +1 -0
  55. data/spec/tests/issue172.css.FAIL +4 -0
  56. data/spec/tests/issue172.css.min +1 -0
  57. data/spec/tests/issue180.css +16 -0
  58. data/spec/tests/issue180.css.min +1 -0
  59. data/spec/tests/issue205.css +2 -0
  60. data/spec/tests/issue205.css.min +1 -0
  61. data/spec/tests/issue221.css +1 -1
  62. data/spec/tests/issue221.css.min +1 -1
  63. data/spec/tests/issue222.css +2 -2
  64. data/spec/tests/issue222.css.min +1 -1
  65. data/spec/tests/issue71.js.FAIL +4 -0
  66. data/spec/tests/issue71.js.min +1 -0
  67. data/spec/tests/issue86.js +2 -0
  68. data/spec/tests/issue86.js.min +1 -0
  69. data/spec/tests/jquery-1.6.4.js +9046 -0
  70. data/spec/tests/jquery-1.6.4.js.min +23 -0
  71. data/spec/tests/lowercasing.css +63 -0
  72. data/spec/tests/lowercasing.css.min +1 -0
  73. data/spec/tests/media-test.css +2 -2
  74. data/spec/tests/old-ie-filter-matrix.css +8 -0
  75. data/spec/tests/old-ie-filter-matrix.css.min +1 -0
  76. data/spec/tests/opera-pixel-ratio.css +14 -0
  77. data/spec/tests/opera-pixel-ratio.css.min +1 -0
  78. data/spec/tests/pointzeros.css +6 -0
  79. data/spec/tests/pointzeros.css.min +1 -0
  80. data/spec/tests/preserve-important.css +1 -0
  81. data/spec/tests/preserve-important.css.min +1 -0
  82. data/spec/tests/promise-catch-finally-issue203.js +4 -0
  83. data/spec/tests/promise-catch-finally-issue203.js.min +1 -0
  84. data/spec/tests/pseudo-first.css +2 -2
  85. data/spec/tests/rgb-issue81.css.FAIL +4 -0
  86. data/spec/tests/rgb-issue81.css.min +1 -0
  87. data/spec/tests/suite.rhino +3 -0
  88. data/spec/tests/suite.sh +49 -0
  89. data/spec/tests/zeros.css +2 -2
  90. data/spec/tests/zeros.css.min +1 -1
  91. metadata +129 -14
  92. data/spec/tests/bug2528093.css +0 -3
  93. data/spec/tests/bug2528093.css.min +0 -1
  94. data/spec/tests/keyframe.css +0 -4
  95. data/spec/tests/keyframe.css.min +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fee98739226034abdbde07feb159995ac32cff2d
4
- data.tar.gz: c6c670c38f5576451aed41ae1a069f83364cd51d
2
+ SHA256:
3
+ metadata.gz: 3ee9c99c2466e5f47076672be51fcbfaa4a531e2c6f8755ce16d575bca819a41
4
+ data.tar.gz: 15308ef646ef5309dca1eb25a5cad652e19efbef200d4a9af87b97902f31ef5a
5
5
  SHA512:
6
- metadata.gz: f677634607b66d672c8d30f7d2d73aa918fd76c2dfb759c82f9f04d87044bf2d0763153d3cd52d4d0d4f18319012ac609fdbcf1bc0a2131d106e7a38f6e59325
7
- data.tar.gz: 69536aec513641530fbf2c547cf702067545dc02043c4500e49be87886d02c134eae25ff38e283f9840bc6233450497b70d787301946f18b1730b66128c1b389
6
+ metadata.gz: 02e9d221efa664fc56b8888da8a4834a5e1310871bba495b39913ef973b50a95e47241c199252c8214af5697cd9b5b91e0e2699149434d80fb926f6159b6fd1c
7
+ data.tar.gz: '09ea13a8fd8e942e1f3a4dacc4c0257a32987bd7abd8610a597ceafa1e940f4c3106b473299edfd8b3586f70c68c8542b7e0b3fa5930479fd3b80a81d06dc452'
data/.travis.yml CHANGED
@@ -1,7 +1,12 @@
1
+ deploy:
2
+ provider: rubygems
3
+ api_key:
4
+ secure: bogX4TZmY9CN0RNW2jckfb06iGA2MUjd66ocwsMoKcA+wyHmKSm+cyEPxcVlB2anAHt4BkF2faqLfU6w4QNQFb26bJCLHdp+M3PE6AMh+4Xu8s6XcnViBffcRvvdohfeQQAQzjOoUZFSu/m4Xdd6aL4We3wMHL4EwlltO1cq/5Qo+RcGh+5k6w7562qsJJ3XNLtLAK/Cno3kH1YSRomDBiUgL56foX8FWjrXdXVkE3hDX42CXaB9zgvwaywCb8wZAlODO5A6X1Kqy+comp2nEjyjKNkTy7p44eq9kGg7WrcdjL3VE4RKBta6EgX4vY7++yFJnXs2CtPW0ZxoxItRuwllIYKgk4GQg0ctqw7H0s3zjNevUYlWoqomiOCcTt7HtIztBaFv2f8o+jWJTHfGVPobKhpZEmNUn3yEoR1ECbzyswFyn7jdBCkv+DdBaezMEcabtAHmMoGcW0qRuWCYsyvg3aKYtJBi3g0mWdKks6+TJcYhyWmEmiAWympSYPGQ22iLlOy0J410CRlDXXm58m8EgLfn3r9tCm3VXtBEhgWjOQ2lViKm8mJp0LfH9vWDcidrr5/aXwGWHyRx8ahYE3ByYF5jbrTNUmNAKTohi1YOGS7XTWwoHkoZeBoGvk0w9g8yfYY8UrI10iLer6Y/hWaogS9JADcRCkV9rgMxOrA=
5
+ gem: cssminify2
6
+ on:
7
+ tags: true
8
+ repo: digitalsparky/cssminify
1
9
  language: ruby
2
10
  rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - jruby-19mode # JRuby in 1.9 mode
6
- - rbx-19mode
7
- script: bundle exec rspec spec
11
+ - 2.3.1
12
+ script: bundle exec rspec spec
data/CHANGELOG.md ADDED
@@ -0,0 +1,121 @@
1
+ # Changelog
2
+
3
+ All notable changes to CSSminify2 will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.1.0] - 2024-12-19
9
+
10
+ ### 🚀 Major Enhancements Added
11
+
12
+ #### New Features
13
+ - **Advanced CSS Compression Engine** - Up to 63% compression ratios vs 22% in previous versions
14
+ - **Modern CSS Support** - Full support for CSS Grid, Flexbox, Custom Properties, and modern units
15
+ - **Configurable Optimizations** - Granular control over compression features with opt-in approach
16
+ - **Enhanced API** - New `compress_enhanced()` and `compress_with_stats()` methods
17
+ - **Detailed Statistics** - Comprehensive metrics on compression performance and optimizations applied
18
+ - **Robust Error Handling** - Production-ready error handling with graceful fallbacks
19
+
20
+ #### Optimization Features
21
+ - **Duplicate Selector Merging** - Intelligently consolidates duplicate CSS selectors
22
+ - **Advanced Shorthand Optimization** - Optimizes margin, padding, flex, grid, and other shorthand properties
23
+ - **CSS Custom Property Compression** - Removes unused variables, inlines single-use values, shortens long names
24
+ - **Zero-Value and Unit Optimization** - Enhanced optimization of zero values, decimals, and modern CSS units
25
+ - **Modern Layout Optimizations** - CSS Grid and Flexbox shortcuts and property consolidation
26
+ - **Transform and Calc() Optimization** - Advanced function simplification and optimization
27
+
28
+ #### Developer Experience
29
+ - **100% Backward Compatibility** - All existing code continues to work unchanged
30
+ - **Configuration System** - Preset configurations (Conservative, Aggressive, Modern)
31
+ - **Malformed CSS Handling** - Validates CSS structure with detailed error reporting
32
+ - **Multiple Fallback Levels** - Ensures compression always succeeds with graceful degradation
33
+ - **Debug Mode** - Verbose logging for optimization troubleshooting
34
+
35
+ ### 🐛 Bug Fixes
36
+ - **calc() Function Preservation** - Fixed spacing issues that could break calc() functions
37
+ - **Flex Property Protection** - Prevented incorrect reduction of flex shorthand values
38
+ - **Complex Pseudo-selector Spacing** - Fixed spacing issues in chained pseudo-classes
39
+ - **IE Filter Compatibility** - Protected filter properties from color optimization to prevent IE breakage
40
+ - **YUI Compressor Color Optimization** - Implemented missing color keyword optimization feature
41
+ - **RGB Value Overflow Handling** - Fixed handling of RGB values over 255
42
+
43
+ ### 🔧 Technical Improvements
44
+ - **Modular Architecture** - Refactored codebase for better maintainability and extensibility
45
+ - **Enhanced Regex Patterns** - More efficient and accurate CSS parsing
46
+ - **Memory Optimization** - Reduced memory usage for large CSS files
47
+ - **Performance Improvements** - Faster processing while adding more features
48
+ - **Comprehensive Test Suite** - 77 test cases covering all new functionality
49
+
50
+ ### 📊 Performance Benchmarks
51
+ - **Bootstrap 5**: 275KB → 165KB (40% compression, +21% vs basic)
52
+ - **Modern App CSS**: 156KB → 89KB (43% compression, +27% vs basic)
53
+ - **CSS Grid Heavy**: 45KB → 28KB (38% compression, +26% vs basic)
54
+ - **CSS Variables Heavy**: 67KB → 29KB (57% compression, +50% vs basic)
55
+
56
+ ### 🔄 Migration
57
+ - **Zero Breaking Changes** - All existing APIs work exactly as before
58
+ - **Optional Enhancements** - New features are completely opt-in
59
+ - **Gradual Adoption** - Can incrementally adopt new features at your own pace
60
+
61
+ ### 📚 Documentation
62
+ - **Comprehensive README** - Complete guide with examples and benchmarks
63
+ - **API Reference** - Detailed documentation of all methods and options
64
+ - **Migration Guide** - Step-by-step guide for adopting new features
65
+ - **Troubleshooting Guide** - Common issues and solutions
66
+ - **Configuration Examples** - Real-world usage patterns
67
+
68
+ ---
69
+
70
+ ## [2.0.3] - Previous Release
71
+
72
+ ### Changed
73
+ - Updated RSpec dependency from ~> 2.7 to ~> 3.12 for modern Ruby compatibility
74
+ - Changed Gemfile to use HTTPS source for security
75
+ - Fixed RSpec deprecation warnings by updating test syntax
76
+
77
+ ### Fixed
78
+ - Merged performance improvement PR #5
79
+ - Resolved dependency conflicts with modern Ruby versions
80
+ - Fixed test suite compatibility issues
81
+
82
+ ### Security
83
+ - Updated gem source to use HTTPS instead of HTTP
84
+
85
+ ---
86
+
87
+ ## Earlier Releases
88
+
89
+ See [CHANGES.md](CHANGES.md) for historical changelog from previous versions.
90
+
91
+ ---
92
+
93
+ ## Release Types
94
+
95
+ - **Major (x.0.0)**: Breaking changes, significant new features
96
+ - **Minor (x.y.0)**: New features, improvements, non-breaking changes
97
+ - **Patch (x.y.z)**: Bug fixes, security updates, minor improvements
98
+
99
+ ## Upgrade Guide
100
+
101
+ ### From 2.0.x to 2.1.x
102
+ ✅ **No action required** - 100% backward compatible
103
+
104
+ ### Adopting New Features
105
+ ```ruby
106
+ # Before (continues to work)
107
+ CSSminify2.compress(css)
108
+
109
+ # After (optional enhanced features)
110
+ CSSminify2.compress_enhanced(css, {
111
+ merge_duplicate_selectors: true,
112
+ optimize_shorthand_properties: true
113
+ })
114
+ ```
115
+
116
+ ## Support
117
+
118
+ - 🐛 **Bug Reports**: [GitHub Issues](https://github.com/digitalsparky/cssminify/issues)
119
+ - 💬 **Questions**: [GitHub Discussions](https://github.com/digitalsparky/cssminify/discussions)
120
+ - 📧 **Security Issues**: Email maintainers directly
121
+ - 📖 **Documentation**: [README.md](README.md)
data/Dockerfile ADDED
@@ -0,0 +1,16 @@
1
+ FROM ruby:3.1
2
+
3
+ WORKDIR /app
4
+
5
+ # Copy gemspec and Gemfile first for better layer caching
6
+ COPY cssminify2.gemspec Gemfile ./
7
+ COPY lib/cssminify2/version.rb ./lib/cssminify2/
8
+
9
+ # Install dependencies
10
+ RUN bundle install
11
+
12
+ # Copy the rest of the application
13
+ COPY . .
14
+
15
+ # Run tests by default
16
+ CMD ["bundle", "exec", "rspec"]
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in cssminify.gemspec
4
4
  gemspec