to_regexp 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/lib/to_regexp.rb +3 -1
- data/lib/to_regexp/version.rb +1 -1
- data/test/test_to_regexp.rb +2 -0
- metadata +1 -1
data/CHANGELOG
CHANGED
data/lib/to_regexp.rb
CHANGED
@@ -35,7 +35,9 @@ module ToRegexp
|
|
35
35
|
unless options.is_a?(::Hash)
|
36
36
|
raise ::ArgumentError, "[to_regexp] Options must be a Hash"
|
37
37
|
end
|
38
|
-
str = self
|
38
|
+
str = self
|
39
|
+
|
40
|
+
return if options[:detect] and str == ''
|
39
41
|
|
40
42
|
if options[:literal] or (options[:detect] and REGEXP_DELIMITERS.none? { |k, v| str.start_with?(k) and str.end_with?(v) })
|
41
43
|
content = ::Regexp.escape str
|
data/lib/to_regexp/version.rb
CHANGED
data/test/test_to_regexp.rb
CHANGED
@@ -123,6 +123,8 @@ class TestToRegexp < Test::Unit::TestCase
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def test_016_detect
|
126
|
+
assert_equal nil, ''.to_regexp(detect: true)
|
127
|
+
assert_equal //, '//'.to_regexp(detect: true)
|
126
128
|
assert_equal /foo/, 'foo'.to_regexp(detect: true)
|
127
129
|
assert_equal %r{foo\\b}, 'foo\b'.to_regexp(detect: true)
|
128
130
|
assert_equal %r{foo\b}, '/foo\b/'.to_regexp(detect: true)
|