re2 0.7.0 → 1.0.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.
@@ -1,12 +1,10 @@
1
- require "spec_helper"
2
-
3
- describe RE2::Scanner do
1
+ RSpec.describe RE2::Scanner do
4
2
  describe "#regexp" do
5
3
  it "returns the original pattern for the scanner" do
6
4
  re = RE2::Regexp.new('(\w+)')
7
5
  scanner = re.scan("It is a truth")
8
6
 
9
- scanner.regexp.must_be_same_as(re)
7
+ expect(scanner.regexp).to equal(re)
10
8
  end
11
9
  end
12
10
 
@@ -16,7 +14,7 @@ describe RE2::Scanner do
16
14
  text = "It is a truth"
17
15
  scanner = re.scan(text)
18
16
 
19
- scanner.string.must_be_same_as(text)
17
+ expect(scanner.string).to equal(text)
20
18
  end
21
19
  end
22
20
 
@@ -24,32 +22,32 @@ describe RE2::Scanner do
24
22
  it "returns the next array of matches" do
25
23
  r = RE2::Regexp.new('(\w+)')
26
24
  scanner = r.scan("It is a truth universally acknowledged")
27
- scanner.scan.must_equal(["It"])
28
- scanner.scan.must_equal(["is"])
29
- scanner.scan.must_equal(["a"])
30
- scanner.scan.must_equal(["truth"])
31
- scanner.scan.must_equal(["universally"])
32
- scanner.scan.must_equal(["acknowledged"])
33
- scanner.scan.must_be_nil
25
+ expect(scanner.scan).to eq(["It"])
26
+ expect(scanner.scan).to eq(["is"])
27
+ expect(scanner.scan).to eq(["a"])
28
+ expect(scanner.scan).to eq(["truth"])
29
+ expect(scanner.scan).to eq(["universally"])
30
+ expect(scanner.scan).to eq(["acknowledged"])
31
+ expect(scanner.scan).to be_nil
34
32
  end
35
33
 
36
34
  it "returns an empty array if there are no capturing groups" do
37
35
  r = RE2::Regexp.new('\w+')
38
36
  scanner = r.scan("Foo bar")
39
- scanner.scan.must_equal([])
37
+ expect(scanner.scan).to eq([])
40
38
  end
41
39
 
42
40
  it "returns nil if there is no match" do
43
41
  r = RE2::Regexp.new('\d+')
44
42
  scanner = r.scan("Foo bar")
45
- scanner.scan.must_be_nil
43
+ expect(scanner.scan).to be_nil
46
44
  end
47
45
  end
48
46
 
49
47
  it "is enumerable" do
50
48
  r = RE2::Regexp.new('(\d)')
51
49
  scanner = r.scan("There are 1 some 2 numbers 3")
52
- scanner.must_be_kind_of(Enumerable)
50
+ expect(scanner).to be_a(Enumerable)
53
51
  end
54
52
 
55
53
  describe "#each" do
@@ -61,7 +59,7 @@ describe RE2::Scanner do
61
59
  matches << match
62
60
  end
63
61
 
64
- matches.must_equal([["1"], ["2"], ["3"]])
62
+ expect(matches).to eq([["1"], ["2"], ["3"]])
65
63
  end
66
64
 
67
65
  it "returns an enumerator when not given a block" do
@@ -70,9 +68,9 @@ describe RE2::Scanner do
70
68
 
71
69
  # Prior to Ruby 1.9, Enumerator was within Enumerable.
72
70
  if defined?(Enumerator)
73
- scanner.each.must_be_kind_of(Enumerator)
71
+ expect(scanner.each).to be_a(Enumerator)
74
72
  elsif defined?(Enumerable::Enumerator)
75
- scanner.each.must_be_kind_of(Enumerable::Enumerator)
73
+ expect(scanner.each).to be_a(Enumerable::Enumerator)
76
74
  end
77
75
  end
78
76
  end
@@ -81,10 +79,10 @@ describe RE2::Scanner do
81
79
  it "resets any consumption" do
82
80
  r = RE2::Regexp.new('(\d)')
83
81
  scanner = r.scan("There are 1 some 2 numbers 3")
84
- scanner.to_enum.first.must_equal(["1"])
85
- scanner.to_enum.first.must_equal(["2"])
82
+ expect(scanner.to_enum.first).to eq(["1"])
83
+ expect(scanner.to_enum.first).to eq(["2"])
86
84
  scanner.rewind
87
- scanner.to_enum.first.must_equal(["1"])
85
+ expect(scanner.to_enum.first).to eq(["1"])
88
86
  end
89
87
  end
90
88
  end
@@ -1,57 +1,56 @@
1
- require "spec_helper"
2
1
  require "re2/string"
3
2
 
4
3
  class String
5
4
  include RE2::String
6
5
  end
7
6
 
8
- describe RE2::String do
7
+ RSpec.describe RE2::String do
9
8
  describe "#re2_sub" do
10
9
  it "delegates to RE2.Replace to perform replacement" do
11
- "My name is Robert Paulson".re2_sub('Robert', 'Crobert').must_equal("My name is Crobert Paulson")
10
+ expect("My name is Robert Paulson".re2_sub('Robert', 'Crobert')).to eq("My name is Crobert Paulson")
12
11
  end
13
12
 
14
13
  it "doesn't perform an in-place replacement" do
15
14
  string = "My name is Robert Paulson"
16
- string.re2_sub('Robert', 'Crobert').wont_be_same_as(string)
15
+ expect(string.re2_sub('Robert', 'Crobert')).to_not equal(string)
17
16
  end
18
17
  end
19
18
 
20
19
  describe "#re2_gsub" do
21
20
  it "delegates to RE2.GlobalReplace to perform replacement" do
22
- "My name is Robert Paulson".re2_gsub('a', 'e').must_equal("My neme is Robert Peulson")
21
+ expect("My name is Robert Paulson".re2_gsub('a', 'e')).to eq("My neme is Robert Peulson")
23
22
  end
24
23
 
25
24
  it "doesn't perform an in-place replacement" do
26
25
  string = "My name is Robert Paulson"
27
- string.re2_gsub('a', 'e').wont_be_same_as(string)
26
+ expect(string.re2_gsub('a', 'e')).to_not equal(string)
28
27
  end
29
28
  end
30
29
 
31
30
  describe "#re2_match" do
32
31
  it "delegates to RE2::Regexp#match to perform matches" do
33
32
  md = "My name is Robert Paulson".re2_match('My name is (\S+) (\S+)')
34
- md.must_be_instance_of(RE2::MatchData)
35
- md[0].must_equal("My name is Robert Paulson")
36
- md[1].must_equal("Robert")
37
- md[2].must_equal("Paulson")
33
+ expect(md).to be_a(RE2::MatchData)
34
+ expect(md[0]).to eq("My name is Robert Paulson")
35
+ expect(md[1]).to eq("Robert")
36
+ expect(md[2]).to eq("Paulson")
38
37
  end
39
38
 
40
39
  it "supports limiting the number of matches" do
41
40
  md = "My name is Robert Paulson".re2_match('My name is (\S+) (\S+)', 0)
42
- md.must_equal(true)
41
+ expect(md).to eq(true)
43
42
  end
44
43
  end
45
44
 
46
45
  describe "#re2_escape" do
47
46
  it "escapes the string for use in regular expressions" do
48
- "1.5-2.0?".re2_escape.must_equal('1\.5\-2\.0\?')
47
+ expect("1.5-2.0?".re2_escape).to eq('1\.5\-2\.0\?')
49
48
  end
50
49
  end
51
50
 
52
51
  describe "#re2_quote" do
53
52
  it "escapes the string for use in regular expressions" do
54
- "1.5-2.0?".re2_quote.must_equal('1\.5\-2\.0\?')
53
+ expect("1.5-2.0?".re2_quote).to eq('1\.5\-2\.0\?')
55
54
  end
56
55
  end
57
56
  end
@@ -1,79 +1,75 @@
1
- require "spec_helper"
2
-
3
- describe RE2 do
1
+ RSpec.describe RE2 do
4
2
  describe "#Replace" do
5
3
  it "only replaces the first occurrence of the pattern" do
6
- RE2.Replace("woo", "o", "a").must_equal("wao")
4
+ expect(RE2.Replace("woo", "o", "a")).to eq("wao")
7
5
  end
8
6
 
9
7
  it "performs replacement based on regular expressions" do
10
- RE2.Replace("woo", "o+", "e").must_equal("we")
8
+ expect(RE2.Replace("woo", "o+", "e")).to eq("we")
11
9
  end
12
10
 
13
11
  it "supports flags in patterns" do
14
- RE2.Replace("Good morning", "(?i)gOOD MORNING", "hi").must_equal("hi")
12
+ expect(RE2.Replace("Good morning", "(?i)gOOD MORNING", "hi")).to eq("hi")
15
13
  end
16
14
 
17
15
  it "does not perform replacements in-place" do
18
16
  name = "Robert"
19
17
  replacement = RE2.Replace(name, "R", "Cr")
20
- replacement.must_equal("Crobert")
21
- name.wont_be_same_as(replacement)
18
+ expect(name).to_not equal(replacement)
22
19
  end
23
20
 
24
21
  it "supports passing an RE2::Regexp as the pattern" do
25
22
  re = RE2::Regexp.new('wo{2}')
26
- RE2.Replace("woo", re, "miaow").must_equal("miaow")
23
+ expect(RE2.Replace("woo", re, "miaow")).to eq("miaow")
27
24
  end
28
25
 
29
26
  it "respects any passed RE2::Regexp's flags" do
30
27
  re = RE2::Regexp.new('gOOD MORNING', :case_sensitive => false)
31
- RE2.Replace("Good morning", re, "hi").must_equal("hi")
28
+ expect(RE2.Replace("Good morning", re, "hi")).to eq("hi")
32
29
  end
33
30
 
34
31
  if String.method_defined?(:encoding)
35
32
  it "preserves the original string's encoding" do
36
33
  original = "Foo"
37
34
  replacement = RE2.Replace(original, "oo", "ah")
38
- original.encoding.must_equal(replacement.encoding)
35
+ expect(original.encoding).to eq(replacement.encoding)
39
36
  end
40
37
  end
41
38
  end
42
39
 
43
40
  describe "#GlobalReplace" do
44
41
  it "replaces every occurrence of a pattern" do
45
- RE2.GlobalReplace("woo", "o", "a").must_equal("waa")
42
+ expect(RE2.GlobalReplace("woo", "o", "a")).to eq("waa")
46
43
  end
47
44
 
48
45
  it "performs replacement based on regular expressions" do
49
- RE2.GlobalReplace("woohoo", "o+", "e").must_equal("wehe")
46
+ expect(RE2.GlobalReplace("woohoo", "o+", "e")).to eq("wehe")
50
47
  end
51
48
 
52
49
  it "supports flags in patterns" do
53
- RE2.GlobalReplace("Robert", "(?i)r", "w").must_equal("wobewt")
50
+ expect(RE2.GlobalReplace("Robert", "(?i)r", "w")).to eq("wobewt")
54
51
  end
55
52
 
56
53
  it "does not perform replacement in-place" do
57
54
  name = "Robert"
58
55
  replacement = RE2.GlobalReplace(name, "(?i)R", "w")
59
- replacement.must_equal("wobewt")
60
- name.wont_be_same_as(replacement)
56
+ expect(name).to_not equal(replacement)
61
57
  end
62
58
 
63
59
  it "supports passing an RE2::Regexp as the pattern" do
64
60
  re = RE2::Regexp.new('wo{2,}')
65
- RE2.GlobalReplace("woowooo", re, "miaow").must_equal("miaowmiaow")
61
+ expect(RE2.GlobalReplace("woowooo", re, "miaow")).to eq("miaowmiaow")
66
62
  end
67
63
 
68
64
  it "respects any passed RE2::Regexp's flags" do
69
65
  re = RE2::Regexp.new('gOOD MORNING', :case_sensitive => false)
70
- RE2.GlobalReplace("Good morning Good morning", re, "hi").must_equal("hi hi")
66
+ expect(RE2.GlobalReplace("Good morning Good morning", re, "hi")).to eq("hi hi")
71
67
  end
72
68
  end
73
69
 
74
70
  describe "#QuoteMeta" do
75
71
  it "escapes a string so it can be used as a regular expression" do
76
- RE2.QuoteMeta("1.5-2.0?").must_equal('1\.5\-2\.0\?')
72
+ expect(RE2.QuoteMeta("1.5-2.0?")).to eq('1\.5\-2\.0\?')
77
73
  end
78
74
  end
79
75
  end
@@ -1,3 +1,19 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
1
  require "re2"
3
- require "minitest/autorun"
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
+ end
7
+
8
+ config.mock_with :rspec do |mocks|
9
+ mocks.verify_partial_doubles = true
10
+ end
11
+
12
+ config.filter_run :focus
13
+ config.run_all_when_everything_filtered = true
14
+ config.disable_monkey_patching!
15
+ config.warnings = true
16
+ config.default_formatter = 'doc' if config.files_to_run.one?
17
+ config.order = :random
18
+ Kernel.srand config.seed
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: re2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Mucur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-25 00:00:00.000000000 Z
11
+ date: 2016-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.9'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.4'
33
+ version: '3.2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.4'
40
+ version: '3.2'
41
41
  description: Ruby bindings to re2, "an efficient, principled regular expression library".
42
42
  email: ruby.re2@librelist.com
43
43
  executables: []
@@ -60,9 +60,9 @@ files:
60
60
  - spec/re2/string_spec.rb
61
61
  - spec/re2_spec.rb
62
62
  - spec/spec_helper.rb
63
- homepage: http://github.com/mudge/re2
63
+ homepage: https://github.com/mudge/re2
64
64
  licenses:
65
- - BSD
65
+ - BSD-3-Clause
66
66
  metadata: {}
67
67
  post_install_message:
68
68
  rdoc_options: []
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.2.2
83
+ rubygems_version: 2.5.1
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Ruby bindings to re2.