regexgen 0.1.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dir-locals.el +4 -0
- data/.github/workflows/main.yml +14 -16
- data/.rubocop.yml +4 -74
- data/.rubocop_todo.yml +3 -3
- data/.ruby-version +1 -1
- data/.solargraph.yml +17 -0
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +54 -19
- data/README.md +14 -1
- data/Rakefile +5 -1
- data/bin/regexgen +33 -0
- data/lib/regexgen/ast.rb +12 -10
- data/lib/regexgen/minimize.rb +22 -8
- data/lib/regexgen/regex.rb +39 -3
- data/lib/regexgen/set.rb +4 -2
- data/lib/regexgen/trie.rb +1 -1
- data/lib/regexgen/version.rb +1 -1
- data/lib/regexgen.rb +1 -1
- data/regexgen.gemspec +4 -3
- metadata +30 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d4795aa7ce199e2818f541f0e1bbcb49c75c1767ada19faba309107f119afd9
|
4
|
+
data.tar.gz: 8c6f5e905c16356c643f0d0b9991081023055b74d801613cc6ecb53c2c63edfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d99428533020d7b8423d6cef3fbb1d5e6000a34d42266869473db0a921a7975b32f24c5f3c126c0ccb64c0c9d63b09d8a438fc5d0d8fbf42c1a4a1131d76053
|
7
|
+
data.tar.gz: d2639356091418e3e74bae4813c904a10100d0306ef255e6f90ac737b2f15609dd31a658610a3525cd445b0414cb24f3f01cd92fa1a5ee33fc1794ceb820d280
|
data/.dir-locals.el
ADDED
data/.github/workflows/main.yml
CHANGED
@@ -1,23 +1,21 @@
|
|
1
|
-
name:
|
1
|
+
name: Ruby
|
2
2
|
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
3
|
+
on: [push,pull_request]
|
8
4
|
|
9
5
|
jobs:
|
10
6
|
build:
|
11
|
-
|
12
7
|
runs-on: ubuntu-latest
|
13
|
-
|
14
8
|
steps:
|
15
9
|
- uses: actions/checkout@v2
|
16
|
-
- name:
|
17
|
-
uses: ruby/setup-ruby@v1
|
18
|
-
|
19
|
-
|
20
|
-
- name:
|
21
|
-
run:
|
22
|
-
|
23
|
-
|
10
|
+
- name: Set up Ruby
|
11
|
+
uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.4
|
14
|
+
- name: Install
|
15
|
+
run: |
|
16
|
+
gem install bundler -v 2.2.29
|
17
|
+
bundle install
|
18
|
+
- name: Type check
|
19
|
+
run: bundle exec solargraph typecheck --level typed
|
20
|
+
- name: Unit tests
|
21
|
+
run: bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -8,77 +8,7 @@ Naming/MethodParameterName:
|
|
8
8
|
- 'lib/regexgen/regex.rb'
|
9
9
|
- 'lib/regexgen/ast.rb'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Lint/BinaryOperatorWithIdenticalOperands:
|
16
|
-
Enabled: true
|
17
|
-
Lint/DeprecatedOpenSSLConstant:
|
18
|
-
Enabled: true
|
19
|
-
Lint/DuplicateElsifCondition:
|
20
|
-
Enabled: true
|
21
|
-
Lint/DuplicateRescueException:
|
22
|
-
Enabled: true
|
23
|
-
Lint/EmptyConditionalBody:
|
24
|
-
Enabled: true
|
25
|
-
Lint/FloatComparison:
|
26
|
-
Enabled: true
|
27
|
-
Lint/MissingSuper:
|
28
|
-
Enabled: true
|
29
|
-
Lint/MixedRegexpCaptureTypes:
|
30
|
-
Enabled: true
|
31
|
-
Lint/OutOfRangeRegexpRef:
|
32
|
-
Enabled: true
|
33
|
-
Lint/RaiseException:
|
34
|
-
Enabled: true
|
35
|
-
Lint/SelfAssignment:
|
36
|
-
Enabled: true
|
37
|
-
Lint/StructNewOverride:
|
38
|
-
Enabled: true
|
39
|
-
Lint/TopLevelReturnWithArgument:
|
40
|
-
Enabled: true
|
41
|
-
Lint/UnreachableLoop:
|
42
|
-
Enabled: true
|
43
|
-
Style/AccessorGrouping:
|
44
|
-
Enabled: true
|
45
|
-
Style/ArrayCoercion:
|
46
|
-
Enabled: true
|
47
|
-
Style/BisectedAttrAccessor:
|
48
|
-
Enabled: true
|
49
|
-
Style/CaseLikeIf:
|
50
|
-
Enabled: true
|
51
|
-
Style/ExplicitBlockArgument:
|
52
|
-
Enabled: true
|
53
|
-
Style/ExponentialNotation:
|
54
|
-
Enabled: true
|
55
|
-
Style/GlobalStdStream:
|
56
|
-
Enabled: true
|
57
|
-
Style/HashAsLastArrayItem:
|
58
|
-
Enabled: true
|
59
|
-
Style/HashEachMethods:
|
60
|
-
Enabled: true
|
61
|
-
Style/HashLikeCase:
|
62
|
-
Enabled: true
|
63
|
-
Style/HashTransformKeys:
|
64
|
-
Enabled: true
|
65
|
-
Style/HashTransformValues:
|
66
|
-
Enabled: true
|
67
|
-
Style/OptionalBooleanParameter:
|
68
|
-
Enabled: true
|
69
|
-
Style/RedundantAssignment:
|
70
|
-
Enabled: true
|
71
|
-
Style/RedundantFetchBlock:
|
72
|
-
Enabled: true
|
73
|
-
Style/RedundantFileExtensionInRequire:
|
74
|
-
Enabled: true
|
75
|
-
Style/RedundantRegexpCharacterClass:
|
76
|
-
Enabled: true
|
77
|
-
Style/RedundantRegexpEscape:
|
78
|
-
Enabled: true
|
79
|
-
Style/SingleArgumentDig:
|
80
|
-
Enabled: true
|
81
|
-
Style/SlicingWithRange:
|
82
|
-
Enabled: true
|
83
|
-
Style/StringConcatenation:
|
84
|
-
Enabled: true
|
11
|
+
AllCops:
|
12
|
+
TargetRubyVersion: 2.5
|
13
|
+
NewCops: enable
|
14
|
+
SuggestExtensions: false
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2020-08-
|
3
|
+
# on 2020-08-18 06:34:11 UTC using RuboCop version 0.89.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -9,7 +9,7 @@
|
|
9
9
|
# Offense count: 5
|
10
10
|
# Configuration parameters: IgnoredMethods.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 73
|
13
13
|
|
14
14
|
# Offense count: 7
|
15
15
|
# Configuration parameters: IgnoredMethods.
|
@@ -19,7 +19,7 @@ Metrics/CyclomaticComplexity:
|
|
19
19
|
# Offense count: 6
|
20
20
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
21
21
|
Metrics/MethodLength:
|
22
|
-
Max:
|
22
|
+
Max: 47
|
23
23
|
|
24
24
|
# Offense count: 1
|
25
25
|
# Configuration parameters: CountComments, CountAsOne.
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.4
|
data/.solargraph.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
include:
|
3
|
+
- "**/*.rb"
|
4
|
+
exclude:
|
5
|
+
- spec/**/*
|
6
|
+
- test/**/*
|
7
|
+
- vendor/**/*
|
8
|
+
- ".bundle/**/*"
|
9
|
+
require: []
|
10
|
+
domains: []
|
11
|
+
reporters:
|
12
|
+
- rubocop
|
13
|
+
- require_not_found
|
14
|
+
- typecheck:typed
|
15
|
+
require_paths: []
|
16
|
+
plugins: []
|
17
|
+
max_files: 5000
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [0.3.1] - 2021-10-14
|
4
|
+
|
5
|
+
- Fix missing `require 'set'`
|
6
|
+
|
7
|
+
## [0.3.0] - 2020-08-18
|
8
|
+
|
9
|
+
- Improve performance
|
10
|
+
|
11
|
+
## [0.2.1] - 2020-08-11
|
12
|
+
|
13
|
+
- Bug fix
|
14
|
+
- Correct link in readme
|
15
|
+
|
16
|
+
## [0.2.0] - 2020-08-11
|
17
|
+
|
18
|
+
- Bug fix
|
19
|
+
- Now includes `bin/regexgen` executable
|
20
|
+
|
21
|
+
## [0.1.1] - 2020-08-11
|
22
|
+
|
23
|
+
- Correct gem metadata
|
24
|
+
|
25
|
+
## [0.1.0] - 2020-08-10
|
26
|
+
|
27
|
+
- Initial release
|
data/Gemfile.lock
CHANGED
@@ -1,44 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
regexgen (0.
|
4
|
+
regexgen (0.3.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
9
|
+
ast (2.4.2)
|
10
|
+
backport (1.2.0)
|
11
|
+
benchmark (0.1.1)
|
10
12
|
byebug (11.1.3)
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
e2mmap (0.1.0)
|
15
|
+
jaro_winkler (1.5.4)
|
16
|
+
kramdown (2.3.1)
|
17
|
+
rexml
|
18
|
+
kramdown-parser-gfm (1.1.0)
|
19
|
+
kramdown (~> 2.0)
|
20
|
+
mini_portile2 (2.6.1)
|
21
|
+
minitest (5.14.4)
|
22
|
+
nokogiri (1.12.5)
|
23
|
+
mini_portile2 (~> 2.6.1)
|
24
|
+
racc (~> 1.4)
|
25
|
+
parallel (1.21.0)
|
26
|
+
parser (3.0.2.0)
|
14
27
|
ast (~> 2.4.1)
|
28
|
+
racc (1.5.2)
|
15
29
|
rainbow (3.0.0)
|
16
30
|
rake (12.3.3)
|
17
|
-
regexp_parser (1.
|
18
|
-
|
19
|
-
|
31
|
+
regexp_parser (2.1.1)
|
32
|
+
reverse_markdown (2.0.0)
|
33
|
+
nokogiri
|
34
|
+
rexml (3.2.5)
|
35
|
+
rubocop (1.22.1)
|
20
36
|
parallel (~> 1.10)
|
21
|
-
parser (>=
|
37
|
+
parser (>= 3.0.0.0)
|
22
38
|
rainbow (>= 2.2.2, < 4.0)
|
23
|
-
regexp_parser (>= 1.
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
24
40
|
rexml
|
25
|
-
rubocop-ast (>=
|
41
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
26
42
|
ruby-progressbar (~> 1.7)
|
27
|
-
unicode-display_width (>= 1.4.0, <
|
28
|
-
rubocop-ast (
|
29
|
-
parser (>=
|
30
|
-
ruby-progressbar (1.
|
31
|
-
|
43
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
44
|
+
rubocop-ast (1.12.0)
|
45
|
+
parser (>= 3.0.1.1)
|
46
|
+
ruby-progressbar (1.11.0)
|
47
|
+
solargraph (0.44.0)
|
48
|
+
backport (~> 1.2)
|
49
|
+
benchmark
|
50
|
+
bundler (>= 1.17.2)
|
51
|
+
diff-lcs (~> 1.4)
|
52
|
+
e2mmap
|
53
|
+
jaro_winkler (~> 1.5)
|
54
|
+
kramdown (~> 2.3)
|
55
|
+
kramdown-parser-gfm (~> 1.1)
|
56
|
+
parser (~> 3.0)
|
57
|
+
reverse_markdown (>= 1.0.5, < 3)
|
58
|
+
rubocop (>= 0.52)
|
59
|
+
thor (~> 1.0)
|
60
|
+
tilt (~> 2.0)
|
61
|
+
yard (~> 0.9, >= 0.9.24)
|
62
|
+
thor (1.1.0)
|
63
|
+
tilt (2.0.10)
|
64
|
+
unicode-display_width (2.1.0)
|
65
|
+
yard (0.9.26)
|
32
66
|
|
33
67
|
PLATFORMS
|
34
68
|
ruby
|
35
69
|
|
36
70
|
DEPENDENCIES
|
37
|
-
byebug
|
71
|
+
byebug
|
38
72
|
minitest (~> 5.0)
|
39
73
|
rake (~> 12.0)
|
40
74
|
regexgen!
|
41
|
-
rubocop
|
75
|
+
rubocop
|
76
|
+
solargraph
|
42
77
|
|
43
78
|
BUNDLED WITH
|
44
|
-
2.
|
79
|
+
2.2.29
|
data/README.md
CHANGED
@@ -29,6 +29,19 @@ require 'regexgen'
|
|
29
29
|
Regexgen.generate(['foobar', 'foobaz', 'foozap', 'fooza']) #=> /foo(?:zap?|ba[rz])/
|
30
30
|
```
|
31
31
|
|
32
|
+
## CLI
|
33
|
+
|
34
|
+
`regexgen` also has a simple CLI to generate regexes using inputs from the
|
35
|
+
command line.
|
36
|
+
|
37
|
+
```sh
|
38
|
+
$ regexgen
|
39
|
+
usage: regexgen [-mix] strings...
|
40
|
+
-m Multiline flag
|
41
|
+
-i Case-insensitive flag
|
42
|
+
-x Extended flag
|
43
|
+
```
|
44
|
+
|
32
45
|
## Unicode handling
|
33
46
|
|
34
47
|
Unlike the JavaScript version, this package does not do any special Unicode
|
@@ -76,7 +89,7 @@ git commits and tags, and push the `.gem` file to
|
|
76
89
|
## Contributing
|
77
90
|
|
78
91
|
Bug reports and pull requests are welcome on GitHub at
|
79
|
-
https://github.com/amake/regexgen.
|
92
|
+
https://github.com/amake/regexgen-ruby.
|
80
93
|
|
81
94
|
|
82
95
|
## License
|
data/Rakefile
CHANGED
data/bin/regexgen
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'regexgen'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
REGEX_FLAGS = {
|
8
|
+
'm' => 'Multiline flag',
|
9
|
+
'i' => 'Case-insensitive flag',
|
10
|
+
'x' => 'Extended flag'
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
flags = []
|
14
|
+
op = OptionParser.new do |opts|
|
15
|
+
opts.banner = "usage: regexgen [-#{REGEX_FLAGS.keys.join}] strings..."
|
16
|
+
REGEX_FLAGS.each do |flag, description|
|
17
|
+
opts.on("-#{flag}", description) { |_| flags << flag }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
op.parse!
|
23
|
+
rescue OptionParser::InvalidOption => e
|
24
|
+
puts e, op.help
|
25
|
+
exit(1)
|
26
|
+
end
|
27
|
+
|
28
|
+
if ARGV.empty?
|
29
|
+
puts op.help
|
30
|
+
exit(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
puts Regexgen.generate(ARGV, flags)
|
data/lib/regexgen/ast.rb
CHANGED
@@ -178,21 +178,23 @@ module Regexgen
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def remove_substring(side, len)
|
181
|
-
|
182
|
-
|
181
|
+
case side
|
182
|
+
when :start then Literal.new(@value[len...@value.length])
|
183
|
+
when :end then Literal.new(@value[0...(@value.length - len)])
|
184
|
+
else raise "Unknown side: #{side}"
|
185
|
+
end
|
183
186
|
end
|
184
187
|
end
|
185
188
|
|
186
|
-
class<<self
|
189
|
+
class << self
|
187
190
|
def parens(exp, parent)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
191
|
+
if exp.precedence < parent.precedence &&
|
192
|
+
!(exp.respond_to?(:single_character?) && exp.single_character?) &&
|
193
|
+
!(exp.respond_to?(:single_codepoint?) && exp.single_codepoint?)
|
194
|
+
"(?:#{exp})"
|
195
|
+
else
|
196
|
+
exp.to_s
|
193
197
|
end
|
194
|
-
|
195
|
-
str
|
196
198
|
end
|
197
199
|
end
|
198
200
|
end
|
data/lib/regexgen/minimize.rb
CHANGED
@@ -5,7 +5,7 @@ require 'regexgen/set'
|
|
5
5
|
module Regexgen
|
6
6
|
using SetUtil
|
7
7
|
|
8
|
-
class<<self
|
8
|
+
class << self
|
9
9
|
# Hopcroft's DSA minimization algorithm
|
10
10
|
# https://en.wikipedia.org/wiki/DFA_minimization#Hopcroft's_algorithm
|
11
11
|
#
|
@@ -41,20 +41,34 @@ module Regexgen
|
|
41
41
|
# c is a letter of the alphabet
|
42
42
|
# A ∩ B is intersection (A & B)
|
43
43
|
# |A| is the cardinality of A (A.size)
|
44
|
-
def minimize(root
|
44
|
+
def minimize(root)
|
45
45
|
states = root.visit
|
46
46
|
final_states = states.select(&:accepting).to_set
|
47
47
|
|
48
|
+
# Create a map of incoming transitions to each state, grouped by
|
49
|
+
# character.
|
50
|
+
transitions = Hash.new { |h, k| h[k] = Hash.new { |h_, k_| h_[k_] = Set.new } }
|
51
|
+
states.each_with_object(transitions) do |s, acc|
|
52
|
+
s.transitions.each do |t, st|
|
53
|
+
acc[st][t] << s
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
48
57
|
p = Set[states, final_states]
|
49
58
|
w = Set.new(p)
|
50
59
|
until w.empty?
|
51
60
|
a = w.shift
|
52
|
-
alphabet.each do |c|
|
53
|
-
x = states.each_with_object(Set.new) do |s, acc|
|
54
|
-
next unless s.transitions.key?(c)
|
55
61
|
|
56
|
-
|
62
|
+
# Collect states that have transitions leading to states in a, grouped
|
63
|
+
# by character.
|
64
|
+
t = Hash.new { |h, k| h[k] = Set.new }
|
65
|
+
a.each_with_object(t) do |s, acc|
|
66
|
+
transitions[s].each do |t_, x|
|
67
|
+
acc[t_].merge(x)
|
57
68
|
end
|
69
|
+
end
|
70
|
+
|
71
|
+
t.each_value do |x|
|
58
72
|
p.to_a.each do |y|
|
59
73
|
intersection = x & y
|
60
74
|
next if intersection.empty?
|
@@ -62,9 +76,9 @@ module Regexgen
|
|
62
76
|
complement = y - x
|
63
77
|
next if complement.empty?
|
64
78
|
|
65
|
-
p.
|
79
|
+
p.replace_item(y, intersection, complement)
|
66
80
|
if w.include?(y)
|
67
|
-
w.
|
81
|
+
w.replace_item(y, intersection, complement)
|
68
82
|
elsif intersection.size <= complement.size
|
69
83
|
w.add(intersection)
|
70
84
|
else
|
data/lib/regexgen/regex.rb
CHANGED
@@ -3,7 +3,43 @@
|
|
3
3
|
require 'regexgen/ast'
|
4
4
|
|
5
5
|
module Regexgen
|
6
|
-
class<<self
|
6
|
+
class << self
|
7
|
+
# Brzozowski algebraic method
|
8
|
+
# https://cs.stackexchange.com/a/2392
|
9
|
+
#
|
10
|
+
# Largely ported from
|
11
|
+
# https://github.com/devongovett/regexgen/blob/7ef10aef3a414b10554822cdf6e90389582b1890/src/regex.js
|
12
|
+
#
|
13
|
+
# Initialize B
|
14
|
+
#
|
15
|
+
# for i = 1 to m:
|
16
|
+
# if final(i):
|
17
|
+
# B[i] := ε
|
18
|
+
# else:
|
19
|
+
# B[i] := ∅
|
20
|
+
#
|
21
|
+
# Initialize A
|
22
|
+
#
|
23
|
+
# for i = 1 to m:
|
24
|
+
# for j = 1 to m:
|
25
|
+
# for a in Σ:
|
26
|
+
# if trans(i, a, j):
|
27
|
+
# A[i,j] := a
|
28
|
+
# else:
|
29
|
+
# A[i,j] := ∅
|
30
|
+
#
|
31
|
+
# Solve
|
32
|
+
#
|
33
|
+
# for n = m decreasing to 1:
|
34
|
+
# B[n] := star(A[n,n]) . B[n]
|
35
|
+
# for j = 1 to n:
|
36
|
+
# A[n,j] := star(A[n,n]) . A[n,j];
|
37
|
+
# for i = 1 to n:
|
38
|
+
# B[i] += A[i,n] . B[n]
|
39
|
+
# for j = 1 to n:
|
40
|
+
# A[i,j] += A[i,n] . A[n,j]
|
41
|
+
#
|
42
|
+
# Result is e := B[1]
|
7
43
|
def to_regex(root)
|
8
44
|
states = root.visit.to_a
|
9
45
|
|
@@ -22,9 +58,9 @@ module Regexgen
|
|
22
58
|
|
23
59
|
(states.length - 1).downto(0) do |n|
|
24
60
|
if a[n][n]
|
25
|
-
b[n] = concat(star(a[n][n], b[n])
|
61
|
+
b[n] = concat(star(a[n][n]), b[n])
|
26
62
|
(0...n).each do |j|
|
27
|
-
a[n][j] = concat(
|
63
|
+
a[n][j] = concat(star(a[n][n]), a[n][j])
|
28
64
|
end
|
29
65
|
end
|
30
66
|
|
data/lib/regexgen/set.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'set'
|
4
|
+
|
3
5
|
module Regexgen
|
4
6
|
module SetUtil
|
5
7
|
refine Set do
|
@@ -9,8 +11,8 @@ module Regexgen
|
|
9
11
|
item
|
10
12
|
end
|
11
13
|
|
12
|
-
def
|
13
|
-
raise unless delete?(search)
|
14
|
+
def replace_item(search, *replacements)
|
15
|
+
raise("Failed to delete #{search}") unless delete?(search)
|
14
16
|
|
15
17
|
merge(replacements)
|
16
18
|
end
|
data/lib/regexgen/trie.rb
CHANGED
data/lib/regexgen/version.rb
CHANGED
data/lib/regexgen.rb
CHANGED
data/regexgen.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = 'Generate a minimal regex matching a set of strings'
|
12
12
|
spec.homepage = 'https://github.com/amake/regexgen-ruby'
|
13
13
|
spec.license = 'MIT'
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
15
15
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
17
|
spec.metadata['source_code_uri'] = 'https://github.com/amake/regexgen-ruby.git'
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ['lib']
|
27
27
|
|
28
|
-
spec.add_development_dependency 'byebug'
|
29
|
-
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'byebug'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
spec.add_development_dependency 'solargraph'
|
30
31
|
end
|
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Madlon-Kay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: solargraph
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- aaron@madlon-kay.com
|
@@ -45,18 +59,22 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
62
|
+
- ".dir-locals.el"
|
48
63
|
- ".github/workflows/main.yml"
|
49
64
|
- ".gitignore"
|
50
65
|
- ".rubocop.yml"
|
51
66
|
- ".rubocop_todo.yml"
|
52
67
|
- ".ruby-version"
|
68
|
+
- ".solargraph.yml"
|
53
69
|
- ".travis.yml"
|
70
|
+
- CHANGELOG.md
|
54
71
|
- Gemfile
|
55
72
|
- Gemfile.lock
|
56
73
|
- LICENSE.txt
|
57
74
|
- README.md
|
58
75
|
- Rakefile
|
59
76
|
- bin/console
|
77
|
+
- bin/regexgen
|
60
78
|
- bin/setup
|
61
79
|
- lib/regexgen.rb
|
62
80
|
- lib/regexgen/ast.rb
|
@@ -81,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
99
|
requirements:
|
82
100
|
- - ">="
|
83
101
|
- !ruby/object:Gem::Version
|
84
|
-
version: 2.
|
102
|
+
version: 2.5.0
|
85
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
104
|
requirements:
|
87
105
|
- - ">="
|
88
106
|
- !ruby/object:Gem::Version
|
89
107
|
version: '0'
|
90
108
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.1.6
|
92
110
|
signing_key:
|
93
111
|
specification_version: 4
|
94
112
|
summary: Generate a minimal regex matching a set of strings
|