regexp-examples 1.2.1 → 1.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: d049ada3d2ac8bd900ed9b1d03066b28f805ae72
4
- data.tar.gz: b68954dec1f8db36d531244ddb3dbbbb2a6edd92
3
+ metadata.gz: b9894154e2704c92fcb6ca8754341277d703b32c
4
+ data.tar.gz: 3e63a6729574eac68d254315766919c5e09f4b23
5
5
  SHA512:
6
- metadata.gz: a2db5421c17dfc6eec5e99caa78c95320432f8d1ace3d5647d02e8d8356518d360bd6409ec69ee8290e6da51b0ee1fbc30ca63dfe22855262ea0ba43e2e31e65
7
- data.tar.gz: e9bb1f444f866dff086953c0e851846f54f9cdf2139e94bfa51f7430277c8201c79c34eaaf459cc6d6f637e0e0f53ac1ecbd2144f6ae7edeaa2a1d2334bef8d7
6
+ metadata.gz: 17d0bb4de2e56575c782a77de333ed1c99facaa75f91d4b29ebd33b9343e37a35f337f1e75f0c62517c9b4865156bb7dd77518e3caf76077c38815dc3f638710
7
+ data.tar.gz: cf2d3b8d98116c909bd6aeb949e891f6fdfa5140fca42454a5a1c1bd24f4cb7cca6254a914b400b3776e7629281b66e688391f9e9e7536dcb298ea58fef798c2
data/.gitignore CHANGED
@@ -10,6 +10,7 @@
10
10
  *.so
11
11
  *.o
12
12
  *.a
13
+ .*.sw?
13
14
  mkmf.log
14
15
  tags
15
16
  /coverage/
data/README.md CHANGED
@@ -188,7 +188,7 @@ There are no known major bugs with this library. However, there are a few obscur
188
188
  * Nested repeat operators are incorrectly parsed, e.g. `/b{2}{3}/` - which *should* be interpreted like `/b{6}/`. (However, there is probably no reason
189
189
  to ever write regexes like this!)
190
190
 
191
- Some of the most obscure regexp features are not even mentioned in [the ruby docs](ruby-doc.org/core/Regexp.html).
191
+ Some of the most obscure regexp features are not even mentioned in [the ruby docs](http://ruby-doc.org/core/Regexp.html).
192
192
  However, full documentation on all the intricate obscurities in the ruby (version 2.x) regexp parser can be found
193
193
  [here](https://raw.githubusercontent.com/k-takata/Onigmo/master/doc/RE).
194
194
 
@@ -200,7 +200,7 @@ If you'd like to understand this in more detail, check out what I had to say in
200
200
  Using any of the following will raise a `RegexpExamples::IllegalSyntax` exception:
201
201
 
202
202
  * Lookarounds, e.g. `/foo(?=bar)/`, `/foo(?!bar)/`, `/(?<=foo)bar/`, `/(?<!foo)bar/`
203
- * [Anchors](http://ruby-doc.org/core-2.2.0/Regexp.html#class-Regexp-label-Anchors) (`\b`, `\B`, `\G`, `^`, `\A`, `$`, `\z`, `\Z`), e.g. `/\bword\b/`, `/line1\n^line2/`
203
+ * [Anchors](http://ruby-doc.org/core/Regexp.html#class-Regexp-label-Anchors) (`\b`, `\B`, `\G`, `^`, `\A`, `$`, `\z`, `\Z`), e.g. `/\bword\b/`, `/line1\n^line2/`
204
204
  * Anchors are really just special cases of lookarounds!
205
205
  * However, a special case has been made to allow `^`, `\A` and `\G` at the start of a pattern; and to allow `$`, `\z` and `\Z` at the end of pattern. In such cases, the characters are effectively just ignored.
206
206
  * Subexpression calls (`\g`), e.g. `/(?<name> ... \g<name>* )/`
@@ -19,7 +19,8 @@ module RegexpExamples
19
19
  end
20
20
 
21
21
  def self.join_preserving_capture_groups(result)
22
- # Only save the LAST group from repeated capture groups, e.g. /([ab]){2}/
22
+ # Only save the LAST group from repeated capture groups, because
23
+ # e.g. /([ab]){2} \1/.examples should NOT include "ab a"
23
24
  # (Hence the need for "reverse"!)
24
25
  subgroups = result
25
26
  .flat_map(&:all_subgroups)
@@ -14,8 +14,8 @@ module RegexpExamples
14
14
 
15
15
  attr_reader :range_store
16
16
 
17
- def initialize(filename = STORE_FILENAME)
18
- @range_store = PStore.new(File.expand_path("../../../db/#{filename}", __FILE__))
17
+ def initialize
18
+ @range_store = PStore.new(unicode_ranges_file)
19
19
  end
20
20
 
21
21
  def get(key)
@@ -28,6 +28,13 @@ module RegexpExamples
28
28
 
29
29
  private
30
30
 
31
+ def unicode_ranges_file
32
+ db_path = File.join(__dir__, '../../db')
33
+ Dir["#{db_path}/*.pstore"].sort.select do |file|
34
+ file <= "#{db_path}/unicode_ranges_#{RUBY_VERSION[0..2]}.pstore"
35
+ end.last
36
+ end
37
+
31
38
  # TODO: Document example input/output of this method
32
39
  # It's pretty simple, but this code is a little confusing!!
33
40
  def ranges_to_unicode(ranges)
@@ -1,4 +1,4 @@
1
1
  # Gem version
2
2
  module RegexpExamples
3
- VERSION = '1.2.1'
3
+ VERSION = '1.3.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regexp-examples
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Lord
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,6 @@ files:
54
54
  - README.md
55
55
  - Rakefile
56
56
  - db/unicode_ranges_2.0.pstore
57
- - db/unicode_ranges_2.1.pstore
58
57
  - db/unicode_ranges_2.2.pstore
59
58
  - db/unicode_ranges_2.3.pstore
60
59
  - db/unicode_ranges_2.4.pstore
@@ -1 +0,0 @@
1
- unicode_ranges_2.0.pstore