flavour_saver 4.0.2 → 5.0.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +14 -0
  3. data/.standard.yml +1 -0
  4. data/CHANGELOG.md +57 -0
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +48 -5
  7. data/README.md +153 -271
  8. data/flavour_saver.gemspec +17 -19
  9. data/lib/flavour_saver/error.rb +5 -0
  10. data/lib/flavour_saver/helpers.rb +19 -18
  11. data/lib/flavour_saver/lexer.rb +123 -50
  12. data/lib/flavour_saver/nodes.rb +107 -19
  13. data/lib/flavour_saver/parser.rb +339 -161
  14. data/lib/flavour_saver/partial.rb +4 -6
  15. data/lib/flavour_saver/rails_partial.rb +10 -4
  16. data/lib/flavour_saver/runtime.rb +76 -81
  17. data/lib/flavour_saver/template.rb +3 -5
  18. data/lib/flavour_saver/version.rb +1 -1
  19. data/lib/flavour_saver.rb +17 -17
  20. data/spec/acceptance/backtrack_spec.rb +9 -9
  21. data/spec/acceptance/comment_spec.rb +7 -7
  22. data/spec/acceptance/custom_block_helper_spec.rb +12 -12
  23. data/spec/acceptance/custom_helper_spec.rb +8 -8
  24. data/spec/acceptance/ensure_no_rce_spec.rb +64 -53
  25. data/spec/acceptance/handlebars_qunit_spec.rb +295 -297
  26. data/spec/acceptance/if_else_spec.rb +6 -6
  27. data/spec/acceptance/multi_level_with_spec.rb +10 -11
  28. data/spec/acceptance/nesting_depth_spec.rb +34 -0
  29. data/spec/acceptance/one_character_identifier_spec.rb +8 -8
  30. data/spec/acceptance/raw_block_spec.rb +7 -7
  31. data/spec/acceptance/sections_spec.rb +17 -14
  32. data/spec/acceptance/segment_literals_spec.rb +5 -5
  33. data/spec/acceptance/simple_expression_spec.rb +9 -9
  34. data/spec/acceptance/subexpression_spec.rb +18 -17
  35. data/spec/acceptance/unless_spec.rb +19 -6
  36. data/spec/lib/flavour_saver/lexer_spec.rb +103 -89
  37. data/spec/lib/flavour_saver/nodes_spec.rb +85 -0
  38. data/spec/lib/flavour_saver/parser_spec.rb +155 -95
  39. data/spec/lib/flavour_saver/runtime_spec.rb +94 -96
  40. data/spec/lib/flavour_saver/template_spec.rb +1 -2
  41. metadata +19 -48
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80a0e1999365ccda78e958e0155d4dbd22144714aa0aaf313d3a989e91b4679f
4
- data.tar.gz: ee60228f697c8e271e733b42edb51c4a6fa45dec5178f2df1e6cd097f46401fe
3
+ metadata.gz: 23a4ae44f910bb19202d1336927b028f8f1678c3474a46d5ada75eeb67295ff6
4
+ data.tar.gz: dcbedf38a360efeed2e7319c22eb60730578457354d0dd2872eafb76526d07aa
5
5
  SHA512:
6
- metadata.gz: c743bbef88d41fb1953d56fda4ef393109263ca609899e119e0e9f4e80ee9481c12737c7678ff037edec6ddebd169b4dc8343683a3efc81ace61a716a0d4e7c0
7
- data.tar.gz: 65fb2bc85b97ea6d1f833521350870a637ea9736af104f98c33973d97d5aaf078f950eac0152b636bb7164a0c3483a83e1fffcece6816a9f51c50e09aeeedf07
6
+ metadata.gz: 754890fa64a87d71f5c53ad8f471c52490268361bb0adb91ec53207cfd27de9738b723a4022477e522324442fbb671a0f5613fe0e5e46013afe5db05d9bd2571
7
+ data.tar.gz: ccb789b768c7406b1453cdf635dec3e8737b28b7e81bd6b7323baaacb13b76846367623a00b27d3157005e4df2522448af4c83c224e891ad91c61d66990a369e
@@ -25,6 +25,20 @@ jobs:
25
25
  - name: Run tests
26
26
  run: bundle exec rspec
27
27
 
28
+ standard:
29
+
30
+ runs-on: ubuntu-latest
31
+
32
+ steps:
33
+ - uses: actions/checkout@v6
34
+ - name: Set up Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: '3.4'
38
+ bundler-cache: true
39
+ - name: Run Standard
40
+ run: bundle exec standardrb
41
+
28
42
  publish-gem:
29
43
  if: github.ref_type == 'tag'
30
44
  runs-on: ubuntu-latest
data/.standard.yml ADDED
@@ -0,0 +1 @@
1
+ ruby_version: 3.1
data/CHANGELOG.md CHANGED
@@ -7,6 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## 5.0.0
11
+
12
+ ### Removed
13
+
14
+ * The `rltk` dependency, and with it its transitive `ffi` native extension.
15
+ RLTK's last release was in 2015 and FlavourSaver pinned it below 3.0, so the
16
+ gem could never be updated in an application's bundle. The lexer, parser and
17
+ AST base class are now part of FlavourSaver itself; `tilt` is the only
18
+ runtime dependency. Parsing is about five times faster.
19
+
20
+ ### Added
21
+
22
+ * `FlavourSaver::Error`, a common base class for the errors raised by an
23
+ invalid template: `FlavourSaver::Lexer::LexingError`,
24
+ `FlavourSaver::Parser::NotInLanguage` and
25
+ `FlavourSaver::Parser::UnbalancedBlockError`.
26
+
27
+ ### Changed
28
+
29
+ * Syntax errors raise `FlavourSaver::Parser::NotInLanguage` instead of
30
+ `RLTK::NotInLanguage`, and unlexable input raises
31
+ `FlavourSaver::Lexer::LexingError` instead of `RLTK::LexingError`. The
32
+ `LexingError` message now quotes the first 50 characters of the input the
33
+ lexer couldn't match.
34
+
35
+ **Migrating:** a `rescue RLTK::NotInLanguage` or `rescue RLTK::LexingError`
36
+ now raises `NameError` when an exception reaches it, because Ruby only looks
37
+ up the constants in a `rescue` clause at that point. Replace them with
38
+ `rescue FlavourSaver::Error`, which also catches
39
+ `FlavourSaver::Parser::UnbalancedBlockError` (raised for a closing tag with
40
+ no matching opening, such as `{{#foo}}{{#bar}}{{/foo}}`).
41
+ * `FlavourSaver::Lexer`, `FlavourSaver::Parser` and `FlavourSaver::Node` no
42
+ longer inherit from RLTK classes. Tokens respond to `type` and `value` but
43
+ no longer carry a `position`.
44
+ * AST node fields are type-checked as they were under RLTK. Setting one to
45
+ the wrong type, whether in the constructor or with a setter, raises
46
+ `FlavourSaver::Node::TypeMismatch` instead of `RLTK::TypeMismatch`. Like
47
+ RLTK's, it is a `StandardError` and not a `FlavourSaver::Error`, so
48
+ `rescue FlavourSaver::Error` doesn't catch it. An application that rewrites
49
+ the AST before rendering gets the error where it builds the bad node, not at
50
+ render time.
51
+ * RLTK's core-class monkey patches (`Object#returning`, `TrueClass#to_i`,
52
+ `FalseClass#to_i`, `Integer#to_bool`, `Class#subclass_of?` and friends) are
53
+ no longer loaded into applications that use FlavourSaver.
54
+
55
+ ### Fixed
56
+
57
+ * An inverted section with an `{{else}}`, such as
58
+ `{{^items}}none{{else}}some{{/items}}`, raised `RLTK::TypeMismatch` at parse
59
+ time. It now renders the body when the value is falsy and the `{{else}}`
60
+ section when it is truthy.
61
+ * A deeply nested template overflowed the stack and raised `SystemStackError`,
62
+ which `rescue FlavourSaver::Error` doesn't catch. Inside a Fiber, rendering
63
+ that happened at fewer than 100 levels. A template that nests blocks and
64
+ subexpressions more than 32 levels deep (`FlavourSaver::Parser::MAX_DEPTH`)
65
+ now raises `FlavourSaver::Parser::NotInLanguage`.
66
+
10
67
  ## 4.0.2
11
68
 
12
69
  * Bump locked dependency versions
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in flavour_saver.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,8 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flavour_saver (4.0.2)
5
- rltk (< 3.0)
4
+ flavour_saver (5.0.0)
6
5
  tilt (~> 2.6)
7
6
 
8
7
  GEM
@@ -20,6 +19,7 @@ GEM
20
19
  minitest (>= 5.1, < 6)
21
20
  securerandom (>= 0.3)
22
21
  tzinfo (~> 2.0, >= 2.0.5)
22
+ ast (2.4.3)
23
23
  base64 (0.3.0)
24
24
  benchmark (0.5.0)
25
25
  bigdecimal (4.1.2)
@@ -27,14 +27,22 @@ GEM
27
27
  connection_pool (2.5.5)
28
28
  diff-lcs (1.6.2)
29
29
  drb (2.2.3)
30
- ffi (1.17.4)
31
30
  i18n (1.15.2)
32
31
  concurrent-ruby (~> 1.0)
32
+ json (2.21.2)
33
+ language_server-protocol (3.17.0.6)
34
+ lint_roller (1.1.0)
33
35
  logger (1.7.0)
34
36
  minitest (5.27.0)
37
+ parallel (1.28.0)
38
+ parser (3.3.12.0)
39
+ ast (~> 2.4.1)
40
+ racc
41
+ prism (1.9.0)
42
+ racc (1.8.1)
43
+ rainbow (3.1.1)
35
44
  rake (13.4.2)
36
- rltk (2.2.1)
37
- ffi (>= 1.0.0)
45
+ regexp_parser (2.13.1)
38
46
  rspec (3.13.2)
39
47
  rspec-core (~> 3.13.0)
40
48
  rspec-expectations (~> 3.13.0)
@@ -48,10 +56,44 @@ GEM
48
56
  diff-lcs (>= 1.2.0, < 2.0)
49
57
  rspec-support (~> 3.13.0)
50
58
  rspec-support (3.13.7)
59
+ rubocop (1.88.2)
60
+ json (~> 2.3)
61
+ language_server-protocol (~> 3.17.0.2)
62
+ lint_roller (~> 1.1.0)
63
+ parallel (>= 1.10)
64
+ parser (>= 3.3.0.2)
65
+ rainbow (>= 2.2.2, < 4.0)
66
+ regexp_parser (>= 2.9.3, < 3.0)
67
+ rubocop-ast (>= 1.49.0, < 2.0)
68
+ ruby-progressbar (~> 1.7)
69
+ unicode-display_width (>= 2.4.0, < 4.0)
70
+ rubocop-ast (1.50.0)
71
+ parser (>= 3.3.7.2)
72
+ prism (~> 1.7)
73
+ rubocop-performance (1.26.1)
74
+ lint_roller (~> 1.1)
75
+ rubocop (>= 1.75.0, < 2.0)
76
+ rubocop-ast (>= 1.47.1, < 2.0)
77
+ ruby-progressbar (1.13.0)
51
78
  securerandom (0.4.1)
79
+ standard (1.56.0)
80
+ language_server-protocol (~> 3.17.0.2)
81
+ lint_roller (~> 1.0)
82
+ rubocop (~> 1.88.0)
83
+ standard-custom (~> 1.0.0)
84
+ standard-performance (~> 1.8)
85
+ standard-custom (1.0.2)
86
+ lint_roller (~> 1.0)
87
+ rubocop (~> 1.50)
88
+ standard-performance (1.9.0)
89
+ lint_roller (~> 1.1)
90
+ rubocop-performance (~> 1.26.0)
52
91
  tilt (2.8.0)
53
92
  tzinfo (2.0.6)
54
93
  concurrent-ruby (~> 1.0)
94
+ unicode-display_width (3.3.0)
95
+ unicode-emoji (~> 4.3)
96
+ unicode-emoji (4.3.0)
55
97
 
56
98
  PLATFORMS
57
99
  ruby
@@ -61,6 +103,7 @@ DEPENDENCIES
61
103
  flavour_saver!
62
104
  rake
63
105
  rspec
106
+ standard
64
107
 
65
108
  BUNDLED WITH
66
109
  2.3.7