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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e86e086268d6721f47706182ff5ea253c144a1c17a204ebe35ecb8c1f706cc89
4
- data.tar.gz: a88cd0e49107c29290c840d66a859a67538977b18fc3294b5df97894b99897ae
3
+ metadata.gz: 7d4795aa7ce199e2818f541f0e1bbcb49c75c1767ada19faba309107f119afd9
4
+ data.tar.gz: 8c6f5e905c16356c643f0d0b9991081023055b74d801613cc6ecb53c2c63edfc
5
5
  SHA512:
6
- metadata.gz: 9ea1ab6014151731615350e3eaeb5e975fb346e23b442c673077f424e806fae63c2a2db9058a041a8c32e523287c6417bdad0f54b6991c30c7f46e3ddc0fbcc1
7
- data.tar.gz: ff525455e5a7ecbd1a2bbde4a618f1b192ebadfaf7c13c3d7f4bbdd750103b472c700bcbddda2a937466486c60310b28a5123d0030c97264903d9c11787cafd3
6
+ metadata.gz: 7d99428533020d7b8423d6cef3fbb1d5e6000a34d42266869473db0a921a7975b32f24c5f3c126c0ccb64c0c9d63b09d8a438fc5d0d8fbf42c1a4a1131d76053
7
+ data.tar.gz: d2639356091418e3e74bae4813c904a10100d0306ef255e6f90ac737b2f15609dd31a658610a3525cd445b0414cb24f3f01cd92fa1a5ee33fc1794ceb820d280
@@ -1,25 +1,21 @@
1
- name: CI
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: Setup Ruby, JRuby and TruffleRuby
17
- uses: ruby/setup-ruby@v1.40.0
18
- - name: Install dependencies
19
- run: bundle install
20
- - name: Run tests
21
- run: bundle exec rake test
22
- - name: Lint
23
- run: bundle exec rubocop
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
- Layout/EmptyLinesAroundAttributeAccessor:
12
- Enabled: true
13
- Layout/SpaceAroundMethodCallOperator:
14
- Enabled: true
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.6.5
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.0)
4
+ regexgen (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.1)
10
- backport (1.1.2)
11
- benchmark (0.1.0)
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
- maruku (0.7.3)
16
- mini_portile2 (2.4.0)
17
- minitest (5.14.1)
18
- nokogiri (1.10.10)
19
- mini_portile2 (~> 2.4.0)
20
- parallel (1.19.2)
21
- parser (2.7.1.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)
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.7.1)
31
+ regexp_parser (2.1.1)
26
32
  reverse_markdown (2.0.0)
27
33
  nokogiri
28
- rexml (3.2.4)
29
- rubocop (0.89.1)
34
+ rexml (3.2.5)
35
+ rubocop (1.22.1)
30
36
  parallel (~> 1.10)
31
- parser (>= 2.7.1.1)
37
+ parser (>= 3.0.0.0)
32
38
  rainbow (>= 2.2.2, < 4.0)
33
- regexp_parser (>= 1.7)
39
+ regexp_parser (>= 1.8, < 3.0)
34
40
  rexml
35
- rubocop-ast (>= 0.3.0, < 1.0)
41
+ rubocop-ast (>= 1.12.0, < 2.0)
36
42
  ruby-progressbar (~> 1.7)
37
- unicode-display_width (>= 1.4.0, < 2.0)
38
- rubocop-ast (0.3.0)
39
- parser (>= 2.7.1.4)
40
- ruby-progressbar (1.10.1)
41
- solargraph (0.39.14)
42
- backport (~> 1.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
- maruku (~> 0.7, >= 0.7.3)
48
- nokogiri (~> 1.9, >= 1.9.1)
49
- parser (~> 2.3)
54
+ kramdown (~> 2.3)
55
+ kramdown-parser-gfm (~> 1.1)
56
+ parser (~> 3.0)
50
57
  reverse_markdown (>= 1.0.5, < 3)
51
- rubocop (~> 0.52)
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.1)
62
+ thor (1.1.0)
56
63
  tilt (2.0.10)
57
- unicode-display_width (1.7.0)
58
- yard (0.9.25)
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 (~> 11)
71
+ byebug
65
72
  minitest (~> 5.0)
66
73
  rake (~> 12.0)
67
74
  regexgen!
68
- rubocop (~> 0.89)
69
- solargraph (~> 0.39)
75
+ rubocop
76
+ solargraph
70
77
 
71
78
  BUNDLED WITH
72
- 2.1.4
79
+ 2.2.29
data/Rakefile CHANGED
@@ -9,4 +9,8 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList['test/**/*_test.rb']
10
10
  end
11
11
 
12
- task default: :test
12
+ require 'rubocop/rake_task'
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
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
- return Literal.new(@value[len..]) if side == :start
182
- return Literal.new(@value[0...(@value.length - len)]) if side == :end
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
- str = exp.to_s
189
- if exp.precedence < parent.precedence
190
- unless exp.respond_to?(:single_character?) && exp.single_character?
191
- return "(?:#{str})" unless exp.respond_to?(:single_codepoint?) && exp.single_codepoint?
192
- end
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
@@ -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.replace(y, intersection, complement)
79
+ p.replace_item(y, intersection, complement)
80
80
  if w.include?(y)
81
- w.replace(y, intersection, complement)
81
+ w.replace_item(y, intersection, complement)
82
82
  elsif intersection.size <= complement.size
83
83
  w.add(intersection)
84
84
  else
@@ -3,7 +3,7 @@
3
3
  require 'regexgen/ast'
4
4
 
5
5
  module Regexgen
6
- class<<self
6
+ class << self
7
7
  # Brzozowski algebraic method
8
8
  # https://cs.stackexchange.com/a/2392
9
9
  #
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 replace(search, *replacements)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Regexgen
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
data/lib/regexgen.rb CHANGED
@@ -5,7 +5,7 @@ require 'regexgen/trie'
5
5
 
6
6
  # Generate regular expressions that match a set of strings
7
7
  module Regexgen
8
- class <<self
8
+ class << self
9
9
  def generate(strings, flags = nil)
10
10
  Trie.new.tap { |t| strings.each(&t.method(:add)) }
11
11
  .to_regex(flags)
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.3.0')
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', '~> 11'
29
- spec.add_development_dependency 'rubocop', '~> 0.89'
30
- spec.add_development_dependency 'solargraph', '~> 0.39'
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.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: 2020-08-18 00:00:00.000000000 Z
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: '11'
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: '11'
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.89'
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.89'
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.39'
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.39'
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.3.0
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.0.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