to_regexp 0.1.2 → 0.2.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.
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.2.0 / 2013-02-13
2
+
3
+ * Breaking changes
4
+
5
+ * Strings are no longer stripped before conversion is attempted
6
+ * :detect will make '' into nil and '//' into //
7
+
1
8
  0.1.2 / 2013-02-13
2
9
 
3
10
  * Enhancements
@@ -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.strip
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
@@ -1,3 +1,3 @@
1
1
  module ToRegexp
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: to_regexp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: