iobuffer 1.1.0 → 1.1.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.
data/ext/extconf.rb CHANGED
@@ -6,4 +6,4 @@ if have_macro("HAVE_RB_IO_T", "rubyio.h")
6
6
  have_struct_member("rb_io_t", "fd", "rubyio.h")
7
7
  end
8
8
 
9
- create_makefile("iobuffer")
9
+ create_makefile("iobuffer/iobuffer_ext")
data/ext/iobuffer.c CHANGED
@@ -81,7 +81,7 @@ static int buffer_write_to(struct buffer * buf, int fd);
81
81
  * Ruby IO objects.
82
82
  */
83
83
  void
84
- Init_iobuffer()
84
+ Init_iobuffer_ext()
85
85
  {
86
86
  cIO_Buffer = rb_define_class_under(rb_cIO, "Buffer", rb_cObject);
87
87
  rb_define_alloc_func(cIO_Buffer, IO_Buffer_allocate);
@@ -287,6 +287,9 @@ IO_Buffer_prepend(VALUE self, VALUE data)
287
287
  * Read the specified abount of data from the buffer. If no value
288
288
  * is given the entire contents of the buffer are returned. Any data
289
289
  * read from the buffer is cleared.
290
+ * The given length must be greater than 0 or an exception would raise.
291
+ * If the buffer size is zero then an empty string is returned (regardless
292
+ * the given length).
290
293
  */
291
294
  static VALUE
292
295
  IO_Buffer_read(int argc, VALUE * argv, VALUE self)
@@ -299,18 +302,15 @@ IO_Buffer_read(int argc, VALUE * argv, VALUE self)
299
302
 
300
303
  if (rb_scan_args(argc, argv, "01", &length_obj) == 1) {
301
304
  length = NUM2INT(length_obj);
302
- } else {
303
- if (buf->size == 0)
304
- return rb_str_new2("");
305
-
306
- length = buf->size;
307
- }
308
-
309
- if (length > buf->size)
305
+ if(length < 1)
306
+ rb_raise(rb_eArgError, "length must be greater than zero");
307
+ if(length > buf->size)
308
+ length = buf->size;
309
+ } else
310
310
  length = buf->size;
311
311
 
312
- if (length < 1)
313
- rb_raise(rb_eArgError, "length must be greater than zero");
312
+ if(buf->size == 0)
313
+ return rb_str_new2("");
314
314
 
315
315
  str = rb_str_new(0, length);
316
316
  buffer_read(buf, RSTRING_PTR(str), length);
@@ -1,5 +1,5 @@
1
1
  class IO
2
2
  class Buffer
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
- end
5
+ end
data/lib/iobuffer.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'iobuffer/version'
2
+ require 'iobuffer_ext'
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iobuffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
- requirement: &70187477766020 !ruby/object:Gem::Requirement
16
+ requirement: &70314510650840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70187477766020
24
+ version_requirements: *70314510650840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70187477765400 !ruby/object:Gem::Requirement
27
+ requirement: &70314510650200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70187477765400
35
+ version_requirements: *70314510650200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70187477764500 !ruby/object:Gem::Requirement
38
+ requirement: &70314510649400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,16 +43,19 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70187477764500
46
+ version_requirements: *70314510649400
47
47
  description: fast buffers for non-blocking IO
48
48
  email:
49
49
  - tony.arcieri@gmail.com
50
50
  executables: []
51
- extensions: []
51
+ extensions:
52
+ - ext/extconf.rb
52
53
  extra_rdoc_files: []
53
54
  files:
54
55
  - README.md
55
56
  - lib/iobuffer/version.rb
57
+ - lib/iobuffer.rb
58
+ - lib/iobuffer_ext.bundle
56
59
  - ext/iobuffer.c
57
60
  - ext/extconf.rb
58
61
  homepage: https://github.com/tarcieri/iobuffer