iobuffer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 0.1.1:
2
+
3
+ * Ruby 1.8.7 compatibility fix
4
+
1
5
  0.1.0:
2
6
 
3
7
  * Initial release
data/ext/extconf.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'mkmf'
2
2
 
3
- dir_config("bytequeue")
3
+ dir_config("iobuffer")
4
4
  have_library("c", "main")
5
+ if have_macro("HAVE_RB_IO_T", "rubyio.h")
6
+ have_struct_member("rb_io_t", "fd", "rubyio.h")
7
+ end
5
8
 
6
9
  create_makefile("iobuffer")
data/ext/iobuffer.c CHANGED
@@ -15,7 +15,7 @@
15
15
  #include <errno.h>
16
16
 
17
17
  /* Macro for retrieving the file descriptor from an FPTR */
18
- #if !HAVE_RB_IO_T || (RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 8)
18
+ #if !HAVE_RB_IO_T_FD
19
19
  #define FPTR_TO_FD(fptr) fileno(fptr->f)
20
20
  #else
21
21
  #define FPTR_TO_FD(fptr) fptr->fd
@@ -83,6 +83,7 @@ void Init_iobuffer()
83
83
  rb_define_method(cIO_Buffer, "empty?", IO_Buffer_empty, 0);
84
84
  rb_define_method(cIO_Buffer, "<<", IO_Buffer_append, 1);
85
85
  rb_define_method(cIO_Buffer, "append", IO_Buffer_append, 1);
86
+ rb_define_method(cIO_Buffer, "write", IO_Buffer_append, 1);
86
87
  rb_define_method(cIO_Buffer, "prepend", IO_Buffer_prepend, 1);
87
88
  rb_define_method(cIO_Buffer, "read", IO_Buffer_read, -1);
88
89
  rb_define_method(cIO_Buffer, "to_str", IO_Buffer_to_str, 0);
@@ -596,4 +597,4 @@ static int buffer_read_from(struct buffer *buf, int fd)
596
597
  } while(bytes_read == nbytes);
597
598
 
598
599
  return total_bytes_read;
599
- }
600
+ }
data/iobuffer.gemspec CHANGED
@@ -2,10 +2,10 @@ require 'rubygems'
2
2
 
3
3
  GEMSPEC = Gem::Specification.new do |s|
4
4
  s.name = "iobuffer"
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
  s.authors = "Tony Arcieri"
7
7
  s.email = "tony@medioh.com"
8
- s.date = "2008-10-30"
8
+ s.date = "2009-08-28"
9
9
  s.summary = "Fast C-based buffer for non-blocking I/O"
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.required_ruby_version = '>= 1.8.6'
data/spec/buffer_spec.rb CHANGED
@@ -5,40 +5,43 @@ describe IO::Buffer do
5
5
  @buffer = IO::Buffer.new
6
6
  @buffer.size.should == 0
7
7
  end
8
-
8
+
9
9
  it "appends data" do
10
10
  @buffer.append "foo"
11
11
  @buffer.size.should == 3
12
-
13
- @buffer.append "bar"
12
+
13
+ @buffer << "bar"
14
14
  @buffer.size.should == 6
15
-
16
- @buffer.read.should == "foobar"
15
+
16
+ @buffer.write "baz"
17
+ @buffer.size.should == 9
18
+
19
+ @buffer.read.should == "foobarbaz"
17
20
  @buffer.size.should == 0
18
21
  end
19
-
22
+
20
23
  it "prepends data" do
21
24
  @buffer.prepend "foo"
22
25
  @buffer.size.should == 3
23
-
26
+
24
27
  @buffer.prepend "bar"
25
28
  @buffer.size.should == 6
26
-
29
+
27
30
  @buffer.read.should == "barfoo"
28
31
  @buffer.size.should == 0
29
32
  end
30
-
33
+
31
34
  it "mixes prepending and appending properly" do
32
35
  source_data = %w{foo bar baz qux}
33
36
  actions = permutator([:append, :prepend] * 2)
34
-
37
+
35
38
  actions.each do |sequence|
36
39
  sequence.each_with_index do |entry, i|
37
40
  @buffer.send(entry, source_data[i])
38
41
  end
39
-
42
+
40
43
  @buffer.size.should == sequence.size * 3
41
-
44
+
42
45
  i = 0
43
46
  expected = sequence.inject('') do |str, action|
44
47
  case action
@@ -47,18 +50,18 @@ describe IO::Buffer do
47
50
  when :prepend
48
51
  str = source_data[i] + str
49
52
  end
50
-
53
+
51
54
  i += 1
52
55
  str
53
56
  end
54
-
57
+
55
58
  @buffer.read.should == expected
56
59
  end
57
60
  end
58
-
61
+
59
62
  it "reads data in chunks properly" do
60
63
  @buffer.append "foobarbazqux"
61
-
64
+
62
65
  @buffer.read(1).should == 'f'
63
66
  @buffer.read(2).should == 'oo'
64
67
  @buffer.read(3).should == 'bar'
@@ -66,51 +69,51 @@ describe IO::Buffer do
66
69
  @buffer.read(1).should == 'u'
67
70
  @buffer.read(2).should == 'x'
68
71
  end
69
-
72
+
70
73
  it "converts to a string" do
71
74
  @buffer.append "foobar"
72
75
  @buffer.to_str == "foobar"
73
76
  end
74
-
77
+
75
78
  it "clears data" do
76
79
  @buffer.append "foo"
77
80
  @buffer.prepend "bar"
78
-
81
+
79
82
  @buffer.clear
80
83
  @buffer.size.should == 0
81
84
  @buffer.read.should == ""
82
-
85
+
83
86
  @buffer.prepend "foo"
84
87
  @buffer.prepend "bar"
85
88
  @buffer.append "baz"
86
-
89
+
87
90
  @buffer.clear
88
91
  @buffer.size.should == 0
89
92
  @buffer.read.should == ""
90
93
  end
91
-
94
+
92
95
  it "knows when it's empty" do
93
96
  @buffer.should be_empty
94
97
  @buffer.append "foo"
95
98
  @buffer.should_not be_empty
96
99
  end
97
-
100
+
98
101
  #######
99
102
  private
100
103
  #######
101
-
104
+
102
105
  def permutator(input)
103
106
  output = []
104
107
  return output if input.empty?
105
-
108
+
106
109
  (0..input.size - 1).inject([]) do |a, n|
107
110
  if a.empty?
108
111
  input.each { |x| output << [x] }
109
112
  else
110
113
  input.each { |x| output += a.map { |y| [x, *y] } }
111
114
  end
112
-
115
+
113
116
  output.dup
114
117
  end
115
118
  end
116
- end
119
+ end
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: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-30 00:00:00 -06:00
12
+ date: 2009-08-28 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,11 +24,7 @@ extra_rdoc_files:
24
24
  - README
25
25
  - CHANGES
26
26
  files:
27
- - ext/conftest.dSYM
28
- - ext/conftest.dSYM/Contents
29
27
  - ext/conftest.dSYM/Contents/Info.plist
30
- - ext/conftest.dSYM/Contents/Resources
31
- - ext/conftest.dSYM/Contents/Resources/DWARF
32
28
  - ext/conftest.dSYM/Contents/Resources/DWARF/conftest
33
29
  - ext/extconf.rb
34
30
  - ext/iobuffer.c
@@ -43,6 +39,8 @@ files:
43
39
  - CHANGES
44
40
  has_rdoc: true
45
41
  homepage: http://rev.rubyforge.org
42
+ licenses: []
43
+
46
44
  post_install_message:
47
45
  rdoc_options:
48
46
  - --title
@@ -67,9 +65,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
65
  requirements: []
68
66
 
69
67
  rubyforge_project: rev
70
- rubygems_version: 1.3.0
68
+ rubygems_version: 1.3.5
71
69
  signing_key:
72
- specification_version: 2
70
+ specification_version: 3
73
71
  summary: Fast C-based buffer for non-blocking I/O
74
72
  test_files: []
75
73