vagrant-unbundled 2.2.6.1 → 2.2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -9
- data/vagrant.gemspec +1 -1
- data/vendor/bundle/ruby/2.6.0/bundler/gems/vagrant-spec-abfc34474d12/vagrant-spec.gemspec +1 -1
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/CHANGELOG +79 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/MIT-LICENSE +21 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/README.rdoc +109 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/Rakefile +78 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/lib/erubi/capture_end.rb +52 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/lib/erubi.rb +211 -0
- data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/test/test.rb +780 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/README.md +354 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/Rakefile +18 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/TODO +15 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/central_directory.rb +208 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/compressor.rb +9 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/constants.rb +63 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/encryption.rb +11 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/null_encryption.rb +43 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/traditional_encryption.rb +99 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/decompressor.rb +13 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/deflater.rb +34 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/dos_time.rb +48 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/entry.rb +700 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/entry_set.rb +86 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/errors.rb +18 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/generic.rb +43 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/ntfs.rb +90 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb +44 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/universal_time.rb +47 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/unix.rb +37 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/zip64.rb +68 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/zip64_placeholder.rb +15 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field.rb +101 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/file.rb +443 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/filesystem.rb +627 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/inflater.rb +66 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/input_stream.rb +173 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras/abstract_input_stream.rb +111 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras/abstract_output_stream.rb +43 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras.rb +36 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_compressor.rb +15 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_decompressor.rb +27 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_input_stream.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/output_stream.rb +189 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_compressor.rb +23 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb +40 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/streamable_directory.rb +15 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/streamable_stream.rb +56 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/version.rb +3 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip.rb +71 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example.rb +81 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb +31 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_recursive.rb +54 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/gtk_ruby_zip.rb +84 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/qtzip.rb +92 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/write_simple.rb +12 -0
- data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/zipfind.rb +66 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/LICENSE +202 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/README.md +276 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/bin/rwinrm +90 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/connection.rb +84 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/connection_opts.rb +90 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/exceptions.rb +88 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/response_handler.rb +127 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/transport.rb +462 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/transport_factory.rb +64 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/output.rb +58 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/create_pipeline.xml.erb +167 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/fragment.rb +68 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message.rb +128 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/base.rb +47 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/error_record.rb +66 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_host_call.rb +30 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_output.rb +48 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_state.rb +38 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/runspacepool_host_call.rb +30 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/runspacepool_state.rb +37 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/session_capability.rb +34 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data.rb +40 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_defragmenter.rb +62 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_factory.rb +86 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_fragmenter.rb +58 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/powershell_output_decoder.rb +142 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/receive_response_reader.rb +95 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/session_capability.xml.erb +7 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/uuid.rb +39 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/base.rb +187 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/cmd.rb +63 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/power_shell.rb +206 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/retryable.rb +44 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/shell_factory.rb +56 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/version.rb +5 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/base.rb +57 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/cleanup_command.rb +60 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/close_shell.rb +49 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command.rb +100 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command_output.rb +75 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command_output_decoder.rb +54 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/configuration.rb +44 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/create_pipeline.rb +64 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/create_shell.rb +115 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/header.rb +213 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/init_runspace_pool.rb +96 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/iso8601_duration.rb +58 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/keep_alive.rb +66 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/receive_response_reader.rb +128 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/send_data.rb +66 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/soap.rb +49 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/wql_pull.rb +54 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/wql_query.rb +98 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/write_stdin.rb +86 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm.rb +37 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/LICENSE +202 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/README.md +99 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm/shells/elevated.rb +108 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm-elevated/scripts/elevated_shell.ps1 +116 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm-elevated.rb +17 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/LICENSE +202 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/README.md +82 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/bin/rwinrmcp +87 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/core/file_transporter.rb +569 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/core/tmp_zip.rb +178 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/exceptions.rb +29 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/file_manager.rb +158 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/check_files.ps1.erb +49 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/checksum.ps1.erb +13 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/create_dir.ps1.erb +6 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/delete.ps1.erb +6 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/download.ps1.erb +17 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/exists.ps1.erb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/extract_files.ps1.erb +52 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/scripts.rb +47 -0
- data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs.rb +29 -0
- data/vendor/bundle/ruby/2.6.0/specifications/erubi-1.9.0.gemspec +38 -0
- data/vendor/bundle/ruby/2.6.0/specifications/rubyzip-2.0.0.gemspec +45 -0
- data/vendor/bundle/ruby/2.6.0/specifications/winrm-2.3.3.gemspec +73 -0
- data/vendor/bundle/ruby/2.6.0/specifications/winrm-elevated-1.1.2.gemspec +50 -0
- data/vendor/bundle/ruby/2.6.0/specifications/winrm-fs-1.3.4.gemspec +58 -0
- data/version.txt +1 -1
- metadata +142 -6
@@ -0,0 +1,780 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
unless defined?(TESTDIR)
|
4
|
+
TESTDIR = File.dirname(__FILE__)
|
5
|
+
LIBDIR = TESTDIR == '.' ? '../lib' : File.dirname(TESTDIR) + '/lib'
|
6
|
+
$: << TESTDIR
|
7
|
+
$: << LIBDIR
|
8
|
+
end
|
9
|
+
|
10
|
+
if ENV['COVERAGE']
|
11
|
+
require 'coverage'
|
12
|
+
require 'simplecov'
|
13
|
+
|
14
|
+
ENV.delete('COVERAGE')
|
15
|
+
SimpleCov.instance_eval do
|
16
|
+
start do
|
17
|
+
add_filter "/test/"
|
18
|
+
add_group('Missing'){|src| src.covered_percent < 100}
|
19
|
+
add_group('Covered'){|src| src.covered_percent == 100}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'erubi'
|
25
|
+
require 'erubi/capture_end'
|
26
|
+
|
27
|
+
ENV['MT_NO_PLUGINS'] = '1' # Work around stupid autoloading of plugins
|
28
|
+
gem 'minitest'
|
29
|
+
require 'minitest/global_expectations/autorun'
|
30
|
+
|
31
|
+
describe Erubi::Engine do
|
32
|
+
before do
|
33
|
+
@options = {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_output(input, src, result, &block)
|
37
|
+
t = (@options[:engine] || Erubi::Engine).new(input, @options)
|
38
|
+
tsrc = t.src
|
39
|
+
eval(tsrc, block.binding).must_equal result
|
40
|
+
tsrc = tsrc.gsub("'.freeze;", "';") if RUBY_VERSION >= '2.1'
|
41
|
+
tsrc.must_equal src
|
42
|
+
end
|
43
|
+
|
44
|
+
def setup_foo
|
45
|
+
@foo = Object.new
|
46
|
+
@foo.instance_variable_set(:@t, self)
|
47
|
+
def self.a; @a; end
|
48
|
+
def @foo.bar
|
49
|
+
@t.a << "a"
|
50
|
+
yield
|
51
|
+
@t.a << 'b'
|
52
|
+
@t.a.buffer.upcase!
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup_bar
|
57
|
+
def self.bar
|
58
|
+
@a << "a"
|
59
|
+
yield
|
60
|
+
@a << 'b'
|
61
|
+
@a.upcase
|
62
|
+
end
|
63
|
+
def self.baz
|
64
|
+
@a << "c"
|
65
|
+
yield
|
66
|
+
@a << 'd'
|
67
|
+
@a * 2
|
68
|
+
end
|
69
|
+
def self.quux
|
70
|
+
@a << "a"
|
71
|
+
3.times do |i|
|
72
|
+
@a << "c#{i}"
|
73
|
+
yield i
|
74
|
+
@a << "d#{i}"
|
75
|
+
end
|
76
|
+
@a << "b"
|
77
|
+
@a.upcase
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should handle no options" do
|
82
|
+
list = ['&\'<>"2']
|
83
|
+
check_output(<<END1, <<END2, <<END3){}
|
84
|
+
<table>
|
85
|
+
<tbody>
|
86
|
+
<% i = 0
|
87
|
+
list.each_with_index do |item, i| %>
|
88
|
+
<tr>
|
89
|
+
<td><%= i+1 %></td>
|
90
|
+
<td><%== item %></td>
|
91
|
+
</tr>
|
92
|
+
<% end %>
|
93
|
+
</tbody>
|
94
|
+
</table>
|
95
|
+
<%== i+1 %>
|
96
|
+
END1
|
97
|
+
_buf = ::String.new; _buf << '<table>
|
98
|
+
<tbody>
|
99
|
+
'; i = 0
|
100
|
+
list.each_with_index do |item, i|
|
101
|
+
_buf << ' <tr>
|
102
|
+
<td>'; _buf << ( i+1 ).to_s; _buf << '</td>
|
103
|
+
<td>'; _buf << ::Erubi.h(( item )); _buf << '</td>
|
104
|
+
</tr>
|
105
|
+
'; end
|
106
|
+
_buf << ' </tbody>
|
107
|
+
</table>
|
108
|
+
'; _buf << ::Erubi.h(( i+1 )); _buf << '
|
109
|
+
';
|
110
|
+
_buf.to_s
|
111
|
+
END2
|
112
|
+
<table>
|
113
|
+
<tbody>
|
114
|
+
<tr>
|
115
|
+
<td>1</td>
|
116
|
+
<td>&'<>"2</td>
|
117
|
+
</tr>
|
118
|
+
</tbody>
|
119
|
+
</table>
|
120
|
+
1
|
121
|
+
END3
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should strip only whitespace for <%, <%- and <%# tags" do
|
125
|
+
check_output(<<END1, <<END2, <<END3){}
|
126
|
+
<% 1 %>
|
127
|
+
a
|
128
|
+
<%- 2 %>
|
129
|
+
b
|
130
|
+
<%# 3 %>
|
131
|
+
c
|
132
|
+
/<% 1 %>
|
133
|
+
a
|
134
|
+
/ <%- 2 %>
|
135
|
+
b
|
136
|
+
//<%# 3 %>
|
137
|
+
c
|
138
|
+
<% 1 %> /
|
139
|
+
a
|
140
|
+
<%- 2 %>/
|
141
|
+
b
|
142
|
+
<%# 3 %>//
|
143
|
+
c
|
144
|
+
END1
|
145
|
+
_buf = ::String.new; 1
|
146
|
+
_buf << 'a
|
147
|
+
'; 2
|
148
|
+
_buf << 'b
|
149
|
+
';
|
150
|
+
_buf << 'c
|
151
|
+
/'; 1 ; _buf << '
|
152
|
+
'; _buf << 'a
|
153
|
+
/ '; 2 ; _buf << '
|
154
|
+
'; _buf << 'b
|
155
|
+
//';
|
156
|
+
_buf << '
|
157
|
+
'; _buf << 'c
|
158
|
+
'; _buf << ' '; 1 ; _buf << ' /
|
159
|
+
a
|
160
|
+
'; _buf << ' '; 2 ; _buf << '/
|
161
|
+
b
|
162
|
+
'; _buf << ' ';; _buf << '//
|
163
|
+
c
|
164
|
+
';
|
165
|
+
_buf.to_s
|
166
|
+
END2
|
167
|
+
a
|
168
|
+
b
|
169
|
+
c
|
170
|
+
/
|
171
|
+
a
|
172
|
+
/
|
173
|
+
b
|
174
|
+
//
|
175
|
+
c
|
176
|
+
/
|
177
|
+
a
|
178
|
+
/
|
179
|
+
b
|
180
|
+
//
|
181
|
+
c
|
182
|
+
END3
|
183
|
+
end
|
184
|
+
|
185
|
+
it "should handle ensure option" do
|
186
|
+
list = ['&\'<>"2']
|
187
|
+
@options[:ensure] = true
|
188
|
+
@options[:bufvar] = '@a'
|
189
|
+
@a = 'bar'
|
190
|
+
check_output(<<END1, <<END2, <<END3){}
|
191
|
+
<table>
|
192
|
+
<tbody>
|
193
|
+
<% i = 0
|
194
|
+
list.each_with_index do |item, i| %>
|
195
|
+
<tr>
|
196
|
+
<td><%= i+1 %></td>
|
197
|
+
<td><%== item %></td>
|
198
|
+
</tr>
|
199
|
+
<% end %>
|
200
|
+
</tbody>
|
201
|
+
</table>
|
202
|
+
<%== i+1 %>
|
203
|
+
END1
|
204
|
+
begin; __original_outvar = @a if defined?(@a); @a = ::String.new; @a << '<table>
|
205
|
+
<tbody>
|
206
|
+
'; i = 0
|
207
|
+
list.each_with_index do |item, i|
|
208
|
+
@a << ' <tr>
|
209
|
+
<td>'; @a << ( i+1 ).to_s; @a << '</td>
|
210
|
+
<td>'; @a << ::Erubi.h(( item )); @a << '</td>
|
211
|
+
</tr>
|
212
|
+
'; end
|
213
|
+
@a << ' </tbody>
|
214
|
+
</table>
|
215
|
+
'; @a << ::Erubi.h(( i+1 )); @a << '
|
216
|
+
';
|
217
|
+
@a.to_s
|
218
|
+
; ensure
|
219
|
+
@a = __original_outvar
|
220
|
+
end
|
221
|
+
END2
|
222
|
+
<table>
|
223
|
+
<tbody>
|
224
|
+
<tr>
|
225
|
+
<td>1</td>
|
226
|
+
<td>&'<>"2</td>
|
227
|
+
</tr>
|
228
|
+
</tbody>
|
229
|
+
</table>
|
230
|
+
1
|
231
|
+
END3
|
232
|
+
@a.must_equal 'bar'
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should have <%|= with CaptureEndEngine not escape by default" do
|
236
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>').src).must_equal '&'
|
237
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape=>false).src).must_equal '&'
|
238
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape_capture=>false).src).must_equal '&'
|
239
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape=>true).src).must_equal '&'
|
240
|
+
eval(::Erubi::CaptureEndEngine.new('<%|= "&" %><%| %>', :escape_capture=>true).src).must_equal '&'
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should have <%|== with CaptureEndEngine escape by default" do
|
244
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>').src).must_equal '&'
|
245
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape=>true).src).must_equal '&'
|
246
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape_capture=>true).src).must_equal '&'
|
247
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape=>false).src).must_equal '&'
|
248
|
+
eval(::Erubi::CaptureEndEngine.new('<%|== "&" %><%| %>', :escape_capture=>false).src).must_equal '&'
|
249
|
+
end
|
250
|
+
|
251
|
+
[['', false], ['=', true]].each do |ind, escape|
|
252
|
+
it "should allow <%|=#{ind} and <%| for capturing with CaptureEndEngine with :escape_capture => #{escape} and :escape => #{!escape}" do
|
253
|
+
@options[:bufvar] = '@a'
|
254
|
+
@options[:capture] = true
|
255
|
+
@options[:escape_capture] = escape
|
256
|
+
@options[:escape] = !escape
|
257
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
258
|
+
setup_bar
|
259
|
+
check_output(<<END1, <<END2, <<END3){}
|
260
|
+
<table>
|
261
|
+
<tbody>
|
262
|
+
<%|=#{ind} bar do %>
|
263
|
+
<b><%=#{ind} '&' %></b>
|
264
|
+
<%| end %>
|
265
|
+
</tbody>
|
266
|
+
</table>
|
267
|
+
END1
|
268
|
+
#{'__erubi = ::Erubi;' unless escape}@a = ::String.new; @a << '<table>
|
269
|
+
<tbody>
|
270
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do @a << '
|
271
|
+
'; @a << ' <b>'; @a << #{!escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
272
|
+
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
273
|
+
'; @a << ' </tbody>
|
274
|
+
</table>
|
275
|
+
';
|
276
|
+
@a.to_s
|
277
|
+
END2
|
278
|
+
<table>
|
279
|
+
<tbody>
|
280
|
+
A
|
281
|
+
<B>&</B>
|
282
|
+
B
|
283
|
+
</tbody>
|
284
|
+
</table>
|
285
|
+
END3
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
[['', true], ['=', false]].each do |ind, escape|
|
290
|
+
it "should allow <%|=#{ind} and <%| for capturing with CaptureEndEngine when with :escape => #{escape}" do
|
291
|
+
@options[:bufvar] = '@a'
|
292
|
+
@options[:escape] = escape
|
293
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
294
|
+
setup_bar
|
295
|
+
check_output(<<END1, <<END2, <<END3){}
|
296
|
+
<table>
|
297
|
+
<tbody>
|
298
|
+
<%|=#{ind} bar do %>
|
299
|
+
<b><%=#{ind} '&' %></b>
|
300
|
+
<%| end %>
|
301
|
+
</tbody>
|
302
|
+
</table>
|
303
|
+
END1
|
304
|
+
#{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
|
305
|
+
<tbody>
|
306
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
|
307
|
+
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
308
|
+
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
309
|
+
'; @a << ' </tbody>
|
310
|
+
</table>
|
311
|
+
';
|
312
|
+
@a.to_s
|
313
|
+
END2
|
314
|
+
<table>
|
315
|
+
<tbody>
|
316
|
+
A
|
317
|
+
<B>&AMP;</B>
|
318
|
+
B
|
319
|
+
</tbody>
|
320
|
+
</table>
|
321
|
+
END3
|
322
|
+
end
|
323
|
+
|
324
|
+
it "should handle loops in <%|=#{ind} and <%| for capturing with CaptureEndEngine when with :escape => #{escape}" do
|
325
|
+
@options[:bufvar] = '@a'
|
326
|
+
@options[:escape] = escape
|
327
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
328
|
+
setup_bar
|
329
|
+
check_output(<<END1, <<END2, <<END3){}
|
330
|
+
<table>
|
331
|
+
<tbody>
|
332
|
+
<%|=#{ind} quux do |i| %>
|
333
|
+
<b><%=#{ind} "\#{i}&" %></b>
|
334
|
+
<%| end %>
|
335
|
+
</tbody>
|
336
|
+
</table>
|
337
|
+
END1
|
338
|
+
#{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
|
339
|
+
<tbody>
|
340
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( quux do |i| @a << '
|
341
|
+
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( "\#{i}&" )); @a << '</b>
|
342
|
+
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
343
|
+
'; @a << ' </tbody>
|
344
|
+
</table>
|
345
|
+
';
|
346
|
+
@a.to_s
|
347
|
+
END2
|
348
|
+
<table>
|
349
|
+
<tbody>
|
350
|
+
AC0
|
351
|
+
<B>0&AMP;</B>
|
352
|
+
D0C1
|
353
|
+
<B>1&AMP;</B>
|
354
|
+
D1C2
|
355
|
+
<B>2&AMP;</B>
|
356
|
+
D2B
|
357
|
+
</tbody>
|
358
|
+
</table>
|
359
|
+
END3
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should allow <%|=#{ind} and <%| for nested capturing with CaptureEndEngine when with :escape => #{escape}" do
|
363
|
+
@options[:bufvar] = '@a'
|
364
|
+
@options[:escape] = escape
|
365
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
366
|
+
setup_bar
|
367
|
+
check_output(<<END1, <<END2, <<END3){}
|
368
|
+
<table>
|
369
|
+
<tbody>
|
370
|
+
<%|=#{ind} bar do %>
|
371
|
+
<b><%=#{ind} '&' %></b>
|
372
|
+
<%|=#{ind} baz do %>e<%| end %>
|
373
|
+
<%| end %>
|
374
|
+
</tbody>
|
375
|
+
</table>
|
376
|
+
END1
|
377
|
+
#{'__erubi = ::Erubi;' if escape}@a = ::String.new; @a << '<table>
|
378
|
+
<tbody>
|
379
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( bar do @a << '
|
380
|
+
'; @a << ' <b>'; @a << #{escape ? '__erubi' : '::Erubi'}.h(( '&' )); @a << '</b>
|
381
|
+
'; @a << ' ';begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << #{escape ? '__erubi' : '::Erubi'}.h(( baz do @a << 'e'; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
382
|
+
'; @a << ' '; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
383
|
+
'; @a << ' </tbody>
|
384
|
+
</table>
|
385
|
+
';
|
386
|
+
@a.to_s
|
387
|
+
END2
|
388
|
+
<table>
|
389
|
+
<tbody>
|
390
|
+
A
|
391
|
+
<B>&AMP;</B>
|
392
|
+
CEDCED
|
393
|
+
B
|
394
|
+
</tbody>
|
395
|
+
</table>
|
396
|
+
END3
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
[:outvar, :bufvar].each do |var|
|
401
|
+
it "should handle :#{var} and :freeze options" do
|
402
|
+
@options[var] = "@_out_buf"
|
403
|
+
@options[:freeze] = true
|
404
|
+
@items = [2]
|
405
|
+
i = 0
|
406
|
+
check_output(<<END1, <<END2, <<END3){}
|
407
|
+
<table>
|
408
|
+
<% for item in @items %>
|
409
|
+
<tr>
|
410
|
+
<td><%= i+1 %></td>
|
411
|
+
<td><%== item %></td>
|
412
|
+
</tr>
|
413
|
+
<% end %>
|
414
|
+
</table>
|
415
|
+
END1
|
416
|
+
# frozen_string_literal: true
|
417
|
+
@_out_buf = ::String.new; @_out_buf << '<table>
|
418
|
+
'; for item in @items
|
419
|
+
@_out_buf << ' <tr>
|
420
|
+
<td>'; @_out_buf << ( i+1 ).to_s; @_out_buf << '</td>
|
421
|
+
<td>'; @_out_buf << ::Erubi.h(( item )); @_out_buf << '</td>
|
422
|
+
</tr>
|
423
|
+
'; end
|
424
|
+
@_out_buf << '</table>
|
425
|
+
';
|
426
|
+
@_out_buf.to_s
|
427
|
+
END2
|
428
|
+
<table>
|
429
|
+
<tr>
|
430
|
+
<td>1</td>
|
431
|
+
<td>2</td>
|
432
|
+
</tr>
|
433
|
+
</table>
|
434
|
+
END3
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
it "should handle <%% and <%# syntax" do
|
439
|
+
@items = [2]
|
440
|
+
i = 0
|
441
|
+
check_output(<<END1, <<END2, <<END3){}
|
442
|
+
<table>
|
443
|
+
<%% for item in @items %>
|
444
|
+
<tr>
|
445
|
+
<td><%# i+1 %></td>
|
446
|
+
<td><%# item %></td>
|
447
|
+
</tr>
|
448
|
+
<%% end %>
|
449
|
+
</table>
|
450
|
+
END1
|
451
|
+
_buf = ::String.new; _buf << '<table>
|
452
|
+
'; _buf << '<% for item in @items %>
|
453
|
+
'; _buf << ' <tr>
|
454
|
+
<td>';; _buf << '</td>
|
455
|
+
<td>';; _buf << '</td>
|
456
|
+
</tr>
|
457
|
+
'; _buf << ' <% end %>
|
458
|
+
'; _buf << '</table>
|
459
|
+
';
|
460
|
+
_buf.to_s
|
461
|
+
END2
|
462
|
+
<table>
|
463
|
+
<% for item in @items %>
|
464
|
+
<tr>
|
465
|
+
<td></td>
|
466
|
+
<td></td>
|
467
|
+
</tr>
|
468
|
+
<% end %>
|
469
|
+
</table>
|
470
|
+
END3
|
471
|
+
end
|
472
|
+
|
473
|
+
it "should handle :trim => false option" do
|
474
|
+
@options[:trim] = false
|
475
|
+
@items = [2]
|
476
|
+
i = 0
|
477
|
+
check_output(<<END1, <<END2, <<END3){}
|
478
|
+
<table>
|
479
|
+
<% for item in @items %>
|
480
|
+
<tr>
|
481
|
+
<td><%#
|
482
|
+
i+1
|
483
|
+
%></td>
|
484
|
+
<td><%== item %></td>
|
485
|
+
</tr>
|
486
|
+
<% end %><%#%>
|
487
|
+
<% i %>a
|
488
|
+
<% i %>
|
489
|
+
</table>
|
490
|
+
END1
|
491
|
+
_buf = ::String.new; _buf << '<table>
|
492
|
+
'; _buf << ' '; for item in @items ; _buf << '
|
493
|
+
'; _buf << ' <tr>
|
494
|
+
<td>';
|
495
|
+
|
496
|
+
_buf << '</td>
|
497
|
+
<td>'; _buf << ::Erubi.h(( item )); _buf << '</td>
|
498
|
+
</tr>
|
499
|
+
'; _buf << ' '; end ;
|
500
|
+
_buf << '
|
501
|
+
'; _buf << ' '; i ; _buf << 'a
|
502
|
+
'; _buf << ' '; i ; _buf << '
|
503
|
+
'; _buf << '</table>
|
504
|
+
';
|
505
|
+
_buf.to_s
|
506
|
+
END2
|
507
|
+
<table>
|
508
|
+
|
509
|
+
<tr>
|
510
|
+
<td></td>
|
511
|
+
<td>2</td>
|
512
|
+
</tr>
|
513
|
+
|
514
|
+
a
|
515
|
+
|
516
|
+
</table>
|
517
|
+
END3
|
518
|
+
end
|
519
|
+
|
520
|
+
[:escape, :escape_html].each do |opt|
|
521
|
+
it "should handle :#{opt} and :escapefunc options" do
|
522
|
+
@options[opt] = true
|
523
|
+
@options[:escapefunc] = 'h.call'
|
524
|
+
h = proc{|s| s.to_s*2}
|
525
|
+
list = ['2']
|
526
|
+
check_output(<<END1, <<END2, <<END3){}
|
527
|
+
<table>
|
528
|
+
<tbody>
|
529
|
+
<% i = 0
|
530
|
+
list.each_with_index do |item, i| %>
|
531
|
+
<tr>
|
532
|
+
<td><%= i+1 %></td>
|
533
|
+
<td><%== item %></td>
|
534
|
+
</tr>
|
535
|
+
<% end %>
|
536
|
+
</tbody>
|
537
|
+
</table>
|
538
|
+
<%== i+1 %>
|
539
|
+
END1
|
540
|
+
_buf = ::String.new; _buf << '<table>
|
541
|
+
<tbody>
|
542
|
+
'; i = 0
|
543
|
+
list.each_with_index do |item, i|
|
544
|
+
_buf << ' <tr>
|
545
|
+
<td>'; _buf << h.call(( i+1 )); _buf << '</td>
|
546
|
+
<td>'; _buf << ( item ).to_s; _buf << '</td>
|
547
|
+
</tr>
|
548
|
+
'; end
|
549
|
+
_buf << ' </tbody>
|
550
|
+
</table>
|
551
|
+
'; _buf << ( i+1 ).to_s; _buf << '
|
552
|
+
';
|
553
|
+
_buf.to_s
|
554
|
+
END2
|
555
|
+
<table>
|
556
|
+
<tbody>
|
557
|
+
<tr>
|
558
|
+
<td>11</td>
|
559
|
+
<td>2</td>
|
560
|
+
</tr>
|
561
|
+
</tbody>
|
562
|
+
</table>
|
563
|
+
1
|
564
|
+
END3
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
it "should handle :escape option without :escapefunc option" do
|
569
|
+
@options[:escape] = true
|
570
|
+
list = ['&\'<>"2']
|
571
|
+
check_output(<<END1, <<END2, <<END3){}
|
572
|
+
<table>
|
573
|
+
<tbody>
|
574
|
+
<% i = 0
|
575
|
+
list.each_with_index do |item, i| %>
|
576
|
+
<tr>
|
577
|
+
<td><%== i+1 %></td>
|
578
|
+
<td><%= item %></td>
|
579
|
+
</tr>
|
580
|
+
<% end %>
|
581
|
+
</tbody>
|
582
|
+
</table>
|
583
|
+
END1
|
584
|
+
__erubi = ::Erubi;_buf = ::String.new; _buf << '<table>
|
585
|
+
<tbody>
|
586
|
+
'; i = 0
|
587
|
+
list.each_with_index do |item, i|
|
588
|
+
_buf << ' <tr>
|
589
|
+
<td>'; _buf << ( i+1 ).to_s; _buf << '</td>
|
590
|
+
<td>'; _buf << __erubi.h(( item )); _buf << '</td>
|
591
|
+
</tr>
|
592
|
+
'; end
|
593
|
+
_buf << ' </tbody>
|
594
|
+
</table>
|
595
|
+
';
|
596
|
+
_buf.to_s
|
597
|
+
END2
|
598
|
+
<table>
|
599
|
+
<tbody>
|
600
|
+
<tr>
|
601
|
+
<td>1</td>
|
602
|
+
<td>&'<>"2</td>
|
603
|
+
</tr>
|
604
|
+
</tbody>
|
605
|
+
</table>
|
606
|
+
END3
|
607
|
+
end
|
608
|
+
|
609
|
+
it "should handle :preamble and :postamble options" do
|
610
|
+
@options[:preamble] = '_buf = String.new("1");'
|
611
|
+
@options[:postamble] = "_buf[0...18]\n"
|
612
|
+
list = ['2']
|
613
|
+
check_output(<<END1, <<END2, <<END3){}
|
614
|
+
<table>
|
615
|
+
<tbody>
|
616
|
+
<% i = 0
|
617
|
+
list.each_with_index do |item, i| %>
|
618
|
+
<tr>
|
619
|
+
<td><%= i+1 %></td>
|
620
|
+
<td><%== item %></td>
|
621
|
+
</tr>
|
622
|
+
<% end %>
|
623
|
+
</tbody>
|
624
|
+
</table>
|
625
|
+
<%== i+1 %>
|
626
|
+
END1
|
627
|
+
_buf = String.new("1"); _buf << '<table>
|
628
|
+
<tbody>
|
629
|
+
'; i = 0
|
630
|
+
list.each_with_index do |item, i|
|
631
|
+
_buf << ' <tr>
|
632
|
+
<td>'; _buf << ( i+1 ).to_s; _buf << '</td>
|
633
|
+
<td>'; _buf << ::Erubi.h(( item )); _buf << '</td>
|
634
|
+
</tr>
|
635
|
+
'; end
|
636
|
+
_buf << ' </tbody>
|
637
|
+
</table>
|
638
|
+
'; _buf << ::Erubi.h(( i+1 )); _buf << '
|
639
|
+
';
|
640
|
+
_buf[0...18]
|
641
|
+
END2
|
642
|
+
1<table>
|
643
|
+
<tbody>
|
644
|
+
END3
|
645
|
+
end
|
646
|
+
|
647
|
+
it "should have working filename accessor" do
|
648
|
+
Erubi::Engine.new('', :filename=>'foo.rb').filename.must_equal 'foo.rb'
|
649
|
+
end
|
650
|
+
|
651
|
+
it "should have working bufvar accessor" do
|
652
|
+
Erubi::Engine.new('', :bufvar=>'foo').bufvar.must_equal 'foo'
|
653
|
+
Erubi::Engine.new('', :outvar=>'foo').bufvar.must_equal 'foo'
|
654
|
+
end
|
655
|
+
|
656
|
+
it "should work with BasicObject methods" do
|
657
|
+
c = Class.new(BasicObject)
|
658
|
+
c.class_eval("def a; #{Erubi::Engine.new('2').src} end")
|
659
|
+
c.new.a.must_equal '2'
|
660
|
+
end if defined?(BasicObject)
|
661
|
+
|
662
|
+
it "should return frozen object" do
|
663
|
+
Erubi::Engine.new('').frozen?.must_equal true
|
664
|
+
end
|
665
|
+
|
666
|
+
it "should have frozen src" do
|
667
|
+
Erubi::Engine.new('').src.frozen?.must_equal true
|
668
|
+
end
|
669
|
+
|
670
|
+
it "should raise an error if a tag is not handled when a custom regexp is used" do
|
671
|
+
proc{Erubi::Engine.new('<%] %>', :regexp =>/<%(={1,2}|\]|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m)}.must_raise ArgumentError
|
672
|
+
proc{Erubi::CaptureEndEngine.new('<%] %>', :regexp =>/<%(={1,2}|\]|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m)}.must_raise ArgumentError
|
673
|
+
end
|
674
|
+
|
675
|
+
it "should respect the :yield_returns_buffer option for making templates return the (potentially modified) buffer" do
|
676
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
677
|
+
@options[:bufvar] = '@a'
|
678
|
+
|
679
|
+
def self.bar
|
680
|
+
a = String.new
|
681
|
+
a << "a"
|
682
|
+
yield 'burgers'
|
683
|
+
case b = (yield 'salads')
|
684
|
+
when String
|
685
|
+
a << b
|
686
|
+
a << 'b'
|
687
|
+
a.upcase
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
check_output(<<END1, <<END2, <<END3){}
|
692
|
+
<%|= bar do |item| %>
|
693
|
+
Let's eat <%= item %>!
|
694
|
+
<% nil %><%| end %>
|
695
|
+
END1
|
696
|
+
@a = ::String.new;begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do |item| @a << '
|
697
|
+
'; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '!
|
698
|
+
'; nil ; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
699
|
+
';
|
700
|
+
@a.to_s
|
701
|
+
END2
|
702
|
+
|
703
|
+
END3
|
704
|
+
|
705
|
+
@options[:yield_returns_buffer] = true
|
706
|
+
|
707
|
+
check_output(<<END1, <<END2, <<END3) {}
|
708
|
+
<%|= bar do |item| %>
|
709
|
+
Let's eat <%= item %>!
|
710
|
+
<% nil %><%| end %>
|
711
|
+
END1
|
712
|
+
@a = ::String.new;begin; (__erubi_stack ||= []) << @a; @a = ::String.new; __erubi_stack.last << (( bar do |item| @a << '
|
713
|
+
'; @a << 'Let\\'s eat '; @a << ( item ).to_s; @a << '!
|
714
|
+
'; nil ; @a; end )).to_s; ensure; @a = __erubi_stack.pop; end; @a << '
|
715
|
+
';
|
716
|
+
@a.to_s
|
717
|
+
END2
|
718
|
+
A
|
719
|
+
LET'S EAT BURGERS!
|
720
|
+
|
721
|
+
LET'S EAT SALADS!
|
722
|
+
B
|
723
|
+
END3
|
724
|
+
end
|
725
|
+
|
726
|
+
it "should respect the :yield_returns_buffer option for making templates return the (potentially modified) buffer as the result of the block" do
|
727
|
+
@options[:engine] = ::Erubi::CaptureEndEngine
|
728
|
+
@options[:yield_returns_buffer] = true
|
729
|
+
|
730
|
+
def self.bar(foo = nil)
|
731
|
+
if foo.nil?
|
732
|
+
yield
|
733
|
+
else
|
734
|
+
foo
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
check_output(<<END1, <<END2, <<END3) {}
|
739
|
+
<%|= bar do %>
|
740
|
+
Let's eat the tacos!
|
741
|
+
<%| end %>
|
742
|
+
|
743
|
+
Delicious!
|
744
|
+
END1
|
745
|
+
_buf = ::String.new;begin; (__erubi_stack ||= []) << _buf; _buf = ::String.new; __erubi_stack.last << (( bar do _buf << '
|
746
|
+
'; _buf << 'Let\\'s eat the tacos!
|
747
|
+
'; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << '
|
748
|
+
'; _buf << '
|
749
|
+
Delicious!
|
750
|
+
';
|
751
|
+
_buf.to_s
|
752
|
+
END2
|
753
|
+
|
754
|
+
Let's eat the tacos!
|
755
|
+
|
756
|
+
|
757
|
+
Delicious!
|
758
|
+
END3
|
759
|
+
|
760
|
+
check_output(<<END1, <<END2, <<END3) {}
|
761
|
+
<%|= bar("Don't eat the burgers!") do %>
|
762
|
+
Let's eat burgers!
|
763
|
+
<%| end %>
|
764
|
+
|
765
|
+
Delicious!
|
766
|
+
END1
|
767
|
+
_buf = ::String.new;begin; (__erubi_stack ||= []) << _buf; _buf = ::String.new; __erubi_stack.last << (( bar(\"Don't eat the burgers!\") do _buf << '
|
768
|
+
'; _buf << 'Let\\'s eat burgers!
|
769
|
+
'; _buf; end )).to_s; ensure; _buf = __erubi_stack.pop; end; _buf << '
|
770
|
+
'; _buf << '
|
771
|
+
Delicious!
|
772
|
+
';
|
773
|
+
_buf.to_s
|
774
|
+
END2
|
775
|
+
Don't eat the burgers!
|
776
|
+
|
777
|
+
Delicious!
|
778
|
+
END3
|
779
|
+
end
|
780
|
+
end
|