eventmachine-maglev- 0.12.10 → 1.0.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. data/.gitignore +7 -0
  2. data/.yardopts +7 -0
  3. data/Gemfile +3 -0
  4. data/README.md +109 -0
  5. data/Rakefile +14 -368
  6. data/docs/DocumentationGuidesIndex.md +27 -0
  7. data/docs/GettingStarted.md +521 -0
  8. data/docs/old/DEFERRABLES +246 -0
  9. data/docs/{KEYBOARD → old/KEYBOARD} +15 -11
  10. data/docs/old/LIGHTWEIGHT_CONCURRENCY +130 -0
  11. data/docs/old/SMTP +4 -0
  12. data/docs/old/SPAWNED_PROCESSES +148 -0
  13. data/eventmachine.gemspec +20 -26
  14. data/examples/guides/getting_started/01_eventmachine_echo_server.rb +18 -0
  15. data/examples/guides/getting_started/02_eventmachine_echo_server_that_recognizes_exit_command.rb +22 -0
  16. data/examples/guides/getting_started/03_simple_chat_server.rb +149 -0
  17. data/examples/guides/getting_started/04_simple_chat_server_step_one.rb +27 -0
  18. data/examples/guides/getting_started/05_simple_chat_server_step_two.rb +43 -0
  19. data/examples/guides/getting_started/06_simple_chat_server_step_three.rb +98 -0
  20. data/examples/guides/getting_started/07_simple_chat_server_step_four.rb +121 -0
  21. data/examples/guides/getting_started/08_simple_chat_server_step_five.rb +141 -0
  22. data/examples/{ex_channel.rb → old/ex_channel.rb} +3 -3
  23. data/examples/old/ex_tick_loop_array.rb +15 -0
  24. data/examples/old/ex_tick_loop_counter.rb +32 -0
  25. data/ext/binder.cpp +0 -1
  26. data/ext/cmain.cpp +40 -29
  27. data/ext/ed.cpp +189 -134
  28. data/ext/ed.h +34 -40
  29. data/ext/em.cpp +388 -340
  30. data/ext/em.h +29 -32
  31. data/ext/eventmachine.h +7 -6
  32. data/ext/extconf.rb +57 -48
  33. data/ext/fastfilereader/extconf.rb +5 -3
  34. data/ext/fastfilereader/mapper.cpp +1 -1
  35. data/ext/fastfilereader/rubymain.cpp +0 -1
  36. data/ext/kb.cpp +1 -3
  37. data/ext/pipe.cpp +9 -11
  38. data/ext/project.h +12 -8
  39. data/ext/rubymain.cpp +158 -112
  40. data/java/src/com/rubyeventmachine/EmReactor.java +3 -2
  41. data/lib/em/buftok.rb +35 -63
  42. data/lib/em/callback.rb +43 -11
  43. data/lib/em/channel.rb +22 -15
  44. data/lib/em/completion.rb +303 -0
  45. data/lib/em/connection.rb +341 -208
  46. data/lib/em/deferrable/pool.rb +2 -0
  47. data/lib/em/deferrable.rb +20 -2
  48. data/lib/em/file_watch.rb +37 -18
  49. data/lib/em/iterator.rb +270 -0
  50. data/lib/em/pool.rb +146 -0
  51. data/lib/em/process_watch.rb +5 -4
  52. data/lib/em/processes.rb +8 -4
  53. data/lib/em/protocols/httpclient.rb +27 -11
  54. data/lib/em/protocols/httpclient2.rb +15 -5
  55. data/lib/em/protocols/line_protocol.rb +29 -0
  56. data/lib/em/protocols/memcache.rb +17 -9
  57. data/lib/em/protocols/object_protocol.rb +2 -1
  58. data/lib/em/protocols/postgres3.rb +2 -1
  59. data/lib/em/protocols/smtpclient.rb +19 -11
  60. data/lib/em/protocols/smtpserver.rb +101 -8
  61. data/lib/em/protocols/stomp.rb +9 -7
  62. data/lib/em/protocols/tcptest.rb +3 -2
  63. data/lib/em/protocols.rb +1 -1
  64. data/lib/{pr_eventmachine.rb → em/pure_ruby.rb} +188 -205
  65. data/lib/em/queue.rb +23 -13
  66. data/lib/em/resolver.rb +192 -0
  67. data/lib/em/spawnable.rb +9 -10
  68. data/lib/em/streamer.rb +34 -46
  69. data/lib/em/threaded_resource.rb +90 -0
  70. data/lib/em/tick_loop.rb +85 -0
  71. data/lib/em/timers.rb +8 -3
  72. data/lib/em/version.rb +1 -1
  73. data/lib/eventmachine.rb +582 -686
  74. data/lib/jeventmachine.rb +25 -3
  75. data/tasks/package.rake +98 -0
  76. data/tasks/test.rake +8 -0
  77. data/tests/em_test_helper.rb +64 -0
  78. data/tests/test_attach.rb +56 -56
  79. data/tests/test_basic.rb +111 -168
  80. data/tests/test_channel.rb +5 -6
  81. data/tests/test_completion.rb +177 -0
  82. data/tests/test_connection_count.rb +1 -3
  83. data/tests/test_defer.rb +3 -32
  84. data/tests/test_deferrable.rb +35 -0
  85. data/tests/test_epoll.rb +27 -57
  86. data/tests/test_error_handler.rb +10 -7
  87. data/tests/test_exc.rb +6 -33
  88. data/tests/test_file_watch.rb +51 -35
  89. data/tests/test_futures.rb +10 -38
  90. data/tests/test_get_sock_opt.rb +27 -20
  91. data/tests/test_handler_check.rb +1 -3
  92. data/tests/test_hc.rb +49 -112
  93. data/tests/test_httpclient.rb +34 -62
  94. data/tests/test_httpclient2.rb +14 -39
  95. data/tests/test_inactivity_timeout.rb +44 -40
  96. data/tests/test_kb.rb +26 -52
  97. data/tests/test_ltp.rb +27 -71
  98. data/tests/test_ltp2.rb +1 -30
  99. data/tests/test_next_tick.rb +2 -31
  100. data/tests/test_object_protocol.rb +8 -9
  101. data/tests/test_pause.rb +45 -37
  102. data/tests/test_pending_connect_timeout.rb +42 -38
  103. data/tests/test_pool.rb +128 -0
  104. data/tests/test_process_watch.rb +37 -37
  105. data/tests/test_processes.rb +92 -110
  106. data/tests/test_proxy_connection.rb +137 -61
  107. data/tests/test_pure.rb +30 -67
  108. data/tests/test_queue.rb +10 -4
  109. data/tests/test_resolver.rb +55 -0
  110. data/tests/test_running.rb +1 -29
  111. data/tests/test_sasl.rb +8 -33
  112. data/tests/test_send_file.rb +163 -188
  113. data/tests/test_servers.rb +12 -55
  114. data/tests/test_shutdown_hooks.rb +23 -0
  115. data/tests/test_smtpclient.rb +1 -29
  116. data/tests/test_smtpserver.rb +1 -29
  117. data/tests/test_spawn.rb +2 -31
  118. data/tests/test_ssl_args.rb +9 -10
  119. data/tests/test_ssl_methods.rb +1 -3
  120. data/tests/test_ssl_verify.rb +63 -63
  121. data/tests/test_threaded_resource.rb +53 -0
  122. data/tests/test_tick_loop.rb +59 -0
  123. data/tests/test_timers.rb +52 -91
  124. data/tests/test_ud.rb +1 -29
  125. data/tests/test_unbind_reason.rb +31 -0
  126. metadata +113 -70
  127. data/README +0 -82
  128. data/docs/DEFERRABLES +0 -133
  129. data/docs/LIGHTWEIGHT_CONCURRENCY +0 -70
  130. data/docs/SMTP +0 -2
  131. data/docs/SPAWNED_PROCESSES +0 -89
  132. data/ext/cplusplus.cpp +0 -202
  133. data/ext/emwin.cpp +0 -300
  134. data/ext/emwin.h +0 -94
  135. data/ext/epoll.cpp +0 -26
  136. data/ext/epoll.h +0 -25
  137. data/ext/eventmachine_cpp.h +0 -96
  138. data/ext/files.cpp +0 -94
  139. data/ext/files.h +0 -65
  140. data/ext/sigs.cpp +0 -89
  141. data/ext/sigs.h +0 -32
  142. data/java/src/com/rubyeventmachine/application/Application.java +0 -194
  143. data/java/src/com/rubyeventmachine/application/Connection.java +0 -74
  144. data/java/src/com/rubyeventmachine/application/ConnectionFactory.java +0 -37
  145. data/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +0 -46
  146. data/java/src/com/rubyeventmachine/application/PeriodicTimer.java +0 -38
  147. data/java/src/com/rubyeventmachine/application/Timer.java +0 -54
  148. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +0 -109
  149. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +0 -148
  150. data/java/src/com/rubyeventmachine/tests/EMTest.java +0 -80
  151. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +0 -53
  152. data/java/src/com/rubyeventmachine/tests/TestServers.java +0 -75
  153. data/java/src/com/rubyeventmachine/tests/TestTimers.java +0 -90
  154. data/lib/evma/callback.rb +0 -32
  155. data/lib/evma/container.rb +0 -75
  156. data/lib/evma/factory.rb +0 -77
  157. data/lib/evma/protocol.rb +0 -87
  158. data/lib/evma/reactor.rb +0 -48
  159. data/lib/evma.rb +0 -32
  160. data/setup.rb +0 -1585
  161. data/tests/test_errors.rb +0 -82
  162. data/tests/testem.rb +0 -31
  163. data/web/whatis +0 -7
  164. /data/{docs/GNU → GNU} +0 -0
  165. /data/{docs/COPYING → LICENSE} +0 -0
  166. /data/docs/{ChangeLog → old/ChangeLog} +0 -0
  167. /data/docs/{EPOLL → old/EPOLL} +0 -0
  168. /data/docs/{INSTALL → old/INSTALL} +0 -0
  169. /data/docs/{LEGAL → old/LEGAL} +0 -0
  170. /data/docs/{PURE_RUBY → old/PURE_RUBY} +0 -0
  171. /data/docs/{RELEASE_NOTES → old/RELEASE_NOTES} +0 -0
  172. /data/docs/{TODO → old/TODO} +0 -0
  173. /data/examples/{ex_queue.rb → old/ex_queue.rb} +0 -0
  174. /data/examples/{helper.rb → old/helper.rb} +0 -0
data/.gitignore CHANGED
@@ -11,4 +11,11 @@ Makefile
11
11
  *.log
12
12
  *.def
13
13
  *.pdb
14
+ *.dSYM
14
15
  java/src/.project
16
+ *.rbc
17
+ Gemfile.lock
18
+
19
+ .yardoc/*
20
+ doc/*
21
+
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --no-private
2
+ --protected
3
+ --markup="markdown" lib/**/*.rb
4
+ --main README.md
5
+ --exclude jeventmachine --exclude pure_ruby
6
+ -
7
+ docs/*.md
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+ gemspec
3
+
data/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # About EventMachine #
2
+
3
+
4
+ ## What is EventMachine ##
5
+
6
+ EventMachine is an event-driven I/O and lightweight concurrency library for Ruby.
7
+ It provides event-driven I/O using the [Reactor pattern](http://en.wikipedia.org/wiki/Reactor_pattern),
8
+ much like [JBoss Netty](http://www.jboss.org/netty), [Apache MINA](http://mina.apache.org/),
9
+ Python's [Twisted](http://twistedmatrix.com), [Node.js](http://nodejs.org), libevent and libev.
10
+
11
+ EventMachine is designed to simultaneously meet two key needs:
12
+
13
+ * Extremely high scalability, performance and stability for the most demanding production environments.
14
+ * An API that eliminates the complexities of high-performance threaded network programming,
15
+ allowing engineers to concentrate on their application logic.
16
+
17
+ This unique combination makes EventMachine a premier choice for designers of critical networked
18
+ applications, including Web servers and proxies, email and IM production systems, authentication/authorization
19
+ processors, and many more.
20
+
21
+ EventMachine has been around since yearly 2000s and is a mature and battle tested library.
22
+
23
+
24
+ ## What EventMachine is good for? ##
25
+
26
+ * Scalable event-driven servers. Examples: [Thin](http://code.macournoyer.com/thin/) or [Goliath](https://github.com/postrank-labs/goliath/).
27
+ * Scalable asynchronous clients for various protocols, RESTful APIs and so on. Examples: [em-http-request](https://github.com/igrigorik/em-http-request) or [amqp gem](https://github.com/ruby-amqp/amqp).
28
+ * Efficient network proxies with custom logic. Examples: [Proxymachine](https://github.com/mojombo/proxymachine/).
29
+ * File and network monitoring tools. Examples: [eventmachine-tail](https://github.com/jordansissel/eventmachine-tail) and [logstash](https://github.com/logstash/logstash).
30
+
31
+
32
+
33
+ ## What platforms are supported by EventMachine? ##
34
+
35
+ EventMachine supports Ruby 1.8.7, 1.9.2, REE, JRuby and **works well on Windows** as well
36
+ as many operating systems from the Unix family (Linux, Mac OS X, BSD flavors).
37
+
38
+
39
+
40
+ ## Install the gem ##
41
+
42
+ Install it with [RubyGems](https://rubygems.org/)
43
+
44
+ gem install eventmachine
45
+
46
+ or add this to your Gemfile if you use [Bundler](http://gembundler.com/):
47
+
48
+ gem "eventmachine"
49
+
50
+
51
+
52
+ ## Getting started ##
53
+
54
+ For an introduction to EventMachine, check out:
55
+
56
+ * [blog post about EventMachine by Ilya Grigorik](http://www.igvita.com/2008/05/27/ruby-eventmachine-the-speed-demon/).
57
+ * [EventMachine Introductions by Dan Sinclair](http://everburning.com/news/eventmachine-introductions/).
58
+
59
+
60
+ ### Server example: Echo server ###
61
+
62
+ Here's a fully-functional echo server written with EventMachine:
63
+
64
+ require 'eventmachine'
65
+
66
+ module EchoServer
67
+ def post_init
68
+ puts "-- someone connected to the echo server!"
69
+ end
70
+
71
+ def receive_data data
72
+ send_data ">>>you sent: #{data}"
73
+ close_connection if data =~ /quit/i
74
+ end
75
+
76
+ def unbind
77
+ puts "-- someone disconnected from the echo server!"
78
+ end
79
+ end
80
+
81
+ # Note that this will block current thread.
82
+ EventMachine.run {
83
+ EventMachine.start_server "127.0.0.1", 8081, EchoServer
84
+ }
85
+
86
+
87
+ ## EventMachine documentation ##
88
+
89
+ Currently we only have [reference documentation](http://eventmachine.rubyforge.org) and a [wiki](https://github.com/eventmachine/eventmachine/wiki).
90
+
91
+
92
+ ## Community and where to get help ##
93
+
94
+ * Join the [mailing list](http://groups.google.com/group/eventmachine) (Google Group)
95
+ * Join IRC channel #eventmachine on irc.freenode.net
96
+
97
+
98
+ ## License and copyright ##
99
+
100
+ EventMachine is copyrighted free software made available under the terms
101
+ of either the GPL or Ruby's License.
102
+
103
+ Copyright: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
104
+
105
+
106
+ ## Alternatives ##
107
+
108
+ If you are unhappy with EventMachine and want to use Ruby, check out [Cool.io](http://coolio.github.com/).
109
+ One caveat: by May 2011, it did not support JRuby and Windows.
data/Rakefile CHANGED
@@ -1,374 +1,20 @@
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
- #++
1
+ require 'rubygems' unless defined?(Gem)
2
+ require 'rake' unless defined?(Rake)
3
+ import *Dir['tasks/*.rake']
14
4
 
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
5
+ require File.expand_path('../lib/em/version', __FILE__)
6
+ GEMSPEC = eval(File.read(File.expand_path('../eventmachine.gemspec', __FILE__)))
298
7
 
8
+ require 'yard'
299
9
  require 'rake/clean'
10
+ task :clobber => :clean
300
11
 
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
12
+ desc "Build eventmachine, then run tests."
13
+ task :default => [:compile, :test]
361
14
 
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
15
+ desc 'Generate documentation'
16
+ YARD::Rake::YardocTask.new do |t|
17
+ t.files = ['lib/**/*.rb', '-', 'docs/*.md']
18
+ t.options = ['--main', 'README.md', '--no-private']
19
+ t.options = ['--exclude', 'lib/jeventmachine', '--exclude', 'lib/pr_eventmachine']
371
20
  end
372
-
373
- task :clobber => :clean
374
- task :test => :build
@@ -0,0 +1,27 @@
1
+ # EventMachine documentation guides #
2
+
3
+ Welcome to the documentation guides for [EventMachine](http://github.com/eventmachine/eventmachine),
4
+ a fast and simple event-processing library for Ruby programs (à la JBoss Netty, Twisted, Node.js
5
+ and so on).
6
+
7
+ ## Guide list ##
8
+
9
+ * {file:docs/GettingStarted.md Getting started with EventMachine}
10
+ * {file:docs/EventDrivenServers.md Writing event-driven servers}
11
+ * {file:docs/EventDrivenClients.md Writing event-driven clients}
12
+ * {file:docs/ConnectionFailureAndRecovery.md Connection Failure and Recovery}
13
+ * {file:docs/TLS.md TLS (aka SSL)}
14
+ * {file:docs/Ecosystem.md EventMachine ecosystem}: Thin, Goliath, em-http-request, em-websockets, Proxymachine and beyond
15
+ * {file:docs/BlockingEventLoop.md On blocking the event loop: why it is harmful for performance and how to avoid it}
16
+ * {file:docs/LightweightConcurrency.md Lightweight concurrency with EventMachine}
17
+ * {file:docs/Deferrables.md Deferrables}
18
+ * {file:docs/ModernKernelInputOutputAPIs.md Brief introduction to epoll, kqueue, select}
19
+ * {file:docs/WorkingWithOtherIOSources.md Working with other IO sources such as the keyboard}
20
+
21
+
22
+ ## Tell us what you think! ##
23
+
24
+ Please take a moment and tell us what you think about this guide on the [EventMachine mailing list](http://bit.ly/jW3cR3)
25
+ or in the #eventmachine channel on irc.freenode.net: what was unclear? What wasn't covered?
26
+ Maybe you don't like the guide style or the grammar and spelling are incorrect? Reader feedback is
27
+ key to making documentation better.