undies 3.0.0.rc.1 → 3.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -2
- data/bench/bench_runner.rb +2 -2
- data/lib/undies/api.rb +9 -7
- data/lib/undies/version.rb +1 -1
- data/test/element_node_test.rb +11 -8
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/bench/bench_runner.rb
CHANGED
data/lib/undies/api.rb
CHANGED
@@ -86,23 +86,25 @@ module Undies
|
|
86
86
|
alias_method :__element, :__open_element
|
87
87
|
alias_method :__tag, :__open_element
|
88
88
|
|
89
|
-
def __closed_element(name, *args
|
89
|
+
def __closed_element(name, *args)
|
90
90
|
@_undies_io.
|
91
91
|
current.
|
92
|
-
element_node(ElementNode.new(
|
92
|
+
element_node(ElementNode.new(
|
93
|
+
@_undies_io, Element::Closed.new(name, *args)
|
94
|
+
)).
|
93
95
|
element
|
94
96
|
end
|
95
97
|
alias_method :__closed_tag, :__closed_element
|
96
98
|
|
97
|
-
|
99
|
+
OPEN_TAGS.each do |tag|
|
98
100
|
define_method("_#{tag}") do |*args, &build|
|
99
|
-
|
101
|
+
__open_element(tag, *args, &build)
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
|
104
|
-
define_method("_#{tag}") do |*args
|
105
|
-
|
105
|
+
SELF_CLOSING_TAGS.each do |tag|
|
106
|
+
define_method("_#{tag}") do |*args|
|
107
|
+
__closed_element(tag, *args)
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
data/lib/undies/version.rb
CHANGED
data/test/element_node_test.rb
CHANGED
@@ -11,7 +11,7 @@ class Undies::ElementNode
|
|
11
11
|
before do
|
12
12
|
# io test with :pp 1 so we can test newline insertion
|
13
13
|
# io test with level 1 so we can test element start tag writing
|
14
|
-
@io = Undies::IO.new(@out = "", :pp => 1, :level =>
|
14
|
+
@io = Undies::IO.new(@out = "", :pp => 1, :level => 2)
|
15
15
|
@e = Undies::Element.open(:div, "hi")
|
16
16
|
@en = Undies::ElementNode.new(@io, @e)
|
17
17
|
end
|
@@ -146,20 +146,22 @@ class Undies::ElementNode
|
|
146
146
|
|
147
147
|
should "write out the start tag with IO#newline when an element is given" do
|
148
148
|
subject.element_node(@en1)
|
149
|
-
assert_equal "<div>#{@io.newline}", @out
|
149
|
+
assert_equal "#{@io.line_indent(-1)}<div>#{@io.newline}", @out
|
150
150
|
end
|
151
151
|
|
152
152
|
should "write out any cached content and cache new markup when given" do
|
153
153
|
subject.element_node @en1
|
154
154
|
subject.element_node @en2
|
155
|
-
assert_equal "<div>#{@io.newline}#{@io.line_indent}<strong>blah</strong>#{@io.newline}", @out
|
155
|
+
assert_equal "#{@io.line_indent(-1)}<div>#{@io.newline}#{@io.line_indent}<strong>blah</strong>#{@io.newline}", @out
|
156
156
|
assert_equal @en2, subject.cached
|
157
157
|
end
|
158
158
|
|
159
159
|
should "write out the end tag with IO#newline indented when popped" do
|
160
160
|
subject.element_node(@en1)
|
161
|
+
expected = "#{@io.line_indent(-1)}<div>#{@io.newline}#{@io.line_indent}<strong>blah</strong>#{@io.newline}#{@io.line_indent(-1)}</div>#{@io.newline}"
|
161
162
|
subject.pop
|
162
|
-
|
163
|
+
|
164
|
+
assert_equal expected, @out
|
163
165
|
end
|
164
166
|
|
165
167
|
end
|
@@ -174,13 +176,14 @@ class Undies::ElementNode
|
|
174
176
|
|
175
177
|
should "write out the start tag with IO#newline when a partial is given" do
|
176
178
|
subject.partial("partial markup")
|
177
|
-
assert_equal "<div>#{@io.newline}", @out
|
179
|
+
assert_equal "#{@io.line_indent(-1)}<div>#{@io.newline}", @out
|
178
180
|
end
|
179
181
|
|
180
182
|
should "write out the end tag with IO#newline indented when a partial is given" do
|
181
183
|
subject.partial(" partial markup\n")
|
184
|
+
expected = "#{@io.line_indent(-1)}<div>#{@io.newline}#{@io.line_indent}partial markup#{@io.newline}#{@io.line_indent(-1)}</div>#{@io.newline}"
|
182
185
|
subject.pop
|
183
|
-
assert_equal
|
186
|
+
assert_equal expected, @out
|
184
187
|
end
|
185
188
|
|
186
189
|
end
|
@@ -192,7 +195,7 @@ class Undies::ElementNode
|
|
192
195
|
subject.attrs(:test => 'value')
|
193
196
|
subject.element_node(@en1)
|
194
197
|
|
195
|
-
assert_equal "<div test=\"value\">#{@io.newline}", @out
|
198
|
+
assert_equal "#{@io.line_indent(-1)}<div test=\"value\">#{@io.newline}", @out
|
196
199
|
end
|
197
200
|
|
198
201
|
should "not effect the start tag once child elements have been written" do
|
@@ -200,7 +203,7 @@ class Undies::ElementNode
|
|
200
203
|
subject.element_node(@en1)
|
201
204
|
subject.attrs(:another => 'val')
|
202
205
|
|
203
|
-
assert_equal "<div test=\"value\">#{@io.newline}", @out
|
206
|
+
assert_equal "#{@io.line_indent(-1)}<div test=\"value\">#{@io.newline}", @out
|
204
207
|
end
|
205
208
|
|
206
209
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15424113
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- rc
|
11
|
-
-
|
12
|
-
version: 3.0.0.rc.
|
11
|
+
- 2
|
12
|
+
version: 3.0.0.rc.2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Kelly Redding
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-04-
|
20
|
+
date: 2012-04-18 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
type: :development
|