smparkes-eventmachine 0.12.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/.gitignore +15 -0
  2. data/README +81 -0
  3. data/Rakefile +374 -0
  4. data/docs/COPYING +60 -0
  5. data/docs/ChangeLog +211 -0
  6. data/docs/DEFERRABLES +133 -0
  7. data/docs/EPOLL +141 -0
  8. data/docs/GNU +281 -0
  9. data/docs/INSTALL +13 -0
  10. data/docs/KEYBOARD +38 -0
  11. data/docs/LEGAL +25 -0
  12. data/docs/LIGHTWEIGHT_CONCURRENCY +70 -0
  13. data/docs/PURE_RUBY +75 -0
  14. data/docs/RELEASE_NOTES +94 -0
  15. data/docs/SMTP +2 -0
  16. data/docs/SPAWNED_PROCESSES +89 -0
  17. data/docs/TODO +8 -0
  18. data/eventmachine.gemspec +40 -0
  19. data/examples/ex_channel.rb +43 -0
  20. data/examples/ex_queue.rb +2 -0
  21. data/examples/helper.rb +2 -0
  22. data/ext/binder.cpp +125 -0
  23. data/ext/binder.h +46 -0
  24. data/ext/cmain.cpp +827 -0
  25. data/ext/cplusplus.cpp +202 -0
  26. data/ext/ed.cpp +1901 -0
  27. data/ext/ed.h +424 -0
  28. data/ext/em.cpp +2288 -0
  29. data/ext/em.h +229 -0
  30. data/ext/emwin.cpp +300 -0
  31. data/ext/emwin.h +94 -0
  32. data/ext/epoll.cpp +26 -0
  33. data/ext/epoll.h +25 -0
  34. data/ext/eventmachine.h +122 -0
  35. data/ext/eventmachine_cpp.h +96 -0
  36. data/ext/extconf.rb +150 -0
  37. data/ext/fastfilereader/extconf.rb +85 -0
  38. data/ext/fastfilereader/mapper.cpp +214 -0
  39. data/ext/fastfilereader/mapper.h +59 -0
  40. data/ext/fastfilereader/rubymain.cpp +127 -0
  41. data/ext/files.cpp +94 -0
  42. data/ext/files.h +65 -0
  43. data/ext/kb.cpp +81 -0
  44. data/ext/page.cpp +107 -0
  45. data/ext/page.h +51 -0
  46. data/ext/pipe.cpp +349 -0
  47. data/ext/project.h +156 -0
  48. data/ext/rubymain.cpp +1194 -0
  49. data/ext/sigs.cpp +89 -0
  50. data/ext/sigs.h +32 -0
  51. data/ext/ssl.cpp +460 -0
  52. data/ext/ssl.h +94 -0
  53. data/java/.classpath +8 -0
  54. data/java/.project +17 -0
  55. data/java/src/com/rubyeventmachine/EmReactor.java +570 -0
  56. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  57. data/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
  58. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
  59. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
  60. data/java/src/com/rubyeventmachine/application/Application.java +194 -0
  61. data/java/src/com/rubyeventmachine/application/Connection.java +74 -0
  62. data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +37 -0
  63. data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +46 -0
  64. data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +38 -0
  65. data/java/src/com/rubyeventmachine/application/Timer.java +54 -0
  66. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -0
  67. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -0
  68. data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  69. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  70. data/java/src/com/rubyeventmachine/tests/TestServers.java +75 -0
  71. data/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -0
  72. data/lib/em/buftok.rb +138 -0
  73. data/lib/em/callback.rb +26 -0
  74. data/lib/em/channel.rb +57 -0
  75. data/lib/em/connection.rb +564 -0
  76. data/lib/em/deferrable.rb +192 -0
  77. data/lib/em/file_watch.rb +54 -0
  78. data/lib/em/future.rb +61 -0
  79. data/lib/em/messages.rb +66 -0
  80. data/lib/em/process_watch.rb +44 -0
  81. data/lib/em/processes.rb +119 -0
  82. data/lib/em/protocols/header_and_content.rb +138 -0
  83. data/lib/em/protocols/httpclient.rb +263 -0
  84. data/lib/em/protocols/httpclient2.rb +590 -0
  85. data/lib/em/protocols/line_and_text.rb +125 -0
  86. data/lib/em/protocols/linetext2.rb +161 -0
  87. data/lib/em/protocols/memcache.rb +323 -0
  88. data/lib/em/protocols/object_protocol.rb +45 -0
  89. data/lib/em/protocols/postgres3.rb +247 -0
  90. data/lib/em/protocols/saslauth.rb +175 -0
  91. data/lib/em/protocols/smtpclient.rb +357 -0
  92. data/lib/em/protocols/smtpserver.rb +547 -0
  93. data/lib/em/protocols/socks4.rb +66 -0
  94. data/lib/em/protocols/stomp.rb +200 -0
  95. data/lib/em/protocols/tcptest.rb +53 -0
  96. data/lib/em/protocols.rb +36 -0
  97. data/lib/em/queue.rb +61 -0
  98. data/lib/em/spawnable.rb +85 -0
  99. data/lib/em/streamer.rb +130 -0
  100. data/lib/em/timers.rb +56 -0
  101. data/lib/em/version.rb +3 -0
  102. data/lib/eventmachine.rb +1592 -0
  103. data/lib/evma/callback.rb +32 -0
  104. data/lib/evma/container.rb +75 -0
  105. data/lib/evma/factory.rb +77 -0
  106. data/lib/evma/protocol.rb +87 -0
  107. data/lib/evma/reactor.rb +48 -0
  108. data/lib/evma.rb +32 -0
  109. data/lib/jeventmachine.rb +257 -0
  110. data/lib/pr_eventmachine.rb +1022 -0
  111. data/setup.rb +1585 -0
  112. data/tasks/cpp.rake_example +77 -0
  113. data/tests/client.crt +31 -0
  114. data/tests/client.key +51 -0
  115. data/tests/test_attach.rb +126 -0
  116. data/tests/test_basic.rb +284 -0
  117. data/tests/test_channel.rb +63 -0
  118. data/tests/test_connection_count.rb +35 -0
  119. data/tests/test_defer.rb +47 -0
  120. data/tests/test_epoll.rb +160 -0
  121. data/tests/test_error_handler.rb +35 -0
  122. data/tests/test_errors.rb +82 -0
  123. data/tests/test_exc.rb +55 -0
  124. data/tests/test_file_watch.rb +49 -0
  125. data/tests/test_futures.rb +198 -0
  126. data/tests/test_get_sock_opt.rb +30 -0
  127. data/tests/test_handler_check.rb +37 -0
  128. data/tests/test_hc.rb +218 -0
  129. data/tests/test_httpclient.rb +218 -0
  130. data/tests/test_httpclient2.rb +153 -0
  131. data/tests/test_inactivity_timeout.rb +50 -0
  132. data/tests/test_kb.rb +60 -0
  133. data/tests/test_ltp.rb +182 -0
  134. data/tests/test_ltp2.rb +317 -0
  135. data/tests/test_next_tick.rb +133 -0
  136. data/tests/test_object_protocol.rb +37 -0
  137. data/tests/test_pause.rb +70 -0
  138. data/tests/test_pending_connect_timeout.rb +48 -0
  139. data/tests/test_process_watch.rb +48 -0
  140. data/tests/test_processes.rb +128 -0
  141. data/tests/test_proxy_connection.rb +92 -0
  142. data/tests/test_pure.rb +125 -0
  143. data/tests/test_queue.rb +44 -0
  144. data/tests/test_running.rb +42 -0
  145. data/tests/test_sasl.rb +72 -0
  146. data/tests/test_send_file.rb +242 -0
  147. data/tests/test_servers.rb +76 -0
  148. data/tests/test_smtpclient.rb +83 -0
  149. data/tests/test_smtpserver.rb +85 -0
  150. data/tests/test_spawn.rb +322 -0
  151. data/tests/test_ssl_args.rb +79 -0
  152. data/tests/test_ssl_methods.rb +50 -0
  153. data/tests/test_ssl_verify.rb +82 -0
  154. data/tests/test_timers.rb +162 -0
  155. data/tests/test_ud.rb +36 -0
  156. data/tests/testem.rb +31 -0
  157. data/web/whatis +7 -0
  158. metadata +237 -0
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ pkg
2
+ rdoc
3
+ Makefile
4
+
5
+ *.bundle
6
+ *.dll
7
+ *.so
8
+ *.jar
9
+ *.class
10
+ *.o
11
+ *.log
12
+ *.def
13
+ *.pdb
14
+ *.dSYM
15
+ java/src/.project
data/README ADDED
@@ -0,0 +1,81 @@
1
+ = RUBY/EventMachine
2
+
3
+ Homepage:: http://rubyeventmachine.com
4
+ Rubyforge Page:: http://rubyforge.org/projects/eventmachine
5
+ Google Group:: http://groups.google.com/group/eventmachine
6
+ RDoc:: http://eventmachine.rubyforge.org
7
+ IRC:: ##eventmachine on irc.freenode.net
8
+ Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Email:: gmail address: garbagecat10
10
+
11
+ EventMachine is copyrighted free software made available under the terms
12
+ of either the GPL or Ruby's License. See the file COPYING for full licensing
13
+ information.
14
+ See EventMachine and EventMachine::Connection for documentation and
15
+ usage examples.
16
+
17
+ EventMachine implements a fast, single-threaded engine for arbitrary network
18
+ communications. It's extremely easy to use in Ruby. EventMachine wraps all
19
+ interactions with IP sockets, allowing programs to concentrate on the
20
+ implementation of network protocols. It can be used to create both network
21
+ servers and clients. To create a server or client, a Ruby program only needs
22
+ to specify the IP address and port, and provide a Module that implements the
23
+ communications protocol. Implementations of several standard network protocols
24
+ are provided with the package, primarily to serve as examples. The real goal
25
+ of EventMachine is to enable programs to easily interface with other programs
26
+ using TCP/IP, especially if custom protocols are required.
27
+
28
+ A Ruby program uses EventMachine by registering the addresses and ports of
29
+ network servers and clients, and then entering an event-handling loop.
30
+ EventMachine contains glue code in Ruby which will execute callbacks to
31
+ user-supplied code for all significant events occurring in the clients
32
+ and servers. These events include connection acceptance, startup, data-receipt,
33
+ shutdown, and timer events. Arbitrary processing can be performed by user code
34
+ during event callbacks, including sending data to one or more remote network
35
+ peers, startup and shutdown of network connections, and installation of new
36
+ event handlers.
37
+
38
+ The EventMachine implements a very familiar model for network programming.
39
+ It emphasizes: 1) the maximum possible isolation of user code from network
40
+ objects like sockets; 2) maximum performance and scalability; and 3) extreme
41
+ ease-of-use for user code. It attempts to provide a higher-level interface
42
+ than similar projects which expose a variety of low-level event-handling
43
+ and networking objects to Ruby programs.
44
+
45
+ The design and implementation of EventMachine grows out of nearly ten years
46
+ of experience writing high-performance, high-scaling network server applications.
47
+ We have taken particular account of the challenges and lessons described as
48
+ the "C10K problem" by Dan Kegel and others.
49
+
50
+ EventMachine consists of an extension library written in C++ (which can be
51
+ accessed from languages other than Ruby), and a Ruby module which can be dropped
52
+ into user programs. On most platforms, EventMachine uses the
53
+ <tt>select(2)</tt> system call,
54
+ so it will run on a large range of Unix-like systems and on Microsoft
55
+ Windows with good performance and scalability. On Linux 2.6 kernels, EventMachine
56
+ automatically configures itself to use <tt>epoll(4)</tt> instead of
57
+ <tt>select(2),</tt> so scalability on that platform can be significantly
58
+ improved.
59
+
60
+ Here's a fully-functional echo server written with EventMachine:
61
+
62
+ require 'eventmachine'
63
+
64
+ module EchoServer
65
+ def post_init
66
+ puts "-- someone connected to the echo server!"
67
+ end
68
+
69
+ def receive_data data
70
+ send_data ">>>you sent: #{data}"
71
+ close_connection if data =~ /quit/i
72
+ end
73
+
74
+ def unbind
75
+ puts "-- someone disconnected from the echo server!"
76
+ end
77
+ end
78
+
79
+ EventMachine::run {
80
+ EventMachine::start_server "127.0.0.1", 8081, EchoServer
81
+ }
data/Rakefile ADDED
@@ -0,0 +1,374 @@
1
+ #!/usr/bin/env rake
2
+ #--
3
+ # Ruby/EventMachine
4
+ # http://rubyeventmachine.com
5
+ # Copyright (C) 2006-07 by Francis Cianfrocca
6
+ #
7
+ # This program is copyrighted free software. You may use it under
8
+ # the terms of either the GPL or Ruby's License. See the file
9
+ # COPYING in the EventMachine distribution for full licensing
10
+ # information.
11
+ #
12
+ # $Id$
13
+ #++
14
+
15
+ ### OLD RAKE: ###
16
+ # # The tasks and external gemspecs we used to generate binary gems are now
17
+ # # obsolete. Use Patrick Hurley's gembuilder to build binary gems for any
18
+ # # desired platform.
19
+ # # To build a binary gem on Win32, ensure that the include and lib paths
20
+ # # both contain the proper references to OPENSSL. Use the static version
21
+ # # of the libraries, not the dynamic, otherwise we expose the user to a
22
+ # # runtime dependency.
23
+ #
24
+ # # To build a binary gem for win32, first build rubyeventmachine.so
25
+ # # using VC6 outside of the build tree (the normal way: ruby extconf.rb,
26
+ # # and then nmake). Then copy rubyeventmachine.so into the lib directory,
27
+ # # and run rake gemwin32.
28
+ #
29
+
30
+ require 'rubygems' unless defined?(Gem)
31
+ require 'rake' unless defined?(Rake)
32
+
33
+ Package = false # Build zips and tarballs?
34
+ Dir.glob('tasks/*.rake').each { |r| Rake.application.add_import r }
35
+
36
+ # e.g. rake EVENTMACHINE_LIBRARY=java for forcing java build tasks as defaults!
37
+ $eventmachine_library = :java if RUBY_PLATFORM =~ /java/ || ENV['EVENTMACHINE_LIBRARY'] == 'java'
38
+ $eventmachine_library = :pure_ruby if ENV['EVENTMACHINE_LIBRARY'] == 'pure_ruby'
39
+
40
+ MAKE = ENV['MAKE'] || if RUBY_PLATFORM =~ /mswin/ # mingw uses make.
41
+ 'nmake'
42
+ else
43
+ 'make'
44
+ end
45
+
46
+ desc "Build gemspec, then build eventmachine, then run tests."
47
+ task :default => [:build, :test]
48
+
49
+ desc "Build extension (or EVENTMACHINE_LIBRARY) and place in lib"
50
+ build_task = 'ext:build'
51
+ build_task = 'java:build' if $eventmachine_library == :java
52
+ build_task = :dummy_build if $eventmachine_library == :pure_ruby
53
+ task :build => build_task do |t|
54
+ Dir.glob('{ext,java/src,ext/fastfilereader}/*.{so,bundle,dll,jar}').each do |f|
55
+ mv f, "lib"
56
+ end
57
+ end
58
+
59
+ task :dummy_build
60
+
61
+ require 'rake/testtask'
62
+ Rake::TestTask.new(:test) do |t|
63
+ t.pattern = 'tests/**/test_*.rb'
64
+ t.warning = true
65
+ end
66
+
67
+ # Basic clean definition, this is enhanced by imports aswell.
68
+ task :clean do
69
+ chdir 'ext' do
70
+ sh "#{MAKE} clean" if test ?e, 'Makefile'
71
+ end
72
+ chdir 'ext/fastfilereader' do
73
+ sh "#{MAKE} clean" if test ?e, 'Makefile'
74
+ end
75
+ Dir.glob('**/Makefile').each { |file| rm file }
76
+ Dir.glob('**/*.{o,so,bundle,class,jar,dll,log}').each { |file| rm file }
77
+ Dir.glob('ext/**/conftest.dSYM').each{ |file| rm_rf file }
78
+ end
79
+
80
+ Spec = Gem::Specification.new do |s|
81
+ s.name = "eventmachine"
82
+ s.summary = "Ruby/EventMachine library"
83
+ s.platform = Gem::Platform::RUBY
84
+
85
+ s.has_rdoc = true
86
+ s.rdoc_options = %w(--title EventMachine --main README --line-numbers -x lib/em/version -x lib/emva -x lib/evma/ -x lib/pr_eventmachine -x lib/jeventmachine)
87
+ s.extra_rdoc_files = Dir['README,docs/*']
88
+
89
+ s.files = `git ls-files`.split("\n")
90
+
91
+ s.require_path = 'lib'
92
+
93
+ # TODO / XXX - should we enable this? rubygems fails the install if anything
94
+ # is broken. What we could do is CI submission, though, and always terminate
95
+ # with a positive code...
96
+ # s.test_file = "tests/testem.rb"
97
+
98
+ # XXX Using rake to compile extensions breaks when you have multiple ruby installations
99
+ # and your path isn't set. We can switch back to this once the Gem.exec patch is merged.
100
+ # s.extensions = "Rakefile"
101
+ s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
102
+
103
+ s.author = "Francis Cianfrocca"
104
+ s.email = "garbagecat10@gmail.com"
105
+ s.rubyforge_project = 'eventmachine'
106
+ s.homepage = "http://rubyeventmachine.com"
107
+
108
+ # Pulled in from readme, as code to pull from readme was not working!
109
+ # Might be worth removing as no one seems to use gem info anyway.
110
+ s.description = <<-EOD
111
+ EventMachine implements a fast, single-threaded engine for arbitrary network
112
+ communications. It's extremely easy to use in Ruby. EventMachine wraps all
113
+ interactions with IP sockets, allowing programs to concentrate on the
114
+ implementation of network protocols. It can be used to create both network
115
+ servers and clients. To create a server or client, a Ruby program only needs
116
+ to specify the IP address and port, and provide a Module that implements the
117
+ communications protocol. Implementations of several standard network protocols
118
+ are provided with the package, primarily to serve as examples. The real goal
119
+ of EventMachine is to enable programs to easily interface with other programs
120
+ using TCP/IP, especially if custom protocols are required.
121
+ EOD
122
+
123
+ require 'lib/em/version'
124
+ s.version = EventMachine::VERSION
125
+ end
126
+
127
+ if RUBY_PLATFORM =~ /mswin/
128
+ Spec.platform = 'x86-mswin32-60'
129
+ Spec.files += %w[ lib/rubyeventmachine.so lib/fastfilereaderext.so ]
130
+ Spec.extensions = nil
131
+ elsif RUBY_PLATFORM =~ /java/
132
+ Spec.platform = 'java'
133
+ Spec.files += %w[ lib/em_reactor.jar ]
134
+ Spec.extensions = nil
135
+ end
136
+
137
+ # this is a hack right now, it requires installing msysgit in the global path so it can use tar/curl/etc.
138
+ namespace :win32 do
139
+ task :check_git do
140
+ unless `git` =~ /rebase/
141
+ raise 'git not found, install msys git into the GLOBAL PATH: http://msysgit.googlecode.com/files/Git-1.6.2-preview20090308.exe'
142
+ end
143
+ end
144
+
145
+ task :check_vc6 do
146
+ begin
147
+ raise unless `nmake 2>&1` =~ /Microsoft/
148
+ rescue
149
+ raise 'VC6 not found, please run c:\vc\setvc.bat vc6'
150
+ end
151
+ end
152
+
153
+ task :check_perl do
154
+ unless `perl --version` =~ /ActiveState/
155
+ raise 'ActiveState perl required to build OpenSSL: http://downloads.activestate.com/ActivePerl/Windows/5.10/ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi'
156
+ end
157
+ end
158
+
159
+ task :build_openssl => [:check_git, :check_perl, :check_vc6] do
160
+ mkdir_p 'build'
161
+ chdir 'build' do
162
+ unless File.exists?('openssl-0.9.8j')
163
+ sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl.tar.gz'
164
+ sh 'tar zxvf openssl.tar.gz' rescue nil # fails because of symlinks
165
+ end
166
+
167
+ mkdir_p 'local'
168
+ chdir 'openssl-0.9.8j' do
169
+ sh "perl Configure VC-WIN32 --prefix=\"../local/\""
170
+ sh 'ms\do_ms.bat'
171
+ sh 'nmake -f ms\nt.mak install'
172
+ end
173
+
174
+ chdir '../ext' do
175
+ sh 'git clean -fd .'
176
+ end
177
+
178
+ mv 'local/include/openssl', '../ext/'
179
+ mv 'local/lib/ssleay32.lib', '../ext/'
180
+ mv 'local/lib/libeay32.lib', '../ext/'
181
+ end
182
+ end
183
+
184
+ desc "build binary win32 gem"
185
+ task :gem => :build_openssl do
186
+ Rake::Task['build'].invoke
187
+ Rake::Task['gem'].invoke
188
+ end
189
+ end
190
+
191
+ namespace :ext do
192
+ ext_sources = FileList['ext/*.{h,cpp,rb,c}']
193
+ ffr_sources = FileList['ext/fastfilereader/*.{h,cpp,rb}']
194
+ file ext_extconf = 'ext/extconf.rb'
195
+ file ffr_extconf = 'ext/fastfilereader/extconf.rb'
196
+ ext_libname = "lib/rubyeventmachine.#{Config::CONFIG['DLEXT']}"
197
+ ffr_libname = "lib/fastfilereaderext.#{Config::CONFIG['DLEXT']}"
198
+
199
+ file ext_libname => ext_sources + ['ext/Makefile'] do
200
+ chdir('ext') { sh MAKE }
201
+ end
202
+
203
+ file ffr_libname => ffr_sources + ['ext/fastfilereader/Makefile'] do
204
+ chdir('ext/fastfilereader') { sh MAKE }
205
+ end
206
+
207
+ desc "Build C++ extension"
208
+ task :build => [:make]
209
+
210
+ task :make => ext_libname
211
+ task :make => ffr_libname
212
+
213
+ file 'ext/Makefile' => ext_extconf do
214
+ chdir 'ext' do
215
+ ruby 'extconf.rb'
216
+ end
217
+ end
218
+
219
+ file 'ext/fastfilereader/Makefile' => ffr_extconf do
220
+ chdir 'ext/fastfilereader' do
221
+ ruby 'extconf.rb'
222
+ end
223
+ end
224
+ end
225
+
226
+ namespace :java do
227
+ # This task creates the JRuby JAR file and leaves it in the lib directory.
228
+ # This step is required before executing the jgem task.
229
+ desc "Build java extension"
230
+ task :build => [:jar] do |t|
231
+ mv 'java/em_reactor.jar', 'lib/'
232
+ end
233
+
234
+ task :compile do
235
+ chdir('java') do
236
+ mkdir_p "build"
237
+ sh 'javac src/com/rubyeventmachine/*.java -d build'
238
+ end
239
+ end
240
+
241
+ task :jar => [:compile] do
242
+ chdir('java/build') do
243
+ sh "jar -cf ../em_reactor.jar com/rubyeventmachine/*.class"
244
+ end
245
+ end
246
+
247
+ desc "build a java binary gem"
248
+ task :gem => :build do
249
+ Spec.platform = 'java'
250
+ Spec.files += %w[ lib/em_reactor.jar ]
251
+ Spec.extensions = nil
252
+
253
+ Rake::Task['gem'].invoke
254
+ end
255
+ end
256
+
257
+ namespace :osx do
258
+ desc "Build OSX binary gem"
259
+ task :gem do
260
+ Spec.platform = RUBY_PLATFORM.sub(/darwin.+$/, 'darwin')
261
+ Spec.files += %w[ lib/rubyeventmachine.bundle lib/fastfilereaderext.bundle ]
262
+ Spec.extensions = nil
263
+
264
+ Rake::Task['build'].invoke
265
+ Rake::Task['gem'].invoke
266
+ end
267
+
268
+ # XXX gcc will still prefer the shared libssl on the system, so we need to hack the extconf
269
+ # XXX to use the static library to make this actually work
270
+ task :static_gem => [:build_openssl, :gem]
271
+
272
+ task :build_openssl do
273
+ mkdir_p 'build'
274
+ chdir 'build' do
275
+ unless File.exists?('openssl-0.9.8j')
276
+ sh 'curl http://www.openssl.org/source/openssl-0.9.8j.tar.gz > openssl-0.9.8j.tar.gz'
277
+ sh 'tar zxvf openssl-0.9.8j.tar.gz'
278
+ end
279
+
280
+ mkdir_p 'local'
281
+ chdir 'openssl-0.9.8j' do
282
+ local_dir = File.expand_path(File.join(File.dirname(__FILE__),'build','local'))
283
+ sh "./config --prefix=#{local_dir}"
284
+ sh 'make'
285
+ sh 'make install'
286
+ end
287
+
288
+ chdir '../ext' do
289
+ sh 'git clean -fd .'
290
+ end
291
+
292
+ mv 'local/include/openssl', '../ext/'
293
+ mv 'local/lib/libssl.a', '../ext/'
294
+ mv 'local/lib/libcrypto.a', '../ext/'
295
+ end
296
+ end
297
+ end
298
+
299
+ require 'rake/clean'
300
+
301
+ rdoc_task_type = begin
302
+ require 'rdoc/task'
303
+ RDoc::Task
304
+ rescue LoadError
305
+ require 'rake/rdoctask'
306
+ Rake::RDocTask
307
+ end
308
+ df = begin; require 'rdoc/generator/darkfish'; true; rescue LoadError; end
309
+ rdtask = rdoc_task_type.new do |rd|
310
+ rd.title = Spec.name
311
+ rd.rdoc_dir = 'rdoc'
312
+ rd.main = "README"
313
+ rd.rdoc_files.include("lib/**/*.rb", *Spec.extra_rdoc_files)
314
+ rd.rdoc_files.exclude(*%w(lib/em/version lib/emva lib/evma/ lib/pr_eventmachine lib/jeventmachine))
315
+ rd.template = 'darkfish' if df
316
+ end
317
+ Rake::Task[:clean].enhance [:clobber_rdoc]
318
+
319
+ desc 'Generate and open documentation'
320
+ task :docs => :rdoc do
321
+ case RUBY_PLATFORM
322
+ when /darwin/ ; sh 'open rdoc/index.html'
323
+ when /mswin|mingw/ ; sh 'start rdoc\index.html'
324
+ else
325
+ sh 'firefox rdoc/index.html'
326
+ end
327
+ end
328
+
329
+ def windows?; RUBY_PLATFORM =~ /mswin|mingw/; end
330
+ def sudo(cmd)
331
+ if windows? || (require 'etc'; Etc.getpwuid.uid == 0)
332
+ sh cmd
333
+ else
334
+ sh "sudo #{cmd}"
335
+ end
336
+ end
337
+ def gem_cmd(action, name, *args)
338
+ rb = Gem.ruby rescue nil
339
+ rb ||= (require 'rbconfig'; File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']))
340
+ sudo "#{rb} -r rubygems -e 'require %{rubygems/gem_runner}; Gem::GemRunner.new.run(%w{#{action} #{name} #{args.join(' ')}})'"
341
+ end
342
+
343
+ begin
344
+ require 'rubygems/package_task'
345
+ Gem::PackageTask
346
+ rescue LoadError
347
+ require 'rake/gempackagetask'
348
+ Rake::GemPackageTask
349
+ end.new(Spec) do |pkg|
350
+ pkg.need_tar, pkg.need_tar_gz, pkg.need_zip = true, true, true if Package
351
+ pkg.gem_spec = Spec
352
+ end
353
+
354
+ Rake::Task[:clean].enhance [:clobber_package]
355
+
356
+ namespace :gem do
357
+ desc 'Install gem (and sudo if required)'
358
+ task :install => :package do
359
+ gem_cmd(:install, "pkg/#{Spec.name}-#{Spec.version}.gem")
360
+ end
361
+
362
+ desc 'Uninstall gem (and sudo if required)'
363
+ task :uninstall do
364
+ gem_cmd(:uninstall, "#{Spec.name}", "-v=#{Spec.version}")
365
+ end
366
+
367
+ desc "Generate new gemspec"
368
+ task :spec => :clobber do
369
+ open("eventmachine.gemspec", 'w') { |f| f.write Spec.to_ruby }
370
+ end
371
+ end
372
+
373
+ task :clobber => :clean
374
+ task :test => :build
data/docs/COPYING ADDED
@@ -0,0 +1,60 @@
1
+ EventMachine is copyrighted free software owned by Francis Cianfrocca
2
+ (blackhedd ... gmail.com). The Owner of this software permits you to
3
+ redistribute and/or modify the software under either the terms of the GPL
4
+ version 2 (see the file GPL), or the conditions below ("Ruby License"):
5
+
6
+ 1. You may make and give away verbatim copies of the source form of this
7
+ software without restriction, provided that you retain ALL of the
8
+ original copyright notices and associated disclaimers.
9
+
10
+ 2. You may modify your copy of the software in any way, provided that
11
+ you do at least ONE of the following:
12
+
13
+ a) place your modifications in the Public Domain or otherwise
14
+ make them Freely Available, such as by posting said
15
+ modifications to Usenet or an equivalent medium, or by allowing
16
+ the author to include your modifications in the software.
17
+
18
+ b) use the modified software only within your corporation or
19
+ organization.
20
+
21
+ c) give non-standard binaries non-standard names, with
22
+ instructions on where to get the original software distribution.
23
+
24
+ d) make other distribution arrangements with the Owner.
25
+
26
+ 3. You may distribute the software in object code or binary form,
27
+ provided that you do at least ONE of the following:
28
+
29
+ a) distribute the binaries and library files of the software,
30
+ together with instructions (in a manual page or equivalent)
31
+ on where to get the original distribution.
32
+
33
+ b) accompany the distribution with the machine-readable source of
34
+ the software.
35
+
36
+ c) give non-standard binaries non-standard names, with
37
+ instructions on where to get the original software distribution.
38
+
39
+ d) make other distribution arrangements with the Owner.
40
+
41
+ 4. You may modify and include parts of the software into any other
42
+ software (possibly commercial), provided you comply with the terms in
43
+ Sections 1, 2, and 3 above. But some files in the distribution
44
+ are not written by the Owner, so they may be made available to you
45
+ under different terms.
46
+
47
+ For the list of those files and their copying conditions, see the
48
+ file LEGAL.
49
+
50
+ 5. The scripts and library files supplied as input to or produced as
51
+ output from the software do not automatically fall under the
52
+ copyright of the software, but belong to whoever generated them,
53
+ and may be sold commercially, and may be aggregated with this
54
+ software.
55
+
56
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
57
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
58
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
59
+ PURPOSE.
60
+