eventmachine-eventmachine 0.12.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/Rakefile +169 -0
  2. data/docs/COPYING +60 -0
  3. data/docs/ChangeLog +183 -0
  4. data/docs/DEFERRABLES +138 -0
  5. data/docs/EPOLL +141 -0
  6. data/docs/GNU +281 -0
  7. data/docs/INSTALL +15 -0
  8. data/docs/KEYBOARD +38 -0
  9. data/docs/LEGAL +25 -0
  10. data/docs/LIGHTWEIGHT_CONCURRENCY +72 -0
  11. data/docs/PURE_RUBY +77 -0
  12. data/docs/README +74 -0
  13. data/docs/RELEASE_NOTES +96 -0
  14. data/docs/SMTP +9 -0
  15. data/docs/SPAWNED_PROCESSES +93 -0
  16. data/docs/TODO +10 -0
  17. data/ext/binder.cpp +126 -0
  18. data/ext/binder.h +48 -0
  19. data/ext/cmain.cpp +530 -0
  20. data/ext/cplusplus.cpp +172 -0
  21. data/ext/ed.cpp +1473 -0
  22. data/ext/ed.h +361 -0
  23. data/ext/em.cpp +1895 -0
  24. data/ext/em.h +170 -0
  25. data/ext/emwin.cpp +300 -0
  26. data/ext/emwin.h +94 -0
  27. data/ext/epoll.cpp +26 -0
  28. data/ext/epoll.h +25 -0
  29. data/ext/eventmachine.h +90 -0
  30. data/ext/eventmachine_cpp.h +94 -0
  31. data/ext/extconf.rb +150 -0
  32. data/ext/files.cpp +94 -0
  33. data/ext/files.h +65 -0
  34. data/ext/kb.cpp +368 -0
  35. data/ext/page.cpp +107 -0
  36. data/ext/page.h +51 -0
  37. data/ext/pipe.cpp +327 -0
  38. data/ext/project.h +119 -0
  39. data/ext/rubymain.cpp +683 -0
  40. data/ext/sigs.cpp +89 -0
  41. data/ext/sigs.h +32 -0
  42. data/ext/ssl.cpp +408 -0
  43. data/ext/ssl.h +86 -0
  44. data/java/src/com/rubyeventmachine/Application.java +196 -0
  45. data/java/src/com/rubyeventmachine/Connection.java +74 -0
  46. data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
  47. data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
  48. data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
  49. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  50. data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
  51. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
  52. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
  53. data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
  54. data/java/src/com/rubyeventmachine/Timer.java +54 -0
  55. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
  56. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
  57. data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  58. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  59. data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
  60. data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
  61. data/lib/em/deferrable.rb +208 -0
  62. data/lib/em/eventable.rb +39 -0
  63. data/lib/em/future.rb +62 -0
  64. data/lib/em/messages.rb +66 -0
  65. data/lib/em/processes.rb +68 -0
  66. data/lib/em/spawnable.rb +88 -0
  67. data/lib/em/streamer.rb +112 -0
  68. data/lib/eventmachine.rb +1763 -0
  69. data/lib/eventmachine_version.rb +31 -0
  70. data/lib/evma.rb +32 -0
  71. data/lib/evma/callback.rb +32 -0
  72. data/lib/evma/container.rb +75 -0
  73. data/lib/evma/factory.rb +77 -0
  74. data/lib/evma/protocol.rb +87 -0
  75. data/lib/evma/reactor.rb +48 -0
  76. data/lib/jeventmachine.rb +137 -0
  77. data/lib/pr_eventmachine.rb +1011 -0
  78. data/lib/protocols/buftok.rb +127 -0
  79. data/lib/protocols/header_and_content.rb +129 -0
  80. data/lib/protocols/httpcli2.rb +794 -0
  81. data/lib/protocols/httpclient.rb +270 -0
  82. data/lib/protocols/line_and_text.rb +122 -0
  83. data/lib/protocols/linetext2.rb +163 -0
  84. data/lib/protocols/postgres.rb +261 -0
  85. data/lib/protocols/saslauth.rb +179 -0
  86. data/lib/protocols/smtpclient.rb +308 -0
  87. data/lib/protocols/smtpserver.rb +556 -0
  88. data/lib/protocols/stomp.rb +130 -0
  89. data/lib/protocols/tcptest.rb +57 -0
  90. data/tasks/cpp.rake +77 -0
  91. data/tasks/project.rake +78 -0
  92. data/tasks/tests.rake +192 -0
  93. data/tests/test_attach.rb +66 -0
  94. data/tests/test_basic.rb +231 -0
  95. data/tests/test_defer.rb +47 -0
  96. data/tests/test_epoll.rb +161 -0
  97. data/tests/test_errors.rb +82 -0
  98. data/tests/test_eventables.rb +78 -0
  99. data/tests/test_exc.rb +58 -0
  100. data/tests/test_futures.rb +214 -0
  101. data/tests/test_hc.rb +218 -0
  102. data/tests/test_httpclient.rb +215 -0
  103. data/tests/test_httpclient2.rb +133 -0
  104. data/tests/test_kb.rb +61 -0
  105. data/tests/test_ltp.rb +192 -0
  106. data/tests/test_ltp2.rb +320 -0
  107. data/tests/test_next_tick.rb +102 -0
  108. data/tests/test_processes.rb +56 -0
  109. data/tests/test_pure.rb +129 -0
  110. data/tests/test_running.rb +47 -0
  111. data/tests/test_sasl.rb +74 -0
  112. data/tests/test_send_file.rb +245 -0
  113. data/tests/test_servers.rb +80 -0
  114. data/tests/test_smtpclient.rb +81 -0
  115. data/tests/test_smtpserver.rb +93 -0
  116. data/tests/test_spawn.rb +329 -0
  117. data/tests/test_ssl_args.rb +68 -0
  118. data/tests/test_timers.rb +146 -0
  119. data/tests/test_ud.rb +43 -0
  120. data/tests/testem.rb +31 -0
  121. metadata +197 -0
@@ -0,0 +1,68 @@
1
+ require "test/unit"
2
+ require 'tempfile'
3
+
4
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+ require "eventmachine"
6
+
7
+ module EventMachine
8
+ def self._set_mocks
9
+ class <<self
10
+ alias set_tls_parms_old set_tls_parms
11
+ alias start_tls_old start_tls
12
+ def set_tls_parms *args; end
13
+ def start_tls *args; end
14
+ end
15
+ end
16
+
17
+ def self._clear_mocks
18
+ class <<self
19
+ alias set_tls_parms set_tls_parms_old
20
+ alias start_tls start_tls_old
21
+ end
22
+ end
23
+ end
24
+
25
+
26
+ class TestSslArgs < Test::Unit::TestCase
27
+ def setup
28
+ EventMachine._set_mocks
29
+ end
30
+
31
+ def teardown
32
+ EventMachine._clear_mocks
33
+ end
34
+
35
+ def test_tls_params_file_doesnt_exist
36
+ priv_file, cert_file = 'foo_priv_key', 'bar_cert_file'
37
+ [priv_file, cert_file].all? do |f|
38
+ assert(!File.exists?(f), "Cert file #{f} seems to exist, and should not for the tests")
39
+ end
40
+
41
+ # associate_callback_target is a pain! (build!)
42
+ conn = EventMachine::Connection.new('foo')
43
+
44
+ assert_raise(EventMachine::FileNotFoundException) do
45
+ conn.start_tls(:private_key_file => priv_file)
46
+ end
47
+ assert_raise(EventMachine::FileNotFoundException) do
48
+ conn.start_tls(:cert_chain_file => cert_file)
49
+ end
50
+ assert_raise(EventMachine::FileNotFoundException) do
51
+ conn.start_tls(:private_key_file => priv_file, :cert_chain_file => cert_file)
52
+ end
53
+ end
54
+
55
+ def test_tls_params_file_does_exist
56
+ priv_file = Tempfile.new('em_test')
57
+ cert_file = Tempfile.new('em_test')
58
+ priv_file_path = priv_file.path
59
+ cert_file_path = cert_file.path
60
+ conn = EventMachine::Connection.new('foo')
61
+ params = {:private_key_file => priv_file_path, :cert_chain_file => cert_file_path}
62
+ begin
63
+ conn.start_tls params
64
+ rescue Object
65
+ assert(false, 'should not have raised an exception')
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,146 @@
1
+ # $Id$
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+ #
27
+
28
+ $:.unshift "../lib"
29
+ require 'eventmachine'
30
+ require 'test/unit'
31
+
32
+
33
+ class TestTimers < Test::Unit::TestCase
34
+
35
+ def setup
36
+ end
37
+
38
+ def teardown
39
+ end
40
+
41
+ def test_timer_with_block
42
+ x = false
43
+ EventMachine.run {
44
+ EventMachine::Timer.new(0.25) {
45
+ x = true
46
+ EventMachine.stop
47
+ }
48
+ }
49
+ assert x
50
+ end
51
+
52
+ def test_timer_with_proc
53
+ x = false
54
+ EventMachine.run {
55
+ EventMachine::Timer.new(0.25, proc {
56
+ x = true
57
+ EventMachine.stop
58
+ })
59
+ }
60
+ assert x
61
+ end
62
+
63
+ def test_timer_cancel
64
+ x = true
65
+ EventMachine.run {
66
+ timer = EventMachine::Timer.new(0.25, proc { x = false })
67
+ timer.cancel
68
+ EventMachine::Timer.new(0.5, proc {EventMachine.stop})
69
+ }
70
+ assert x
71
+ end
72
+
73
+ def test_periodic_timer
74
+ x = 0
75
+ EventMachine.run {
76
+ EventMachine::PeriodicTimer.new(0.1) do
77
+ x += 1
78
+ EventMachine.stop if x == 4
79
+ end
80
+ }
81
+ assert( x == 4 )
82
+ end
83
+
84
+ def test_periodic_timer_cancel
85
+ x = 0
86
+ EventMachine.run {
87
+ pt = EventMachine::PeriodicTimer.new(0.25, proc { x += 1 })
88
+ pt.cancel
89
+ EventMachine::Timer.new(0.5) {EventMachine.stop}
90
+ }
91
+ assert( x == 0 )
92
+ end
93
+
94
+ def test_periodic_timer_self_cancel
95
+ x = 0
96
+ EventMachine.run {
97
+ pt = EventMachine::PeriodicTimer.new(0.1) {
98
+ x += 1
99
+ if x == 4
100
+ pt.cancel
101
+ EventMachine.stop
102
+ end
103
+ }
104
+ }
105
+ assert( x == 4 )
106
+ end
107
+
108
+
109
+ # This test is only applicable to compiled versions of the reactor.
110
+ # Pure ruby and java versions have no built-in limit on the number of outstanding timers.
111
+ #
112
+ def test_timer_change_max_outstanding
113
+ ten_thousand_timers = proc {
114
+ 10000.times {
115
+ EM.add_timer(5) {}
116
+ }
117
+ }
118
+ EM.run {
119
+ if EM.library_type == :pure_ruby
120
+ ten_thousand_timers.call
121
+ elsif EM.library_type == :java
122
+ ten_thousand_timers.call
123
+ else
124
+ begin
125
+ assert_raise( RuntimeError ) {
126
+ ten_thousand_timers.call
127
+ }
128
+ rescue Object
129
+ p $!
130
+ assert(false, $!.message)
131
+ end
132
+ end
133
+ EM.stop
134
+ }
135
+
136
+ assert(!EM.reactor_running?, 'Reactor running when it should not be.')
137
+ EM.set_max_timers( 10001 )
138
+
139
+ EM.run {
140
+ ten_thousand_timers.call
141
+ EM.stop
142
+ }
143
+ end
144
+
145
+ end
146
+
data/tests/test_ud.rb ADDED
@@ -0,0 +1,43 @@
1
+ # $Id$
2
+ #
3
+ # Author:: Francis Cianfrocca (gmail: blackhedd)
4
+ # Homepage:: http://rubyeventmachine.com
5
+ # Date:: 8 April 2006
6
+ #
7
+ # See EventMachine and EventMachine::Connection for documentation and
8
+ # usage examples.
9
+ #
10
+ #----------------------------------------------------------------------------
11
+ #
12
+ # Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
13
+ # Gmail: blackhedd
14
+ #
15
+ # This program is free software; you can redistribute it and/or modify
16
+ # it under the terms of either: 1) the GNU General Public License
17
+ # as published by the Free Software Foundation; either version 2 of the
18
+ # License, or (at your option) any later version; or 2) Ruby's License.
19
+ #
20
+ # See the file COPYING for complete licensing information.
21
+ #
22
+ #---------------------------------------------------------------------------
23
+ #
24
+ #
25
+ #
26
+
27
+ $:.unshift "../lib"
28
+ require 'eventmachine'
29
+ require 'test/unit'
30
+
31
+ class TestUserDefinedEvents < Test::Unit::TestCase
32
+
33
+ def setup
34
+ end
35
+
36
+ def teardown
37
+ end
38
+
39
+ def test_a
40
+ end
41
+
42
+ end
43
+
data/tests/testem.rb ADDED
@@ -0,0 +1,31 @@
1
+ # $Id$
2
+
3
+ require 'test/unit'
4
+
5
+ module EmTestRunner
6
+ @em_root = File.expand_path(File.dirname(__FILE__) + '/../')
7
+ @lib_dir = File.join(@em_root, 'lib')
8
+ @ext_dir = File.join(@em_root, 'ext')
9
+ @java_dir = File.join(@em_root, 'java')
10
+
11
+ def self.run(glob = 'test_*.rb')
12
+ $:.unshift(@lib_dir)
13
+ $:.unshift(@ext_dir)
14
+ $:.unshift(@java_dir)
15
+
16
+ case glob
17
+ when Array
18
+ files = glob
19
+ else
20
+ files = Dir[File.dirname(__FILE__) + '/' + glob]
21
+ end
22
+
23
+ files.each do |tc|
24
+ require tc
25
+ end
26
+ end
27
+ end
28
+
29
+ if __FILE__ == $0
30
+ EmTestRunner.run
31
+ end
metadata ADDED
@@ -0,0 +1,197 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventmachine-eventmachine
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.12.3
5
+ platform: ruby
6
+ authors:
7
+ - Francis Cianfrocca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-08 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: EventMachine implements a fast, single-threaded engine for arbitrary network communications. It's extremely easy to use in Ruby. EventMachine wraps all interactions with IP sockets, allowing programs to concentrate on the implementation of network protocols. It can be used to create both network servers and clients. To create a server or client, a Ruby program only needs to specify the IP address and port, and provide a Module that implements the communications protocol. Implementations of several standard network protocols are provided with the package, primarily to serve as examples. The real goal of EventMachine is to enable programs to easily interface with other programs using TCP/IP, especially if custom protocols are required.
17
+ email: garbagecat10@gmail.com
18
+ executables: []
19
+
20
+ extensions:
21
+ - Rakefile
22
+ extra_rdoc_files:
23
+ - docs/ChangeLog
24
+ - docs/COPYING
25
+ - docs/DEFERRABLES
26
+ - docs/EPOLL
27
+ - docs/GNU
28
+ - docs/INSTALL
29
+ - docs/KEYBOARD
30
+ - docs/LEGAL
31
+ - docs/LIGHTWEIGHT_CONCURRENCY
32
+ - docs/PURE_RUBY
33
+ - docs/README
34
+ - docs/RELEASE_NOTES
35
+ - docs/SMTP
36
+ - docs/SPAWNED_PROCESSES
37
+ - docs/TODO
38
+ files:
39
+ - Rakefile
40
+ - tests/test_attach.rb
41
+ - tests/test_basic.rb
42
+ - tests/test_defer.rb
43
+ - tests/test_epoll.rb
44
+ - tests/test_errors.rb
45
+ - tests/test_eventables.rb
46
+ - tests/test_exc.rb
47
+ - tests/test_futures.rb
48
+ - tests/test_hc.rb
49
+ - tests/test_httpclient.rb
50
+ - tests/test_httpclient2.rb
51
+ - tests/test_kb.rb
52
+ - tests/test_ltp.rb
53
+ - tests/test_ltp2.rb
54
+ - tests/test_next_tick.rb
55
+ - tests/test_processes.rb
56
+ - tests/test_pure.rb
57
+ - tests/test_running.rb
58
+ - tests/test_sasl.rb
59
+ - tests/test_send_file.rb
60
+ - tests/test_servers.rb
61
+ - tests/test_smtpclient.rb
62
+ - tests/test_smtpserver.rb
63
+ - tests/test_spawn.rb
64
+ - tests/test_ssl_args.rb
65
+ - tests/test_timers.rb
66
+ - tests/test_ud.rb
67
+ - tests/testem.rb
68
+ - lib/em
69
+ - lib/em/deferrable.rb
70
+ - lib/em/eventable.rb
71
+ - lib/em/future.rb
72
+ - lib/em/messages.rb
73
+ - lib/em/processes.rb
74
+ - lib/em/spawnable.rb
75
+ - lib/em/streamer.rb
76
+ - lib/eventmachine.rb
77
+ - lib/eventmachine_version.rb
78
+ - lib/evma
79
+ - lib/evma/callback.rb
80
+ - lib/evma/container.rb
81
+ - lib/evma/factory.rb
82
+ - lib/evma/protocol.rb
83
+ - lib/evma/reactor.rb
84
+ - lib/evma.rb
85
+ - lib/jeventmachine.rb
86
+ - lib/pr_eventmachine.rb
87
+ - lib/protocols
88
+ - lib/protocols/buftok.rb
89
+ - lib/protocols/header_and_content.rb
90
+ - lib/protocols/httpcli2.rb
91
+ - lib/protocols/httpclient.rb
92
+ - lib/protocols/line_and_text.rb
93
+ - lib/protocols/linetext2.rb
94
+ - lib/protocols/postgres.rb
95
+ - lib/protocols/saslauth.rb
96
+ - lib/protocols/smtpclient.rb
97
+ - lib/protocols/smtpserver.rb
98
+ - lib/protocols/stomp.rb
99
+ - lib/protocols/tcptest.rb
100
+ - ext/binder.cpp
101
+ - ext/binder.h
102
+ - ext/cmain.cpp
103
+ - ext/cplusplus.cpp
104
+ - ext/ed.cpp
105
+ - ext/ed.h
106
+ - ext/em.cpp
107
+ - ext/em.h
108
+ - ext/emwin.cpp
109
+ - ext/emwin.h
110
+ - ext/epoll.cpp
111
+ - ext/epoll.h
112
+ - ext/eventmachine.h
113
+ - ext/eventmachine_cpp.h
114
+ - ext/extconf.rb
115
+ - ext/files.cpp
116
+ - ext/files.h
117
+ - ext/kb.cpp
118
+ - ext/page.cpp
119
+ - ext/page.h
120
+ - ext/pipe.cpp
121
+ - ext/project.h
122
+ - ext/rubymain.cpp
123
+ - ext/sigs.cpp
124
+ - ext/sigs.h
125
+ - ext/ssl.cpp
126
+ - ext/ssl.h
127
+ - java/src
128
+ - java/src/com
129
+ - java/src/com/rubyeventmachine
130
+ - java/src/com/rubyeventmachine/Application.java
131
+ - java/src/com/rubyeventmachine/Connection.java
132
+ - java/src/com/rubyeventmachine/ConnectionFactory.java
133
+ - java/src/com/rubyeventmachine/DefaultConnectionFactory.java
134
+ - java/src/com/rubyeventmachine/EmReactor.java
135
+ - java/src/com/rubyeventmachine/EmReactorException.java
136
+ - java/src/com/rubyeventmachine/EventableChannel.java
137
+ - java/src/com/rubyeventmachine/EventableDatagramChannel.java
138
+ - java/src/com/rubyeventmachine/EventableSocketChannel.java
139
+ - java/src/com/rubyeventmachine/PeriodicTimer.java
140
+ - java/src/com/rubyeventmachine/tests
141
+ - java/src/com/rubyeventmachine/tests/ApplicationTest.java
142
+ - java/src/com/rubyeventmachine/tests/ConnectTest.java
143
+ - java/src/com/rubyeventmachine/tests/EMTest.java
144
+ - java/src/com/rubyeventmachine/tests/TestDatagrams.java
145
+ - java/src/com/rubyeventmachine/tests/TestServers.java
146
+ - java/src/com/rubyeventmachine/tests/TestTimers.java
147
+ - java/src/com/rubyeventmachine/Timer.java
148
+ - tasks/cpp.rake
149
+ - tasks/project.rake
150
+ - tasks/tests.rake
151
+ - docs/ChangeLog
152
+ - docs/COPYING
153
+ - docs/DEFERRABLES
154
+ - docs/EPOLL
155
+ - docs/GNU
156
+ - docs/INSTALL
157
+ - docs/KEYBOARD
158
+ - docs/LEGAL
159
+ - docs/LIGHTWEIGHT_CONCURRENCY
160
+ - docs/PURE_RUBY
161
+ - docs/README
162
+ - docs/RELEASE_NOTES
163
+ - docs/SMTP
164
+ - docs/SPAWNED_PROCESSES
165
+ - docs/TODO
166
+ has_rdoc: true
167
+ homepage: http://rubyeventmachine.com
168
+ post_install_message:
169
+ rdoc_options:
170
+ - --title
171
+ - EventMachine
172
+ - --main
173
+ - docs/README
174
+ - --line-numbers
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: "0"
182
+ version:
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: "0"
188
+ version:
189
+ requirements: []
190
+
191
+ rubyforge_project: eventmachine
192
+ rubygems_version: 1.2.0
193
+ signing_key:
194
+ specification_version: 2
195
+ summary: Ruby/EventMachine library
196
+ test_files: []
197
+