csscutter 0.3.2.alpha → 0.4.beta

Sign up to get free protection for your applications and to get access to all the features.
data/lib/csscutter.rb CHANGED
@@ -32,5 +32,6 @@ class CssCutter
32
32
  .minify_hex
33
33
  .minify_floats
34
34
  .replace_none_value_with_zero
35
+ .minify_font_weight
35
36
  end
36
37
  end
@@ -1,21 +1,12 @@
1
1
  class CssCutter::Cleaner < String
2
2
  def remove_whitespace
3
3
  strip
4
- .gsub(/\s+/, ' ')
5
- .gsub(/\s*\{\s*/, '{')
6
- .gsub(/\s*\}\s*/, '}')
7
- .gsub(/(\S+)\s*:\s*([^\{\};]+?)(?=[\};])/, '\1:\2')
8
- .gsub(/(\([^\)]*)(\S)\s*:\s*/, '\1\2:')
9
- .gsub(/\s*([,;=\+\>~])\s*/, '\1')
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  class CssCutter
2
- VERSION = '0.3.2.alpha'
2
+ VERSION = '0.4.beta'
3
3
  end
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.3.2.alpha
5
- prerelease: 6
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 00:00:00.000000000 Z
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: -2739630844775803242
40
+ hash: -876732536316891254
41
41
  required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements: