csscutter 0.3.2.alpha → 0.4.beta
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.
- data/lib/csscutter.rb +1 -0
- data/lib/csscutter/cleaner.rb +34 -15
- data/lib/csscutter/simplifier.rb +5 -0
- data/lib/csscutter/version.rb +1 -1
- metadata +6 -6
data/lib/csscutter.rb
CHANGED
data/lib/csscutter/cleaner.rb
CHANGED
@@ -1,21 +1,12 @@
|
|
1
1
|
class CssCutter::Cleaner < String
|
2
2
|
def remove_whitespace
|
3
3
|
strip
|
4
|
-
.
|
5
|
-
.
|
6
|
-
.
|
7
|
-
.
|
8
|
-
.
|
9
|
-
.
|
10
|
-
.gsub('( ', '(')
|
11
|
-
.gsub(' )', ')')
|
12
|
-
.gsub('[ ', '[')
|
13
|
-
.gsub(' ]', ']')
|
14
|
-
.gsub(' ~=', '~=')
|
15
|
-
.gsub(' $=', '$=')
|
16
|
-
.gsub(' *=', '*=')
|
17
|
-
.gsub(' |=', '|=')
|
18
|
-
.gsub(' ^=', '^=')
|
4
|
+
.remove_repeated
|
5
|
+
.remove_around_curly_brackets
|
6
|
+
.remove_between_property_and_value
|
7
|
+
.remove_in_selectors
|
8
|
+
.remove_around_other_brackets
|
9
|
+
.remove_in_attribute_selectors
|
19
10
|
end
|
20
11
|
|
21
12
|
def remove_trailing_semicolons
|
@@ -30,4 +21,32 @@ class CssCutter::Cleaner < String
|
|
30
21
|
def remove_comments
|
31
22
|
gsub /\/\*.*?\*\//, ''
|
32
23
|
end
|
24
|
+
|
25
|
+
def remove_repeated
|
26
|
+
gsub(/\s+/, ' ')
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_around_curly_brackets
|
30
|
+
gsub(/\s*\{\s*/, '{')
|
31
|
+
.gsub(/\s*\}\s*/, '}')
|
32
|
+
end
|
33
|
+
|
34
|
+
def remove_between_property_and_value
|
35
|
+
gsub(/(?:^|\})[^\{:]+\s+:+[^\{]*\{/) { |m| m.gsub ':', '_COLON_' }
|
36
|
+
.gsub(/\s?:\s?/, ':')
|
37
|
+
.gsub('_COLON_', ':')
|
38
|
+
end
|
39
|
+
|
40
|
+
def remove_around_other_brackets
|
41
|
+
gsub(/([\(\[]) /, '\1')
|
42
|
+
.gsub(/ ([\)\]])/, '\1')
|
43
|
+
end
|
44
|
+
|
45
|
+
def remove_in_selectors
|
46
|
+
gsub(/\s?([,;=\+\>~])\s?/, '\1')
|
47
|
+
end
|
48
|
+
|
49
|
+
def remove_in_attribute_selectors
|
50
|
+
gsub(/ ([\~\$\*\|\^])=/, '\1=')
|
51
|
+
end
|
33
52
|
end
|
data/lib/csscutter/simplifier.rb
CHANGED
@@ -31,6 +31,11 @@ class CssCutter::Simplifier < String
|
|
31
31
|
gsub /((\{|;)\s*\w+\s*):(\s*)none(\s*(;|\}))/, '\1:\30\4'
|
32
32
|
end
|
33
33
|
|
34
|
+
def minify_font_weight
|
35
|
+
gsub(/(font|font-weight)(\s*):([^;\}]*\W)?normal([\s;\}])/, '\1\2:\3400\4')
|
36
|
+
.gsub(/(font|font-weight)(\s*):([^;\}]*\W)?bold([\s;\}])/, '\1\2:\3700\4')
|
37
|
+
end
|
38
|
+
|
34
39
|
private
|
35
40
|
def dec_to_hex(number)
|
36
41
|
"%02x" % number.to_i
|
data/lib/csscutter/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csscutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.beta
|
5
|
+
prerelease: 4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- m16a1
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: CSS minifier inspired by cssmin
|
15
15
|
email: a741su@gmail.com
|
@@ -17,10 +17,10 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- lib/csscutter/cleaner.rb
|
21
20
|
- lib/csscutter/simplifier.rb
|
22
|
-
- lib/csscutter/version.rb
|
23
21
|
- lib/csscutter/whitespace_keeper.rb
|
22
|
+
- lib/csscutter/cleaner.rb
|
23
|
+
- lib/csscutter/version.rb
|
24
24
|
- lib/csscutter.rb
|
25
25
|
- License
|
26
26
|
homepage: https://github.com/m16a1/csscutter
|
@@ -37,7 +37,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
segments:
|
39
39
|
- 0
|
40
|
-
hash: -
|
40
|
+
hash: -876732536316891254
|
41
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|