fast_regexp 0.6.1 → 0.6.2

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
  SHA256:
3
- metadata.gz: b7e4b114057d201c62b2d8ec4405b3d2554c1cebf1399433d275e111b93864dd
4
- data.tar.gz: da33511a662b556bcd9d085d0d3a52e2a138120b040a79b37015970486630ee5
3
+ metadata.gz: ece32247dfc6514f567a262e759bf5bc28a63d45703547316851dabdd19f5d27
4
+ data.tar.gz: f68fc5c53b8544fff834dabc4e1d2e516d0a57d6c529e273b416b33f8f6194f4
5
5
  SHA512:
6
- metadata.gz: 6417817f643dd1f81979e02f75b5c211c2921e87fa448fdf33c2a7da4c44980ebe6e53f9a91feb18e494e2feafbbfb03d004d3c97e51a91e3de182d0b09132a1
7
- data.tar.gz: 6ad069ffca51038fe5f74a6ad8496a672c25c8044e76cb084dd965a8cd380beaebba99908460431e41d223f96ac9168d0f02d6fca2e05f3d3fcf3c5661e8b1e2
6
+ metadata.gz: f787fa035f0a0ffa54d717af678068d832831884743210f68094565e57545c2e7da80af7e246af8a255416bbf235092364c850925d926e05fac704e1039957bc
7
+ data.tar.gz: 7cc68035055b11e1f2aa2f89c61e558cd6e5b7e40e69b0b3b793c67b572877abad4800a1258520e65f7b25b14323160e4dd70a13813aff9b8639c622cb51a008
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fast
4
4
  class Regexp
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.2"
6
6
  end
7
7
  end
data/lib/fast_regexp.rb CHANGED
@@ -45,13 +45,21 @@ module Fast
45
45
  allocate.tap { |re| re.send(:initialize, translated, original: pattern, **opts) }
46
46
  end
47
47
 
48
- # Bulk-compile a symbol-keyed hash of patterns. Handy for defining a set
49
- # of regex constants in one shot:
48
+ # Bulk-compile a set of patterns. Two call shapes:
50
49
  #
51
- # RE = Fast::Regexp.create_many(word: '\w+', num: '\d+').freeze
52
- # RE[:word].match("hello")
53
- def create_many(**patterns)
54
- patterns.transform_values { |pat| new(pat) }
50
+ # Fast::Regexp.create_many(word: '\w+', num: '\d+')
51
+ # # => { word: #<Fast::Regexp ...>, num: #<Fast::Regexp ...> }
52
+ #
53
+ # Fast::Regexp.create_many('\w+', '\d+')
54
+ # # => [#<Fast::Regexp ...>, #<Fast::Regexp ...>]
55
+ #
56
+ # Mixing the two raises ArgumentError — pick one shape per call.
57
+ def create_many(*patterns, **named)
58
+ if !patterns.empty? && !named.empty?
59
+ raise ArgumentError, "create_many accepts positional patterns OR keyword patterns, not both"
60
+ end
61
+ return named.transform_values { |pat| new(pat) } if patterns.empty?
62
+ patterns.map { |pat| new(pat) }
55
63
  end
56
64
 
57
65
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_regexp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Jacobs