curlybars 1.3.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/curlybars.rb +0 -1
  3. data/lib/curlybars/configuration.rb +1 -9
  4. data/lib/curlybars/error/base.rb +2 -0
  5. data/lib/curlybars/lexer.rb +3 -0
  6. data/lib/curlybars/method_whitelist.rb +16 -11
  7. data/lib/curlybars/node/block_helper_else.rb +1 -0
  8. data/lib/curlybars/node/if_else.rb +1 -1
  9. data/lib/curlybars/node/path.rb +6 -0
  10. data/lib/curlybars/node/sub_expression.rb +62 -0
  11. data/lib/curlybars/node/unless_else.rb +1 -1
  12. data/lib/curlybars/parser.rb +11 -0
  13. data/lib/curlybars/processor/tilde.rb +3 -0
  14. data/lib/curlybars/rendering_support.rb +9 -1
  15. data/lib/curlybars/template_handler.rb +18 -6
  16. data/lib/curlybars/version.rb +1 -1
  17. data/lib/curlybars/visitor.rb +6 -0
  18. data/spec/acceptance/application_layout_spec.rb +2 -2
  19. data/spec/acceptance/collection_blocks_spec.rb +1 -1
  20. data/spec/acceptance/global_helper_spec.rb +1 -1
  21. data/spec/curlybars/lexer_spec.rb +25 -2
  22. data/spec/curlybars/method_whitelist_spec.rb +15 -0
  23. data/spec/curlybars/rendering_support_spec.rb +4 -9
  24. data/spec/curlybars/template_handler_spec.rb +33 -30
  25. data/spec/integration/cache_spec.rb +20 -18
  26. data/spec/integration/node/block_helper_else_spec.rb +0 -2
  27. data/spec/integration/node/each_else_spec.rb +0 -2
  28. data/spec/integration/node/each_spec.rb +0 -2
  29. data/spec/integration/node/helper_spec.rb +12 -2
  30. data/spec/integration/node/if_else_spec.rb +0 -2
  31. data/spec/integration/node/if_spec.rb +2 -4
  32. data/spec/integration/node/output_spec.rb +0 -2
  33. data/spec/integration/node/partial_spec.rb +0 -2
  34. data/spec/integration/node/path_spec.rb +0 -2
  35. data/spec/integration/node/root_spec.rb +0 -2
  36. data/spec/integration/node/sub_expression_spec.rb +426 -0
  37. data/spec/integration/node/template_spec.rb +0 -2
  38. data/spec/integration/node/unless_else_spec.rb +2 -4
  39. data/spec/integration/node/unless_spec.rb +0 -2
  40. data/spec/integration/node/with_spec.rb +0 -2
  41. data/spec/integration/processors_spec.rb +0 -1
  42. data/spec/integration/visitor_spec.rb +13 -5
  43. metadata +47 -15
@@ -53,8 +53,6 @@ describe "template" do
53
53
  end
54
54
 
55
55
  describe "#validate" do
56
- let(:presenter_class) { double(:presenter_class) }
57
-
58
56
  it "without errors" do
59
57
  dependency_tree = { presenter: { field: nil } }
60
58
 
@@ -82,8 +82,6 @@ describe "{{#unless}}...{{else}}...{{/unless}}" do
82
82
  end
83
83
 
84
84
  describe "#validate" do
85
- let(:presenter_class) { double(:presenter_class) }
86
-
87
85
  it "validates with errors the condition" do
88
86
  dependency_tree = {}
89
87
 
@@ -96,7 +94,7 @@ describe "{{#unless}}...{{else}}...{{/unless}}" do
96
94
  expect(errors).not_to be_empty
97
95
  end
98
96
 
99
- it "validates with errors the helper as condition" do
97
+ it "validates without errors when using a helper in the condition" do
100
98
  dependency_tree = { helper: :helper }
101
99
 
102
100
  source = <<-HBS
@@ -105,7 +103,7 @@ describe "{{#unless}}...{{else}}...{{/unless}}" do
105
103
 
106
104
  errors = Curlybars.validate(dependency_tree, source)
107
105
 
108
- expect(errors).not_to be_empty
106
+ expect(errors).to be_empty
109
107
  end
110
108
 
111
109
  it "validates with errors the nested unless_template" do
@@ -99,8 +99,6 @@ describe "{{#unless}}...{{/unless}}" do
99
99
  end
100
100
 
101
101
  describe "#validate" do
102
- let(:presenter_class) { double(:presenter_class) }
103
-
104
102
  it "validates with errors the condition" do
105
103
  dependency_tree = {}
106
104
 
@@ -75,8 +75,6 @@ describe "{{#with presenter}}...{{/with}}" do
75
75
  end
76
76
 
77
77
  describe "#validate" do
78
- let(:presenter_class) { double(:presenter_class) }
79
-
80
78
  it "without errors" do
81
79
  dependency_tree = { a_presenter: {} }
82
80
 
@@ -1,6 +1,5 @@
1
1
  describe "processors" do
2
2
  let(:presenter) { double(:presenter, dependency_tree: { curlybars: nil }) }
3
- let(:global_helpers_providers) { [] }
4
3
  let(:processor) { double(:processor) }
5
4
 
6
5
  before do
@@ -4,6 +4,8 @@ describe "visitor" do
4
4
  {{#print_args_and_options 'first' 'second' key='value'}}
5
5
  {{/print_args_and_options}}
6
6
 
7
+ {{calc (calc 1 "+" 2) "*" 3}}
8
+
7
9
  {{#render_inverse}}
8
10
  fn
9
11
  {{else}}
@@ -53,7 +55,7 @@ describe "visitor" do
53
55
  it "visits BlockHelperElse nodes" do
54
56
  visitor = counting_visitor_for(Curlybars::Node::BlockHelperElse)
55
57
  output = Curlybars.visit(visitor, source)
56
- expect(output).to eq(4)
58
+ expect(output).to eq(5)
57
59
  end
58
60
 
59
61
  it "visits EachElse nodes" do
@@ -71,13 +73,13 @@ describe "visitor" do
71
73
  it "visits Item nodes" do
72
74
  visitor = counting_visitor_for(Curlybars::Node::Item)
73
75
  output = Curlybars.visit(visitor, source)
74
- expect(output).to eq(42)
76
+ expect(output).to eq(44)
75
77
  end
76
78
 
77
79
  it "visits Literal nodes" do
78
80
  visitor = counting_visitor_for(Curlybars::Node::Literal)
79
81
  output = Curlybars.visit(visitor, source)
80
- expect(output).to eq(3)
82
+ expect(output).to eq(8)
81
83
  end
82
84
 
83
85
  it "visits Option nodes" do
@@ -95,7 +97,7 @@ describe "visitor" do
95
97
  it "visits Path nodes" do
96
98
  visitor = counting_visitor_for(Curlybars::Node::Path)
97
99
  output = Curlybars.visit(visitor, source)
98
- expect(output).to eq(13)
100
+ expect(output).to eq(15)
99
101
  end
100
102
 
101
103
  it "visits Root nodes" do
@@ -104,6 +106,12 @@ describe "visitor" do
104
106
  expect(output).to eq(1)
105
107
  end
106
108
 
109
+ it "visits SubExpression nodes" do
110
+ visitor = counting_visitor_for(Curlybars::Node::SubExpression)
111
+ output = Curlybars.visit(visitor, source)
112
+ expect(output).to eq(1)
113
+ end
114
+
107
115
  it "visits Template nodes" do
108
116
  visitor = counting_visitor_for(Curlybars::Node::Template)
109
117
  output = Curlybars.visit(visitor, source)
@@ -113,7 +121,7 @@ describe "visitor" do
113
121
  it "visits Text nodes" do
114
122
  visitor = counting_visitor_for(Curlybars::Node::Text)
115
123
  output = Curlybars.visit(visitor, source)
116
- expect(output).to eq(28)
124
+ expect(output).to eq(29)
117
125
  end
118
126
 
119
127
  it "visits UnlessElse nodes" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curlybars
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Libo Cannici
@@ -10,10 +10,11 @@ authors:
10
10
  - Mauro Codella
11
11
  - Luís Almeida
12
12
  - Andreas Garnæs
13
+ - Augusto Silva
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
- date: 2019-12-17 00:00:00.000000000 Z
17
+ date: 2021-01-05 00:00:00.000000000 Z
17
18
  dependencies:
18
19
  - !ruby/object:Gem::Dependency
19
20
  name: actionpack
@@ -24,7 +25,7 @@ dependencies:
24
25
  version: '4.2'
25
26
  - - "<"
26
27
  - !ruby/object:Gem::Version
27
- version: '6.0'
28
+ version: '6.2'
28
29
  type: :runtime
29
30
  prerelease: false
30
31
  version_requirements: !ruby/object:Gem::Requirement
@@ -34,7 +35,7 @@ dependencies:
34
35
  version: '4.2'
35
36
  - - "<"
36
37
  - !ruby/object:Gem::Version
37
- version: '6.0'
38
+ version: '6.2'
38
39
  - !ruby/object:Gem::Dependency
39
40
  name: activesupport
40
41
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +45,7 @@ dependencies:
44
45
  version: '4.2'
45
46
  - - "<"
46
47
  - !ruby/object:Gem::Version
47
- version: '6.0'
48
+ version: '6.2'
48
49
  type: :runtime
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -54,7 +55,7 @@ dependencies:
54
55
  version: '4.2'
55
56
  - - "<"
56
57
  - !ruby/object:Gem::Version
57
- version: '6.0'
58
+ version: '6.2'
58
59
  - !ruby/object:Gem::Dependency
59
60
  name: ffi
60
61
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +121,7 @@ dependencies:
120
121
  version: '4.2'
121
122
  - - "<"
122
123
  - !ruby/object:Gem::Version
123
- version: '6.0'
124
+ version: '6.2'
124
125
  type: :development
125
126
  prerelease: false
126
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -130,7 +131,7 @@ dependencies:
130
131
  version: '4.2'
131
132
  - - "<"
132
133
  - !ruby/object:Gem::Version
133
- version: '6.0'
134
+ version: '6.2'
134
135
  - !ruby/object:Gem::Dependency
135
136
  name: rake
136
137
  requirement: !ruby/object:Gem::Requirement
@@ -165,32 +166,60 @@ dependencies:
165
166
  requirements:
166
167
  - - "~>"
167
168
  - !ruby/object:Gem::Version
168
- version: 0.58.2
169
+ version: 1.6.0
169
170
  type: :development
170
171
  prerelease: false
171
172
  version_requirements: !ruby/object:Gem::Requirement
172
173
  requirements:
173
174
  - - "~>"
174
175
  - !ruby/object:Gem::Version
175
- version: 0.58.2
176
+ version: 1.6.0
177
+ - !ruby/object:Gem::Dependency
178
+ name: rubocop-performance
179
+ requirement: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: 1.9.0
184
+ type: :development
185
+ prerelease: false
186
+ version_requirements: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: 1.9.0
191
+ - !ruby/object:Gem::Dependency
192
+ name: rubocop-rake
193
+ requirement: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - "~>"
196
+ - !ruby/object:Gem::Version
197
+ version: 0.5.0
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - "~>"
203
+ - !ruby/object:Gem::Version
204
+ version: 0.5.0
176
205
  - !ruby/object:Gem::Dependency
177
206
  name: rubocop-rspec
178
207
  requirement: !ruby/object:Gem::Requirement
179
208
  requirements:
180
209
  - - "~>"
181
210
  - !ruby/object:Gem::Version
182
- version: 1.28.0
211
+ version: 2.1.0
183
212
  type: :development
184
213
  prerelease: false
185
214
  version_requirements: !ruby/object:Gem::Requirement
186
215
  requirements:
187
216
  - - "~>"
188
217
  - !ruby/object:Gem::Version
189
- version: 1.28.0
218
+ version: 2.1.0
190
219
  description: |-
191
220
  A view layer for your Rails apps that separates structure and logic, using Handlebars templates.
192
221
  Strongly inspired by Curly Template gem by Daniel Schierbeck.
193
- email: libo@zendesk.com
222
+ email: vikings@zendesk.com
194
223
  executables: []
195
224
  extensions: []
196
225
  extra_rdoc_files: []
@@ -219,6 +248,7 @@ files:
219
248
  - lib/curlybars/node/path.rb
220
249
  - lib/curlybars/node/root.rb
221
250
  - lib/curlybars/node/string.rb
251
+ - lib/curlybars/node/sub_expression.rb
222
252
  - lib/curlybars/node/template.rb
223
253
  - lib/curlybars/node/text.rb
224
254
  - lib/curlybars/node/unless_else.rb
@@ -265,6 +295,7 @@ files:
265
295
  - spec/integration/node/partial_spec.rb
266
296
  - spec/integration/node/path_spec.rb
267
297
  - spec/integration/node/root_spec.rb
298
+ - spec/integration/node/sub_expression_spec.rb
268
299
  - spec/integration/node/template_spec.rb
269
300
  - spec/integration/node/unless_else_spec.rb
270
301
  - spec/integration/node/unless_spec.rb
@@ -285,14 +316,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
285
316
  requirements:
286
317
  - - ">="
287
318
  - !ruby/object:Gem::Version
288
- version: '0'
319
+ version: '2.4'
289
320
  required_rubygems_version: !ruby/object:Gem::Requirement
290
321
  requirements:
291
322
  - - ">="
292
323
  - !ruby/object:Gem::Version
293
324
  version: '0'
294
325
  requirements: []
295
- rubygems_version: 3.0.6
326
+ rubygems_version: 3.1.4
296
327
  signing_key:
297
328
  specification_version: 4
298
329
  summary: Create your views using Handlebars templates!
@@ -318,6 +349,7 @@ test_files:
318
349
  - spec/integration/node/unless_else_spec.rb
319
350
  - spec/integration/node/output_spec.rb
320
351
  - spec/integration/node/if_spec.rb
352
+ - spec/integration/node/sub_expression_spec.rb
321
353
  - spec/integration/node/unless_spec.rb
322
354
  - spec/integration/node/with_spec.rb
323
355
  - spec/integration/node/partial_spec.rb