temple 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/lib/temple.rb +0 -1
- data/lib/temple/erb/engine.rb +1 -1
- data/lib/temple/generator.rb +3 -2
- data/lib/temple/generators/erb.rb +0 -4
- data/lib/temple/version.rb +1 -1
- data/test/test_generator.rb +26 -4
- metadata +25 -6
- data/lib/temple/filters/static_freezer.rb +0 -11
- data/test/filters/test_static_freezer.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c1968702feac9a8f7896e4e008493532566765
|
4
|
+
data.tar.gz: 630b90231c21489a501190a82814803d48fe5e48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d9cce38ee024916f18e3ee79f1c4db8d99a52d03abbf51c01c60b91c13fb64259736484281470bf5244e12775083338797dc3c99f44908e05ce63ccc2a79356
|
7
|
+
data.tar.gz: e462b1b2b1acab154556ec0dc5edf3a57004fde0075ee1856e40a54e9e6446f7826a2bdf2c14dbb5d598ea66641e101c99035e5ce2be8185cdf50596d3a01ed7
|
data/CHANGES
CHANGED
data/lib/temple.rb
CHANGED
@@ -44,7 +44,6 @@ module Temple
|
|
44
44
|
autoload :ControlFlow, 'temple/filters/control_flow'
|
45
45
|
autoload :MultiFlattener, 'temple/filters/multi_flattener'
|
46
46
|
autoload :StaticMerger, 'temple/filters/static_merger'
|
47
|
-
autoload :StaticFreezer, 'temple/filters/static_freezer'
|
48
47
|
autoload :DynamicInliner, 'temple/filters/dynamic_inliner'
|
49
48
|
autoload :Escapable, 'temple/filters/escapable'
|
50
49
|
autoload :Eraser, 'temple/filters/eraser'
|
data/lib/temple/erb/engine.rb
CHANGED
data/lib/temple/generator.rb
CHANGED
@@ -11,7 +11,8 @@ module Temple
|
|
11
11
|
|
12
12
|
define_options :save_buffer,
|
13
13
|
capture_generator: 'StringBuffer',
|
14
|
-
buffer: '_buf'
|
14
|
+
buffer: '_buf',
|
15
|
+
freeze_static: RUBY_VERSION >= '2.1'
|
15
16
|
|
16
17
|
def call(exp)
|
17
18
|
[preamble, compile(exp), postamble].flatten.compact.join('; ')
|
@@ -57,7 +58,7 @@ module Temple
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def on_static(text)
|
60
|
-
concat(text.inspect)
|
61
|
+
concat(options[:freeze_static] ? "#{text.inspect}.freeze" : text.inspect)
|
61
62
|
end
|
62
63
|
|
63
64
|
def on_dynamic(code)
|
data/lib/temple/version.rb
CHANGED
data/test/test_generator.rb
CHANGED
@@ -77,7 +77,7 @@ end
|
|
77
77
|
|
78
78
|
describe Temple::Generators::Array do
|
79
79
|
it 'should compile simple expressions' do
|
80
|
-
gen = Temple::Generators::Array.new
|
80
|
+
gen = Temple::Generators::Array.new(freeze_static: false)
|
81
81
|
gen.call([:static, 'test']).should.equal '_buf = []; _buf << ("test"); _buf'
|
82
82
|
gen.call([:dynamic, 'test']).should.equal '_buf = []; _buf << (test); _buf'
|
83
83
|
gen.call([:code, 'test']).should.equal '_buf = []; test; _buf'
|
@@ -85,11 +85,16 @@ describe Temple::Generators::Array do
|
|
85
85
|
gen.call([:multi, [:static, 'a'], [:static, 'b']]).should.equal '_buf = []; _buf << ("a"); _buf << ("b"); _buf'
|
86
86
|
gen.call([:multi, [:static, 'a'], [:dynamic, 'b']]).should.equal '_buf = []; _buf << ("a"); _buf << (b); _buf'
|
87
87
|
end
|
88
|
+
|
89
|
+
it 'should freeze static' do
|
90
|
+
gen = Temple::Generators::Array.new(freeze_static: true)
|
91
|
+
gen.call([:static, 'test']).should.equal '_buf = []; _buf << ("test".freeze); _buf'
|
92
|
+
end
|
88
93
|
end
|
89
94
|
|
90
95
|
describe Temple::Generators::ArrayBuffer do
|
91
96
|
it 'should compile simple expressions' do
|
92
|
-
gen = Temple::Generators::ArrayBuffer.new
|
97
|
+
gen = Temple::Generators::ArrayBuffer.new(freeze_static: false)
|
93
98
|
gen.call([:static, 'test']).should.equal '_buf = "test"'
|
94
99
|
gen.call([:dynamic, 'test']).should.equal '_buf = (test).to_s'
|
95
100
|
gen.call([:code, 'test']).should.equal '_buf = []; test; _buf = _buf.join'
|
@@ -97,11 +102,17 @@ describe Temple::Generators::ArrayBuffer do
|
|
97
102
|
gen.call([:multi, [:static, 'a'], [:static, 'b']]).should.equal '_buf = []; _buf << ("a"); _buf << ("b"); _buf = _buf.join'
|
98
103
|
gen.call([:multi, [:static, 'a'], [:dynamic, 'b']]).should.equal '_buf = []; _buf << ("a"); _buf << (b); _buf = _buf.join'
|
99
104
|
end
|
105
|
+
|
106
|
+
it 'should freeze static' do
|
107
|
+
gen = Temple::Generators::ArrayBuffer.new(freeze_static: true)
|
108
|
+
gen.call([:static, 'test']).should.equal '_buf = "test"'
|
109
|
+
gen.call([:multi, [:dynamic, '1'], [:static, 'test']]).should.equal '_buf = []; _buf << (1); _buf << ("test".freeze); _buf = _buf.join'
|
110
|
+
end
|
100
111
|
end
|
101
112
|
|
102
113
|
describe Temple::Generators::StringBuffer do
|
103
114
|
it 'should compile simple expressions' do
|
104
|
-
gen = Temple::Generators::StringBuffer.new
|
115
|
+
gen = Temple::Generators::StringBuffer.new(freeze_static: false)
|
105
116
|
gen.call([:static, 'test']).should.equal '_buf = "test"'
|
106
117
|
gen.call([:dynamic, 'test']).should.equal '_buf = (test).to_s'
|
107
118
|
gen.call([:code, 'test']).should.equal '_buf = \'\'; test; _buf'
|
@@ -109,6 +120,12 @@ describe Temple::Generators::StringBuffer do
|
|
109
120
|
gen.call([:multi, [:static, 'a'], [:static, 'b']]).should.equal '_buf = \'\'; _buf << ("a"); _buf << ("b"); _buf'
|
110
121
|
gen.call([:multi, [:static, 'a'], [:dynamic, 'b']]).should.equal '_buf = \'\'; _buf << ("a"); _buf << ((b).to_s); _buf'
|
111
122
|
end
|
123
|
+
|
124
|
+
it 'should freeze static' do
|
125
|
+
gen = Temple::Generators::StringBuffer.new(freeze_static: true)
|
126
|
+
gen.call([:static, 'test']).should.equal '_buf = "test"'
|
127
|
+
gen.call([:multi, [:dynamic, '1'], [:static, 'test']]).should.equal '_buf = \'\'; _buf << ((1).to_s); _buf << ("test".freeze); _buf'
|
128
|
+
end
|
112
129
|
end
|
113
130
|
|
114
131
|
describe Temple::Generators::ERB do
|
@@ -125,7 +142,7 @@ end
|
|
125
142
|
|
126
143
|
describe Temple::Generators::RailsOutputBuffer do
|
127
144
|
it 'should compile simple expressions' do
|
128
|
-
gen = Temple::Generators::RailsOutputBuffer.new
|
145
|
+
gen = Temple::Generators::RailsOutputBuffer.new(freeze_static: false)
|
129
146
|
gen.call([:static, 'test']).should.equal '@output_buffer = ActiveSupport::SafeBuffer.new; ' +
|
130
147
|
'@output_buffer.safe_concat(("test")); @output_buffer'
|
131
148
|
gen.call([:dynamic, 'test']).should.equal '@output_buffer = ActiveSupport::SafeBuffer.new; ' +
|
@@ -133,4 +150,9 @@ describe Temple::Generators::RailsOutputBuffer do
|
|
133
150
|
gen.call([:code, 'test']).should.equal '@output_buffer = ActiveSupport::SafeBuffer.new; ' +
|
134
151
|
'test; @output_buffer'
|
135
152
|
end
|
153
|
+
|
154
|
+
it 'should freeze static' do
|
155
|
+
gen = Temple::Generators::RailsOutputBuffer.new(freeze_static: true)
|
156
|
+
gen.call([:static, 'test']).should.equal '@output_buffer = ActiveSupport::SafeBuffer.new; @output_buffer.safe_concat(("test".freeze)); @output_buffer'
|
157
|
+
end
|
136
158
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: temple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus Holm
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tilt
|
@@ -86,7 +86,6 @@ files:
|
|
86
86
|
- lib/temple/filters/escapable.rb
|
87
87
|
- lib/temple/filters/multi_flattener.rb
|
88
88
|
- lib/temple/filters/remove_bom.rb
|
89
|
-
- lib/temple/filters/static_freezer.rb
|
90
89
|
- lib/temple/filters/static_merger.rb
|
91
90
|
- lib/temple/filters/validator.rb
|
92
91
|
- lib/temple/generator.rb
|
@@ -123,7 +122,6 @@ files:
|
|
123
122
|
- test/filters/test_eraser.rb
|
124
123
|
- test/filters/test_escapable.rb
|
125
124
|
- test/filters/test_multi_flattener.rb
|
126
|
-
- test/filters/test_static_freezer.rb
|
127
125
|
- test/filters/test_static_merger.rb
|
128
126
|
- test/helper.rb
|
129
127
|
- test/html/test_attribute_merger.rb
|
@@ -164,5 +162,26 @@ rubygems_version: 2.2.2
|
|
164
162
|
signing_key:
|
165
163
|
specification_version: 4
|
166
164
|
summary: Template compilation framework in Ruby
|
167
|
-
test_files:
|
168
|
-
|
165
|
+
test_files:
|
166
|
+
- test/filters/test_code_merger.rb
|
167
|
+
- test/filters/test_control_flow.rb
|
168
|
+
- test/filters/test_dynamic_inliner.rb
|
169
|
+
- test/filters/test_eraser.rb
|
170
|
+
- test/filters/test_escapable.rb
|
171
|
+
- test/filters/test_multi_flattener.rb
|
172
|
+
- test/filters/test_static_merger.rb
|
173
|
+
- test/helper.rb
|
174
|
+
- test/html/test_attribute_merger.rb
|
175
|
+
- test/html/test_attribute_remover.rb
|
176
|
+
- test/html/test_attribute_sorter.rb
|
177
|
+
- test/html/test_fast.rb
|
178
|
+
- test/html/test_pretty.rb
|
179
|
+
- test/mixins/test_dispatcher.rb
|
180
|
+
- test/mixins/test_grammar_dsl.rb
|
181
|
+
- test/test_engine.rb
|
182
|
+
- test/test_erb.rb
|
183
|
+
- test/test_filter.rb
|
184
|
+
- test/test_generator.rb
|
185
|
+
- test/test_grammar.rb
|
186
|
+
- test/test_map.rb
|
187
|
+
- test/test_utils.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe Temple::Filters::StaticFreezer do
|
4
|
-
if RUBY_VERSION >= '2.1'
|
5
|
-
it 'should freeze static on new ruby' do
|
6
|
-
filter = Temple::Filters::StaticFreezer.new
|
7
|
-
filter.call([:static, 'hi']).should.equal [:dynamic, '"hi".freeze']
|
8
|
-
end
|
9
|
-
else
|
10
|
-
it 'should not freeze static on old ruby' do
|
11
|
-
filter = Temple::Filters::StaticFreezer.new
|
12
|
-
filter.call([:static, 'hi']).should.equal [:static, 'hi']
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should freeze static if free_static==true' do
|
17
|
-
filter = Temple::Filters::StaticFreezer.new(freeze_static: true)
|
18
|
-
filter.call([:static, 'hi']).should.equal [:dynamic, '"hi".freeze']
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should not freeze static if free_static==false' do
|
22
|
-
filter = Temple::Filters::StaticFreezer.new(freeze_static: false)
|
23
|
-
filter.call([:static, 'hi']).should.equal [:static, 'hi']
|
24
|
-
end
|
25
|
-
end
|