corefines 1.4.0 → 1.5.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 +4 -4
- data/CHANGELOG.adoc +5 -0
- data/README.adoc +3 -3
- data/lib/corefines/string.rb +15 -12
- data/lib/corefines/version.rb +1 -1
- data/spec/string/{to_regexp_spec.rb → to_re_spec.rb} +9 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3779e9f17fb899aa96118417ea1426efcdb53d9
|
4
|
+
data.tar.gz: d72b1df9289ae8b439d698af8ae66b469d5aa492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6c1f9221db16740578b134c66820695db1e3ac332e80803c3ff204da2cb77c7ae2374ab43ba0f327c434a3d7399b1dd0b821e45e407a8631e77a86ff4488f8
|
7
|
+
data.tar.gz: e3f0db1ad0602e6e24434d24f17b0a6eeaf0a0173264208aa0e47968d649b178227a9a0cde320a0304b22b65a5cc5637f0e7fc4f2649d79cf0d88da9ac19aee4
|
data/CHANGELOG.adoc
CHANGED
@@ -4,6 +4,11 @@
|
|
4
4
|
:issue-uri: {repo-uri}/issues
|
5
5
|
|
6
6
|
|
7
|
+
== 1.5.0 (2015-05-03)
|
8
|
+
|
9
|
+
* Rename String refinement `#to_regexp` to `#to_re` to avoid bug https://bugs.ruby-lang.org/issues/11117[#11117] in MRI.
|
10
|
+
|
11
|
+
|
7
12
|
== 1.4.0 (2015-05-03)
|
8
13
|
|
9
14
|
* Add new refinement {doc-base-url}/String/ForceUTF8[String#force_utf8].
|
data/README.adoc
CHANGED
@@ -41,12 +41,12 @@ TODO
|
|
41
41
|
Add this line to your application’s Gemfile:
|
42
42
|
|
43
43
|
[source]
|
44
|
-
gem 'corefines', '~> 1.
|
44
|
+
gem 'corefines', '~> 1.5'
|
45
45
|
|
46
46
|
or to your gemspec:
|
47
47
|
|
48
48
|
[source]
|
49
|
-
s.add_runtime_dependency 'corefines', '~> 1.
|
49
|
+
s.add_runtime_dependency 'corefines', '~> 1.5'
|
50
50
|
|
51
51
|
and then execute:
|
52
52
|
|
@@ -171,7 +171,7 @@ Not ideal indeed, but probably the best of what we can achieve.
|
|
171
171
|
** {doc-base-url}/String/RelativePathFrom[#relative_path_from]
|
172
172
|
** {doc-base-url}/String/Remove[#remove]
|
173
173
|
** {doc-base-url}/String/ToB[#to_b]
|
174
|
-
** {doc-base-url}/String/
|
174
|
+
** {doc-base-url}/String/ToRe[#to_re]
|
175
175
|
** {doc-base-url}/String/Unindent[#unindent] (alias `#strip_heredoc`)
|
176
176
|
* {doc-base-url}/Symbol[Symbol]
|
177
177
|
** {doc-base-url}/Symbol/Call[#call]
|
data/lib/corefines/string.rb
CHANGED
@@ -314,22 +314,25 @@ module Corefines
|
|
314
314
|
end
|
315
315
|
|
316
316
|
##
|
317
|
-
# @!method
|
317
|
+
# @!method to_re(opts = {})
|
318
318
|
# Returns a regular expression represented by this string.
|
319
319
|
#
|
320
320
|
# @example
|
321
|
-
# '/^foo/'.
|
322
|
-
# '/foo/i'.
|
323
|
-
# 'foo'.
|
321
|
+
# '/^foo/'.to_re # => /^foo/
|
322
|
+
# '/foo/i'.to_re # => /foo/i
|
323
|
+
# 'foo'.to_re # => nil
|
324
324
|
#
|
325
|
-
# 'foo'.
|
326
|
-
# '^foo*'.
|
325
|
+
# 'foo'.to_re(literal: true) # => /foo/
|
326
|
+
# '^foo*'.to_re(literal: true) # => /\^foo\*/
|
327
327
|
#
|
328
|
-
# '/foo/'.
|
329
|
-
# '$foo/'.
|
330
|
-
# ''.
|
328
|
+
# '/foo/'.to_re(detect: true) # => /foo/
|
329
|
+
# '$foo/'.to_re(detect: true) # => /\$foo\//
|
330
|
+
# ''.to_re(detect: true) # => nil
|
331
331
|
#
|
332
|
-
# '/foo/'.
|
332
|
+
# '/foo/'.to_re(multiline: true) # => /foo/m
|
333
|
+
#
|
334
|
+
# @note This method was renamed from +to_regexp+ to +to_re+ due to bug
|
335
|
+
# in MRI, see {#11117}[https://bugs.ruby-lang.org/issues/11117].
|
333
336
|
#
|
334
337
|
# @param opts [Hash] options
|
335
338
|
# @option opts :literal [Boolean] treat meta characters and other regexp
|
@@ -344,9 +347,9 @@ module Corefines
|
|
344
347
|
# @return [Regexp, nil] a regexp, or +nil+ if +:literal+ is not set or
|
345
348
|
# +false+ and this string doesn't represent a valid regexp or is empty.
|
346
349
|
#
|
347
|
-
module
|
350
|
+
module ToRe
|
348
351
|
refine ::String do
|
349
|
-
def
|
352
|
+
def to_re(opts = {})
|
350
353
|
|
351
354
|
if opts[:literal]
|
352
355
|
content = ::Regexp.escape(self)
|
data/lib/corefines/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
describe String do
|
4
|
-
using Corefines::String::
|
4
|
+
using Corefines::String::to_re
|
5
5
|
|
6
|
-
describe '
|
6
|
+
describe 'to_re' do
|
7
7
|
|
8
8
|
context "with defaults" do
|
9
9
|
{
|
@@ -20,13 +20,13 @@ describe String do
|
|
20
20
|
}
|
21
21
|
.each do |str, expected|
|
22
22
|
it "returns regexp '#{expected.inspect}' for string '#{str}'" do
|
23
|
-
expect(str.
|
23
|
+
expect(str.to_re).to eql expected
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
%w[n e s u nesu].each do |kcode|
|
28
28
|
it "ignores encoding option: #{kcode}" do
|
29
|
-
expect("/foo/#{kcode}".
|
29
|
+
expect("/foo/#{kcode}".to_re).to eql /foo/
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -38,7 +38,7 @@ describe String do
|
|
38
38
|
}
|
39
39
|
.each do |str, expected|
|
40
40
|
it "returns regexp '#{expected.inspect}' for string '#{str}" do
|
41
|
-
expect(str.
|
41
|
+
expect(str.to_re(literal: true)).to eql expected
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -55,21 +55,21 @@ describe String do
|
|
55
55
|
}
|
56
56
|
.each do |str, expected|
|
57
57
|
it "returns regexp '#{expected.inspect}' for string '#{str}'" do
|
58
|
-
expect(str.
|
58
|
+
expect(str.to_re(detect: true)).to eql expected
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
context "with ignore_case" do
|
64
|
-
it { expect('/foo/'.
|
64
|
+
it { expect('/foo/'.to_re(ignore_case: true)).to eql /foo/i }
|
65
65
|
end
|
66
66
|
|
67
67
|
context "with multiline" do
|
68
|
-
it { expect('/foo/'.
|
68
|
+
it { expect('/foo/'.to_re(multiline: true)).to eql /foo/m }
|
69
69
|
end
|
70
70
|
|
71
71
|
context "with extended" do
|
72
|
-
it { expect('/foo/'.
|
72
|
+
it { expect('/foo/'.to_re(extended: true)).to eql /foo/x }
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corefines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Jirutka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -149,7 +149,7 @@ files:
|
|
149
149
|
- spec/string/relative_path_from_spec.rb
|
150
150
|
- spec/string/remove_spec.rb
|
151
151
|
- spec/string/to_b_spec.rb
|
152
|
-
- spec/string/
|
152
|
+
- spec/string/to_re_spec.rb
|
153
153
|
- spec/string/unindent_spec.rb
|
154
154
|
- spec/support/alias_submodules_spec.rb
|
155
155
|
- spec/support/classes_including_module_spec.rb
|