kleene 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12f76babc39f4051cb6a1faf6dbcfbe03d3a52735c8fa2bd3b360b031ae9a0f8
4
- data.tar.gz: c4bc2f26400e80aeca549fdba04c84ef863f1d04c047b885fbaa91668690a4cd
3
+ metadata.gz: f7a82c35643a5cca34172ff2d81f4017663c8255c0cfce8b25caf5e4be71726e
4
+ data.tar.gz: 0dfbdaba90162253ab7f3f07cf376a79012d8108819c70d40fe7e6413abb84ff
5
5
  SHA512:
6
- metadata.gz: 7501f2ad597e59333a792271333e981ffd1e20a4246b94a5f90d4063a311c32815b5c1413d2e9111a1d92da5a5d2eb6168f1c0e175a3a880b0ecf30530766897
7
- data.tar.gz: e7acafe55b63f4d7f4a887af73490a05462be0394c575eedfa42048b454921c44282a17e7e336f2cf4f31831b7fea04fc3a04568b3d5cc2ede467f6e58b655d8
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.8.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)
@@ -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.9.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.9.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