regexgen 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +3 -3
- data/Gemfile.lock +4 -4
- data/lib/regexgen/minimize.rb +19 -5
- data/lib/regexgen/trie.rb +1 -1
- data/lib/regexgen/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: e86e086268d6721f47706182ff5ea253c144a1c17a204ebe35ecb8c1f706cc89
|
4
|
+
data.tar.gz: a88cd0e49107c29290c840d66a859a67538977b18fc3294b5df97894b99897ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ea1ab6014151731615350e3eaeb5e975fb346e23b442c673077f424e806fae63c2a2db9058a041a8c32e523287c6417bdad0f54b6991c30c7f46e3ddc0fbcc1
|
7
|
+
data.tar.gz: ff525455e5a7ecbd1a2bbde4a618f1b192ebadfaf7c13c3d7f4bbdd750103b472c700bcbddda2a937466486c60310b28a5123d0030c97264903d9c11787cafd3
|
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/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
regexgen (0.
|
4
|
+
regexgen (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -26,19 +26,19 @@ GEM
|
|
26
26
|
reverse_markdown (2.0.0)
|
27
27
|
nokogiri
|
28
28
|
rexml (3.2.4)
|
29
|
-
rubocop (0.89.
|
29
|
+
rubocop (0.89.1)
|
30
30
|
parallel (~> 1.10)
|
31
31
|
parser (>= 2.7.1.1)
|
32
32
|
rainbow (>= 2.2.2, < 4.0)
|
33
33
|
regexp_parser (>= 1.7)
|
34
34
|
rexml
|
35
|
-
rubocop-ast (>= 0.
|
35
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
36
36
|
ruby-progressbar (~> 1.7)
|
37
37
|
unicode-display_width (>= 1.4.0, < 2.0)
|
38
38
|
rubocop-ast (0.3.0)
|
39
39
|
parser (>= 2.7.1.4)
|
40
40
|
ruby-progressbar (1.10.1)
|
41
|
-
solargraph (0.39.
|
41
|
+
solargraph (0.39.14)
|
42
42
|
backport (~> 1.1)
|
43
43
|
benchmark
|
44
44
|
bundler (>= 1.17.2)
|
data/lib/regexgen/minimize.rb
CHANGED
@@ -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?
|
data/lib/regexgen/trie.rb
CHANGED
data/lib/regexgen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regexgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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: 2020-08-
|
11
|
+
date: 2020-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|