io-reactor 0.05 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,53 +1,79 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: "0.8"
3
- specification_version: 1
4
2
  name: io-reactor
5
3
  version: !ruby/object:Gem::Version
6
- version: "0.05"
7
- date: 2004-10-27
8
- summary: An implementation of the Reactor design pattern for multiplexed asynchronous single-thread IO.
9
- require_paths:
10
- - lib
11
- - "."
12
- author: Michael Granger
13
- email: ged@FaerieMUD.org
14
- homepage: http://www.deveiate.org/code/IO-Reactor.html
15
- rubyforge_project:
16
- description: An implementation of the Reactor design pattern for multiplexed asynchronous single-thread IO.
17
- autorequire: io/reactor
18
- default_executable:
4
+ version: 1.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Michael Granger
8
+ autorequire:
19
9
  bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-19 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "A pure-Ruby implementation of an asynchronous multiplexed IO Reactor which is based on the Reactor design pattern found in _Pattern-Oriented Software Architecture, Volume 2: Patterns for Concurrent and Networked Objects_. It allows a single thread to demultiplex and dispatch events from one or more IO objects to the appropriate handler."
17
+ email: ged@FaerieMUD.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - Rakefile
26
+ - ChangeLog
27
+ - README
28
+ - LICENSE
29
+ - spec/io/reactor_spec.rb
30
+ - lib/io/reactor.rb
31
+ - rake/dependencies.rb
32
+ - rake/helpers.rb
33
+ - rake/manual.rb
34
+ - rake/packaging.rb
35
+ - rake/publishing.rb
36
+ - rake/rdoc.rb
37
+ - rake/style.rb
38
+ - rake/svn.rb
39
+ - rake/testing.rb
40
+ - rake/verifytask.rb
41
+ - examples/chatserver.rb
42
+ - examples/simple.rb
43
+ - examples/simpleserver.rb
20
44
  has_rdoc: true
21
- required_ruby_version: !ruby/object:Gem::Version::Requirement
45
+ homepage: http://deveiate.org/projects/IO-Reactor/
46
+ post_install_message:
47
+ rdoc_options:
48
+ - -w
49
+ - "4"
50
+ - -SHN
51
+ - -i
52
+ - .
53
+ - -m
54
+ - README
55
+ - -W
56
+ - http://deveiate.org/projects/IO-Reactor//browser/trunk/
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
22
60
  requirements:
23
- -
24
- - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.8.0
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
27
70
  version:
28
- platform: ruby
29
- files:
30
- - lib
31
- - README
32
- - install.rb
33
- - test.rb
34
- - makedocs.rb
35
- - CATALOG
36
- - examples
37
- - ChangeLog
38
- - utils.rb
39
- - io-reactor.gemspec
40
- - lib/io
41
- - lib/io/reactor.rb
42
- - examples/chatserver.rb
43
- test_files:
44
- - test.rb
45
- rdoc_options:
46
- - "--main"
47
- - README
48
- extra_rdoc_files:
49
- - README
50
- executables: []
51
- extensions: []
52
71
  requirements: []
53
- dependencies: []
72
+
73
+ rubyforge_project: io-reactor
74
+ rubygems_version: 1.2.0
75
+ signing_key:
76
+ specification_version: 2
77
+ summary: Multiplexed IO Reactor class
78
+ test_files:
79
+ - spec/io/reactor_spec.rb
data/CATALOG DELETED
@@ -1,10 +0,0 @@
1
- #
2
- # Title: IO-Reactor
3
- # Main: README
4
- # Upload: ssh://oberon/www/devEiate.org/public/code/IO-Reactor/
5
- # Webcvs: http://www.deveiate.org/cgi/viewcvs.cgi/IO-Reactor/
6
- #
7
- lib/io/*
8
- README
9
- ChangeLog
10
- examples/*
data/install.rb DELETED
@@ -1,85 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # $Date: 2003/07/21 14:21:30 $
4
- # Copyright (c) 2000 Masatoshi SEKI
5
- #
6
- # install.rb is copyrighted free software by Masatoshi SEKI.
7
- # You can redistribute it and/or modify it under the same term as Ruby.
8
-
9
- require 'rbconfig'
10
- require 'find'
11
- require 'ftools'
12
-
13
- include Config
14
-
15
- class Installer
16
- protected
17
- def install(from, to, mode = nil, verbose = false)
18
- str = "install '#{from}' to '#{to}'"
19
- str += ", mode=#{mode}" if mode
20
- puts str if verbose
21
- end
22
-
23
- protected
24
- def makedirs(*dirs)
25
- for d in dirs
26
- puts "mkdir #{d}"
27
- end
28
- end
29
-
30
- def initialize(test=false)
31
- @version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
32
- @libdir = File.join(CONFIG["libdir"], "ruby", @version)
33
- @sitelib = find_site_libdir
34
- @ftools = (test) ? self : File
35
- end
36
- public
37
- attr_reader(:libdir, :sitelib)
38
-
39
- private
40
- def find_site_libdir
41
- site_libdir = $:.find {|x| x =~ /site_ruby$/}
42
- if !site_libdir
43
- site_libdir = File.join(@libdir, "site_ruby")
44
- elsif site_libdir !~ Regexp::new( Regexp.quote(@version) )
45
- site_libdir = File.join(site_libdir, @version)
46
- end
47
- site_libdir
48
- end
49
-
50
- public
51
- def files_in_dir(dir)
52
- list = []
53
- Find.find(dir) do |f|
54
- list.push(f)
55
- end
56
- list
57
- end
58
-
59
- public
60
- def install_files(srcdir, files, destdir=@sitelib)
61
- path = []
62
- dir = []
63
-
64
- for f in files
65
- next if (f = f[srcdir.length+1..-1]) == nil
66
- path.push f if File.ftype(File.join(srcdir, f)) == 'file'
67
- dir |= [ File.dirname(File.join(destdir, f)) ]
68
- end
69
- @ftools.makedirs(*dir)
70
- for f in path
71
- @ftools.install(File.join(srcdir, f), File.join(destdir, f), nil, true)
72
- end
73
- end
74
-
75
- public
76
- def install_rb
77
- intall_files('lib', files_in_dir('lib'))
78
- end
79
- end
80
-
81
- if __FILE__ == $0
82
- inst = Installer.new(ARGV.shift == '-n')
83
- inst.install_files('lib', ['lib/io/reactor.rb'])
84
- end
85
-
@@ -1,21 +0,0 @@
1
- require 'date'
2
- Gem::Specification.new do |s|
3
- s.name = %q{io-reactor}
4
- s.version = "0.05"
5
- s.date = Date.today.to_s
6
- s.summary = %q{An implementation of the Reactor design pattern for multiplexed asynchronous single-thread IO.}
7
- s.description =<<DESCRIPTION
8
- An implementation of the Reactor design pattern for multiplexed asynchronous single-thread IO.
9
- DESCRIPTION
10
- s.author = %q{Michael Granger}
11
- s.email = %q{ged@FaerieMUD.org}
12
- s.homepage = %q{http://www.deveiate.org/code/IO-Reactor.html}
13
- s.files = Dir.glob('**/*')
14
- s.require_paths = %w{lib .}
15
- s.autorequire = %q{io/reactor}
16
- s.has_rdoc = true
17
- s.rdoc_options = ["--main", "README"]
18
- s.extra_rdoc_files = ["README"]
19
- s.test_files = %w{test.rb}
20
- s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.0")
21
- end
@@ -1,79 +0,0 @@
1
- #!/usr/bin/ruby
2
- #
3
- # MUES Documentation Generation Script
4
- # $Id: makedocs.rb,v 1.3 2002/09/18 12:33:35 deveiant Exp $
5
- #
6
- # Copyright (c) 2001,2002 The FaerieMUD Consortium.
7
- #
8
- # This is free software. You may use, modify, and/or redistribute this
9
- # software under the terms of the Perl Artistic License. (See
10
- # http://language.perl.com/misc/Artistic.html)
11
- #
12
-
13
- # Muck with the load path and the cwd
14
- $basedir = File::expand_path( $0 ).sub( %r{/makedocs.rb}, '' )
15
- unless $basedir.empty? || Dir.getwd == $basedir
16
- $stderr.puts "Changing working directory from '#{Dir.getwd}' to '#$basedir'"
17
- Dir.chdir( $basedir )
18
- end
19
-
20
- $LOAD_PATH.unshift "docs/lib"
21
-
22
- # Load modules
23
- require 'getoptlong'
24
- require 'rdoc/rdoc'
25
- require "utils"
26
- include UtilityFunctions
27
-
28
- opts = GetoptLong.new
29
- opts.set_options(
30
- [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
31
- [ '--verbose', '-v', GetoptLong::NO_ARGUMENT ]
32
- )
33
-
34
- $docsdir = "docs/html"
35
- $libdirs = %w{poll.c lib examples README}
36
- opts.each {|opt,val|
37
- case opt
38
-
39
- when '--debug'
40
- $debug = true
41
-
42
- when '--verbose'
43
- $verbose = true
44
-
45
- when '--upload'
46
- $upload = true
47
-
48
- end
49
- }
50
-
51
-
52
- header "Making documentation in #$docsdir from files in #{$libdirs.join(', ')}."
53
-
54
- flags = [
55
- '--main', 'README',
56
- '--fmt', 'html',
57
- '--include', 'docs',
58
- '--op', $docsdir,
59
- '--title', "Ruby-Poll"
60
- ]
61
-
62
- message "Running 'rdoc #{flags.join(' ')} #{$libdirs.join(' ')}'\n" if $verbose
63
-
64
- unless $debug
65
- begin
66
- r = RDoc::RDoc.new
67
- r.document( flags + $libdirs )
68
- rescue RDoc::RDocError => e
69
- $stderr.puts e.message
70
- exit(1)
71
- end
72
- end
73
-
74
- # rdoc \
75
- # --all \
76
- # --inline_source \
77
- # --main "lib/mues.rb" \
78
- # --title "Multi-User Environment Server (MUES)" \
79
- # lib server
data/test.rb DELETED
@@ -1,212 +0,0 @@
1
- #!/usr/bin/ruby
2
- # = test.rb
3
- #
4
- # Test suite for Ruby-Poll
5
- #
6
- # == Author
7
- #
8
- # Michael Granger <ged@FaerieMUD.org>
9
- #
10
- # Copyright (c) 2002, 2003 The FaerieMUD Consortium. All rights reserved.
11
- #
12
- # This program is free software. You may use, modify, and/or redistribute this
13
- # software under the same terms as Ruby itself.
14
- #
15
- # This program is distributed in the hope that it will be useful, but WITHOUT
16
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
- # FOR A PARTICULAR PURPOSE.
18
- #
19
- # == Version
20
- #
21
- # $Id: test.rb,v 1.8 2003/08/04 23:57:07 deveiant Exp $
22
- #
23
- #
24
-
25
- $:.unshift "lib", "tests"
26
-
27
- require 'test/unit'
28
- require 'io/reactor'
29
- require 'socket'
30
-
31
- TMPFILE = "testfile.#{$$}"
32
- HOST = 'localhost'
33
- PORT = 5656
34
-
35
- $stderr.sync = $stdout.sync = true
36
-
37
- ### Reactor test case
38
- class IOReactorTestCase < Test::Unit::TestCase
39
-
40
- # Setup method
41
- def setup
42
- @reactor = IO::Reactor::new
43
- @tmpfile = File::open( TMPFILE, "w" )
44
- File::unlink TMPFILE
45
- @sock = TCPServer::new( HOST, PORT )
46
- end
47
- alias_method :set_up, :setup
48
-
49
- # Teardown method
50
- def teardown
51
- @reactor = nil
52
- @tmpfile.close
53
- @sock.close
54
- end
55
- alias_method :tear_down, :teardown
56
-
57
-
58
- # Test to make sure require worked
59
- def test_00_Requires
60
- assert_instance_of Class, IO::Reactor
61
- assert_instance_of IO::Reactor, @reactor
62
- end
63
-
64
-
65
- # Test set and reset with an IO
66
- def test_10_RegisterIO
67
- assert_nothing_raised { @reactor.register $stdout, :write }
68
- assert_nothing_raised { @reactor.add $stdout, :write }
69
- assert @reactor.registered?( $stdout )
70
- assert_equal [:write], @reactor.handles[ $stdout ][:events]
71
- end
72
-
73
-
74
- # Test set and reset with a File
75
- def test_11_RegisterFilehandle
76
- assert_nothing_raised { @reactor.register @tmpfile, :write }
77
- assert_nothing_raised { @reactor.add @tmpfile, :write }
78
- assert @reactor.registered?( @tmpfile )
79
- assert_equal [:write], @reactor.handles[ @tmpfile ][:events]
80
- end
81
-
82
-
83
- # Test set and reset with a File
84
- def test_12_RegisterSocket
85
- assert_nothing_raised { @reactor.register @sock, :read, :write }
86
- assert_nothing_raised { @reactor.add @sock, :read }
87
- assert @reactor.registered?( @sock )
88
- assert_equal [:read], @reactor.handles[ @sock ][:events]
89
- end
90
-
91
-
92
- # Test registration with a callback as an inline block
93
- def test_20_RegisterWithBlock
94
- assert_nothing_raised {
95
- @reactor.register($stdout, :write) {|io,eventMask|
96
- $stderr.puts "Got an output event for STDOUT"
97
- }
98
- }
99
- assert @reactor.handles.key?( $stdout ),
100
- "handles hash doesn't contain $stdout"
101
- assert_equal [:write], @reactor.handles[ $stdout ][:events]
102
- end
103
-
104
-
105
- # Test registration with a Proc argument
106
- def test_21_RegisterWithProc
107
- handlerProc = Proc::new {|io,eventMask|
108
- $stderr.puts "Got an output event for STDOUT"
109
- }
110
- assert_nothing_raised {
111
- @reactor.register( $stdout, :write, &handlerProc )
112
- }
113
- assert @reactor.handles.key?( $stdout ),
114
- "handles hash doesn't contain $stdout"
115
- end
116
-
117
-
118
- # Test registration with a Method argument
119
- def test_22_RegisterWithMethod
120
- assert_nothing_raised {
121
- @reactor.register $stdout, :write, &$stderr.method( :puts )
122
- }
123
- assert @reactor.handles.key?( $stdout ),
124
- "handles hash doesn't contain $stdout"
125
- end
126
-
127
-
128
- # Test registering with an argument
129
- def test_23_RegisterWithArgs
130
- assert_nothing_raised {
131
- @reactor.register $stdout, :write, "foo", &$stderr.method( :puts )
132
- }
133
- assert @reactor.handles.key?( $stdout ),
134
- "handles hash doesn't contain $stdout"
135
- assert_equal ["foo"], @reactor.handles[$stdout][:args]
136
- end
137
-
138
-
139
- # Test the clear method
140
- def test_30_Clear
141
- # Make sure it's empty
142
- assert_nothing_raised {
143
- @reactor.clear
144
- }
145
-
146
- # Test it with one registered
147
- assert_nothing_raised {
148
- @reactor.register $stdout, :write, &$stdout.method( :puts )
149
- @reactor.clear
150
- }
151
- assert ! @reactor.registered?( $stdout ),
152
- "$stdout still registed with the poll handle after clear"
153
- assert_equal 0, @reactor.handles.length
154
- end
155
-
156
-
157
- # Test the #poll method
158
- def test_40_Poll
159
- rv = nil
160
-
161
- @reactor.register $stdout, :write
162
- @reactor.register @tmpfile, :write
163
-
164
- assert_nothing_raised { rv = @reactor.poll(0.1) }
165
- assert_equal 2, rv
166
-
167
- assert_nothing_raised { @reactor.pendingEvents.keys.include?($stdout) }
168
- assert_nothing_raised { @reactor.pendingEvents.keys.include?(@tmpfile) }
169
- end
170
-
171
-
172
- # Test #poll with a block default handler
173
- def test_41_PollWithBlock
174
- rv = nil
175
-
176
- @reactor.register $stdout, :write
177
- @reactor.register @tmpfile, :write
178
-
179
- assert_nothing_raised {
180
- rv = @reactor.poll( 15 ) {|io,event|
181
- $stderr.puts "Default handler got #{io.inspect} with mask #{event}" if $VERBOSE
182
- }
183
- }
184
- end
185
-
186
- # Test polling with an argument
187
- def test_42_PollWithArgs
188
- setval = nil
189
- testAry = %w{foo bar baz}
190
-
191
- @reactor.register( $stdout, :write, *testAry )
192
- assert_equal testAry, @reactor.handles[$stdout][:args]
193
-
194
- assert_nothing_raised {
195
- @reactor.poll( 15 ) {|io,ev,*args|
196
- setval = args
197
- }
198
- }
199
-
200
- assert_equal testAry, setval
201
- end
202
-
203
-
204
- end # class PollTestCase
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-