regexp_trie 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01582ccdb8d800cc4fb4ddcc6e31d333a4078c33
4
- data.tar.gz: 176d5895f95dba8a666e0752766fb4a380062304
3
+ metadata.gz: 262475174a73825ef9b5bfaa579b082876858b0f
4
+ data.tar.gz: e38772708d15f5a0ad150af20d46e0d786422d92
5
5
  SHA512:
6
- metadata.gz: 37e291c4c4384a5a12d2e0d5b8f112dac8fdc97dc9a76e9386be2dbec5f39ed6438fa8479cfc65cfdaa585425b5b772f2e4499d5aa46ea49a4a6f7541dd6bde3
7
- data.tar.gz: f7b71a7c335df3f54d316d7a9afd34022b6081ab6a9207948ec0a7db697bcce9ba7e87a086387cf1d62d13b7933225ee4591d086dd6ad91ad195dd7789059a69
6
+ metadata.gz: 7003a856fd99399cf1e566a8a30847183edac6feb06f25173882ebe4aca9655c7cdba435a617fce7af4ff12f315234aee294b1d63ec319bb0c87aa65e177cb08
7
+ data.tar.gz: ed1a28a0651d084aa186b9a1519fe2beeb06f7ebcbcfc18f712865b64d8d64e19ab99cad67d0bb89607083d5ab623872541e58d89a3d550bb4d85eb036501756
@@ -1,4 +1,7 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  rvm:
4
+ - 2.1.7
5
+ - 2.2.3
3
6
  - 2.3.0
4
- before_install: gem install bundler -v 1.11.2
7
+ before_install: gem install bundler
data/README.md CHANGED
@@ -1,19 +1,21 @@
1
- # RegexpTrie
1
+ # RegexpTrie [![Build Status](https://travis-ci.org/gfx/ruby-regexp_trie.svg?branch=master)](https://travis-ci.org/gfx/ruby-regexp_trie) [![Gem Version](https://badge.fury.io/rb/regexp_trie.svg)](https://badge.fury.io/rb/regexp_trie)
2
2
 
3
3
  ## Synopsis
4
4
 
5
5
  ```ruby
6
6
  #!/usr/bin/env ruby
7
7
  require 'regexp_trie'
8
+
8
9
  # like Regexp.union()
9
- p RegexpTrie.union(%w(foobar fooxar foozap fooza)) # (?-mix:foo(?:bar|xar|zap?))
10
+ p RegexpTrie.union(%w(foobar fooxar foozap fooza)) # /foo(?:bar|xar|zap?)/
11
+ p RegexpTrie.union(%w(foobar fooxar foozap fooza), option: Regexp::IGNORECASE) # /foo(?:bar|xar|zap?)/i
10
12
 
11
13
  # or object-oriented interface
12
14
  rt = RegexpTrie.new
13
15
  %w(foobar fooxar foozap fooza).each do |word|
14
16
  rt.add(word)
15
17
  end
16
- p rt.to_regexp # (?-mix:foo(?:bar|xar|zap?))
18
+ p rt.to_regexp # /foo(?:bar|xar|zap?)/
17
19
  ```
18
20
 
19
21
  See also the original [Regexp::Trie in Perl](https://metacpan.org/pod/Regexp::Trie).
@@ -46,6 +48,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
46
48
 
47
49
  Bug reports and pull requests are welcome on GitHub at https://github.com/gfx/regexp_trie.
48
50
 
51
+ ## See Also
52
+
53
+ * https://metacpan.org/pod/Regexp::Assemble
54
+ * https://metacpan.org/pod/Regexp::Trie
55
+
49
56
  ## License
50
57
 
51
58
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
59
+
60
+ The original code is @dankogai's [Regexp::Trie](https://metacpan.org/pod/Regexp::Trie).
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'regexp_trie'
3
+
3
4
  # like Regexp.union()
4
5
  p RegexpTrie.union(%w(foobar fooxar foozap fooza)) # /foo(?:bar|xar|zap?)/
6
+ p RegexpTrie.union(%w(foobar fooxar foozap fooza), option: Regexp::IGNORECASE) # /foo(?:bar|xar|zap?)/i
5
7
 
6
8
  # or object-oriented interface
7
9
  rt = RegexpTrie.new
@@ -17,7 +17,7 @@ class RegexpTrie
17
17
  @head = {}
18
18
  end
19
19
 
20
- # @param [String] pattern
20
+ # @param [String] str
21
21
  def add(str)
22
22
  return self unless str && str.size > 0
23
23
 
@@ -26,7 +26,7 @@ class RegexpTrie
26
26
  entry[c] ||= {}
27
27
  entry = entry[c]
28
28
  end
29
- entry[''] = true # terminator
29
+ entry[:end] = true
30
30
  self
31
31
  end
32
32
 
@@ -42,7 +42,7 @@ class RegexpTrie
42
42
  private
43
43
 
44
44
  def build(entry)
45
- return nil if entry[''] && entry.size == 1
45
+ return nil if entry[:end] && entry.size == 1
46
46
 
47
47
  alt = []
48
48
  cc = []
@@ -72,7 +72,7 @@ class RegexpTrie
72
72
  if cconly
73
73
  "#{result}?"
74
74
  else
75
- "(?:#{$result})?"
75
+ "(?:#{result})?"
76
76
  end
77
77
  else
78
78
  result
@@ -1,3 +1,3 @@
1
1
  class RegexpTrie
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp_trie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - FUJI Goro (gfx)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.5.1
112
+ rubygems_version: 2.4.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Optimized Regexp builder with Trie