mmapscanner 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/ext/mmapscanner.c CHANGED
@@ -220,7 +220,11 @@ static VALUE to_s(VALUE obj)
220
220
 
221
221
  static VALUE slice(VALUE obj, VALUE pos, VALUE len)
222
222
  {
223
- return create_from_mmapscanner(obj, pos, len);
223
+ if (NUM2LL(pos) < 0)
224
+ rb_raise(rb_eRangeError, "offset out of range: %lld", NUM2LL(pos));
225
+ if (NUM2LL(len) < 0)
226
+ rb_raise(rb_eRangeError, "length out of range: %lld", NUM2LL(len));
227
+ return create_from_mmapscanner(obj, NUM2ULL(pos), NUM2ULL(len));
224
228
  }
225
229
 
226
230
  static VALUE inspect(VALUE obj)
@@ -36,7 +36,8 @@ describe MmapScanner do
36
36
  end
37
37
  describe '#slice' do
38
38
  it 'returns MmapScanner' do
39
- subject.slice(10, 100).should be_instance_of MmapScanner
39
+ subject.slice(5, 8).should be_instance_of MmapScanner
40
+ subject.slice(5, 8).to_s.should == '56789012'
40
41
  end
41
42
  end
42
43
  it '#inspect returns "#<MmapScanner>"' do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mmapscanner
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.3
5
+ version: 0.3.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - TOMITA Masahiro
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-24 00:00:00 Z
13
+ date: 2011-08-18 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description:
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements: []
50
50
 
51
51
  rubyforge_project:
52
- rubygems_version: 1.8.5
52
+ rubygems_version: 1.8.6.1
53
53
  signing_key:
54
54
  specification_version: 3
55
55
  summary: MmapScanner like StringScanner but it use mmap(2)-ed data