trenni 3.6.1 → 3.7.0
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/.travis.yml +15 -21
- data/Gemfile +1 -4
- data/lib/trenni/template.rb +4 -3
- data/lib/trenni/version.rb +1 -1
- data/spec/spec_helper.rb +2 -19
- data/spec/trenni/template_spec.rb +83 -64
- data/trenni.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5137222fc49006a71dbcc1b9730dba3ff670660df9502bdae43db6d242d25a7
|
4
|
+
data.tar.gz: 47494cf08dfb486a74c3efd236419f02638f3bd1b593446acd1f26fbd1d87870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501b5b7fc01eb1da1650c4d32dc296998b428b0919f904b195da5b2f2c53ccd40fcf2bad16f43291d833293987e5fda43adfbdfc21834f97273ee2e460575622
|
7
|
+
data.tar.gz: 9e7f6a39cf968a59a553c4209644c50a1b69cde60cb99abf437ad662395f9c4e488fa6d20aefdf61c29e0aec90ca879cdbf29c7fe19e90b9cf8ff4eb9d7274f4
|
data/.travis.yml
CHANGED
@@ -1,29 +1,23 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
before_install:
|
5
|
-
- gem update --system
|
6
|
-
- gem install bundler
|
2
|
+
cache: bundler
|
7
3
|
|
8
4
|
before_script:
|
9
|
-
- sh -c "cd ext && rake compile"
|
10
|
-
|
11
|
-
rvm:
|
12
|
-
- 2.1
|
13
|
-
- 2.2
|
14
|
-
- 2.3
|
15
|
-
- 2.4
|
16
|
-
- 2.5
|
17
|
-
- 2.6
|
18
|
-
- ruby-head
|
19
|
-
- jruby-head
|
20
|
-
- rbx-2
|
5
|
+
- sh -c "cd ext && bundle exec rake compile"
|
21
6
|
|
22
|
-
env:
|
23
|
-
- COVERAGE=true
|
24
|
-
- COVERAGE=true TRENNI_PREFER_FALLBACK=y
|
25
7
|
matrix:
|
8
|
+
include:
|
9
|
+
- rvm: 2.3
|
10
|
+
- rvm: 2.4
|
11
|
+
- rvm: 2.5
|
12
|
+
- rvm: 2.6
|
13
|
+
- rvm: 2.6
|
14
|
+
env: TRENNI_PREFER_FALLBACK=y
|
15
|
+
- rvm: 2.6
|
16
|
+
env: COVERAGE=Summary
|
17
|
+
- rvm: ruby-head
|
18
|
+
- rvm: jruby-head
|
19
|
+
- rvm: truffleruby
|
26
20
|
allow_failures:
|
27
|
-
- rvm: "
|
21
|
+
- rvm: "truffleruby"
|
28
22
|
- rvm: "ruby-head"
|
29
23
|
- rvm: "jruby-head"
|
data/Gemfile
CHANGED
@@ -5,9 +5,7 @@ gemspec
|
|
5
5
|
|
6
6
|
group :development do
|
7
7
|
gem 'pry'
|
8
|
-
|
9
8
|
gem "rake-compiler"
|
10
|
-
|
11
9
|
gem "ruby-beautify"
|
12
10
|
end
|
13
11
|
|
@@ -15,8 +13,7 @@ group :test do
|
|
15
13
|
gem 'ruby-prof', platforms: [:mri]
|
16
14
|
gem "benchmark-ips"
|
17
15
|
|
18
|
-
gem '
|
19
|
-
gem 'coveralls', require: false
|
16
|
+
gem 'covered'
|
20
17
|
|
21
18
|
# For comparisons:
|
22
19
|
gem "nokogiri"
|
data/lib/trenni/template.rb
CHANGED
@@ -95,8 +95,9 @@ module Trenni
|
|
95
95
|
self.new(FileBuffer.new(path), *args).freeze
|
96
96
|
end
|
97
97
|
|
98
|
-
def initialize(buffer)
|
98
|
+
def initialize(buffer, binding: TOPLEVEL_BINDING)
|
99
99
|
@buffer = buffer
|
100
|
+
@binding = binding
|
100
101
|
end
|
101
102
|
|
102
103
|
def freeze
|
@@ -119,7 +120,7 @@ module Trenni
|
|
119
120
|
Buffer.new(to_string(scope), path: @buffer.path)
|
120
121
|
end
|
121
122
|
|
122
|
-
def to_proc(scope = binding)
|
123
|
+
def to_proc(scope = @binding.dup)
|
123
124
|
@compiled_proc ||= eval("proc{|#{OUT}|;#{code}}", scope, @buffer.path).freeze
|
124
125
|
end
|
125
126
|
|
@@ -150,7 +151,7 @@ module Trenni
|
|
150
151
|
class Assembler < Template::Assembler
|
151
152
|
# Output a string interpolation.
|
152
153
|
def expression(text)
|
153
|
-
@code << "Markup.append(#{OUT},(#{text}));"
|
154
|
+
@code << "Trenni::Markup.append(#{OUT},(#{text}));"
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
data/lib/trenni/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,23 +1,6 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
|
4
|
-
require 'simplecov'
|
5
|
-
|
6
|
-
SimpleCov.start do
|
7
|
-
add_filter "/spec/"
|
8
|
-
end
|
9
|
-
|
10
|
-
if ENV['TRAVIS']
|
11
|
-
require 'coveralls'
|
12
|
-
Coveralls.wear!
|
13
|
-
end
|
14
|
-
rescue LoadError
|
15
|
-
warn "Could not load simplecov: #{$!}"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
require "bundler/setup"
|
20
|
-
require "trenni"
|
2
|
+
require 'covered/rspec'
|
3
|
+
require 'trenni'
|
21
4
|
|
22
5
|
begin
|
23
6
|
require 'ruby-prof'
|
@@ -25,89 +25,108 @@ require 'trenni/parsers'
|
|
25
25
|
require 'benchmark'
|
26
26
|
|
27
27
|
RSpec.describe Trenni::Template do
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
RSpec.describe Trenni::Template do
|
39
|
-
let(:template_path) {File.expand_path('template_spec/lines.trenni', __dir__)}
|
40
|
-
let(:template) {Trenni::Template.load_file template_path}
|
41
|
-
let(:code) {template.send(:code)}
|
42
|
-
|
43
|
-
it "should parse xhtml template and produce identical output" do
|
44
|
-
expect(code.lines[0]).to match(/apple/)
|
45
|
-
expect(code.lines[5]).to match(/banana/)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
RSpec.describe Trenni::Template do
|
50
|
-
let(:template_path) {File.expand_path('template_spec/builder.trenni', __dir__)}
|
51
|
-
let(:template) {Trenni::Template.load_file template_path}
|
52
|
-
let(:code) {template.send(:code)}
|
53
|
-
|
54
|
-
it "should capture and output the contents of the block" do
|
55
|
-
expect(template.to_string).to be == 'Hello World!'
|
28
|
+
context 'large.xhtml' do
|
29
|
+
let(:template_path) {File.expand_path('corpus/large.xhtml', __dir__)}
|
30
|
+
let(:template) {Trenni::Template.load_file template_path}
|
31
|
+
let(:output) {template.to_string}
|
32
|
+
|
33
|
+
it "should parse xhtml template and produce identical output" do
|
34
|
+
expect{output}.to_not raise_error
|
35
|
+
expect(output).to be == File.read(template_path)
|
36
|
+
end
|
56
37
|
end
|
57
|
-
end
|
58
|
-
|
59
|
-
RSpec.describe Trenni::Template do
|
60
|
-
let(:capture_template) {Trenni::Template.load_file File.expand_path('template_spec/capture.trenni', __dir__)}
|
61
38
|
|
62
|
-
|
63
|
-
|
39
|
+
context 'lines.trenni' do
|
40
|
+
let(:template_path) {File.expand_path('template_spec/lines.trenni', __dir__)}
|
41
|
+
let(:template) {Trenni::Template.load_file template_path}
|
42
|
+
let(:code) {template.send(:code)}
|
43
|
+
|
44
|
+
it "should parse xhtml template and produce identical output" do
|
45
|
+
expect(code.lines[0]).to match(/apple/)
|
46
|
+
expect(code.lines[5]).to match(/banana/)
|
47
|
+
end
|
64
48
|
end
|
65
49
|
|
66
|
-
|
67
|
-
|
50
|
+
context 'builder.trenni' do
|
51
|
+
let(:template_path) {File.expand_path('template_spec/builder.trenni', __dir__)}
|
52
|
+
let(:template) {Trenni::Template.load_file template_path}
|
53
|
+
let(:code) {template.send(:code)}
|
68
54
|
|
69
|
-
|
70
|
-
|
55
|
+
it "should capture and output the contents of the block" do
|
56
|
+
expect(template.to_string).to be == 'Hello World!'
|
57
|
+
end
|
71
58
|
end
|
72
59
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
60
|
+
context 'capture.trenni' do
|
61
|
+
let(:capture_template) {Trenni::Template.load_file File.expand_path('template_spec/capture.trenni', __dir__)}
|
62
|
+
|
63
|
+
it "should be able to capture output" do
|
64
|
+
expect(capture_template.to_string).to be == '"TEST TEST TEST\n"'
|
65
|
+
end
|
66
|
+
|
67
|
+
it "compiled template should match line numbers" do
|
68
|
+
code_lines = capture_template.send(:code).lines
|
69
|
+
|
70
|
+
expect(code_lines.count).to be == 4
|
71
|
+
expect(code_lines[3]).to include("inspect")
|
72
|
+
end
|
77
73
|
end
|
78
74
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
context 'buffer.trenni' do
|
76
|
+
let(:buffer_template) {Trenni::Template.load_file File.expand_path('template_spec/buffer.trenni', __dir__)}
|
77
|
+
|
78
|
+
it "should be able to fetch output buffer" do
|
79
|
+
expect(buffer_template.to_string).to be == 'test'
|
80
|
+
end
|
83
81
|
end
|
84
82
|
|
85
|
-
|
86
|
-
|
87
|
-
it "should process list of items" do
|
88
|
-
buffer = Trenni::Buffer.new('<?r items.each do |item| ?>#{item}<?r end ?>')
|
89
|
-
template = Trenni::Template.new(buffer)
|
83
|
+
context 'nested.trenni' do
|
84
|
+
let(:nested_template) {Trenni::Template.load_file File.expand_path('template_spec/nested.trenni', __dir__)}
|
90
85
|
|
91
|
-
|
86
|
+
it "should be able to handle nested interpolations" do
|
87
|
+
expect(nested_template.to_string).to be == "Hello world!"
|
88
|
+
end
|
92
89
|
end
|
93
90
|
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
context 'items' do
|
92
|
+
let(:items) {1..4}
|
93
|
+
|
94
|
+
it "should process list of items" do
|
95
|
+
buffer = Trenni::Buffer.new('<?r items.each do |item| ?>#{item}<?r end ?>')
|
96
|
+
template = Trenni::Template.new(buffer)
|
97
|
+
|
98
|
+
expect(template.to_string(self)).to be == "1234"
|
99
|
+
end
|
97
100
|
|
98
|
-
|
101
|
+
it "should have correct indentation" do
|
102
|
+
buffer = Trenni::Buffer.new("\t<?r items.each do |item| ?>\n\t\#{item}\n\t<?r end ?>\n")
|
103
|
+
template = Trenni::Template.new(buffer)
|
104
|
+
|
105
|
+
expect(template.to_string(self)).to be == "\t1\n\t2\n\t3\n\t4\n"
|
106
|
+
end
|
99
107
|
end
|
100
108
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
109
|
+
context 'escaped.trenni' do
|
110
|
+
let(:escaped_template) {Trenni::Template.load_file File.expand_path('template_spec/escaped.trenni', __dir__)}
|
111
|
+
|
112
|
+
it "should have the same number of lines as input" do
|
113
|
+
expect(escaped_template.send(:code).lines.count).to be == 2
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should process escaped characters" do
|
117
|
+
expect(escaped_template.to_string).to be ==
|
118
|
+
"This\\nisn't one line.\n" +
|
119
|
+
"\\tIndentation is the best."
|
120
|
+
end
|
105
121
|
end
|
106
122
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
123
|
+
context 'scope' do
|
124
|
+
it "should use default top-level binding if none provided" do
|
125
|
+
buffer = Trenni::Buffer.new('#{Module.nesting.inspect}')
|
126
|
+
template = Trenni::Template.new(buffer)
|
127
|
+
|
128
|
+
expect(template.to_string(self)).to be == "[]"
|
129
|
+
end
|
111
130
|
end
|
112
131
|
end
|
113
132
|
|
data/trenni.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.extensions = %w[ext/Rakefile]
|
28
28
|
spec.add_dependency "rake-compiler"
|
29
29
|
|
30
|
-
spec.add_development_dependency "bundler"
|
30
|
+
spec.add_development_dependency "bundler"
|
31
31
|
spec.add_development_dependency "rspec", "~> 3.4"
|
32
32
|
spec.add_development_dependency "rake"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trenni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
- !ruby/object:Gem::Version
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
|
-
rubygems_version: 3.0.
|
173
|
+
rubygems_version: 3.0.4
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: A fast native templating system that compiles directly to Ruby code.
|