htmlmin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/lib/htmlmin.rb +5 -0
- data/lib/htmlmin/buffer.rb +3 -1
- data/lib/htmlmin/max_line_len.rb +30 -0
- data/lib/htmlmin/slot_machines/common.rb +4 -2
- data/lib/htmlmin/version.rb +1 -1
- data/test/input/line_length_1.txt +1 -0
- data/test/input/line_length_2.txt +1 -0
- data/test/input/line_length_3.txt +11 -0
- data/test/input/line_length_4.txt +2 -0
- data/test/options/comment_7.rb +2 -1
- data/test/options/comment_8.rb +2 -1
- data/test/options/line_length_1.rb +7 -0
- data/test/options/line_length_2.rb +7 -0
- data/test/options/line_length_3.rb +7 -0
- data/test/options/line_length_4.rb +7 -0
- data/test/output/line_length_1.txt +2 -0
- data/test/output/line_length_2.txt +2 -0
- data/test/output/line_length_3.txt +2 -0
- data/test/output/line_length_4.txt +3 -0
- metadata +27 -2
data/README.md
CHANGED
data/lib/htmlmin.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "htmlmin/version"
|
2
2
|
require "htmlmin/buffer"
|
3
|
+
require "htmlmin/max_line_len"
|
3
4
|
require "htmlmin/slot_machines"
|
4
5
|
|
5
6
|
module HTMLMin
|
@@ -12,6 +13,7 @@ module HTMLMin
|
|
12
13
|
END_OF_FILE = ''
|
13
14
|
|
14
15
|
extend HTMLMin::Buffer
|
16
|
+
extend HTMLMin::MaxLineLen
|
15
17
|
extend HTMLMin::SlotMachines::Common
|
16
18
|
extend HTMLMin::SlotMachines::Comment
|
17
19
|
extend HTMLMin::SlotMachines::Doctype
|
@@ -24,6 +26,8 @@ module HTMLMin
|
|
24
26
|
|
25
27
|
:minify_whitespaces => true,
|
26
28
|
|
29
|
+
:max_line_len => 32768, # 32k - safety feature
|
30
|
+
|
27
31
|
:debug => false
|
28
32
|
}
|
29
33
|
|
@@ -46,6 +50,7 @@ module HTMLMin
|
|
46
50
|
end
|
47
51
|
|
48
52
|
def init_slot_machine
|
53
|
+
init_max_line_len
|
49
54
|
clear_buffer
|
50
55
|
@state = :text_prespaced
|
51
56
|
@prev_state = nil
|
data/lib/htmlmin/buffer.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module HTMLMin
|
2
|
+
|
3
|
+
module MaxLineLen
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
SPACE = [" ", "\s", "\n", "\r", "\t"]
|
8
|
+
|
9
|
+
def check_max_line_len(char)
|
10
|
+
if char == "\n"
|
11
|
+
init_max_line_len
|
12
|
+
else
|
13
|
+
@newline_pos = @result.length if SPACE.include?(char)
|
14
|
+
@line_length += 1
|
15
|
+
end
|
16
|
+
|
17
|
+
if @line_length >= @settings[:max_line_len] && !@newline_pos.nil?
|
18
|
+
@result[@newline_pos - 1] = "\n"
|
19
|
+
init_max_line_len
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def init_max_line_len
|
24
|
+
@newline_pos = nil
|
25
|
+
@line_length = 0
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/lib/htmlmin/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
Hello there, i am just a long line text - nothing else. I should be splitted at the end of previous sentence.
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello there, i am just a long line text - nothing else. I should be splitted at the end of previous sentence.
|
data/test/options/comment_7.rb
CHANGED
data/test/options/comment_8.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: htmlmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2011-08-
|
12
|
+
date: 2011-08-24 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: HTMLMin is a HTML-code minification tool implemented in Ruby. It works
|
15
15
|
like a slot machine.
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- htmlmin.gemspec
|
27
27
|
- lib/htmlmin.rb
|
28
28
|
- lib/htmlmin/buffer.rb
|
29
|
+
- lib/htmlmin/max_line_len.rb
|
29
30
|
- lib/htmlmin/slot_machines.rb
|
30
31
|
- lib/htmlmin/slot_machines/comment.rb
|
31
32
|
- lib/htmlmin/slot_machines/common.rb
|
@@ -43,6 +44,10 @@ files:
|
|
43
44
|
- test/input/comment_8.txt
|
44
45
|
- test/input/doctype_1.txt
|
45
46
|
- test/input/doctype_2.txt
|
47
|
+
- test/input/line_length_1.txt
|
48
|
+
- test/input/line_length_2.txt
|
49
|
+
- test/input/line_length_3.txt
|
50
|
+
- test/input/line_length_4.txt
|
46
51
|
- test/input/tag_1.txt
|
47
52
|
- test/input/tag_2.txt
|
48
53
|
- test/input/text_1.txt
|
@@ -50,6 +55,10 @@ files:
|
|
50
55
|
- test/input/text_3.txt
|
51
56
|
- test/options/comment_7.rb
|
52
57
|
- test/options/comment_8.rb
|
58
|
+
- test/options/line_length_1.rb
|
59
|
+
- test/options/line_length_2.rb
|
60
|
+
- test/options/line_length_3.rb
|
61
|
+
- test/options/line_length_4.rb
|
53
62
|
- test/output/cc_1.txt
|
54
63
|
- test/output/comment_1.txt
|
55
64
|
- test/output/comment_2.txt
|
@@ -61,6 +70,10 @@ files:
|
|
61
70
|
- test/output/comment_8.txt
|
62
71
|
- test/output/doctype_1.txt
|
63
72
|
- test/output/doctype_2.txt
|
73
|
+
- test/output/line_length_1.txt
|
74
|
+
- test/output/line_length_2.txt
|
75
|
+
- test/output/line_length_3.txt
|
76
|
+
- test/output/line_length_4.txt
|
64
77
|
- test/output/tag_1.txt
|
65
78
|
- test/output/tag_2.txt
|
66
79
|
- test/output/text_1.txt
|
@@ -104,6 +117,10 @@ test_files:
|
|
104
117
|
- test/input/comment_8.txt
|
105
118
|
- test/input/doctype_1.txt
|
106
119
|
- test/input/doctype_2.txt
|
120
|
+
- test/input/line_length_1.txt
|
121
|
+
- test/input/line_length_2.txt
|
122
|
+
- test/input/line_length_3.txt
|
123
|
+
- test/input/line_length_4.txt
|
107
124
|
- test/input/tag_1.txt
|
108
125
|
- test/input/tag_2.txt
|
109
126
|
- test/input/text_1.txt
|
@@ -111,6 +128,10 @@ test_files:
|
|
111
128
|
- test/input/text_3.txt
|
112
129
|
- test/options/comment_7.rb
|
113
130
|
- test/options/comment_8.rb
|
131
|
+
- test/options/line_length_1.rb
|
132
|
+
- test/options/line_length_2.rb
|
133
|
+
- test/options/line_length_3.rb
|
134
|
+
- test/options/line_length_4.rb
|
114
135
|
- test/output/cc_1.txt
|
115
136
|
- test/output/comment_1.txt
|
116
137
|
- test/output/comment_2.txt
|
@@ -122,6 +143,10 @@ test_files:
|
|
122
143
|
- test/output/comment_8.txt
|
123
144
|
- test/output/doctype_1.txt
|
124
145
|
- test/output/doctype_2.txt
|
146
|
+
- test/output/line_length_1.txt
|
147
|
+
- test/output/line_length_2.txt
|
148
|
+
- test/output/line_length_3.txt
|
149
|
+
- test/output/line_length_4.txt
|
125
150
|
- test/output/tag_1.txt
|
126
151
|
- test/output/tag_2.txt
|
127
152
|
- test/output/text_1.txt
|