undies 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +4 -1
- data/README.rdoc +22 -1
- data/bench/bench_runner.rb +42 -61
- data/lib/undies/element.rb +51 -32
- data/lib/undies/node.rb +62 -11
- data/lib/undies/node_stack.rb +111 -0
- data/lib/undies/output.rb +9 -32
- data/lib/undies/template.rb +83 -25
- data/lib/undies/version.rb +1 -1
- data/test/element_test.rb +69 -48
- data/test/fixtures/write_thing.rb +21 -0
- data/test/node_stack_test.rb +109 -0
- data/test/node_test.rb +66 -16
- data/test/output_test.rb +13 -73
- data/test/template_builder_render_test.rb +32 -0
- data/test/template_source_render_test.rb +115 -0
- data/test/template_test.rb +149 -167
- data/undies.gemspec +1 -0
- metadata +32 -11
- data/lib/undies/node_buffer.rb +0 -35
- data/test/node_buffer_test.rb +0 -54
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 2.2.
|
9
|
+
- 1
|
10
|
+
version: 2.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -15,11 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-03-15 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|
22
|
-
prerelease: false
|
23
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
23
|
none: false
|
25
24
|
requirements:
|
@@ -30,11 +29,11 @@ dependencies:
|
|
30
29
|
- 1
|
31
30
|
- 0
|
32
31
|
version: "1.0"
|
33
|
-
version_requirements: *id001
|
34
32
|
name: bundler
|
33
|
+
version_requirements: *id001
|
34
|
+
prerelease: false
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
type: :development
|
37
|
-
prerelease: false
|
38
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
40
39
|
requirements:
|
@@ -46,8 +45,24 @@ dependencies:
|
|
46
45
|
- 7
|
47
46
|
- 3
|
48
47
|
version: 0.7.3
|
49
|
-
version_requirements: *id002
|
50
48
|
name: assert
|
49
|
+
version_requirements: *id002
|
50
|
+
prerelease: false
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
type: :development
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 11
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
- 0
|
62
|
+
version: "0.0"
|
63
|
+
name: whysoslow
|
64
|
+
version_requirements: *id003
|
65
|
+
prerelease: false
|
51
66
|
description: A pure-Ruby DSL for streaming templated HTML, XML, or plain text. Named for its gratuitous use of the underscore.
|
52
67
|
email:
|
53
68
|
- kelly@kelredd.com
|
@@ -78,21 +93,24 @@ files:
|
|
78
93
|
- lib/undies/element.rb
|
79
94
|
- lib/undies/named_source.rb
|
80
95
|
- lib/undies/node.rb
|
81
|
-
- lib/undies/
|
96
|
+
- lib/undies/node_stack.rb
|
82
97
|
- lib/undies/output.rb
|
83
98
|
- lib/undies/source.rb
|
84
99
|
- lib/undies/source_stack.rb
|
85
100
|
- lib/undies/template.rb
|
86
101
|
- lib/undies/version.rb
|
87
102
|
- test/element_test.rb
|
103
|
+
- test/fixtures/write_thing.rb
|
88
104
|
- test/helper.rb
|
89
105
|
- test/irb.rb
|
90
106
|
- test/named_source_test.rb
|
91
|
-
- test/
|
107
|
+
- test/node_stack_test.rb
|
92
108
|
- test/node_test.rb
|
93
109
|
- test/output_test.rb
|
94
110
|
- test/source_stack_test.rb
|
95
111
|
- test/source_test.rb
|
112
|
+
- test/template_builder_render_test.rb
|
113
|
+
- test/template_source_render_test.rb
|
96
114
|
- test/template_test.rb
|
97
115
|
- test/templates/content.html.rb
|
98
116
|
- test/templates/index.html.rb
|
@@ -134,14 +152,17 @@ specification_version: 3
|
|
134
152
|
summary: A pure-Ruby DSL for streaming templated HTML, XML, or plain text. Named for its gratuitous use of the underscore.
|
135
153
|
test_files:
|
136
154
|
- test/element_test.rb
|
155
|
+
- test/fixtures/write_thing.rb
|
137
156
|
- test/helper.rb
|
138
157
|
- test/irb.rb
|
139
158
|
- test/named_source_test.rb
|
140
|
-
- test/
|
159
|
+
- test/node_stack_test.rb
|
141
160
|
- test/node_test.rb
|
142
161
|
- test/output_test.rb
|
143
162
|
- test/source_stack_test.rb
|
144
163
|
- test/source_test.rb
|
164
|
+
- test/template_builder_render_test.rb
|
165
|
+
- test/template_source_render_test.rb
|
145
166
|
- test/template_test.rb
|
146
167
|
- test/templates/content.html.rb
|
147
168
|
- test/templates/index.html.rb
|
data/lib/undies/node_buffer.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Undies
|
2
|
-
|
3
|
-
class NodeBuffer < ::Array
|
4
|
-
|
5
|
-
# a node buffer is a FIFO used to, well, buffer node data for output.
|
6
|
-
# nodes are pushed on the stack for processing and flushed to output
|
7
|
-
# when pulled. empty the buffer by flushing it to output.
|
8
|
-
|
9
|
-
# the buffer allows for dynamic node handling while limiting memory
|
10
|
-
# bloat. the Output handler ensures that only 1 node is buffered
|
11
|
-
# in memory at any given time by pulling the previous node to output
|
12
|
-
# before pushing the next node for processing.
|
13
|
-
|
14
|
-
def initialize(*args)
|
15
|
-
# always initialize empty
|
16
|
-
super()
|
17
|
-
end
|
18
|
-
|
19
|
-
def push(node)
|
20
|
-
super
|
21
|
-
node
|
22
|
-
end
|
23
|
-
|
24
|
-
def pull(output)
|
25
|
-
if (node = self.shift)
|
26
|
-
node.class.flush(output, node)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def flush(output)
|
31
|
-
self.pull(output) while self.size > 0
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
data/test/node_buffer_test.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require "assert"
|
2
|
-
|
3
|
-
require "stringio"
|
4
|
-
require "undies/node"
|
5
|
-
require "undies/element"
|
6
|
-
require "undies/node_buffer"
|
7
|
-
|
8
|
-
class Undies::NodeStack
|
9
|
-
|
10
|
-
class BasicTests < Assert::Context
|
11
|
-
desc 'a node buffer'
|
12
|
-
before do
|
13
|
-
@nb = Undies::NodeBuffer.new
|
14
|
-
end
|
15
|
-
subject { @nb }
|
16
|
-
|
17
|
-
should have_instance_method :push, :pull, :flush
|
18
|
-
|
19
|
-
should "be an Array" do
|
20
|
-
assert_kind_of Array, subject
|
21
|
-
end
|
22
|
-
|
23
|
-
should "empty by default" do
|
24
|
-
assert subject.empty?
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
class PushPullFlushTests < BasicTests
|
30
|
-
before do
|
31
|
-
@stream_test_output = Undies::Output.new(@outstream = StringIO.new(@out = ""))
|
32
|
-
end
|
33
|
-
|
34
|
-
should "flush nodes" do
|
35
|
-
node = Undies::Node.new("lala")
|
36
|
-
subject.push(node); subject.pull(@stream_test_output)
|
37
|
-
assert_equal "lala", @out
|
38
|
-
end
|
39
|
-
|
40
|
-
should "flush elements with no content" do
|
41
|
-
elem = Undies::Element.new("span")
|
42
|
-
subject.push(elem); subject.pull(@stream_test_output)
|
43
|
-
assert_equal "<span />", @out
|
44
|
-
end
|
45
|
-
|
46
|
-
should "flush elements with content" do
|
47
|
-
elem = Undies::Element.new("div") {}
|
48
|
-
subject.push(elem); subject.pull(@stream_test_output)
|
49
|
-
assert_equal "<div></div>", @out
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|