html_press 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/html_press/html.rb +4 -3
- data/lib/html_press/uglifier.rb +6 -3
- data/lib/html_press/version.rb +1 -1
- data/spec/html_press_spec.rb +3 -0
- metadata +93 -88
data/lib/html_press/html.rb
CHANGED
@@ -5,7 +5,8 @@ module HtmlPress
|
|
5
5
|
:logger => false,
|
6
6
|
:unquoted_attributes => false,
|
7
7
|
:drop_empty_values => false,
|
8
|
-
:strip_crlf => false
|
8
|
+
:strip_crlf => false,
|
9
|
+
:js_minifier_options => false
|
9
10
|
}
|
10
11
|
|
11
12
|
def initialize (options = {})
|
@@ -71,7 +72,7 @@ module HtmlPress
|
|
71
72
|
attrs(m, 'script', true)
|
72
73
|
end
|
73
74
|
begin
|
74
|
-
js_compressed = HtmlPress.js_compressor js
|
75
|
+
js_compressed = HtmlPress.js_compressor js, @options[:js_minifier_options]
|
75
76
|
m.gsub!(js, js_compressed)
|
76
77
|
rescue Exception => e
|
77
78
|
log e.message
|
@@ -292,7 +293,7 @@ module HtmlPress
|
|
292
293
|
if events.include? name
|
293
294
|
value_original.gsub! /^javascript:\s+|;$/, ''
|
294
295
|
begin
|
295
|
-
value_original = HtmlPress.js_compressor value_original
|
296
|
+
value_original = HtmlPress.js_compressor value_original, @options[:js_minifier_options]
|
296
297
|
# TODO what about escaped attribute values?
|
297
298
|
if delimiter == "\""
|
298
299
|
value_original.gsub! "\"", "'"
|
data/lib/html_press/uglifier.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module HtmlPress
|
2
2
|
begin
|
3
3
|
require 'uglifier'
|
4
|
-
|
5
|
-
|
4
|
+
# Available options https://github.com/lautis/uglifier#options
|
5
|
+
def self.js_compressor (text, options = nil)
|
6
|
+
options ||= {}
|
7
|
+
options[:inline_script] = true
|
8
|
+
Uglifier.new(options).compile(text).gsub(/;$/,'')
|
6
9
|
end
|
7
10
|
rescue LoadError => e
|
8
|
-
def self.js_compressor (text)
|
11
|
+
def self.js_compressor (text, options = nil)
|
9
12
|
text
|
10
13
|
end
|
11
14
|
end
|
data/lib/html_press/version.rb
CHANGED
data/spec/html_press_spec.rb
CHANGED
@@ -44,6 +44,9 @@ describe HtmlPress do
|
|
44
44
|
pressed_script = "<script>" + HtmlPress.js_compressor(script) + "</script>"
|
45
45
|
script = " <script>" + script + "</script> "
|
46
46
|
HtmlPress.press(script).should eql pressed_script
|
47
|
+
|
48
|
+
script = %q{<script>window.jQuery||document.write('<script src="/components/jquery/jquery.js"><\/script>')</script>}
|
49
|
+
HtmlPress.press(script).should eql script
|
47
50
|
end
|
48
51
|
|
49
52
|
it "should compress css in style tags" do
|
metadata
CHANGED
@@ -1,103 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_press
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- stereobooster
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-10-06 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rspec
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rake
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
33
24
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
38
32
|
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rake
|
39
36
|
prerelease: false
|
40
|
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
47
49
|
name: css_press
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 0.3.2
|
54
|
-
type: :runtime
|
55
50
|
prerelease: false
|
56
|
-
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
52
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 23
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
- 3
|
60
|
+
- 2
|
61
61
|
version: 0.3.2
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: uglifier
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
62
|
type: :runtime
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: uglifier
|
71
66
|
prerelease: false
|
72
|
-
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
68
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
86
76
|
type: :runtime
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: htmlentities
|
87
80
|
prerelease: false
|
88
|
-
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
82
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :runtime
|
91
|
+
version_requirements: *id005
|
94
92
|
description: Ruby gem for compressing html
|
95
|
-
email:
|
93
|
+
email:
|
96
94
|
- stereobooster@gmail.com
|
97
95
|
executables: []
|
96
|
+
|
98
97
|
extensions: []
|
98
|
+
|
99
99
|
extra_rdoc_files: []
|
100
|
-
|
100
|
+
|
101
|
+
files:
|
101
102
|
- .gitignore
|
102
103
|
- .travis.yml
|
103
104
|
- Gemfile
|
@@ -115,32 +116,36 @@ files:
|
|
115
116
|
- spec/html_press_spec.rb
|
116
117
|
homepage: https://github.com/stereobooster/html_press
|
117
118
|
licenses: []
|
119
|
+
|
118
120
|
post_install_message:
|
119
121
|
rdoc_options: []
|
120
|
-
|
122
|
+
|
123
|
+
require_paths:
|
121
124
|
- lib
|
122
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
126
|
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
|
128
|
-
segments:
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 3
|
131
|
+
segments:
|
129
132
|
- 0
|
130
|
-
|
131
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
version: "0"
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
135
|
none: false
|
133
|
-
requirements:
|
134
|
-
- -
|
135
|
-
- !ruby/object:Gem::Version
|
136
|
-
|
137
|
-
segments:
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
140
|
+
segments:
|
138
141
|
- 0
|
139
|
-
|
142
|
+
version: "0"
|
140
143
|
requirements: []
|
144
|
+
|
141
145
|
rubyforge_project: html_press
|
142
|
-
rubygems_version: 1.8.
|
146
|
+
rubygems_version: 1.8.24
|
143
147
|
signing_key:
|
144
148
|
specification_version: 3
|
145
149
|
summary: Compress html
|
146
150
|
test_files: []
|
151
|
+
|