cssmin 1.0.0 → 1.0.1

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 (3) hide show
  1. data/HISTORY +3 -0
  2. data/lib/cssmin.rb +22 -19
  3. metadata +3 -3
data/HISTORY CHANGED
@@ -1,5 +1,8 @@
1
1
  CSSMin History
2
2
  ================================================================================
3
3
 
4
+ Version 1.0.1 (2008-07-25)
5
+ * Fixed a rare bug that could result in redundant semicolons.
6
+
4
7
  Version 1.0.0 (2008-03-22)
5
8
  * First release.
@@ -1,10 +1,10 @@
1
1
  #--
2
2
  # Copyright (c) 2008 Ryan Grove <ryan@wonko.com>
3
3
  # All rights reserved.
4
- #
4
+ #
5
5
  # Redistribution and use in source and binary forms, with or without
6
6
  # modification, are permitted provided that the following conditions are met:
7
- #
7
+ #
8
8
  # * Redistributions of source code must retain the above copyright notice,
9
9
  # this list of conditions and the following disclaimer.
10
10
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -13,7 +13,7 @@
13
13
  # * Neither the name of this project nor the names of its contributors may be
14
14
  # used to endorse or promote products derived from this software without
15
15
  # specific prior written permission.
16
- #
16
+ #
17
17
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
18
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
19
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -33,7 +33,7 @@
33
33
  # script.
34
34
  #
35
35
  # Author:: Ryan Grove (mailto:ryan@wonko.com)
36
- # Version:: 1.0.0 (2008-03-22)
36
+ # Version:: 1.0.1 (2008-07-25)
37
37
  # Copyright:: Copyright (c) 2008 Ryan Grove. All rights reserved.
38
38
  # License:: New BSD License (http://opensource.org/licenses/bsd-license.php)
39
39
  # Website:: http://github.com/rgrove/cssmin/
@@ -51,17 +51,17 @@ module CSSMin
51
51
  # returns a String containing minified CSS.
52
52
  def self.minify(input)
53
53
  css = input.is_a?(IO) ? input.read : input.to_s
54
-
54
+
55
55
  # Remove comments.
56
56
  css.gsub!(/\/\*[\s\S]*?\*\//, '')
57
-
57
+
58
58
  # Compress all runs of whitespace to a single space to make things easier
59
59
  # to work with.
60
60
  css.gsub!(/\s+/, ' ')
61
-
61
+
62
62
  # Replace box model hacks with placeholders.
63
63
  css.gsub!(/"\\"\}\\""/, '___BMH___')
64
-
64
+
65
65
  # Remove unnecessary spaces, but be careful not to turn "p :link {...}"
66
66
  # into "p:link{...}".
67
67
  css.gsub!(/(?:^|\})[^\{:]+\s+:+[^\{]*\{/) do |match|
@@ -70,38 +70,41 @@ module CSSMin
70
70
  css.gsub!(/\s+([!\{\};:>+\(\)\],])/, '\1')
71
71
  css.gsub!('___PSEUDOCLASSCOLON___', ':')
72
72
  css.gsub!(/([!\{\}:;>+\(\[,])\s+/, '\1')
73
-
73
+
74
74
  # Add missing semicolons.
75
75
  css.gsub!(/([^;\}])\}/, '\1;}')
76
-
76
+
77
77
  # Replace 0(%, em, ex, px, in, cm, mm, pt, pc) with just 0.
78
78
  css.gsub!(/([\s:])([+-]?0)(?:%|em|ex|px|in|cm|mm|pt|pc)/i, '\1\2')
79
-
79
+
80
80
  # Replace 0 0 0 0; with 0.
81
81
  css.gsub!(/:(?:0 )+0;/, ':0;')
82
-
82
+
83
83
  # Replace background-position:0; with background-position:0 0;
84
84
  css.gsub!('background-position:0;', 'background-position:0 0;')
85
-
85
+
86
86
  # Replace 0.6 with .6, but only when preceded by : or a space.
87
87
  css.gsub!(/(:|\s)0+\.(\d+)/, '\1.\2')
88
-
88
+
89
89
  # Convert rgb color values to hex values.
90
90
  css.gsub!(/rgb\s*\(\s*([0-9,\s]+)\s*\)/) do |match|
91
91
  '#' << $1.scan(/\d+/).map{|n| n.to_i.to_s(16).rjust(2, '0') }.join
92
92
  end
93
-
93
+
94
94
  # Compress color hex values, making sure not to touch values used in IE
95
95
  # filters, since they would break.
96
96
  css.gsub!(/([^"'=\s])\s*#([0-9a-f])\2([0-9a-f])\3([0-9a-f])\4/i, '\1#\2\3\4')
97
-
97
+
98
98
  # Remove empty rules.
99
99
  css.gsub!(/[^\}]+\{;\}\n/, '')
100
-
100
+
101
101
  # Re-insert box model hacks.
102
102
  css.gsub!('___BMH___', '"\"}\""')
103
-
103
+
104
+ # Prevent redundant semicolons.
105
+ css.gsub!(/;;+/, ';')
106
+
104
107
  css.strip
105
108
  end
106
-
109
+
107
110
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cssmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Grove
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-22 00:00:00 -07:00
12
+ date: 2008-07-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  requirements: []
48
48
 
49
49
  rubyforge_project: riposte
50
- rubygems_version: 1.0.1
50
+ rubygems_version: 1.2.0
51
51
  signing_key:
52
52
  specification_version: 2
53
53
  summary: Ruby library for minifying CSS.