kleene 0.8.0 → 0.10.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/Gemfile.lock +6 -6
- data/lib/kleene/naive_online_regex.rb +22 -7
- data/lib/kleene/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: f7a82c35643a5cca34172ff2d81f4017663c8255c0cfce8b25caf5e4be71726e
|
4
|
+
data.tar.gz: 0dfbdaba90162253ab7f3f07cf376a79012d8108819c70d40fe7e6413abb84ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611c2bfdc05d5dfb2a9fc68612c51cccf48629094b324976d63af7a571bcaf3bb4da44983b997d589f889fcf81987ef96c55b154659909ce92311180d913c6a4
|
7
|
+
data.tar.gz: 6a34c286a65174f0d3c1dd807419bb338e76e21ee9fa045efd6187de86b07b3874e01c862ae5ec098af075daf1f0de11dab19f6b13250742509bda60ecff1d0e
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kleene (0.
|
4
|
+
kleene (0.9.0)
|
5
5
|
activesupport (~> 7.1)
|
6
6
|
regexp_parser (~> 2.8)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (7.1.
|
11
|
+
activesupport (7.1.2)
|
12
12
|
base64
|
13
13
|
bigdecimal
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -20,13 +20,13 @@ GEM
|
|
20
20
|
tzinfo (~> 2.0)
|
21
21
|
ast (2.4.2)
|
22
22
|
backport (1.2.0)
|
23
|
-
base64 (0.
|
24
|
-
benchmark (0.
|
23
|
+
base64 (0.2.0)
|
24
|
+
benchmark (0.3.0)
|
25
25
|
bigdecimal (3.1.4)
|
26
26
|
concurrent-ruby (1.2.2)
|
27
27
|
connection_pool (2.4.1)
|
28
28
|
diff-lcs (1.5.0)
|
29
|
-
drb (2.
|
29
|
+
drb (2.2.0)
|
30
30
|
ruby2_keywords
|
31
31
|
e2mmap (0.1.0)
|
32
32
|
i18n (1.14.1)
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
kramdown (~> 2.0)
|
40
40
|
language_server-protocol (3.17.0.3)
|
41
41
|
minitest (5.20.0)
|
42
|
-
mutex_m (0.
|
42
|
+
mutex_m (0.2.0)
|
43
43
|
nokogiri (1.15.4-x86_64-linux)
|
44
44
|
racc (~> 1.4)
|
45
45
|
parallel (1.23.0)
|
@@ -49,24 +49,35 @@ module Kleene
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def drop_matches_that_have_rolled_off(number_of_chars_at_front_of_buffer_that_rolled_off)
|
52
|
-
@matches_per_regex.
|
53
|
-
|
52
|
+
@matches_per_regex.transform_values! do |match_set|
|
53
|
+
new_set = Set.new
|
54
|
+
match_set.each do |online_match|
|
55
|
+
online_match_clone = online_match.clone
|
56
|
+
online_match_clone.decrement_offsets(number_of_chars_at_front_of_buffer_that_rolled_off)
|
57
|
+
new_set << online_match_clone if online_match_clone.offsets.first > 0
|
58
|
+
end
|
59
|
+
new_set
|
54
60
|
end
|
61
|
+
|
55
62
|
end
|
56
63
|
end
|
57
64
|
|
58
65
|
# A {Regexp, MatchData} pair
|
59
66
|
class OnlineMatch
|
60
|
-
|
61
|
-
attr_reader :
|
62
|
-
attr_reader :
|
63
|
-
attr_reader :offsets # Regexp # MatchData # Array(Int) -> [start, end] # excludes the end offset
|
67
|
+
attr_reader :regex # Regexp
|
68
|
+
attr_reader :match # MatchData
|
69
|
+
attr_reader :offsets # Array(Int) -> [start, end] # excludes the end offset
|
64
70
|
|
65
71
|
def initialize(regex, match)
|
66
|
-
@regex
|
72
|
+
@regex = regex
|
73
|
+
@match = match
|
67
74
|
@offsets = match.offset(0)
|
68
75
|
end
|
69
76
|
|
77
|
+
def clone
|
78
|
+
OnlineMatch.new(@regex, @match)
|
79
|
+
end
|
80
|
+
|
70
81
|
def identity
|
71
82
|
[@regex, @offsets, to_a]
|
72
83
|
end
|
@@ -98,5 +109,9 @@ module Kleene
|
|
98
109
|
def [](*args)
|
99
110
|
@match.method(:[]).call(*args)
|
100
111
|
end
|
112
|
+
|
113
|
+
def decrement_offsets(decrement)
|
114
|
+
@offsets = @offsets.map {|offset| offset - decrement }
|
115
|
+
end
|
101
116
|
end
|
102
117
|
end
|
data/lib/kleene/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kleene
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Ellis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|