html_press 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/LICENSE.txt +22 -0
- data/html_press.gemspec +4 -7
- data/lib/html_press.rb +2 -1
- data/lib/html_press/html.rb +3 -3
- data/lib/html_press/version.rb +1 -1
- data/spec/html_press_spec.rb +1 -1
- metadata +10 -9
- data/lib/html_press/css_press.rb +0 -21
data/Gemfile
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 sterebooster
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/html_press.gemspec
CHANGED
@@ -10,20 +10,17 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/stereobooster/html_press"
|
11
11
|
s.summary = %q{Compress html}
|
12
12
|
s.description = %q{Ruby gem for compressing html}
|
13
|
-
|
14
|
-
s.rubyforge_project = "html_press"
|
13
|
+
s.license = "MIT"
|
15
14
|
|
16
15
|
s.files = `git ls-files`.split("\n")
|
17
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
18
|
s.require_paths = ["lib"]
|
20
19
|
|
21
|
-
# s.add_dependency "nokogiri"
|
22
|
-
|
23
20
|
s.add_development_dependency "rspec"
|
24
21
|
s.add_development_dependency "rake"
|
25
22
|
|
26
|
-
s.
|
27
|
-
s.
|
28
|
-
s.
|
23
|
+
s.add_dependency "multi_css", ">= 0.1.0"
|
24
|
+
s.add_dependency "uglifier"
|
25
|
+
s.add_dependency "htmlentities"
|
29
26
|
end
|
data/lib/html_press.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "html_press/version"
|
2
|
-
require "html_press/css_press"
|
3
2
|
require "html_press/uglifier"
|
4
3
|
require "html_press/html_entities"
|
5
4
|
require "html_press/html"
|
6
5
|
|
6
|
+
require 'multi_css'
|
7
|
+
|
7
8
|
module HtmlPress
|
8
9
|
def self.press(text, options = {})
|
9
10
|
HtmlPress::Html.new(options).press text
|
data/lib/html_press/html.rb
CHANGED
@@ -89,7 +89,7 @@ module HtmlPress
|
|
89
89
|
attrs(m, 'style', true)
|
90
90
|
end
|
91
91
|
begin
|
92
|
-
css_compressed =
|
92
|
+
css_compressed = MultiCss.min css
|
93
93
|
m.gsub!(css, css_compressed)
|
94
94
|
rescue Exception => e
|
95
95
|
log e.message
|
@@ -269,14 +269,14 @@ module HtmlPress
|
|
269
269
|
|
270
270
|
if name == "style"
|
271
271
|
begin
|
272
|
-
value_original =
|
272
|
+
value_original = MultiCss.min_attr value_original
|
273
273
|
# TODO what about escaped attribute values?
|
274
274
|
if delimiter == "\""
|
275
275
|
value_original.gsub!("\"", "'")
|
276
276
|
else
|
277
277
|
value_original.gsub!("'", "\"")
|
278
278
|
end
|
279
|
-
rescue
|
279
|
+
rescue MultiCss::ParseError => e
|
280
280
|
log e.message
|
281
281
|
end
|
282
282
|
end
|
data/lib/html_press/version.rb
CHANGED
data/spec/html_press_spec.rb
CHANGED
@@ -52,7 +52,7 @@ describe HtmlPress do
|
|
52
52
|
|
53
53
|
it "should compress css in style tags" do
|
54
54
|
style = " div { margin: 0px 0px; \n} "
|
55
|
-
pressed_style = "<style>" +
|
55
|
+
pressed_style = "<style>" + MultiCss.min(style) + "</style>"
|
56
56
|
style = " <style>" + style + "</style> "
|
57
57
|
HtmlPress.press(style).should eql pressed_style
|
58
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_press
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -44,13 +44,13 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: multi_css
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.1.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.1.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: uglifier
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,11 +101,11 @@ files:
|
|
101
101
|
- .gitignore
|
102
102
|
- .travis.yml
|
103
103
|
- Gemfile
|
104
|
+
- LICENSE.txt
|
104
105
|
- Rakefile
|
105
106
|
- Readme.md
|
106
107
|
- html_press.gemspec
|
107
108
|
- lib/html_press.rb
|
108
|
-
- lib/html_press/css_press.rb
|
109
109
|
- lib/html_press/html.rb
|
110
110
|
- lib/html_press/html_entities.rb
|
111
111
|
- lib/html_press/uglifier.rb
|
@@ -114,7 +114,8 @@ files:
|
|
114
114
|
- profile/profile.rb
|
115
115
|
- spec/html_press_spec.rb
|
116
116
|
homepage: https://github.com/stereobooster/html_press
|
117
|
-
licenses:
|
117
|
+
licenses:
|
118
|
+
- MIT
|
118
119
|
post_install_message:
|
119
120
|
rdoc_options: []
|
120
121
|
require_paths:
|
@@ -132,8 +133,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
133
|
- !ruby/object:Gem::Version
|
133
134
|
version: '0'
|
134
135
|
requirements: []
|
135
|
-
rubyforge_project:
|
136
|
-
rubygems_version: 1.8.
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 1.8.23
|
137
138
|
signing_key:
|
138
139
|
specification_version: 3
|
139
140
|
summary: Compress html
|
data/lib/html_press/css_press.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module HtmlPress
|
2
|
-
begin
|
3
|
-
require 'css_press'
|
4
|
-
def self.css_compressor (text)
|
5
|
-
text = "a{#{text}}"
|
6
|
-
text = CssPress.press text
|
7
|
-
text.gsub(/^a\{/, '').gsub(/\}$/, '')
|
8
|
-
end
|
9
|
-
def self.style_compressor (text)
|
10
|
-
CssPress.press text
|
11
|
-
end
|
12
|
-
rescue LoadError => e
|
13
|
-
def self.css_compressor (text)
|
14
|
-
text
|
15
|
-
end
|
16
|
-
def self.style_compressor (text)
|
17
|
-
text
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|