ctx_parser 0.2.0 → 0.2.2
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/CHANGELOG.md +11 -0
- data/README-zh.md +2 -0
- data/README.md +2 -0
- data/lib/ctx_parser/block.rb +1 -1
- data/lib/ctx_parser/cursor.rb +7 -4
- data/lib/ctx_parser/line.rb +2 -1
- data/lib/ctx_parser/values.rb +1 -1
- data/lib/ctx_parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ebe907b20b136d10009fd616c196276d2e8f252dc80ccca829f0470037870cae
|
|
4
|
+
data.tar.gz: ec22c079545cde64af1c90ea3ae6914738ad52df680451229f71f157bcac5137
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 41da2cef0eade558dc4e0abbc4ad2929d0a6f3fa43e9571070cc5974e2d84e13bee4cf1e404fe6ab556eabd9f314e3401a1ca1b480be4c2d408beac4a7c74d36
|
|
7
|
+
data.tar.gz: 71c40107cb0a24d0521984594dd0680214fb066f3985e536105b16f7bb1ff0e2a4cdaf2a2e7c5aa9a6834e339652b73d471e4565153355496728d095d57a5aa6
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Changes to the public contract are recorded here. Versions follow Semantic Versioning.
|
|
4
4
|
|
|
5
|
+
## 0.2.2 (2026-10-18)
|
|
6
|
+
|
|
7
|
+
- Preserve exact block, capture and unresolved source text independently of Ruby's global output separator.
|
|
8
|
+
- Normalize source lines independently of Ruby's global input separator, without an intermediate chomp allocation.
|
|
9
|
+
- Build cursor lines directly during scanning instead of retaining an intermediate source-line array.
|
|
10
|
+
- Return false from IP address validation for incompatible string encodings.
|
|
11
|
+
|
|
12
|
+
## 0.2.1 (2026-10-17)
|
|
13
|
+
|
|
14
|
+
- Update the configuration benchmark to use the Baseline 0.2 vendor parser namespace.
|
|
15
|
+
|
|
5
16
|
## 0.2.0 (2026-10-17)
|
|
6
17
|
|
|
7
18
|
- Validate integer inputs and bound types without implicit object conversion; reject mixed MAC separators.
|
data/README-zh.md
CHANGED
|
@@ -99,6 +99,8 @@ bundle exec rake build
|
|
|
99
99
|
|
|
100
100
|
使用声明的最低 Ruby 版本检查兼容性。方法用途统一使用简明中文注释;复杂实现还需说明业务规则、实现思路及关键分支。保持公开返回值与错误契约。真实回显和凭据不可进入示例、fixture、日志或发布包。
|
|
101
101
|
|
|
102
|
+
执行 `bundle exec ruby -Ilib benchmark/source.rb`,可使用合成输入和语义断言测量游标及文档构建的耗时与对象分配量,无需领域 gem。此类本地测量不代表设备性能。
|
|
103
|
+
|
|
102
104
|
## 发布
|
|
103
105
|
|
|
104
106
|
本目录可独立维护为 [ctx_parser](https://github.com/gatework/ctx_parser) 仓库。更新 `VERSION` 和 `CHANGELOG.md`,运行上述验证与构建命令,检查包内文件,再创建 `vVERSION` 标签。
|
data/README.md
CHANGED
|
@@ -99,6 +99,8 @@ bundle exec rake build
|
|
|
99
99
|
|
|
100
100
|
Use the declared minimum Ruby version for compatibility checks. Document source methods and non-obvious business logic in concise Chinese, preserve public return/error contracts, and never add raw device captures or credentials to examples, fixtures, logs, or release archives.
|
|
101
101
|
|
|
102
|
+
Run `bundle exec ruby -Ilib benchmark/source.rb` to measure cursor and document construction with synthetic input and semantic checks. It needs no domain gems and reports elapsed time and allocated objects; these local measurements do not establish device performance.
|
|
103
|
+
|
|
102
104
|
## Release
|
|
103
105
|
|
|
104
106
|
This directory can be maintained as the independent [ctx_parser](https://github.com/gatework/ctx_parser) repository. Update `VERSION` and `CHANGELOG.md`, run the validation and build commands above, and inspect the packaged file list before tagging `vVERSION`.
|
data/lib/ctx_parser/block.rb
CHANGED
|
@@ -97,7 +97,7 @@ module CtxParser
|
|
|
97
97
|
# 返回属于当前配置块的原始来源行。
|
|
98
98
|
def lines = cursor.lines[index..last_index].freeze
|
|
99
99
|
# 返回配置块或捕获事实对应的精确来源文本。
|
|
100
|
-
def content = lines.map(&:raw).join.freeze
|
|
100
|
+
def content = lines.map(&:raw).join("").freeze
|
|
101
101
|
# 返回当前配置块各来源行的处理状态。
|
|
102
102
|
def states = lines.map { |source| cursor.state(source.index) }.freeze
|
|
103
103
|
# 要求块内所有来源行均已解析或明确忽略。
|
data/lib/ctx_parser/cursor.rb
CHANGED
|
@@ -19,9 +19,12 @@ module CtxParser
|
|
|
19
19
|
|
|
20
20
|
@content = Input.text(content, encoding: :transcode).freeze
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
# scan 直接交付每行,避免同时保留原始行数组与 Line 数组。
|
|
23
|
+
@lines = []
|
|
24
|
+
@content.scan(/[^\r\n]*(?:\r\n|\r|\n)|[^\r\n]+\z/) do |raw|
|
|
25
|
+
@lines << Line.new(index: @lines.size, raw: raw)
|
|
26
|
+
end
|
|
27
|
+
@lines.freeze
|
|
25
28
|
@checksum = Digest::SHA256.hexdigest(@content).freeze
|
|
26
29
|
reset!
|
|
27
30
|
end
|
|
@@ -123,7 +126,7 @@ module CtxParser
|
|
|
123
126
|
end
|
|
124
127
|
|
|
125
128
|
# 拼接未解决来源行,并保留原有格式。
|
|
126
|
-
def unparsed_content = unparsed_lines.map(&:raw).join.freeze
|
|
129
|
+
def unparsed_content = unparsed_lines.map(&:raw).join("").freeze
|
|
127
130
|
|
|
128
131
|
# 将事实快照关联到来源块,不将整个块标记为解析成功。
|
|
129
132
|
def capture(block, data:, path:)
|
data/lib/ctx_parser/line.rb
CHANGED
|
@@ -8,7 +8,8 @@ module CtxParser
|
|
|
8
8
|
raise ArgumentError, "Line index must be nonnegative" unless index.is_a?(Integer) && index >= 0
|
|
9
9
|
raise ArgumentError, "Line content must be text" unless raw.is_a?(String)
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# strip 已移除行结束空白,避免 chomp 依赖宿主进程的 $/。
|
|
12
|
+
@text = raw.strip.freeze
|
|
12
13
|
@indent = raw[/\A[ \t]*/].size
|
|
13
14
|
super(index: index, raw: raw.dup.freeze)
|
|
14
15
|
end
|
data/lib/ctx_parser/values.rb
CHANGED
data/lib/ctx_parser/version.rb
CHANGED