regexp_optimized_union 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/readme.md +36 -0
  2. metadata +4 -8
data/readme.md ADDED
@@ -0,0 +1,36 @@
1
+ `Regexp.optimized_union(word_list, regexp_options)` generates optimized regexp for matching union of word list. Works similar to `Regexp.union`, but API receives Regexp compile option.
2
+
3
+ ### Install:
4
+
5
+ ```bash
6
+ gem ins regexp_optimized_union
7
+ ```
8
+
9
+ ### Use:
10
+
11
+ ```ruby
12
+ require 'regexp_optimized_union'
13
+ Regexp.optimized_union(%w[bazfoo bazfoobar bazbar]) #=> /baz(?:foo(?:bar)?|bar)/
14
+ Regexp.optimized_union(%w[fooabar foobbar], 'i') #=> /foo[ab]bar/i
15
+ Regexp.optimized_union(%w[foobar fooabar foogabar]) #=> /foo(?:|a|ga)bar/
16
+ ```
17
+
18
+ ### Caveats:
19
+
20
+ - All words in the list will be escaped.
21
+ - Matching time for the light but compile time for the dark, you are the balance between them.
22
+
23
+ ### Optimizations include:
24
+
25
+ - Treed common prefix extraction.
26
+ - Common suffix aggregation.
27
+ - Optional leaf to `?`.
28
+
29
+ Mostly the same as described in http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/lib/Regexp/List.pm#IMPLEMENTATION
30
+
31
+ ### License (WTFPL)
32
+
33
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
34
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
35
+
36
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp_optimized_union
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,19 +11,15 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! 'Regexp.optimized_union(word_list, regexp_options) generates optimized
15
- regexp for matching union of word list.
16
-
17
- Optimations include: treed common prefix extraction, common suffix aggregation and
18
- optional leaf to ?.
19
-
20
- Mostly the same as described in http://search.cpan.org/~dankogai/Regexp-Optimizer-0.15/lib/Regexp/List.pm#IMPLEMENTATION'
14
+ description: Regexp.optimized_union(word_list, regexp_options) generates optimized
15
+ regexp for matching union of word list
21
16
  email:
22
17
  executables: []
23
18
  extensions: []
24
19
  extra_rdoc_files: []
25
20
  files:
26
21
  - lib/regexp_optimized_union.rb
22
+ - readme.md
27
23
  homepage: https://github.com/luikore/regexp_optimized_union
28
24
  licenses:
29
25
  - WTFPL