slimi 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b30b237b1d1e68744ac90e65d148397a5099a4702482286768afd6db8409a484
4
- data.tar.gz: 055a9e297a5467e35c01d7468ab5d5083df89ef8762bb8c92d3074956751675b
3
+ metadata.gz: e7aed4b0083f7ec850df87f869b5687873dcf98fd6f80ab93854c101e0d03098
4
+ data.tar.gz: bfa813fce529081b2eb876e00a9b722feecf914a5741c9ca341ec2aa8d1463ac
5
5
  SHA512:
6
- metadata.gz: 43d27cd7dc20e1de1d744ae87110bec52727d30786c252cd02de8f31cdc7f86fe4d7cc08d005b5c430c73d1ab68176dc0a73e5ae2376722febfb12f4193dfd68
7
- data.tar.gz: 4ab35e06cb00a9b50cbca0dd34797ad281777fba885141cf41709c6e15f24c8c87a99b55d466ce8c31546a464d507e1a476a3b1d6aa5345a770572a9151b5cd0
6
+ metadata.gz: bcd9e3abde25cca87e45eb7244658ed6a99d56e458d2b0b3e1199252eb5621480fb7afc12f6246f3760e13a07a2efaabd80f45e5deb868212228cbf96b582a01
7
+ data.tar.gz: 9fd6030053873163c81f12646461cb502a4d3632e9de4bd8ec77081546081e50fd7e088ad93f23b15666d54007ca1b298f44dd63eeb74b2f5778e716e5e3d6fc
data/.rubocop.yml CHANGED
@@ -6,6 +6,9 @@ AllCops:
6
6
  Layout/LineLength:
7
7
  Enabled: false
8
8
 
9
+ Lint/InterpolationCheck:
10
+ Enabled: false
11
+
9
12
  Metrics:
10
13
  Enabled: false
11
14
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.1 - 2021-12-21
6
+
7
+ ### Fixed
8
+
9
+ - Fix bug that Slimi::Interpolation was not working.
10
+
5
11
  ## 0.1.0 - 2021-12-20
6
12
 
13
+ ### Added
14
+
7
15
  - Initial release.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Slimi
2
2
 
3
3
  [![test](https://github.com/r7kamura/slimi/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/slimi/actions/workflows/test.yml)
4
+ [![](https://badge.fury.io/rb/slimi.svg)](https://rubygems.org/gems/slimi)
4
5
 
5
6
  Yet another implementation for [Slim](https://github.com/slim-template/slim) template language.
6
7
 
@@ -1,34 +1,55 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'strscan'
4
- require 'temple'
5
4
 
6
5
  module Slimi
7
6
  module Filters
8
- class Interpolation < ::Temple::Filter
7
+ class Interpolation
8
+ def initialize(*); end
9
+
10
+ def call(node)
11
+ convert(node)
12
+ end
13
+
14
+ private
15
+
16
+ def convert(value)
17
+ if value.instance_of?(::Array)
18
+ if value[0] == :slimi && value[1] == :interpolate
19
+ on_slimi_interpolate(value[2], value[3], value[4])
20
+ else
21
+ value.map do |element|
22
+ call(element)
23
+ end
24
+ end
25
+ else
26
+ value
27
+ end
28
+ end
29
+
9
30
  # @param [Integer] begin_
10
31
  # @param [Integer] end_
11
32
  # @return [Array] S-expression.
12
- def on_slimi_interpolate(begin_, end_, string)
33
+ def on_slimi_interpolate(begin_, _end_, string)
13
34
  block = [:multi]
14
35
  scanner = ::StringScanner.new(string)
15
36
  until scanner.eos?
16
37
  charpos = scanner.charpos
17
- if (value = scanner.scan(/\\#\{/) || scanner.scan(/([#\\]?[^#\\]*([#\\][^\\\#{][^#\\]*)*)/))
38
+ if (value = scanner.scan(/\\#\{/))
18
39
  block << [:static, value]
19
40
  elsif scanner.scan(/#\{((?>[^{}]|(\{(?>[^{}]|\g<1>)*\}))*)\}/)
20
41
  code = scanner[1]
21
42
  begin2 = begin_ + charpos + 2
22
- end2 = end_ + scanner.charpos - 1
23
43
  if code.start_with?('{') && code.end_with?('}')
24
44
  escape = true
25
45
  code = code[1..-2]
26
46
  begin2 -= 1
27
- end2 -= 1
28
47
  else
29
48
  escape = false
30
49
  end
31
- block << [:slimi, :position, begin2, end2, [:slim, :output, escape, code, [:multi]]]
50
+ block << [:slimi, :position, begin2, begin2 + code.length, [:slim, :output, escape, code, [:multi]]]
51
+ elsif (value = scanner.scan(/([#\\]?[^#\\]*([#\\][^\\\#{][^#\\]*)*)/)) # rubocop:disable Lint/DuplicateBranch
52
+ block << [:static, value]
32
53
  end
33
54
  end
34
55
  block
data/lib/slimi/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Slimi
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-19 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: temple