tcepsni 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +2 -2
- data/lib/tcepsni/parser.rb +170 -96
- data/lib/tcepsni/vendor/activesupport/ordered_options.rb +9 -6
- data/lib/tcepsni/vendor/ipaddr.rb +1 -2
- data/lib/tcepsni/vendor/pathname.rb +1 -3
- data/lib/tcepsni/vendor/rails/paths/root.rb +13 -6
- data/lib/tcepsni/vendor/string_scanner.rb +18 -13
- data/lib/tcepsni/version.rb +1 -1
- data/lib/tcepsni.rb +2 -6
- data/sig/tcepsni.gen.rbs +25 -34
- data/sig/tcepsni.rbs +34 -3
- data/tcepsni.gemspec +14 -2
- metadata +11 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 93737301f5ec57317f38a815c3f51d40c2227668290e3baa6b642ffd82fb2396
|
|
4
|
+
data.tar.gz: ede377edc499d3469a7fbf6d2c5bea2e2e88568821c71cd5c4de937d72b20d7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2b2779e7457a92b0678b695c17922e9e21960aa812d9ddf940697a80184541f318f457dae3a437be3bff93ead01cc95c08bd7e0cc3dd49fab8d954bdb518abd
|
|
7
|
+
data.tar.gz: 3ccb55ba0d3906d0722b0e39d7c69c5888749eb606cf671255aa7c7226dabddc8deaf6b09176fa6171d2e163da3574235b9d44f220bd9960a44b13890ec420cc
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.4.0 - 2024-08-04
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
* `parse_string` now parses leading double quote
|
|
10
|
+
* `parse_array` now parses leading bracket
|
|
11
|
+
* `parse_hash` now parses leading brace
|
|
12
|
+
* `parse_object` now consider vendors
|
|
13
|
+
* `parse_object`, `parse_integer`, `parse_expression`, and `parse_attributes` do not raise errors
|
|
14
|
+
|
|
15
|
+
### Removed
|
|
16
|
+
|
|
17
|
+
* `Tcepsni::Class#encoding?`
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
* Simple `Range` support and `parse_range`
|
|
22
|
+
* `parse_float`
|
|
23
|
+
* `parse_time`
|
|
24
|
+
* `parse_attribute`
|
|
25
|
+
* `parse_encoding`
|
|
26
|
+
|
|
27
|
+
## 0.3.1 - 2024-07-21
|
|
28
|
+
|
|
29
|
+
Update gemspec fields etc.
|
|
30
|
+
There should be no API changes.
|
|
31
|
+
|
|
5
32
|
## 0.3.0 - 2023-11-18
|
|
6
33
|
|
|
7
34
|
### Changed
|
data/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Tcepsni has a parsing method `Tcepsni.parse(str)`, which returns a parsed Ruby o
|
|
|
15
15
|
## Development
|
|
16
16
|
|
|
17
17
|
After checking out the repo, run `bin/setup` to install dependencies.
|
|
18
|
-
Then, run `rake test
|
|
18
|
+
Then, run `rake test` to run the tests.
|
|
19
19
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
20
20
|
|
|
21
21
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
@@ -27,7 +27,7 @@ Bug reports and pull requests are welcome.
|
|
|
27
27
|
|
|
28
28
|
## License
|
|
29
29
|
|
|
30
|
-
Copyright 2023 gemmaro.
|
|
30
|
+
Copyright 2023, 2024 gemmaro.
|
|
31
31
|
|
|
32
32
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
|
|
33
33
|
You may obtain a copy of the License at [Apache Software Foundation - Apache License, Version 2.0][asl].
|
data/lib/tcepsni/parser.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'forwardable'
|
|
|
3
3
|
|
|
4
4
|
module Tcepsni
|
|
5
5
|
class Parser
|
|
6
|
+
FAIL = Data.define
|
|
7
|
+
|
|
6
8
|
def initialize(source, vendors:)
|
|
7
9
|
@scanner = ::StringScanner.new(source)
|
|
8
10
|
@vendors = vendors.flat_map { |vendor| [*vendor.dependencies, vendor] }.uniq
|
|
@@ -10,152 +12,224 @@ module Tcepsni
|
|
|
10
12
|
|
|
11
13
|
# If it returned nil when failed, it collides with normal nil value.
|
|
12
14
|
def parse_expression
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
pos = @scanner.pos
|
|
29
|
-
@vendors.select { |vendor| vendor.object? }.each do |vendor|
|
|
30
|
-
begin
|
|
31
|
-
@scanner.pos = pos
|
|
32
|
-
return vendor.parse(self)
|
|
33
|
-
rescue Error
|
|
34
|
-
next
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
@scanner.pos = pos
|
|
38
|
-
parse_object
|
|
39
|
-
else
|
|
40
|
-
if (digits = @scanner.scan(/\d+/))
|
|
41
|
-
int = Integer(digits)
|
|
42
|
-
if @scanner.skip('.')
|
|
43
|
-
int2 = parse_integer
|
|
44
|
-
Float("#{int}.#{int2}")
|
|
45
|
-
elsif digits.size == 4 && @scanner.skip(/-(?<month>[01]\d)-(?<day>\d\d) (?<hour>[012]\d):(?<minute>[0-5]\d):(?<second>[0-5]\d) (?<zone>[+-]\d\d\d\d)/)
|
|
46
|
-
Time.new(Integer(int), @scanner[:month], @scanner[:day],
|
|
47
|
-
@scanner[:hour], @scanner[:minute], @scanner[:second],
|
|
48
|
-
@scanner[:zone])
|
|
49
|
-
else
|
|
50
|
-
int
|
|
51
|
-
end
|
|
52
|
-
else
|
|
53
|
-
parse_class
|
|
54
|
-
end
|
|
55
|
-
end
|
|
15
|
+
FAIL == (expr = parse_nil) or return expr
|
|
16
|
+
FAIL == (expr = parse_false) or return expr
|
|
17
|
+
(expr = (parse_true or
|
|
18
|
+
parse_symbol or
|
|
19
|
+
parse_string or
|
|
20
|
+
parse_array or
|
|
21
|
+
parse_hash or
|
|
22
|
+
parse_encoding or
|
|
23
|
+
parse_object or
|
|
24
|
+
parse_range or
|
|
25
|
+
parse_float or
|
|
26
|
+
parse_time or
|
|
27
|
+
parse_integer or
|
|
28
|
+
parse_class)) and return expr
|
|
29
|
+
FAIL
|
|
56
30
|
end
|
|
57
31
|
|
|
58
32
|
alias parse parse_expression
|
|
59
33
|
|
|
34
|
+
def parse_nil
|
|
35
|
+
@scanner.skip(/nil\b/) or return FAIL
|
|
36
|
+
nil
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def parse_true
|
|
40
|
+
@scanner.skip(/true\b/) and true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def parse_false
|
|
44
|
+
@scanner.skip(/false\b/) or return FAIL
|
|
45
|
+
false
|
|
46
|
+
end
|
|
47
|
+
|
|
60
48
|
def parse_integer
|
|
61
|
-
|
|
62
|
-
Integer(int)
|
|
49
|
+
@scanner.scan(/\d+/)&.to_i
|
|
63
50
|
end
|
|
64
51
|
|
|
65
52
|
def parse_identifier
|
|
66
|
-
|
|
67
|
-
id.intern
|
|
53
|
+
@scanner.scan(/[A-Za-z_][A-Za-z0-9_]*/)&.intern
|
|
68
54
|
end
|
|
69
55
|
|
|
70
|
-
def
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
result << @scanner.getch
|
|
56
|
+
def parse_symbol
|
|
57
|
+
pos = @scanner.pos
|
|
58
|
+
@scanner.skip(':') and
|
|
59
|
+
begin
|
|
60
|
+
(id = parse_identifier) and return id
|
|
61
|
+
@scanner.skip('[]') and return :[]
|
|
62
|
+
@scanner.pos = pos
|
|
63
|
+
return
|
|
79
64
|
end
|
|
80
|
-
|
|
81
|
-
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def parse_string
|
|
68
|
+
pos = @scanner.pos
|
|
69
|
+
@scanner.skip('"') or return
|
|
70
|
+
result = +''
|
|
71
|
+
result <<
|
|
72
|
+
if @scanner.skip('"') then return result
|
|
73
|
+
elsif @scanner.skip('\\"') then '"'
|
|
74
|
+
else @scanner.getch
|
|
75
|
+
end until @scanner.eos?
|
|
76
|
+
@scanner.pos = pos
|
|
77
|
+
nil
|
|
82
78
|
end
|
|
83
79
|
|
|
84
80
|
def parse_array
|
|
81
|
+
pos = @scanner.pos
|
|
82
|
+
@scanner.skip('[') or return
|
|
85
83
|
result = []
|
|
86
84
|
until @scanner.eos?
|
|
87
|
-
|
|
85
|
+
FAIL == (expr = parse_expression) and break
|
|
86
|
+
result << expr
|
|
88
87
|
@scanner.skip(', ') or break
|
|
89
88
|
end
|
|
90
|
-
@scanner.skip(']')
|
|
91
|
-
|
|
89
|
+
if @scanner.skip(']')
|
|
90
|
+
result
|
|
91
|
+
else
|
|
92
|
+
@scanner.pos = pos
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
92
95
|
end
|
|
93
96
|
|
|
94
97
|
def parse_hash
|
|
98
|
+
pos = @scanner.pos
|
|
99
|
+
@scanner.skip('{') or return
|
|
95
100
|
result = {}
|
|
96
101
|
until @scanner.eos?
|
|
97
|
-
key = parse_expression
|
|
98
|
-
@scanner.skip('=>')
|
|
99
|
-
|
|
102
|
+
FAIL == (key = parse_expression) and break
|
|
103
|
+
@scanner.skip('=>') and
|
|
104
|
+
FAIL != (value = parse_expression) or
|
|
105
|
+
begin
|
|
106
|
+
@scanner.pos = pos
|
|
107
|
+
return
|
|
108
|
+
end
|
|
100
109
|
result[key] = value
|
|
101
110
|
@scanner.skip(', ') or break
|
|
102
111
|
end
|
|
103
|
-
@scanner.skip('}')
|
|
104
|
-
|
|
112
|
+
if @scanner.skip('}')
|
|
113
|
+
result
|
|
114
|
+
else
|
|
115
|
+
@scanner.pos = pos
|
|
116
|
+
return
|
|
117
|
+
end
|
|
105
118
|
end
|
|
106
119
|
|
|
107
120
|
def parse_class
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
121
|
+
pos = @scanner.pos
|
|
122
|
+
namespaces = [(parse_capitalized_identifier or return)]
|
|
123
|
+
namespaces <<
|
|
124
|
+
begin
|
|
125
|
+
parse_capitalized_identifier or
|
|
126
|
+
begin
|
|
127
|
+
@scanner.pos = pos
|
|
128
|
+
return
|
|
129
|
+
end
|
|
130
|
+
end while @scanner.skip('::')
|
|
114
131
|
*namespaces, name = namespaces
|
|
115
|
-
Tcepsni::Class.new(name
|
|
132
|
+
Tcepsni::Class.new(name:, namespaces:)
|
|
116
133
|
end
|
|
117
134
|
|
|
118
135
|
def parse_capitalized_identifier
|
|
119
|
-
|
|
120
|
-
|
|
136
|
+
@scanner.scan(/[A-Z][A-Za-z0-9_]*/)&.intern
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def parse_encoding
|
|
140
|
+
@scanner.skip(/#<Encoding:(?<name>[^>]+)>/) && Encoding.find(@scanner[:name])
|
|
121
141
|
end
|
|
122
142
|
|
|
123
143
|
def parse_object
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Encoding.find(@scanner[:name])
|
|
129
|
-
else
|
|
130
|
-
memory_reference = parse_memory_reference
|
|
131
|
-
attributes = parse_attributes
|
|
132
|
-
Tcepsni::Object.new(klass: klass, memory_reference: memory_reference, attributes: attributes)
|
|
144
|
+
pos = @scanner.pos
|
|
145
|
+
@scanner.skip('#<') or return
|
|
146
|
+
@vendors.select { |vendor| vendor.object? }.each do |vendor|
|
|
147
|
+
expr = vendor.parse(self) and return expr
|
|
133
148
|
end
|
|
149
|
+
|
|
150
|
+
klass = parse_class and
|
|
151
|
+
memory_reference = parse_memory_reference and
|
|
152
|
+
attributes = parse_attributes and
|
|
153
|
+
@scanner.skip('>') and
|
|
154
|
+
Tcepsni::Object.new(klass:, memory_reference:, attributes:) or
|
|
155
|
+
begin
|
|
156
|
+
@scanner.pos = pos
|
|
157
|
+
nil
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def parse_attribute
|
|
162
|
+
pos = @scanner.pos
|
|
163
|
+
@scanner.skip('@') and
|
|
164
|
+
key = parse_identifier and
|
|
165
|
+
@scanner.skip('=') and
|
|
166
|
+
if FAIL == (value = parse_expression)
|
|
167
|
+
@scanner.pos = pos
|
|
168
|
+
return
|
|
169
|
+
else
|
|
170
|
+
return key, value
|
|
171
|
+
end
|
|
134
172
|
end
|
|
135
173
|
|
|
136
174
|
def parse_attributes
|
|
175
|
+
@scanner.match?('>') and return {}
|
|
176
|
+
pos = @scanner.pos
|
|
137
177
|
attributes = {}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
@scanner.
|
|
143
|
-
attributes[key.intern] = parse_expression
|
|
144
|
-
unless @scanner.skip(',')
|
|
145
|
-
@scanner.skip('>') or raise Error, "no object closer: #{@scanner.inspect}"
|
|
178
|
+
while @scanner.skip(' ')
|
|
179
|
+
key, value = (parse_attribute or return)
|
|
180
|
+
attributes[key] = value
|
|
181
|
+
@scanner.skip(',') or
|
|
182
|
+
if @scanner.match?('>')
|
|
146
183
|
break
|
|
184
|
+
else
|
|
185
|
+
@scanner.pos = pos
|
|
186
|
+
return
|
|
147
187
|
end
|
|
148
|
-
end
|
|
149
188
|
end
|
|
150
189
|
attributes
|
|
151
190
|
end
|
|
152
191
|
|
|
153
192
|
def parse_memory_reference
|
|
154
|
-
@scanner.skip(/:(?<
|
|
155
|
-
Integer(@scanner[:
|
|
193
|
+
@scanner.skip(/:(?<ref>0x[0-9a-f]{16})/) or return
|
|
194
|
+
Integer(@scanner[:ref])
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def parse_range
|
|
198
|
+
pos = @scanner.pos
|
|
199
|
+
int = parse_integer and
|
|
200
|
+
if @scanner.skip("..") && (int2 = parse_integer)
|
|
201
|
+
int..int2
|
|
202
|
+
else
|
|
203
|
+
@scanner.pos = pos
|
|
204
|
+
nil
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def parse_float
|
|
209
|
+
pos = @scanner.pos
|
|
210
|
+
int = parse_integer and
|
|
211
|
+
if @scanner.skip('.') && (int2 = parse_integer)
|
|
212
|
+
Float("#{int}.#{int2}")
|
|
213
|
+
else
|
|
214
|
+
@scanner.pos = pos
|
|
215
|
+
nil
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
def parse_time
|
|
220
|
+
pos = @scanner.pos
|
|
221
|
+
int = parse_integer and
|
|
222
|
+
if int <= 9999 && @scanner.skip(/-(?<month>[01]\d)-(?<day>\d\d) (?<hour>[012]\d):(?<minute>[0-5]\d):(?<second>[0-5]\d) (?<zone>[+-]\d\d\d\d)/)
|
|
223
|
+
Time.new(int, @scanner[:month], @scanner[:day],
|
|
224
|
+
@scanner[:hour], @scanner[:minute], @scanner[:second],
|
|
225
|
+
@scanner[:zone])
|
|
226
|
+
else
|
|
227
|
+
@scanner.pos = pos
|
|
228
|
+
nil
|
|
229
|
+
end
|
|
156
230
|
end
|
|
157
231
|
|
|
158
232
|
extend Forwardable
|
|
159
|
-
def_delegators :@scanner, :skip, :[]
|
|
233
|
+
def_delegators :@scanner, :skip, :[], :match?, :pos, :pos=
|
|
160
234
|
end
|
|
161
235
|
end
|
|
@@ -5,13 +5,16 @@ module Tcepsni
|
|
|
5
5
|
module ActiveSupport
|
|
6
6
|
class OrderedOptions
|
|
7
7
|
def self.parse(parser)
|
|
8
|
-
parser.
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
pos = parser.pos
|
|
9
|
+
parser.skip('ActiveSupport::OrderedOptions ') and
|
|
10
|
+
hash = parser.parse_hash and
|
|
11
|
+
parser.skip('>') or
|
|
12
|
+
begin
|
|
13
|
+
parser.pos = pos
|
|
14
|
+
return
|
|
15
|
+
end
|
|
11
16
|
options = ::ActiveSupport::OrderedOptions.new
|
|
12
|
-
hash.each
|
|
13
|
-
options[key] = val
|
|
14
|
-
end
|
|
17
|
+
hash.each { |key, val| options[key] = val }
|
|
15
18
|
options
|
|
16
19
|
end
|
|
17
20
|
|
|
@@ -4,8 +4,7 @@ module Tcepsni
|
|
|
4
4
|
module Vendor
|
|
5
5
|
class IPAddr
|
|
6
6
|
def self.parse(parser)
|
|
7
|
-
parser.skip(/IPAddr: IPv[46]:(?<addr>[^>]+)>/)
|
|
8
|
-
::IPAddr.new(parser[:addr])
|
|
7
|
+
parser.skip(/IPAddr: IPv[46]:(?<addr>[^>]+)>/) && ::IPAddr.new(parser[:addr])
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
def self.object?
|
|
@@ -4,9 +4,7 @@ module Tcepsni
|
|
|
4
4
|
module Vendor
|
|
5
5
|
class Pathname
|
|
6
6
|
def self.parse(parser)
|
|
7
|
-
parser.skip(
|
|
8
|
-
parser.skip(/(?<path>[^>]+)>/) or raise Error, 'invalid path string and closer'
|
|
9
|
-
::Pathname.new(parser[:path])
|
|
7
|
+
parser.skip(/Pathname:(?<path>[^>]+)>/) && ::Pathname.new(parser[:path])
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
def self.object?
|
|
@@ -13,14 +13,21 @@ module Tcepsni
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.parse(parser)
|
|
16
|
-
parser.skip('Rails::Paths::Root') or
|
|
17
|
-
|
|
18
|
-
if parser.
|
|
19
|
-
|
|
16
|
+
parser.skip('Rails::Paths::Root') or return
|
|
17
|
+
pos = parser.pos
|
|
18
|
+
if (memory_reference = parser.parse_memory_reference)
|
|
19
|
+
if parser.skip(' ...>')
|
|
20
|
+
Tcepsni::Vendor::Rails::Paths::Root.new(memory_reference, {})
|
|
21
|
+
elsif (attrs = parser.parse_attributes) && parser.skip('>')
|
|
22
|
+
Tcepsni::Vendor::Rails::Paths::Root.new(memory_reference, attrs)
|
|
23
|
+
else
|
|
24
|
+
parser.pos = pos
|
|
25
|
+
return
|
|
26
|
+
end
|
|
20
27
|
else
|
|
21
|
-
|
|
28
|
+
parser.pos = pos
|
|
29
|
+
nil
|
|
22
30
|
end
|
|
23
|
-
Tcepsni::Vendor::Rails::Paths::Root.new(memory_reference, attributes)
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
def self.object?
|
|
@@ -4,23 +4,28 @@ module Tcepsni
|
|
|
4
4
|
attr_reader :pos, :total, :scanned, :rest
|
|
5
5
|
|
|
6
6
|
def initialize(pos:, total:, scanned:, rest:)
|
|
7
|
-
@pos
|
|
8
|
-
@total
|
|
7
|
+
@pos = pos
|
|
8
|
+
@total = total
|
|
9
9
|
@scanned = scanned
|
|
10
|
-
@rest
|
|
10
|
+
@rest = rest
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def self.parse(parser)
|
|
14
|
-
parser.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
pos = parser.pos
|
|
15
|
+
parser.skip('StringScanner ') and
|
|
16
|
+
pos = parser.parse_integer and
|
|
17
|
+
parser.skip('/') and
|
|
18
|
+
total = parser.parse_integer and
|
|
19
|
+
parser.skip(' ') and
|
|
20
|
+
scanned = parser.parse_string and
|
|
21
|
+
parser.skip(' @ ') and
|
|
22
|
+
rest = parser.parse_string and
|
|
23
|
+
parser.skip('>') and
|
|
24
|
+
Tcepsni::Vendor::StringScanner.new(pos:, total:, scanned:, rest:) or
|
|
25
|
+
begin
|
|
26
|
+
parser.pos = pos
|
|
27
|
+
nil
|
|
28
|
+
end
|
|
24
29
|
end
|
|
25
30
|
|
|
26
31
|
def self.dependencies
|
data/lib/tcepsni/version.rb
CHANGED
data/lib/tcepsni.rb
CHANGED
|
@@ -2,10 +2,10 @@ require_relative 'tcepsni/version'
|
|
|
2
2
|
require_relative 'tcepsni/parser'
|
|
3
3
|
|
|
4
4
|
module Tcepsni
|
|
5
|
-
|
|
5
|
+
Error = Class.new(StandardError)
|
|
6
6
|
|
|
7
7
|
def self.parse(str, vendors: [])
|
|
8
|
-
Parser.new(str, vendors:
|
|
8
|
+
Parser.new(str, vendors:).parse
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
class Class
|
|
@@ -15,10 +15,6 @@ module Tcepsni
|
|
|
15
15
|
@name = name
|
|
16
16
|
@namespaces = namespaces
|
|
17
17
|
end
|
|
18
|
-
|
|
19
|
-
def encoding?
|
|
20
|
-
@name == :Encoding && @namespaces.empty?
|
|
21
|
-
end
|
|
22
18
|
end
|
|
23
19
|
|
|
24
20
|
class Object
|
data/sig/tcepsni.gen.rbs
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
# Classes
|
|
4
4
|
module Tcepsni
|
|
5
5
|
VERSION: String
|
|
6
|
+
Error: Class
|
|
6
7
|
|
|
7
8
|
# def self.parse: (String str) -> untyped
|
|
8
9
|
|
|
9
10
|
class Parser
|
|
11
|
+
FAIL: untyped
|
|
10
12
|
extend Forwardable
|
|
11
13
|
@scanner: StringScanner
|
|
12
14
|
@vendors: Array[Array[untyped]]
|
|
@@ -24,6 +26,15 @@ module Tcepsni
|
|
|
24
26
|
# def parse_object: -> Object
|
|
25
27
|
# def parse_attributes: -> Hash[Symbol, untyped]
|
|
26
28
|
# def parse_memory_reference: -> Integer
|
|
29
|
+
# def parse_nil: -> nil
|
|
30
|
+
# def parse_true: -> true?
|
|
31
|
+
# def parse_false: -> false
|
|
32
|
+
# def parse_symbol: -> Symbol
|
|
33
|
+
# def parse_range: -> Range?
|
|
34
|
+
# def parse_float: -> Float?
|
|
35
|
+
# def parse_time: -> Time?
|
|
36
|
+
# def parse_encoding: -> Encoding?
|
|
37
|
+
# def parse_attribute: -> [Symbol, untyped]?
|
|
27
38
|
end
|
|
28
39
|
|
|
29
40
|
class Class
|
|
@@ -48,47 +59,27 @@ module Tcepsni
|
|
|
48
59
|
|
|
49
60
|
module Vendor
|
|
50
61
|
class StringScanner
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
# def initialize: (pos: untyped, total: untyped, scanned: untyped, rest: untyped) -> void
|
|
63
|
+
# def self.parse: (untyped parser) -> StringScanner?
|
|
64
|
+
# def self.dependencies: -> Array[untyped]
|
|
65
|
+
# def self.object?: -> true
|
|
66
|
+
# attr_reader pos: untyped
|
|
67
|
+
# attr_reader total: untyped
|
|
68
|
+
# attr_reader scanned: untyped
|
|
69
|
+
# attr_reader rest: untyped
|
|
59
70
|
end
|
|
60
71
|
|
|
61
72
|
module Rails
|
|
62
73
|
module Paths
|
|
63
74
|
class Root
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
# def initialize: (untyped memory_reference, Hash[untyped, untyped] attributes) -> void
|
|
76
|
+
# def self.parse: (untyped parser) -> Root?
|
|
77
|
+
# def self.object?: -> true
|
|
78
|
+
# def self.dependencies: -> [singleton(Pathname)]
|
|
79
|
+
# attr_reader memory_reference: untyped
|
|
80
|
+
# attr_reader attributes: Hash[untyped, untyped]
|
|
70
81
|
end
|
|
71
82
|
end
|
|
72
83
|
end
|
|
73
|
-
|
|
74
|
-
module ActiveSupport
|
|
75
|
-
class OrderedOptions
|
|
76
|
-
def self.parse: (untyped parser) -> untyped
|
|
77
|
-
def self.dependencies: -> Array[untyped]
|
|
78
|
-
def self.object?: -> true
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
class IPAddr
|
|
83
|
-
def self.parse: (untyped parser) -> IPAddr
|
|
84
|
-
def self.object?: -> true
|
|
85
|
-
def self.dependencies: -> Array[untyped]
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
class Pathname
|
|
89
|
-
def self.parse: (untyped parser) -> Pathname
|
|
90
|
-
def self.object?: -> true
|
|
91
|
-
def self.dependencies: -> Array[untyped]
|
|
92
|
-
end
|
|
93
84
|
end
|
|
94
85
|
end
|
data/sig/tcepsni.rbs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
module Tcepsni
|
|
2
2
|
VERSION: String
|
|
3
|
-
|
|
4
|
-
class Error < StandardError
|
|
5
|
-
end
|
|
3
|
+
Error: Class
|
|
6
4
|
|
|
7
5
|
def self.parse: (String str) -> untyped
|
|
8
6
|
|
|
9
7
|
class Parser
|
|
8
|
+
FAIL: untyped
|
|
10
9
|
def initialize: (String source, vendors: Array[untyped]?) -> void
|
|
11
10
|
def parse_expression: -> untyped
|
|
12
11
|
alias parse parse_expression
|
|
@@ -20,6 +19,15 @@ module Tcepsni
|
|
|
20
19
|
def parse_object: -> Object
|
|
21
20
|
def parse_attributes: -> Hash[Symbol, untyped]
|
|
22
21
|
def parse_memory_reference: -> Integer
|
|
22
|
+
def parse_nil: -> nil
|
|
23
|
+
def parse_true: -> true?
|
|
24
|
+
def parse_false: -> false
|
|
25
|
+
def parse_symbol: -> Symbol
|
|
26
|
+
def parse_range: -> Range?
|
|
27
|
+
def parse_float: -> Float?
|
|
28
|
+
def parse_time: -> Time?
|
|
29
|
+
def parse_encoding: -> Encoding?
|
|
30
|
+
def parse_attribute: -> [Symbol, untyped]?
|
|
23
31
|
end
|
|
24
32
|
|
|
25
33
|
class Class
|
|
@@ -44,24 +52,47 @@ module Tcepsni
|
|
|
44
52
|
|
|
45
53
|
module Vendor
|
|
46
54
|
class StringScanner
|
|
55
|
+
attr_reader pos: untyped
|
|
56
|
+
attr_reader total: untyped
|
|
57
|
+
attr_reader scanned: untyped
|
|
58
|
+
attr_reader rest: untyped
|
|
59
|
+
def initialize: (pos: untyped, total: untyped, scanned: untyped, rest: untyped) -> void
|
|
60
|
+
def self.parse: (untyped parser) -> StringScanner?
|
|
61
|
+
def self.dependencies: -> Array[untyped]
|
|
62
|
+
def self.object?: -> true
|
|
47
63
|
end
|
|
48
64
|
|
|
49
65
|
module Rails
|
|
50
66
|
module Paths
|
|
51
67
|
class Root
|
|
68
|
+
attr_reader memory_reference: untyped
|
|
69
|
+
attr_reader attributes: Hash[untyped, untyped]
|
|
70
|
+
def initialize: (untyped memory_reference, Hash[untyped, untyped] attributes) -> void
|
|
71
|
+
def self.parse: (untyped parser) -> Root?
|
|
72
|
+
def self.object?: -> true
|
|
73
|
+
def self.dependencies: -> [singleton(Pathname)]
|
|
52
74
|
end
|
|
53
75
|
end
|
|
54
76
|
end
|
|
55
77
|
|
|
56
78
|
module ActiveSupport
|
|
57
79
|
class OrderedOptions
|
|
80
|
+
def self.parse: (untyped parser) -> nil
|
|
81
|
+
def self.dependencies: -> Array[untyped]
|
|
82
|
+
def self.object?: -> true
|
|
58
83
|
end
|
|
59
84
|
end
|
|
60
85
|
|
|
61
86
|
class IPAddr
|
|
87
|
+
def self.parse: (untyped parser) -> IPAddr
|
|
88
|
+
def self.object?: -> true
|
|
89
|
+
def self.dependencies: -> Array[untyped]
|
|
62
90
|
end
|
|
63
91
|
|
|
64
92
|
class Pathname
|
|
93
|
+
def self.parse: (untyped parser) -> Pathname
|
|
94
|
+
def self.object?: -> true
|
|
95
|
+
def self.dependencies: -> Array[untyped]
|
|
65
96
|
end
|
|
66
97
|
end
|
|
67
98
|
end
|
data/tcepsni.gemspec
CHANGED
|
@@ -9,10 +9,22 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.summary = 'inspected Ruby objects parser'
|
|
10
10
|
spec.description = 'Tcepsni gem is a parser library for inspected strings of Ruby objects.'
|
|
11
11
|
spec.license = 'Apache-2.0'
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
spec.homepage = 'https://codeberg.org/gemmaro/tcepsni'
|
|
14
|
+
|
|
15
|
+
spec.required_ruby_version = '>= 3.2'
|
|
13
16
|
|
|
14
17
|
spec.files = Dir['lib/**/*.rb'] + Dir['sig/**/*.rbs'] +
|
|
15
18
|
['CHANGELOG.md', 'tcepsni.gemspec', 'README.md', 'LICENSE.txt']
|
|
16
19
|
spec.require_paths = ['lib']
|
|
17
|
-
|
|
20
|
+
|
|
21
|
+
spec.metadata = {
|
|
22
|
+
'rubygems_mfa_required' => 'true',
|
|
23
|
+
'bug_tracker_uri' => 'https://codeberg.org/gemmaro/tcepsni/issues',
|
|
24
|
+
'changelog_uri' => 'https://codeberg.org/gemmaro/tcepsni/src/branch/main/CHANGELOG.md',
|
|
25
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/tcepsni',
|
|
26
|
+
'homepage_uri' => spec.homepage,
|
|
27
|
+
'source_code_uri' => spec.homepage,
|
|
28
|
+
'wiki_uri' => 'https://codeberg.org/gemmaro/tcepsni/wiki'
|
|
29
|
+
}
|
|
18
30
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tcepsni
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gemmaro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-08-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Tcepsni gem is a parser library for inspected strings of Ruby objects.
|
|
14
14
|
email:
|
|
@@ -31,11 +31,17 @@ files:
|
|
|
31
31
|
- sig/tcepsni.gen.rbs
|
|
32
32
|
- sig/tcepsni.rbs
|
|
33
33
|
- tcepsni.gemspec
|
|
34
|
-
homepage:
|
|
34
|
+
homepage: https://codeberg.org/gemmaro/tcepsni
|
|
35
35
|
licenses:
|
|
36
36
|
- Apache-2.0
|
|
37
37
|
metadata:
|
|
38
38
|
rubygems_mfa_required: 'true'
|
|
39
|
+
bug_tracker_uri: https://codeberg.org/gemmaro/tcepsni/issues
|
|
40
|
+
changelog_uri: https://codeberg.org/gemmaro/tcepsni/src/branch/main/CHANGELOG.md
|
|
41
|
+
documentation_uri: https://www.rubydoc.info/gems/tcepsni
|
|
42
|
+
homepage_uri: https://codeberg.org/gemmaro/tcepsni
|
|
43
|
+
source_code_uri: https://codeberg.org/gemmaro/tcepsni
|
|
44
|
+
wiki_uri: https://codeberg.org/gemmaro/tcepsni/wiki
|
|
39
45
|
post_install_message:
|
|
40
46
|
rdoc_options: []
|
|
41
47
|
require_paths:
|
|
@@ -44,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
44
50
|
requirements:
|
|
45
51
|
- - ">="
|
|
46
52
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 3.
|
|
53
|
+
version: '3.2'
|
|
48
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
55
|
requirements:
|
|
50
56
|
- - ">="
|
|
51
57
|
- !ruby/object:Gem::Version
|
|
52
58
|
version: '0'
|
|
53
59
|
requirements: []
|
|
54
|
-
rubygems_version: 3.
|
|
60
|
+
rubygems_version: 3.4.19
|
|
55
61
|
signing_key:
|
|
56
62
|
specification_version: 4
|
|
57
63
|
summary: inspected Ruby objects parser
|