regexgen 0.3.0 → 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/.github/workflows/main.yml +12 -16
- data/.rubocop.yml +4 -74
- data/.ruby-version +1 -1
- data/CHANGELOG.md +27 -0
- data/Gemfile.lock +41 -34
- data/Rakefile +5 -1
- data/lib/regexgen/ast.rb +12 -10
- data/lib/regexgen/minimize.rb +3 -3
- data/lib/regexgen/regex.rb +1 -1
- data/lib/regexgen/set.rb +4 -2
- data/lib/regexgen/version.rb +1 -1
- data/lib/regexgen.rb +1 -1
- data/regexgen.gemspec +4 -4
- metadata +17 -16
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/.github/workflows/main.yml
CHANGED
@@ -1,25 +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
|
24
18
|
- name: Type check
|
25
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/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.4
|
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,72 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
regexgen (0.3.
|
4
|
+
regexgen (0.3.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
backport (1.
|
11
|
-
benchmark (0.1.
|
9
|
+
ast (2.4.2)
|
10
|
+
backport (1.2.0)
|
11
|
+
benchmark (0.1.1)
|
12
12
|
byebug (11.1.3)
|
13
|
+
diff-lcs (1.4.4)
|
13
14
|
e2mmap (0.1.0)
|
14
15
|
jaro_winkler (1.5.4)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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)
|
22
27
|
ast (~> 2.4.1)
|
28
|
+
racc (1.5.2)
|
23
29
|
rainbow (3.0.0)
|
24
30
|
rake (12.3.3)
|
25
|
-
regexp_parser (1.
|
31
|
+
regexp_parser (2.1.1)
|
26
32
|
reverse_markdown (2.0.0)
|
27
33
|
nokogiri
|
28
|
-
rexml (3.2.
|
29
|
-
rubocop (
|
34
|
+
rexml (3.2.5)
|
35
|
+
rubocop (1.22.1)
|
30
36
|
parallel (~> 1.10)
|
31
|
-
parser (>=
|
37
|
+
parser (>= 3.0.0.0)
|
32
38
|
rainbow (>= 2.2.2, < 4.0)
|
33
|
-
regexp_parser (>= 1.
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
34
40
|
rexml
|
35
|
-
rubocop-ast (>=
|
41
|
+
rubocop-ast (>= 1.12.0, < 2.0)
|
36
42
|
ruby-progressbar (~> 1.7)
|
37
|
-
unicode-display_width (>= 1.4.0, <
|
38
|
-
rubocop-ast (
|
39
|
-
parser (>=
|
40
|
-
ruby-progressbar (1.
|
41
|
-
solargraph (0.
|
42
|
-
backport (~> 1.
|
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)
|
43
49
|
benchmark
|
44
50
|
bundler (>= 1.17.2)
|
51
|
+
diff-lcs (~> 1.4)
|
45
52
|
e2mmap
|
46
53
|
jaro_winkler (~> 1.5)
|
47
|
-
|
48
|
-
|
49
|
-
parser (~>
|
54
|
+
kramdown (~> 2.3)
|
55
|
+
kramdown-parser-gfm (~> 1.1)
|
56
|
+
parser (~> 3.0)
|
50
57
|
reverse_markdown (>= 1.0.5, < 3)
|
51
|
-
rubocop (
|
58
|
+
rubocop (>= 0.52)
|
52
59
|
thor (~> 1.0)
|
53
60
|
tilt (~> 2.0)
|
54
61
|
yard (~> 0.9, >= 0.9.24)
|
55
|
-
thor (1.0
|
62
|
+
thor (1.1.0)
|
56
63
|
tilt (2.0.10)
|
57
|
-
unicode-display_width (1.
|
58
|
-
yard (0.9.
|
64
|
+
unicode-display_width (2.1.0)
|
65
|
+
yard (0.9.26)
|
59
66
|
|
60
67
|
PLATFORMS
|
61
68
|
ruby
|
62
69
|
|
63
70
|
DEPENDENCIES
|
64
|
-
byebug
|
71
|
+
byebug
|
65
72
|
minitest (~> 5.0)
|
66
73
|
rake (~> 12.0)
|
67
74
|
regexgen!
|
68
|
-
rubocop
|
69
|
-
solargraph
|
75
|
+
rubocop
|
76
|
+
solargraph
|
70
77
|
|
71
78
|
BUNDLED WITH
|
72
|
-
2.
|
79
|
+
2.2.29
|
data/Rakefile
CHANGED
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
|
#
|
@@ -76,9 +76,9 @@ module Regexgen
|
|
76
76
|
complement = y - x
|
77
77
|
next if complement.empty?
|
78
78
|
|
79
|
-
p.
|
79
|
+
p.replace_item(y, intersection, complement)
|
80
80
|
if w.include?(y)
|
81
|
-
w.
|
81
|
+
w.replace_item(y, intersection, complement)
|
82
82
|
elsif intersection.size <= complement.size
|
83
83
|
w.add(intersection)
|
84
84
|
else
|
data/lib/regexgen/regex.rb
CHANGED
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/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,7 +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'
|
30
|
-
spec.add_development_dependency 'solargraph'
|
28
|
+
spec.add_development_dependency 'byebug'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
spec.add_development_dependency 'solargraph'
|
31
31
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
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
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: solargraph
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '0'
|
55
55
|
description:
|
56
56
|
email:
|
57
57
|
- aaron@madlon-kay.com
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- ".ruby-version"
|
68
68
|
- ".solargraph.yml"
|
69
69
|
- ".travis.yml"
|
70
|
+
- CHANGELOG.md
|
70
71
|
- Gemfile
|
71
72
|
- Gemfile.lock
|
72
73
|
- LICENSE.txt
|
@@ -98,14 +99,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
requirements:
|
99
100
|
- - ">="
|
100
101
|
- !ruby/object:Gem::Version
|
101
|
-
version: 2.
|
102
|
+
version: 2.5.0
|
102
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
104
|
requirements:
|
104
105
|
- - ">="
|
105
106
|
- !ruby/object:Gem::Version
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.1.6
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
112
|
summary: Generate a minimal regex matching a set of strings
|