Skip to content

Commit

Permalink
Documentation overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Mar 14, 2009
1 parent 5a736a3 commit 12ff775
Show file tree
Hide file tree
Showing 36 changed files with 434 additions and 364 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY

s.has_rdoc = true
s.rdoc_options = %w(--title EventMachine --main docs/README --line-numbers)
s.rdoc_options = %w(--title EventMachine --main docs/README --line-numbers -x lib/eventmachine_version -x lib/emva -x lib/evma/ -x lib/pr_eventmachine -x lib/jeventmachine)
s.extra_rdoc_files = Dir['docs/*']

s.files = `git ls-files`.split("\n")
Expand Down
5 changes: 0 additions & 5 deletions docs/DEFERRABLES
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
$Id$

[DOCUMENT UNDER CONSTRUCTION]

EventMachine (EM) adds two different formalisms for lightweight concurrency to the Ruby programmer's toolbox: spawned processes and deferrables. This note will show you how to use deferrables. For more information, see the separate document LIGHTWEIGHT_CONCURRENCY.


=== What are Deferrables?

EventMachine's Deferrable borrows heavily from the "deferred" object in Python's "Twisted" event-handling framework. Here's a minimal example that illustrates Deferrable:
Expand Down
6 changes: 2 additions & 4 deletions docs/INSTALL
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
$Id$

If you have obtained an EventMachine source-tarball (.tar.gz):
unzip and untar the tarball, and enter the directory that is
created. In that directory, say:
ruby setup.rb
(You may need to be root to execute this command.)

To create documentation for EventMachine, simply type:
rdoc
in the distro directory. Rdocs will be created in subdirectory doc.
rake rdoc
in the distro directory. Rdocs will be created in subdirectory rdoc.

If you have obtained a gem version of EventMachine, install it in the
usual way (gem install eventmachine). You may need superuser privileges
Expand Down
2 changes: 0 additions & 2 deletions docs/LIGHTWEIGHT_CONCURRENCY
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$Id$

EventMachine (EM) adds two different formalisms for lightweight concurrency to the Ruby programmer's toolbox: spawned processes and deferrables. This note will show you how to use them.


Expand Down
2 changes: 0 additions & 2 deletions docs/PURE_RUBY
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$Id$

EventMachine is supplied in three alternative versions.

1) A version that includes a Ruby extension written in C++. This version requires compilation;
Expand Down
33 changes: 20 additions & 13 deletions docs/README
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
$Id$

= RUBY/EventMachine

Homepage:: http://rubyeventmachine.com
Rubyforge Page:: http://rubyforge.org/projects/eventmachine
Google Group:: http://groups.google.com/group/eventmachine
Mailing List:: http://rubyforge.org/pipermail/eventmachine-talk
RDoc:: http://eventmachine.rubyforge.org
Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
Email:: gmail address: garbagecat10

Expand Down Expand Up @@ -57,18 +59,23 @@ improved.

Here's a fully-functional echo server written with EventMachine:

require 'rubygems'
require 'eventmachine'
require 'eventmachine'

module EchoServer
def receive_data data
send_data ">>>you sent: #{data}"
close_connection if data =~ /quit/i
end
end
module EchoServer
def post_init
puts "-- someone connected to the echo server!"
end

EventMachine::run {
EventMachine::start_server "192.168.0.100", 8081, EchoServer
}
def receive_data data
send_data ">>>you sent: #{data}"
close_connection if data =~ /quit/i
end

def unbind
puts "-- someone disconnected from the echo server!"
end
end

EventMachine::run {
EventMachine::start_server "127.0.0.1", 8081, EchoServer
}
2 changes: 0 additions & 2 deletions docs/RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$Id$

RUBY/EventMachine RELEASE NOTES

--------------------------------------------------
Expand Down
7 changes: 0 additions & 7 deletions docs/SMTP
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
$Id$


[DOCUMENT UNDER CONSTRUCTION]

This note details the usage of EventMachine's built-in support for SMTP. EM supports both client and server connections, which will be described in separate sections.



4 changes: 0 additions & 4 deletions docs/SPAWNED_PROCESSES
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
$Id$

[DOCUMENT UNDER CONSTRUCTION]

EventMachine (EM) adds two different formalisms for lightweight concurrency to the Ruby programmer's toolbox: spawned processes and deferrables. This note will show you how to use spawned processes. For more information, see the separate document LIGHTWEIGHT_CONCURRENCY.


Expand Down
2 changes: 0 additions & 2 deletions docs/TODO
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
$Id$

TODO List:

12Aug06: Noticed by Don Stocks. A TCP connect-request that results
Expand Down
4 changes: 2 additions & 2 deletions eventmachine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Francis Cianfrocca"]
s.date = %q{2009-03-07}
s.date = %q{2009-03-14}
s.description = %q{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.}
s.email = %q{[email protected]}
s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"]
s.extra_rdoc_files = ["docs/ChangeLog", "docs/COPYING", "docs/DEFERRABLES", "docs/EPOLL", "docs/GNU", "docs/INSTALL", "docs/KEYBOARD", "docs/LEGAL", "docs/LIGHTWEIGHT_CONCURRENCY", "docs/PURE_RUBY", "docs/README", "docs/RELEASE_NOTES", "docs/SMTP", "docs/SPAWNED_PROCESSES", "docs/TODO"]
s.files = [".gitignore", "Rakefile", "docs/COPYING", "docs/ChangeLog", "docs/DEFERRABLES", "docs/EPOLL", "docs/GNU", "docs/INSTALL", "docs/KEYBOARD", "docs/LEGAL", "docs/LIGHTWEIGHT_CONCURRENCY", "docs/PURE_RUBY", "docs/README", "docs/RELEASE_NOTES", "docs/SMTP", "docs/SPAWNED_PROCESSES", "docs/TODO", "eventmachine.gemspec", "ext/binder.cpp", "ext/binder.h", "ext/cmain.cpp", "ext/cplusplus.cpp", "ext/ed.cpp", "ext/ed.h", "ext/em.cpp", "ext/em.h", "ext/emwin.cpp", "ext/emwin.h", "ext/epoll.cpp", "ext/epoll.h", "ext/eventmachine.h", "ext/eventmachine_cpp.h", "ext/extconf.rb", "ext/fastfilereader/extconf.rb", "ext/fastfilereader/mapper.cpp", "ext/fastfilereader/mapper.h", "ext/fastfilereader/rubymain.cpp", "ext/files.cpp", "ext/files.h", "ext/kb.cpp", "ext/page.cpp", "ext/page.h", "ext/pipe.cpp", "ext/project.h", "ext/rubymain.cpp", "ext/sigs.cpp", "ext/sigs.h", "ext/ssl.cpp", "ext/ssl.h", "java/.classpath", "java/.project", "java/src/com/rubyeventmachine/Application.java", "java/src/com/rubyeventmachine/Connection.java", "java/src/com/rubyeventmachine/ConnectionFactory.java", "java/src/com/rubyeventmachine/DefaultConnectionFactory.java", "java/src/com/rubyeventmachine/EmReactor.java", "java/src/com/rubyeventmachine/EmReactorException.java", "java/src/com/rubyeventmachine/EventableChannel.java", "java/src/com/rubyeventmachine/EventableDatagramChannel.java", "java/src/com/rubyeventmachine/EventableSocketChannel.java", "java/src/com/rubyeventmachine/PeriodicTimer.java", "java/src/com/rubyeventmachine/Timer.java", "java/src/com/rubyeventmachine/tests/ApplicationTest.java", "java/src/com/rubyeventmachine/tests/ConnectTest.java", "java/src/com/rubyeventmachine/tests/EMTest.java", "java/src/com/rubyeventmachine/tests/TestDatagrams.java", "java/src/com/rubyeventmachine/tests/TestServers.java", "java/src/com/rubyeventmachine/tests/TestTimers.java", "lib/em/deferrable.rb", "lib/em/eventable.rb", "lib/em/future.rb", "lib/em/messages.rb", "lib/em/processes.rb", "lib/em/spawnable.rb", "lib/em/streamer.rb", "lib/eventmachine.rb", "lib/eventmachine_version.rb", "lib/evma.rb", "lib/evma/callback.rb", "lib/evma/container.rb", "lib/evma/factory.rb", "lib/evma/protocol.rb", "lib/evma/reactor.rb", "lib/jeventmachine.rb", "lib/pr_eventmachine.rb", "lib/protocols/buftok.rb", "lib/protocols/header_and_content.rb", "lib/protocols/httpcli2.rb", "lib/protocols/httpclient.rb", "lib/protocols/line_and_text.rb", "lib/protocols/linetext2.rb", "lib/protocols/memcache.rb", "lib/protocols/postgres.rb", "lib/protocols/saslauth.rb", "lib/protocols/smtpclient.rb", "lib/protocols/smtpserver.rb", "lib/protocols/stomp.rb", "lib/protocols/tcptest.rb", "setup.rb", "tasks/cpp.rake", "tasks/project.rake", "tasks/tests.rake", "tests/test_attach.rb", "tests/test_basic.rb", "tests/test_connection_count.rb", "tests/test_defer.rb", "tests/test_epoll.rb", "tests/test_error_handler.rb", "tests/test_errors.rb", "tests/test_eventables.rb", "tests/test_exc.rb", "tests/test_futures.rb", "tests/test_handler_check.rb", "tests/test_hc.rb", "tests/test_httpclient.rb", "tests/test_httpclient2.rb", "tests/test_kb.rb", "tests/test_ltp.rb", "tests/test_ltp2.rb", "tests/test_next_tick.rb", "tests/test_processes.rb", "tests/test_pure.rb", "tests/test_running.rb", "tests/test_sasl.rb", "tests/test_send_file.rb", "tests/test_servers.rb", "tests/test_smtpclient.rb", "tests/test_smtpserver.rb", "tests/test_spawn.rb", "tests/test_ssl_args.rb", "tests/test_ssl_methods.rb", "tests/test_timers.rb", "tests/test_ud.rb", "tests/testem.rb", "web/whatis"]
s.has_rdoc = true
s.homepage = %q{http://rubyeventmachine.com}
s.rdoc_options = ["--title", "EventMachine", "--main", "docs/README", "--line-numbers"]
s.rdoc_options = ["--title", "EventMachine", "--main", "docs/README", "--line-numbers", "-x", "lib/eventmachine_version", "-x", "lib/emva", "-x", "lib/evma/", "-x", "lib/pr_eventmachine", "-x", "lib/jeventmachine"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{eventmachine}
s.rubygems_version = %q{1.3.1}
Expand Down
2 changes: 1 addition & 1 deletion lib/em/deferrable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand Down
4 changes: 2 additions & 2 deletions lib/em/eventable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand All @@ -25,7 +25,7 @@


module EventMachine
module Eventable
module Eventable # :nodoc:

def listen_event event_name
end
Expand Down
3 changes: 2 additions & 1 deletion lib/em/future.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand All @@ -23,6 +23,7 @@
#
#

#--
# This defines EventMachine::Deferrable#future, which requires
# that the rest of EventMachine::Deferrable has already been seen.
# (It's in deferrable.rb.)
Expand Down
2 changes: 1 addition & 1 deletion lib/em/messages.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand Down
26 changes: 13 additions & 13 deletions lib/em/processes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand Down Expand Up @@ -83,22 +83,22 @@ def unbind
# The block or proc passed to EM::system is called with two arguments: the output generated by the command,
# and a Process::Status that contains information about the command's execution.
#
# EM.run{
# EM.system('ls'){ |output,status| puts output if status.exitstatus == 0 }
# }
# EM.run{
# EM.system('ls'){ |output,status| puts output if status.exitstatus == 0 }
# }
#
# You can also supply an additional proc to send some data to the process:
#
# EM.run{
# EM.system('sh', proc{ |process|
# process.send_data("echo hello\n")
# process.send_data("exit\n")
# }, proc{ |out,status|
# puts(out)
# })
# }
# EM.run{
# EM.system('sh', proc{ |process|
# process.send_data("echo hello\n")
# process.send_data("exit\n")
# }, proc{ |out,status|
# puts(out)
# })
# }
#
# Like EM::popen, EM::system currently does not work on windows.
# Like EventMachine.popen, EventMachine.system currently does not work on windows.
#
def EventMachine::system cmd, *args, &cb
cb ||= args.pop if args.last.is_a? Proc
Expand Down
17 changes: 8 additions & 9 deletions lib/em/spawnable.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand All @@ -21,14 +21,11 @@
#
#---------------------------------------------------------------------------
#
#


# Support for Erlang-style processes.
#


module EventMachine
# Support for Erlang-style processes.
#
class SpawnedProcess
#attr_accessor :receiver
def notify *x
Expand All @@ -49,6 +46,7 @@ def notify *x
alias_method :resume, :notify
alias_method :run, :notify # for formulations like (EM.spawn {xxx}).run

#--
# I know I'm missing something stupid, but the inside of class << s
# can't see locally-bound values. It can see globals, though.
def set_receiver blk
Expand All @@ -60,7 +58,7 @@ class << self

end

class YieldBlockFromSpawnedProcess
class YieldBlockFromSpawnedProcess # :nodoc:
def initialize block, notify
@block = [block,notify]
end
Expand All @@ -69,17 +67,18 @@ def pull_out_yield_block
end
end

# Spawn an erlang-style process
def EventMachine.spawn &block
s = SpawnedProcess.new
s.set_receiver block
s
end

def EventMachine.yield &block
def EventMachine.yield &block # :nodoc:
return YieldBlockFromSpawnedProcess.new( block, false )
end

def EventMachine.yield_and_notify &block
def EventMachine.yield_and_notify &block # :nodoc:
return YieldBlockFromSpawnedProcess.new( block, true )
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/em/streamer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $Id$
#--
#
# Author:: Francis Cianfrocca (gmail: blackhedd)
# Homepage:: http://rubyeventmachine.com
Expand Down
Loading

0 comments on commit 12ff775

Please sign in to comment.