fmt 0.3.3 → 0.3.5
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/lib/fmt/parsers/embed_parser.rb +1 -1
- data/lib/fmt/parsers/macro_parser.rb +1 -1
- data/lib/fmt/parsers/pipeline_parser.rb +1 -1
- data/lib/fmt/parsers/template_parser.rb +18 -12
- data/lib/fmt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c00b656522d9a8a4623d577bc7c0740bb5c6a7f81a4cbc0d6459b844b8177107
|
4
|
+
data.tar.gz: 54c8d23268fb964d2c75af86a55e2011d08699ffd1d004672563abf837833c26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de078ce04f2abd8f67b25a5625d0cf96b418f804bf50e882d9029ae808dba9fa35255bb428e9410b6da120eab9fe3045c66b50555bc50b923822c9af4d40793a
|
7
|
+
data.tar.gz: abf3571f4aa30568112c55ca4861e2526c5aabbe1bd373309f0d86bfa65529ed453eb500c1d80694f8716b67200b016bc3eff51d4c460929061850064907ee43
|
@@ -10,7 +10,7 @@ module Fmt
|
|
10
10
|
# @rbs key: Symbol -- key for embed
|
11
11
|
# @rbs placeholder: String -- placeholder for embed
|
12
12
|
def initialize(urtext = "", key:, placeholder:)
|
13
|
-
@urtext = urtext.to_s
|
13
|
+
@urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?")
|
14
14
|
@key = key
|
15
15
|
@placeholder = placeholder
|
16
16
|
end
|
@@ -8,7 +8,7 @@ module Fmt
|
|
8
8
|
# Constructor
|
9
9
|
# @rbs urtext: String -- original source code
|
10
10
|
def initialize(urtext = "")
|
11
|
-
@urtext = urtext.to_s
|
11
|
+
@urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?")
|
12
12
|
end
|
13
13
|
|
14
14
|
attr_reader :urtext # : String -- original source code
|
@@ -8,7 +8,7 @@ module Fmt
|
|
8
8
|
# Constructor
|
9
9
|
# @rbs urtext: String -- original source code
|
10
10
|
def initialize(urtext = "")
|
11
|
-
@urtext = urtext.to_s
|
11
|
+
@urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?")
|
12
12
|
end
|
13
13
|
|
14
14
|
attr_reader :urtext # : String -- original source code
|
@@ -5,15 +5,15 @@
|
|
5
5
|
module Fmt
|
6
6
|
# Parses a template from a string and builds an AST (Abstract Syntax Tree)
|
7
7
|
class TemplateParser < Parser
|
8
|
-
EMBED_PEEK = %r{(?=#{esc Sigils::EMBED_PREFIX})}
|
9
|
-
PIPELINE_PEEK = %r{(?=[#{Sigils::FORMAT_PREFIX}][^#{Sigils::FORMAT_PREFIX}])}
|
10
|
-
PERCENT_LITERAL = %r{[#{Sigils::FORMAT_PREFIX}]{2}}
|
11
|
-
WHITESPACE = %r{\s}
|
8
|
+
EMBED_PEEK = %r{(?=#{esc Sigils::EMBED_PREFIX})}ou # : Regexp -- detects start of an embed prefix (look ahead)
|
9
|
+
PIPELINE_PEEK = %r{(?=[#{Sigils::FORMAT_PREFIX}][^#{Sigils::FORMAT_PREFIX}])}ou # : Regexp -- detects start of a pipeline (look ahead)
|
10
|
+
PERCENT_LITERAL = %r{[#{Sigils::FORMAT_PREFIX}]{2}}ou # : Regexp -- detects a percent literal
|
11
|
+
WHITESPACE = %r{\s}ou # : Regexp -- detects whitespace
|
12
12
|
|
13
13
|
# Constructor
|
14
14
|
# @rbs urtext: String -- original source code
|
15
15
|
def initialize(urtext = "")
|
16
|
-
@urtext = urtext.to_s
|
16
|
+
@urtext = urtext.to_s.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "?")
|
17
17
|
end
|
18
18
|
|
19
19
|
attr_reader :urtext # : String -- original source code
|
@@ -118,23 +118,29 @@ module Fmt
|
|
118
118
|
def extract_next_pipeline(scanner)
|
119
119
|
return nil unless scanner.skip_until(PIPELINE_PEEK)
|
120
120
|
|
121
|
-
index = scanner.
|
121
|
+
index = scanner.charpos
|
122
122
|
|
123
123
|
until scanner.eos?
|
124
|
-
|
125
|
-
|
124
|
+
len = 1
|
125
|
+
val = nil
|
126
|
+
val = scanner.peek(len += 1) until val&.valid_encoding?
|
127
|
+
if val&.match? PERCENT_LITERAL
|
128
|
+
scanner.pos += len
|
126
129
|
next
|
127
130
|
end
|
128
131
|
|
129
|
-
|
130
|
-
|
132
|
+
len = 0
|
133
|
+
val = nil
|
134
|
+
val = scanner.peek(len += 1) until val&.valid_encoding?
|
135
|
+
case [index, scanner.charpos, val]
|
136
|
+
in [i, pos, Sigils::FORMAT_PREFIX] if i == pos then scanner.getch
|
131
137
|
in [i, pos, Sigils::FORMAT_PREFIX] if i != pos then break
|
132
138
|
in [i, pos, WHITESPACE] if arguments_balanced?(scanner.string[i...pos]) then break
|
133
|
-
else scanner.
|
139
|
+
else scanner.getch
|
134
140
|
end
|
135
141
|
end
|
136
142
|
|
137
|
-
scanner.string[index...scanner.
|
143
|
+
scanner.string[index...scanner.charpos]
|
138
144
|
end
|
139
145
|
|
140
146
|
# Extracts pipelines from the source
|
data/lib/fmt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Hopkins (hopsoft)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|