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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03ad3b5293809eb768a2bb47eb3f1a9ccee680d7d71873d75c7511eb9fc711be
4
- data.tar.gz: cb0e8f6600e878153bf2454cea8e3dd4dc67d1872660bd1a77b0648a5f91efa5
3
+ metadata.gz: f7a82c35643a5cca34172ff2d81f4017663c8255c0cfce8b25caf5e4be71726e
4
+ data.tar.gz: 0dfbdaba90162253ab7f3f07cf376a79012d8108819c70d40fe7e6413abb84ff
5
5
  SHA512:
6
- metadata.gz: f7043fb3024741baf02ed48de44d14c616d4bb83315ad23481d0908c962fbd41a56a9ccc8d0444577526baa94933621b43203c29b2cba14192d98d8f5a7246ef
7
- data.tar.gz: a78f7aee47db290800efa79cb6096d604f30dc249907db8759bb319b29f01d378801395557a9a8760fc3b6d06e2e447335398de053e1594233da62128a3aafb9
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.7.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.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.1.1)
24
- benchmark (0.2.1)
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.1.1)
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.1.2)
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.each do |regex, match_set|
53
- match_set.reject! {|online_match| online_match.offsets.first < number_of_chars_at_front_of_buffer_that_rolled_off }
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
- # Regexp # MatchData # Array(Int) -> [start, end] # excludes the end offset
61
- attr_reader :regex
62
- attr_reader :match
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, @match, @offsets = regex, match
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
@@ -1,3 +1,3 @@
1
1
  module Kleene
2
- VERSION = "0.8.0"
2
+ VERSION = "0.10.0"
3
3
  end
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.8.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-07 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport