token-resolver 2.0.18 → 2.0.19
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
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +31 -1
- data/README.md +4 -2
- data/lib/token/resolver/document.rb +64 -0
- data/lib/token/resolver/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +6 -6
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 528ccca8cd81b3442ac406d404a0c64210fd14026fae07c5e1ffa0d62dc5242b
|
|
4
|
+
data.tar.gz: 367a85efda52a84b70631e2ec68c58789b30221454b0dada7f69eeb2d1b07572
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f96385367bf597e3101957c2f1c52e2bb08ed3779116907c33863c67fb8499e5621d3aa9010a79cce6984d301fc485ebabc662ff3ad9d56d62e93c8d6c185b52
|
|
7
|
+
data.tar.gz: b99e13b7b0f0b55c3325dd6f76dba42d44dd5ff7a7f18ee70f6ba7e792b599266b4cd93af39c443c35994f6237054e24a15112aae1fb483bf10cab49eb497026
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,34 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
30
30
|
|
|
31
31
|
### Security
|
|
32
32
|
|
|
33
|
+
## [2.0.19] - 2026-12-03
|
|
34
|
+
|
|
35
|
+
- TAG: [v2.0.19][2.0.19t]
|
|
36
|
+
- COVERAGE: 99.67% -- 304/305 lines in 11 files
|
|
37
|
+
- BRANCH COVERAGE: 98.63% -- 72/73 branches in 11 files
|
|
38
|
+
- 98.41% documented
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- kettle-jem-template-20261025-001 - Duel performance regression guards: the
|
|
43
|
+
Perf workflow compares each pull request, each push to main, and, on a
|
|
44
|
+
schedule, the last release, and `rake duel` compares local changes, with
|
|
45
|
+
the benchmarks in `duel/`.
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Replace per-character Parslet scanning in `Token::Resolver::Document` with a compiled `Regexp` scanner (keeping Parslet as a `RegexpError` fallback), cutting parse+resolve CPU time by ~100× and allocations by ~80×
|
|
50
|
+
- [kc] kettle-jem/template: updated 19 project files since the last release:
|
|
51
|
+
- code and tests (1)
|
|
52
|
+
- dependencies (10)
|
|
53
|
+
- documentation (1)
|
|
54
|
+
- other (3)
|
|
55
|
+
- workflows (4)
|
|
56
|
+
|
|
57
|
+
- kettle-jem-template-20261203-007 - Split non-Linux CI lanes (macOS and
|
|
58
|
+
Windows) out of `.github/workflows/current.yml` into `.github/workflows/platforms.yml`
|
|
59
|
+
(with `fail-fast: false`) so macOS runner starvation does not turn the Current MRI badge red.
|
|
60
|
+
|
|
33
61
|
## [2.0.18] - 2026-12-03
|
|
34
62
|
|
|
35
63
|
- TAG: [v2.0.18][2.0.18t]
|
|
@@ -522,7 +550,9 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
522
550
|
|
|
523
551
|
### Security
|
|
524
552
|
|
|
525
|
-
[Unreleased]: https://github.com/kettle-dev/token-resolver/compare/v2.0.
|
|
553
|
+
[Unreleased]: https://github.com/kettle-dev/token-resolver/compare/v2.0.19...HEAD
|
|
554
|
+
[2.0.19]: https://github.com/kettle-dev/token-resolver/compare/v2.0.18...v2.0.19
|
|
555
|
+
[2.0.19t]: https://github.com/kettle-dev/token-resolver/releases/tag/v2.0.19
|
|
526
556
|
[2.0.18]: https://github.com/kettle-dev/token-resolver/compare/v2.0.17...v2.0.18
|
|
527
557
|
[2.0.18t]: https://github.com/kettle-dev/token-resolver/releases/tag/v2.0.18
|
|
528
558
|
[2.0.17]: https://github.com/kettle-dev/token-resolver/compare/v2.0.16...v2.0.17
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# 🪙 Token::Resolver
|
|
4
4
|
|
|
5
|
-
[![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: AGPL-3.0-only OR PolyForm-Small-Business-1.0.0][📄license-img]][📄license] [![Total downloads][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Heads][🚎3-hd-wfi]][🚎3-hd-wf] [![CI Runtime Dependencies @ HEAD][🚎12-crh-wfi]][🚎12-crh-wf] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI Truffle Ruby][🚎9-t-wfi]][🚎9-t-wf] [![CI JRuby][🚎10-j-wfi]][🚎10-j-wf] [![Deps Locked][🚎13-🔒️-wfi]][🚎13-🔒️-wf] [![Deps Unlocked][🚎14-🔓️-wfi]][🚎14-🔓️-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf] [![CI Style][🚎5-st-wfi]][🚎5-st-wf]
|
|
5
|
+
[![Version][👽versioni]][👽version] [![Ruby Users Forum][✉️ruby-forum-top-img]][✉️ruby-forum] [![GitHub tag (latest SemVer)][⛳️tag-img]][⛳️tag] [![License: AGPL-3.0-only OR PolyForm-Small-Business-1.0.0][📄license-img]][📄license] [![Total downloads][👽dl-ranki]][👽dl-rank] [![CodeCov Test Coverage][🏀codecovi]][🏀codecov] [![Coveralls Test Coverage][🏀coveralls-img]][🏀coveralls] [![QLTY Test Coverage][🏀qlty-covi]][🏀qlty-cov] [![QLTY Maintainability][🏀qlty-mnti]][🏀qlty-mnt] [![CI Heads][🚎3-hd-wfi]][🚎3-hd-wf] [![CI Runtime Dependencies @ HEAD][🚎12-crh-wfi]][🚎12-crh-wf] [![CI Current][🚎11-c-wfi]][🚎11-c-wf] [![CI Truffle Ruby][🚎9-t-wfi]][🚎9-t-wf] [![CI JRuby][🚎10-j-wfi]][🚎10-j-wf] [![Deps Locked][🚎13-🔒️-wfi]][🚎13-🔒️-wf] [![Deps Unlocked][🚎14-🔓️-wfi]][🚎14-🔓️-wf] [![CI Test Coverage][🚎2-cov-wfi]][🚎2-cov-wf] [![CI Style][🚎5-st-wfi]][🚎5-st-wf] [![Duel][⚔️duel-img]][⚔️duel]
|
|
6
6
|
|
|
7
7
|
`if ci_badges.map(&:color).detect { it != "green"}` ☝️ [let me know on Discord][✉️discord-invite] or [RubyForum][✉️ruby-forum], as I may have missed the notification.
|
|
8
8
|
|
|
@@ -502,7 +502,7 @@ Thanks for RTFM. ☺️
|
|
|
502
502
|
[📌gitmoji]: https://gitmoji.dev
|
|
503
503
|
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
504
504
|
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
505
|
-
[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.
|
|
505
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-0.305-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
506
506
|
[🔐security]: https://github.com/kettle-dev/token-resolver/blob/main/SECURITY.md
|
|
507
507
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
508
508
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
@@ -512,6 +512,8 @@ Thanks for RTFM. ☺️
|
|
|
512
512
|
[📄license-compat]: https://www.apache.org/legal/resolved.html#category-x
|
|
513
513
|
[📄license-compat-img]: https://img.shields.io/badge/Apache_Incompatible:_Category_X-%E2%9C%97-C0392B.svg?style=flat&logo=Apache
|
|
514
514
|
|
|
515
|
+
[⚔️duel]: https://github.com/sferik/duel-ruby
|
|
516
|
+
[⚔️duel-img]: https://raw.githubusercontent.com/sferik/duel-ruby/main/assets/badge.svg
|
|
515
517
|
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
|
|
516
518
|
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-259D6C.svg?style=flat
|
|
517
519
|
[🚎yard-current]: http://rubydoc.info/gems/token-resolver
|
|
@@ -63,12 +63,51 @@ module Token
|
|
|
63
63
|
tokens.empty?
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
@scanner_cache = {} # rubocop:disable ThreadSafety/MutableClassInstanceVariable
|
|
67
|
+
@scanner_cache_mutex = Mutex.new
|
|
68
|
+
|
|
69
|
+
class << self
|
|
70
|
+
# Build (or retrieve from cache) compiled Regexp matchers for a Config.
|
|
71
|
+
#
|
|
72
|
+
# @param config [Config] Token configuration
|
|
73
|
+
# @return [Array(Regexp, Regexp)] [token_pattern, separator_pattern]
|
|
74
|
+
def compiled_patterns(config)
|
|
75
|
+
@scanner_cache_mutex.synchronize do
|
|
76
|
+
@scanner_cache[config] ||= build_patterns(config)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
private
|
|
81
|
+
|
|
82
|
+
def build_patterns(config)
|
|
83
|
+
terminators = ([config.post] + config.separators).uniq
|
|
84
|
+
term_lookahead = "(?!#{terminators.map { |t| Regexp.escape(t) }.join("|")})"
|
|
85
|
+
seg_re = "(?:#{term_lookahead}#{config.segment_pattern})+"
|
|
86
|
+
sep_re = config.separators.map { |s| Regexp.escape(s) }.join("|")
|
|
87
|
+
min_rep = config.min_segments - 1
|
|
88
|
+
max_rep = config.max_segments ? (config.max_segments - 1).to_s : ""
|
|
89
|
+
|
|
90
|
+
token_re = Regexp.new(
|
|
91
|
+
"\\G#{Regexp.escape(config.pre)}(#{seg_re}(?:(?:#{sep_re})#{seg_re}){#{min_rep},#{max_rep}})#{Regexp.escape(config.post)}"
|
|
92
|
+
)
|
|
93
|
+
sep_split_re = Regexp.new("(?:#{sep_re})")
|
|
94
|
+
[token_re, sep_split_re]
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
66
98
|
private
|
|
67
99
|
|
|
68
100
|
def parse(input)
|
|
69
101
|
# Fast-path: if input doesn't contain the pre delimiter, no tokens possible
|
|
70
102
|
return [Node::Text.new(input)] if input.nil? || input.empty? || !input.include?(@config.pre)
|
|
71
103
|
|
|
104
|
+
scan(input)
|
|
105
|
+
rescue RegexpError
|
|
106
|
+
# Fallback to Parslet if a custom segment_pattern isn't directly embeddable
|
|
107
|
+
parse_with_parslet(input)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def parse_with_parslet(input)
|
|
72
111
|
parser_class = Grammar.build(@config)
|
|
73
112
|
tree = parser_class.new.parse(input)
|
|
74
113
|
Transform.apply(tree, @config)
|
|
@@ -76,6 +115,31 @@ module Token
|
|
|
76
115
|
# Grammar should never fail, but if it does, treat entire input as text
|
|
77
116
|
[Node::Text.new(input)]
|
|
78
117
|
end
|
|
118
|
+
|
|
119
|
+
def scan(input)
|
|
120
|
+
token_re, sep_split_re = self.class.compiled_patterns(@config)
|
|
121
|
+
pre = @config.pre
|
|
122
|
+
nodes = []
|
|
123
|
+
text_start = 0
|
|
124
|
+
search_pos = 0
|
|
125
|
+
len = input.length
|
|
126
|
+
|
|
127
|
+
while search_pos < len && (hit = input.index(pre, search_pos))
|
|
128
|
+
match = token_re.match(input, hit)
|
|
129
|
+
if match
|
|
130
|
+
nodes << Node::Text.new(input[text_start...hit]) if hit > text_start
|
|
131
|
+
segments = match[1].split(sep_split_re, -1)
|
|
132
|
+
nodes << Node::Token.new(segments, @config)
|
|
133
|
+
text_start = match.end(0)
|
|
134
|
+
search_pos = text_start
|
|
135
|
+
else
|
|
136
|
+
search_pos = hit + 1
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
nodes << Node::Text.new(input[text_start..]) if text_start < len
|
|
141
|
+
nodes
|
|
142
|
+
end
|
|
79
143
|
end
|
|
80
144
|
end
|
|
81
145
|
end
|
|
@@ -5,7 +5,7 @@ module Token
|
|
|
5
5
|
# Version namespace for this gem.
|
|
6
6
|
module Version
|
|
7
7
|
# Current gem version.
|
|
8
|
-
VERSION = "2.0.
|
|
8
|
+
VERSION = "2.0.19"
|
|
9
9
|
end
|
|
10
10
|
# Current gem version exposed at the traditional constant location.
|
|
11
11
|
VERSION = Version::VERSION # Traditional Constant Location
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: token-resolver
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Peter H. Boling
|
|
@@ -88,7 +88,7 @@ dependencies:
|
|
|
88
88
|
-
|
|
89
89
|
- ">="
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
|
-
version: 3.1.
|
|
91
|
+
version: 3.1.39
|
|
92
92
|
type: :development
|
|
93
93
|
prerelease: false
|
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -100,7 +100,7 @@ dependencies:
|
|
|
100
100
|
-
|
|
101
101
|
- ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 3.1.
|
|
103
|
+
version: 3.1.39
|
|
104
104
|
- !ruby/object:Gem::Dependency
|
|
105
105
|
name: bundler-audit
|
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -345,10 +345,10 @@ licenses:
|
|
|
345
345
|
- PolyForm-Small-Business-1.0.0
|
|
346
346
|
metadata:
|
|
347
347
|
homepage_uri: "https://token-resolver.galtzo.com/"
|
|
348
|
-
source_code_uri: "https://github.com/kettle-dev/token-resolver/tree/v2.0.
|
|
349
|
-
changelog_uri: "https://github.com/kettle-dev/token-resolver/blob/v2.0.
|
|
348
|
+
source_code_uri: "https://github.com/kettle-dev/token-resolver/tree/v2.0.19"
|
|
349
|
+
changelog_uri: "https://github.com/kettle-dev/token-resolver/blob/v2.0.19/CHANGELOG.md"
|
|
350
350
|
bug_tracker_uri: "https://github.com/kettle-dev/token-resolver/issues"
|
|
351
|
-
documentation_uri: "https://www.rubydoc.info/gems/token-resolver/2.0.
|
|
351
|
+
documentation_uri: "https://www.rubydoc.info/gems/token-resolver/2.0.19"
|
|
352
352
|
funding_uri: "https://github.com/sponsors/pboling"
|
|
353
353
|
wiki_uri: "https://github.com/kettle-dev/token-resolver/wiki"
|
|
354
354
|
news_uri: "https://www.railsbling.com/tags/token-resolver"
|
metadata.gz.sig
CHANGED
|
Binary file
|