unicode_scanner 1.0.0 → 1.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 544fe42b2d42bf92fd7d75f883dfaaa302bfebe3e5d63915041981f6826fd992
4
+ data.tar.gz: ce414e2699c4d09bc6792ba23358ec7a58f8e275d3ba6b849e646528e74c42f3
5
+ SHA512:
6
+ metadata.gz: c23b7ee2d1604f260fd5007243b71ab8d93b5bedd44c3b3951ed4c462b0210412e7ac0500b28ea2654e6e57c83419e439a55d02434ea8cf20b80119f3bb9b7fe
7
+ data.tar.gz: 325d033aa740c34e0d6c819bc62e14ed45f28f769919dc9920d1c24d39552bf7ef153116920fd7481a3c7bce8d0e397eb86c851f009d43726a1741e6a0bb96dd
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format=documentation
@@ -0,0 +1 @@
1
+ scanner
@@ -0,0 +1 @@
1
+ 2.7.0
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.6"
4
+ - "2.5"
5
+ before_install:
6
+ - gem update --system
7
+ - gem install bundler
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
4
  gem 'rspec'
@@ -1,27 +1,69 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.8.4)
7
- bundler (~> 1.0)
4
+ addressable (2.4.0)
5
+ builder (3.2.4)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.3)
9
+ faraday (0.9.2)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.5.0)
12
+ github_api (0.16.0)
13
+ addressable (~> 2.4.0)
14
+ descendants_tracker (~> 0.0.4)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 3.4)
17
+ mime-types (>= 1.16, < 3.0)
18
+ oauth2 (~> 1.0)
19
+ hashie (4.0.0)
20
+ highline (2.0.3)
21
+ jeweler (2.3.9)
22
+ builder
23
+ bundler
8
24
  git (>= 1.2.5)
25
+ github_api (~> 0.16.0)
26
+ highline (>= 1.6.15)
27
+ nokogiri (>= 1.5.10)
28
+ psych
9
29
  rake
10
30
  rdoc
11
- json (1.7.3)
12
- rake (0.9.2.2)
13
- rdoc (3.12)
14
- json (~> 1.4)
15
- redcarpet (2.1.1)
16
- rspec (2.11.0)
17
- rspec-core (~> 2.11.0)
18
- rspec-expectations (~> 2.11.0)
19
- rspec-mocks (~> 2.11.0)
20
- rspec-core (2.11.0)
21
- rspec-expectations (2.11.1)
22
- diff-lcs (~> 1.1.3)
23
- rspec-mocks (2.11.1)
24
- yard (0.8.2.1)
31
+ semver2
32
+ jwt (2.2.1)
33
+ mime-types (2.99.3)
34
+ mini_portile2 (2.4.0)
35
+ multi_json (1.14.1)
36
+ multi_xml (0.6.0)
37
+ multipart-post (2.1.1)
38
+ nokogiri (1.10.7)
39
+ mini_portile2 (~> 2.4.0)
40
+ oauth2 (1.4.2)
41
+ faraday (>= 0.8, < 2.0)
42
+ jwt (>= 1.0, < 3.0)
43
+ multi_json (~> 1.3)
44
+ multi_xml (~> 0.5)
45
+ rack (>= 1.2, < 3)
46
+ psych (3.1.0)
47
+ rack (2.0.8)
48
+ rake (13.0.1)
49
+ rdoc (6.2.1)
50
+ redcarpet (3.5.0)
51
+ rspec (3.9.0)
52
+ rspec-core (~> 3.9.0)
53
+ rspec-expectations (~> 3.9.0)
54
+ rspec-mocks (~> 3.9.0)
55
+ rspec-core (3.9.0)
56
+ rspec-support (~> 3.9.0)
57
+ rspec-expectations (3.9.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.9.0)
60
+ rspec-mocks (3.9.0)
61
+ diff-lcs (>= 1.2.0, < 2.0)
62
+ rspec-support (~> 3.9.0)
63
+ rspec-support (3.9.0)
64
+ semver2 (3.4.2)
65
+ thread_safe (0.3.6)
66
+ yard (0.9.20)
25
67
 
26
68
  PLATFORMS
27
69
  ruby
@@ -32,3 +74,6 @@ DEPENDENCIES
32
74
  redcarpet
33
75
  rspec
34
76
  yard
77
+
78
+ BUNDLED WITH
79
+ 2.1.2
data/Rakefile CHANGED
@@ -1,12 +1,10 @@
1
- # encoding: utf-8
2
-
3
1
  require 'rubygems'
4
2
  require 'bundler'
5
3
  begin
6
4
  Bundler.setup(:default, :development)
7
5
  rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
6
+ warn e.message
7
+ warn "Run `bundle install` to install missing gems"
10
8
  exit e.status_code
11
9
  end
12
10
  require 'rake'
@@ -17,8 +15,8 @@ Jeweler::Tasks.new do |gem|
17
15
  gem.name = "unicode_scanner"
18
16
  gem.homepage = "http://github.com/RISCfuture/unicode_scanner"
19
17
  gem.license = "MIT"
20
- gem.summary = %Q{Unicode-aware implementation of StringScanner}
21
- gem.description = %Q{An implementation of StringScanner that doesn't split multibyte characters.}
18
+ gem.summary = %(Unicode-aware implementation of StringScanner)
19
+ gem.description = %(An implementation of StringScanner that doesn't split multibyte characters.)
22
20
  gem.email = "git@timothymorgan.info"
23
21
  gem.authors = ["Tim Morgan"]
24
22
  # dependencies defined in Gemfile
@@ -49,5 +47,5 @@ YARD::Rake::YardocTask.new('doc') do |doc|
49
47
  doc.options << '-o' << 'doc'
50
48
  doc.options << '--title' << 'Unicode String Scanner Documentation'
51
49
 
52
- doc.files = %w( lib/**/* README.md )
50
+ doc.files = %w[lib/**/* README.md]
53
51
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -165,8 +165,9 @@ class UnicodeScanner
165
165
  # s.bol? # => true
166
166
 
167
167
  def beginning_of_line?
168
- return nil if @current > @string.length
169
- return true if @current == 0
168
+ return nil if @current > @string.size
169
+ return true if @current.zero?
170
+
170
171
  return @string[@current - 1] == "\n"
171
172
  end
172
173
 
@@ -259,7 +260,8 @@ class UnicodeScanner
259
260
 
260
261
  def getch
261
262
  return nil if eos?
262
- do_scan /./u, true, true, true
263
+
264
+ do_scan(/./u, true, true, true)
263
265
  end
264
266
 
265
267
  # Returns a string that represents the UnicodeScanner object, showing:
@@ -277,14 +279,23 @@ class UnicodeScanner
277
279
  # s.inspect # -> '#<UnicodeScanner 10/21 "...ec 12" @ " 1975...">'
278
280
 
279
281
  def inspect
280
- return "#<#{self.class.to_s} (uninitialized)>" if @string.nil?
281
- return "#<#{self.class.to_s} fin>" if eos?
282
-
283
- if @current == 0
284
- return "#<%s %d/%d @ %s>" % [self.class.to_s, @current, @string.length, inspect_after.inspect]
282
+ return "#<#{self.class} (uninitialized)>" if @string.nil?
283
+ return "#<#{self.class} fin>" if eos?
284
+
285
+ if @current.zero?
286
+ return format("#<%{class} %<cur>d/%<len>d @ %{after}>",
287
+ class: self.class.to_s,
288
+ cur: @current,
289
+ len: @string.length,
290
+ after: inspect_after.inspect)
285
291
  end
286
292
 
287
- "#<%s %d/%d %s @ %s>" % [self.class.to_s, @current, @string.length, inspect_before.inspect, inspect_after.inspect]
293
+ format("#<%{class} %<cur>d/%<len>d %{before} @ %{after}>",
294
+ class: self.class.to_s,
295
+ cur: @current,
296
+ len: @string.length,
297
+ before: inspect_before.inspect,
298
+ after: inspect_after.inspect)
288
299
  end
289
300
 
290
301
  # Tests whether the given `pattern` is matched from the current scan pointer.
@@ -311,6 +322,7 @@ class UnicodeScanner
311
322
 
312
323
  def matched
313
324
  return nil unless @matched
325
+
314
326
  @matches[0]
315
327
  end
316
328
 
@@ -335,6 +347,7 @@ class UnicodeScanner
335
347
 
336
348
  def matched_size
337
349
  return nil unless @matched
350
+
338
351
  @matches.end(0) - @matches.begin(0)
339
352
  end
340
353
 
@@ -351,6 +364,7 @@ class UnicodeScanner
351
364
 
352
365
  def peek(len)
353
366
  return '' if eos?
367
+
354
368
  @string[@current, len]
355
369
  end
356
370
 
@@ -384,9 +398,10 @@ class UnicodeScanner
384
398
  # s.rest # -> "ring"
385
399
 
386
400
  def pos=(n)
387
- n += @string.length if n < 0
388
- raise RangeError, "index out of range" if n < 0
401
+ n += @string.length if n.negative?
402
+ raise RangeError, "index out of range" if n.negative?
389
403
  raise RangeError, "index out of range" if n > @string.length
404
+
390
405
  @current = n
391
406
  end
392
407
 
@@ -401,6 +416,7 @@ class UnicodeScanner
401
416
 
402
417
  def post_match
403
418
  return nil unless @matched
419
+
404
420
  @string[@previous + @matches.end(0), @string.length]
405
421
  end
406
422
 
@@ -415,6 +431,7 @@ class UnicodeScanner
415
431
 
416
432
  def pre_match
417
433
  return nil unless @matched
434
+
418
435
  @string[0, @previous + @matches.begin(0)]
419
436
  end
420
437
 
@@ -430,6 +447,7 @@ class UnicodeScanner
430
447
 
431
448
  def rest
432
449
  return '' if eos?
450
+
433
451
  return @string[@current, @string.length]
434
452
  end
435
453
 
@@ -437,6 +455,7 @@ class UnicodeScanner
437
455
 
438
456
  def rest_size
439
457
  return 0 if eos?
458
+
440
459
  @string.length - @current
441
460
  end
442
461
 
@@ -550,7 +569,7 @@ class UnicodeScanner
550
569
 
551
570
  # @return [String] The string being scanned.
552
571
 
553
- def string() @string end
572
+ attr_reader :string
554
573
 
555
574
  # Changes the string being scanned to `str` and resets the scanner.
556
575
  #
@@ -561,7 +580,6 @@ class UnicodeScanner
561
580
  @string = str
562
581
  @matched = false
563
582
  @current = 0
564
- str
565
583
  end
566
584
 
567
585
  # Set the scan pointer to the end of the string and clear matching data.
@@ -586,6 +604,7 @@ class UnicodeScanner
586
604
 
587
605
  def unscan
588
606
  raise ScanError, "unscan failed: previous match record not exist" unless @matched
607
+
589
608
  @current = @previous
590
609
  @matched = false
591
610
  self
@@ -602,7 +621,7 @@ class UnicodeScanner
602
621
  @matches = regex.match(@string[@current, @string.length])
603
622
  return nil unless @matches
604
623
 
605
- if head_only && @matches.begin(0) > 0
624
+ if head_only && @matches.begin(0).positive?
606
625
  @matches = nil
607
626
  return nil
608
627
  end
@@ -618,8 +637,8 @@ class UnicodeScanner
618
637
  end
619
638
  end
620
639
 
621
- def inspect_before # inspect1
622
- return '' if @current == 0
640
+ def inspect_before
641
+ return '' if @current.zero?
623
642
 
624
643
  str = String.new
625
644
  len = 0
@@ -635,7 +654,7 @@ class UnicodeScanner
635
654
  return str
636
655
  end
637
656
 
638
- def inspect_after # inspect2
657
+ def inspect_after
639
658
  return '' if eos?
640
659
 
641
660
  str = String.new
@@ -5,8 +5,7 @@ require 'unicode_scanner'
5
5
 
6
6
  # Requires supporting files with custom matchers and macros, etc,
7
7
  # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
9
9
 
10
10
  RSpec.configure do |config|
11
-
12
11
  end
@@ -1,206 +1,204 @@
1
- # encoding: utf-8
2
-
3
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
2
 
5
3
  describe UnicodeScanner do
6
4
  it "should pass all the class-level examples" do
7
- s = UnicodeScanner.new('This is an example string')
8
- s.eos?.should == false
5
+ s = described_class.new('This is an example string')
6
+ expect(s.eos?).to eq(false)
9
7
 
10
- s.scan(/\w+/).should == "This"
11
- s.scan(/\w+/).should == nil
12
- s.scan(/\s+/).should == " "
13
- s.scan(/\s+/).should == nil
14
- s.scan(/\w+/).should == "is"
15
- s.eos?.should == false
8
+ expect(s.scan(/\w+/)).to eq("This")
9
+ expect(s.scan(/\w+/)).to eq(nil)
10
+ expect(s.scan(/\s+/)).to eq(" ")
11
+ expect(s.scan(/\s+/)).to eq(nil)
12
+ expect(s.scan(/\w+/)).to eq("is")
13
+ expect(s.eos?).to eq(false)
16
14
 
17
- s.scan(/\s+/).should == " "
18
- s.scan(/\w+/).should == "an"
19
- s.scan(/\s+/).should == " "
20
- s.scan(/\w+/).should == "example"
21
- s.scan(/\s+/).should == " "
22
- s.scan(/\w+/).should == "string"
23
- s.eos?.should == true
15
+ expect(s.scan(/\s+/)).to eq(" ")
16
+ expect(s.scan(/\w+/)).to eq("an")
17
+ expect(s.scan(/\s+/)).to eq(" ")
18
+ expect(s.scan(/\w+/)).to eq("example")
19
+ expect(s.scan(/\s+/)).to eq(" ")
20
+ expect(s.scan(/\w+/)).to eq("string")
21
+ expect(s.eos?).to eq(true)
24
22
 
25
- s.scan(/\s+/).should == nil
26
- s.scan(/\w+/).should == nil
23
+ expect(s.scan(/\s+/)).to eq(nil)
24
+ expect(s.scan(/\w+/)).to eq(nil)
27
25
  end
28
26
 
29
27
  it "should pass the #concat example" do
30
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
28
+ s = described_class.new("Fri Dec 12 1975 14:39")
31
29
  s.scan(/Fri /)
32
30
  s << " +1000 GMT"
33
- s.string.should == "Fri Dec 12 1975 14:39 +1000 GMT"
34
- s.scan(/Dec/).should == "Dec"
31
+ expect(s.string).to eq("Fri Dec 12 1975 14:39 +1000 GMT")
32
+ expect(s.scan(/Dec/)).to eq("Dec")
35
33
  end
36
34
 
37
35
  it "should pass the #[] example" do
38
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
39
- s.scan(/(\w+) (\w+) (\d+) /).should == "Fri Dec 12 "
40
- s[0].should == "Fri Dec 12 "
41
- s[1].should == "Fri"
42
- s[2].should == "Dec"
43
- s[3].should == "12"
44
- s.post_match.should == "1975 14:39"
45
- s.pre_match.should == ""
36
+ s = described_class.new("Fri Dec 12 1975 14:39")
37
+ expect(s.scan(/(\w+) (\w+) (\d+) /)).to eq("Fri Dec 12 ")
38
+ expect(s[0]).to eq("Fri Dec 12 ")
39
+ expect(s[1]).to eq("Fri")
40
+ expect(s[2]).to eq("Dec")
41
+ expect(s[3]).to eq("12")
42
+ expect(s.post_match).to eq("1975 14:39")
43
+ expect(s.pre_match).to eq("")
46
44
  end
47
45
 
48
46
  it "should pass the #beginning_of_line? example" do
49
- s = UnicodeScanner.new("test\ntest\n")
50
- s.bol?.should == true
47
+ s = described_class.new("test\ntest\n")
48
+ expect(s.bol?).to eq(true)
51
49
  s.scan(/te/)
52
- s.bol?.should == false
50
+ expect(s.bol?).to eq(false)
53
51
  s.scan(/st\n/)
54
- s.bol?.should == true
52
+ expect(s.bol?).to eq(true)
55
53
  s.terminate
56
- s.bol?.should == true
54
+ expect(s.bol?).to eq(true)
57
55
  end
58
56
 
59
57
  it "should pass the #check example" do
60
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
61
- s.check(/Fri/).should == "Fri"
62
- s.pos.should == 0
63
- s.matched.should == "Fri"
64
- s.check(/12/).should == nil
65
- s.matched.should == nil
58
+ s = described_class.new("Fri Dec 12 1975 14:39")
59
+ expect(s.check(/Fri/)).to eq("Fri")
60
+ expect(s.pos).to eq(0)
61
+ expect(s.matched).to eq("Fri")
62
+ expect(s.check(/12/)).to eq(nil)
63
+ expect(s.matched).to eq(nil)
66
64
  end
67
65
 
68
66
  it "should pass the #check_until example" do
69
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
70
- s.check_until(/12/).should == "Fri Dec 12"
71
- s.pos.should == 0
72
- s.matched.should == "12"
67
+ s = described_class.new("Fri Dec 12 1975 14:39")
68
+ expect(s.check_until(/12/)).to eq("Fri Dec 12")
69
+ expect(s.pos).to eq(0)
70
+ expect(s.matched).to eq("12")
73
71
  end
74
72
 
75
73
  it "should pass the #eos? example" do
76
- s = UnicodeScanner.new('test string')
77
- s.eos?.should == false
74
+ s = described_class.new('test string')
75
+ expect(s.eos?).to eq(false)
78
76
  s.scan(/test/)
79
- s.eos?.should == false
77
+ expect(s.eos?).to eq(false)
80
78
  s.terminate
81
- s.eos?.should == true
79
+ expect(s.eos?).to eq(true)
82
80
  end
83
81
 
84
82
  it "should pass the #exist? example" do
85
- s = UnicodeScanner.new('test string')
86
- s.exist?(/s/).should == 3
87
- s.scan(/test/).should == "test"
88
- s.exist?(/s/).should == 2
89
- s.exist?(/e/).should == nil
83
+ s = described_class.new('test string')
84
+ expect(s.exist?(/s/)).to eq(3)
85
+ expect(s.scan(/test/)).to eq("test")
86
+ expect(s.exist?(/s/)).to eq(2)
87
+ expect(s.exist?(/e/)).to eq(nil)
90
88
  end
91
89
 
92
90
  it "should pass a tweaked version of the #getch example" do
93
- s = UnicodeScanner.new("ab")
94
- s.getch.should == "a"
95
- s.getch.should == "b"
96
- s.getch.should == nil
91
+ s = described_class.new("ab")
92
+ expect(s.getch).to eq("a")
93
+ expect(s.getch).to eq("b")
94
+ expect(s.getch).to eq(nil)
97
95
 
98
- s = UnicodeScanner.new("ぁ")
99
- s.getch.should == "ぁ" # Japanese hira-kana "A" in EUC-JP
100
- s.getch.should == nil
96
+ s = described_class.new("ぁ")
97
+ expect(s.getch).to eq("ぁ") # Japanese hira-kana "A" in EUC-JP
98
+ expect(s.getch).to eq(nil)
101
99
  end
102
100
 
103
101
  it "should pass the #inspect example" do
104
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
105
- s.inspect.should == '#<UnicodeScanner 0/21 @ "Fri D...">'
106
- s.scan_until(/12/).should == "Fri Dec 12"
107
- s.inspect.should == '#<UnicodeScanner 10/21 "...ec 12" @ " 1975...">'
102
+ s = described_class.new("Fri Dec 12 1975 14:39")
103
+ expect(s.inspect).to eq('#<UnicodeScanner 0/21 @ "Fri D...">')
104
+ expect(s.scan_until(/12/)).to eq("Fri Dec 12")
105
+ expect(s.inspect).to eq('#<UnicodeScanner 10/21 "...ec 12" @ " 1975...">')
108
106
  end
109
107
 
110
108
  it "should pass the #match? example" do
111
- s = UnicodeScanner.new('test string')
112
- s.match?(/\w+/).should == 4
113
- s.match?(/\w+/).should == 4
114
- s.match?(/\s+/).should == nil
109
+ s = described_class.new('test string')
110
+ expect(s.match?(/\w+/)).to eq(4)
111
+ expect(s.match?(/\w+/)).to eq(4)
112
+ expect(s.match?(/\s+/)).to eq(nil)
115
113
  end
116
114
 
117
115
  it "should pass the #matched example" do
118
- s = UnicodeScanner.new('test string')
119
- s.match?(/\w+/).should == 4
120
- s.matched.should == "test"
116
+ s = described_class.new('test string')
117
+ expect(s.match?(/\w+/)).to eq(4)
118
+ expect(s.matched).to eq("test")
121
119
  end
122
120
 
123
121
  it "should pass the #matched? example" do
124
- s = UnicodeScanner.new('test string')
125
- s.match?(/\w+/).should == 4
126
- s.matched?.should == true
127
- s.match?(/\d+/).should == nil
128
- s.matched?.should == false
122
+ s = described_class.new('test string')
123
+ expect(s.match?(/\w+/)).to eq(4)
124
+ expect(s.matched?).to eq(true)
125
+ expect(s.match?(/\d+/)).to eq(nil)
126
+ expect(s.matched?).to eq(false)
129
127
  end
130
128
 
131
129
  it "should pass the #matched_size example" do
132
- s = UnicodeScanner.new('test string')
133
- s.check(/\w+/).should == "test"
134
- s.matched_size.should == 4
135
- s.check(/\d+/).should == nil
136
- s.matched_size.should == nil
130
+ s = described_class.new('test string')
131
+ expect(s.check(/\w+/)).to eq("test")
132
+ expect(s.matched_size).to eq(4)
133
+ expect(s.check(/\d+/)).to eq(nil)
134
+ expect(s.matched_size).to eq(nil)
137
135
  end
138
136
 
139
137
  it "should pass the #peek example" do
140
- s = UnicodeScanner.new('test string')
141
- s.peek(7).should == "test st"
142
- s.peek(7).should == "test st"
138
+ s = described_class.new('test string')
139
+ expect(s.peek(7)).to eq("test st")
140
+ expect(s.peek(7)).to eq("test st")
143
141
  end
144
142
 
145
143
  it "should pass the #pos example" do
146
- s = UnicodeScanner.new('test string')
147
- s.pos.should == 0
148
- s.scan_until(/str/).should == "test str"
149
- s.pos.should == 8
150
- s.terminate.inspect.should == "#<UnicodeScanner fin>"
151
- s.pos.should == 11
144
+ s = described_class.new('test string')
145
+ expect(s.pos).to eq(0)
146
+ expect(s.scan_until(/str/)).to eq("test str")
147
+ expect(s.pos).to eq(8)
148
+ expect(s.terminate.inspect).to eq("#<UnicodeScanner fin>")
149
+ expect(s.pos).to eq(11)
152
150
  end
153
151
 
154
152
  it "should pass the #pos= example" do
155
- s = UnicodeScanner.new('test string')
156
- (s.pos = 7).should == 7
157
- s.rest.should == "ring"
153
+ s = described_class.new('test string')
154
+ expect(s.pos = 7).to eq(7)
155
+ expect(s.rest).to eq("ring")
158
156
  end
159
157
 
160
158
  it "should pass the #post_match/#pre_match example" do
161
- s = UnicodeScanner.new('test string')
162
- s.scan(/\w+/).should == "test"
163
- s.scan(/\s+/).should == " "
164
- s.pre_match.should == "test"
165
- s.post_match.should == "string"
159
+ s = described_class.new('test string')
160
+ expect(s.scan(/\w+/)).to eq("test")
161
+ expect(s.scan(/\s+/)).to eq(" ")
162
+ expect(s.pre_match).to eq("test")
163
+ expect(s.post_match).to eq("string")
166
164
  end
167
165
 
168
166
  it "should pass the #scan example" do
169
- s = UnicodeScanner.new('test string')
170
- s.scan(/\w+/).should == "test"
171
- s.scan(/\w+/).should == nil
172
- s.scan(/\s+/).should == " "
173
- s.scan(/\w+/).should == "string"
174
- s.scan(/./).should == nil
167
+ s = described_class.new('test string')
168
+ expect(s.scan(/\w+/)).to eq("test")
169
+ expect(s.scan(/\w+/)).to eq(nil)
170
+ expect(s.scan(/\s+/)).to eq(" ")
171
+ expect(s.scan(/\w+/)).to eq("string")
172
+ expect(s.scan(/./)).to eq(nil)
175
173
  end
176
174
 
177
175
  it "should pass the #scan_until example" do
178
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
179
- s.scan_until(/1/).should == "Fri Dec 1"
180
- s.pre_match.should == "Fri Dec "
181
- s.scan_until(/XYZ/).should == nil
176
+ s = described_class.new("Fri Dec 12 1975 14:39")
177
+ expect(s.scan_until(/1/)).to eq("Fri Dec 1")
178
+ expect(s.pre_match).to eq("Fri Dec ")
179
+ expect(s.scan_until(/XYZ/)).to eq(nil)
182
180
  end
183
181
 
184
182
  it "should pass the #skip example" do
185
- s = UnicodeScanner.new('test string')
186
- s.skip(/\w+/).should == 4
187
- s.skip(/\w+/).should == nil
188
- s.skip(/\s+/).should == 1
189
- s.skip(/\w+/).should == 6
190
- s.skip(/./).should == nil
183
+ s = described_class.new('test string')
184
+ expect(s.skip(/\w+/)).to eq(4)
185
+ expect(s.skip(/\w+/)).to eq(nil)
186
+ expect(s.skip(/\s+/)).to eq(1)
187
+ expect(s.skip(/\w+/)).to eq(6)
188
+ expect(s.skip(/./)).to eq(nil)
191
189
  end
192
190
 
193
191
  it "should pass the half-finished #skip_until example" do
194
- s = UnicodeScanner.new("Fri Dec 12 1975 14:39")
195
- s.skip_until(/12/).should == 10
192
+ s = described_class.new("Fri Dec 12 1975 14:39")
193
+ expect(s.skip_until(/12/)).to eq(10)
196
194
  end
197
195
 
198
196
  it "should pass the #unscan example" do
199
- s = UnicodeScanner.new('test string')
200
- s.scan(/\w+/).should == "test"
197
+ s = described_class.new('test string')
198
+ expect(s.scan(/\w+/)).to eq("test")
201
199
  s.unscan
202
- s.scan(/../).should == "te"
203
- s.scan(/\d/).should == nil
204
- -> { s.unscan }.should raise_error(ScanError, 'unscan failed: previous match record not exist')
200
+ expect(s.scan(/../)).to eq("te")
201
+ expect(s.scan(/\d/)).to eq(nil)
202
+ expect { s.unscan }.to raise_error(ScanError, 'unscan failed: previous match record not exist')
205
203
  end
206
204
  end
@@ -2,16 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: unicode_scanner 1.0.1 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = "unicode_scanner"
8
- s.version = "1.0.0"
8
+ s.name = "unicode_scanner".freeze
9
+ s.version = "1.0.1"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Tim Morgan"]
12
- s.date = "2012-07-12"
13
- s.description = "An implementation of StringScanner that doesn't split multibyte characters."
14
- s.email = "git@timothymorgan.info"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Tim Morgan".freeze]
14
+ s.date = "2019-12-26"
15
+ s.description = "An implementation of StringScanner that doesn't split multibyte characters.".freeze
16
+ s.email = "git@timothymorgan.info".freeze
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE.txt",
17
19
  "README.md"
@@ -19,7 +21,9 @@ Gem::Specification.new do |s|
19
21
  s.files = [
20
22
  ".document",
21
23
  ".rspec",
22
- ".rvmrc",
24
+ ".ruby-gemset",
25
+ ".ruby-version",
26
+ ".travis.yml",
23
27
  "Gemfile",
24
28
  "Gemfile.lock",
25
29
  "LICENSE.txt",
@@ -31,34 +35,27 @@ Gem::Specification.new do |s|
31
35
  "spec/unicode_scanner_spec.rb",
32
36
  "unicode_scanner.gemspec"
33
37
  ]
34
- s.homepage = "http://github.com/RISCfuture/unicode_scanner"
35
- s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = "1.8.24"
38
- s.summary = "Unicode-aware implementation of StringScanner"
38
+ s.homepage = "http://github.com/RISCfuture/unicode_scanner".freeze
39
+ s.licenses = ["MIT".freeze]
40
+ s.rubygems_version = "3.1.2".freeze
41
+ s.summary = "Unicode-aware implementation of StringScanner".freeze
39
42
 
40
43
  if s.respond_to? :specification_version then
41
- s.specification_version = 3
44
+ s.specification_version = 4
45
+ end
42
46
 
43
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- s.add_development_dependency(%q<rspec>, [">= 0"])
45
- s.add_development_dependency(%q<redcarpet>, [">= 0"])
46
- s.add_development_dependency(%q<yard>, [">= 0"])
47
- s.add_development_dependency(%q<bundler>, [">= 0"])
48
- s.add_development_dependency(%q<jeweler>, [">= 0"])
49
- else
50
- s.add_dependency(%q<rspec>, [">= 0"])
51
- s.add_dependency(%q<redcarpet>, [">= 0"])
52
- s.add_dependency(%q<yard>, [">= 0"])
53
- s.add_dependency(%q<bundler>, [">= 0"])
54
- s.add_dependency(%q<jeweler>, [">= 0"])
55
- end
47
+ if s.respond_to? :add_runtime_dependency then
48
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
49
+ s.add_development_dependency(%q<redcarpet>.freeze, [">= 0"])
50
+ s.add_development_dependency(%q<yard>.freeze, [">= 0"])
51
+ s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
52
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
56
53
  else
57
- s.add_dependency(%q<rspec>, [">= 0"])
58
- s.add_dependency(%q<redcarpet>, [">= 0"])
59
- s.add_dependency(%q<yard>, [">= 0"])
60
- s.add_dependency(%q<bundler>, [">= 0"])
61
- s.add_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
55
+ s.add_dependency(%q<redcarpet>.freeze, [">= 0"])
56
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
57
+ s.add_dependency(%q<bundler>.freeze, [">= 0"])
58
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
62
59
  end
63
60
  end
64
61
 
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tim Morgan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
11
+ date: 2019-12-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: redcarpet
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: yard
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: bundler
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: jeweler
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: An implementation of StringScanner that doesn't split multibyte characters.
@@ -99,9 +88,11 @@ extra_rdoc_files:
99
88
  - LICENSE.txt
100
89
  - README.md
101
90
  files:
102
- - .document
103
- - .rspec
104
- - .rvmrc
91
+ - ".document"
92
+ - ".rspec"
93
+ - ".ruby-gemset"
94
+ - ".ruby-version"
95
+ - ".travis.yml"
105
96
  - Gemfile
106
97
  - Gemfile.lock
107
98
  - LICENSE.txt
@@ -115,29 +106,24 @@ files:
115
106
  homepage: http://github.com/RISCfuture/unicode_scanner
116
107
  licenses:
117
108
  - MIT
109
+ metadata: {}
118
110
  post_install_message:
119
111
  rdoc_options: []
120
112
  require_paths:
121
113
  - lib
122
114
  required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
115
  requirements:
125
- - - ! '>='
116
+ - - ">="
126
117
  - !ruby/object:Gem::Version
127
118
  version: '0'
128
- segments:
129
- - 0
130
- hash: -3935821298050612576
131
119
  required_rubygems_version: !ruby/object:Gem::Requirement
132
- none: false
133
120
  requirements:
134
- - - ! '>='
121
+ - - ">="
135
122
  - !ruby/object:Gem::Version
136
123
  version: '0'
137
124
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 1.8.24
125
+ rubygems_version: 3.1.2
140
126
  signing_key:
141
- specification_version: 3
127
+ specification_version: 4
142
128
  summary: Unicode-aware implementation of StringScanner
143
129
  test_files: []
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.3@scanner --create