Skip to content

Commit

Permalink
Improve API documentation. Do not generate diagrams: it becomes too big.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Feb 28, 2008
1 parent 95f365a commit 382f8d5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ Rake::RDocTask.new do |rd|
rd.rdoc_files.include("README", "lib/mod_rails/*.rb", "lib/rake/extensions.rb", "ext/mod_rails/*.c")
rd.template = "./doc/template/horo"
rd.title = "Passenger Ruby API"
rd.options << "-S" << "-N" << "-p" << "-H" << "-d"
rd.options << "-S" << "-N" << "-p" << "-H"
end


Expand Down Expand Up @@ -317,7 +317,7 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.extra_rdoc_files = ['README']
s.rdoc_options <<
"-S" << "-N" << "-p" << "-H" << "-d" <<
"-S" << "-N" << "-p" << "-H" <<
'--main' << 'README' <<
'--template' << './doc/template/horo' <<
'--title' << 'Passenger Ruby API'
Expand Down
4 changes: 4 additions & 0 deletions lib/mod_rails/abstract_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ class AbstractServer
class UnknownMessage < StandardError
end

# Raised when a command is invoked that requires that the server is
# not already started.
class ServerAlreadyStarted < StandardError
end

# Raised when a command is invoked that requires that the server is
# already started.
class ServerNotStarted < StandardError
end

Expand Down
4 changes: 4 additions & 0 deletions lib/mod_rails/application.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require 'rubygems'
module ModRails # :nodoc:

# Indicates that there is no Ruby on Rails version installed that satisfies
# a given Ruby on Rails Gem version specification.
class VersionNotFound < StandardError
attr_reader :gem_version_spec

# - +message+: The exception message.
# - +gem_version_spec+: The Ruby on Rails Gem version specification that caused this error.
def initialize(message, gem_version_spec)
super(message)
@gem_version_spec = gem_version_spec
Expand Down
20 changes: 12 additions & 8 deletions lib/mod_rails/application_spawner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
require 'mod_rails/request_handler'
module ModRails # :nodoc

# Raised when an ApplicationSpawner, FrameworkSpawner or SpawnManager is
# unable to spawn a new application.
class SpawnError < StandardError
end

# This class is capable of spawns instances of a single Ruby on Rails application.
# It does so by preloading as much of the application's code as possible, then creating
# instances of the application using what is already preloaded. This makes it spawning
Expand All @@ -16,28 +21,27 @@ module ModRails # :nodoc
class ApplicationSpawner < AbstractServer
include Utils

# The user ID of the root user.
ROOT_UID = 0
# The group ID of the root user.
ROOT_GID = 0

class SpawnError < StandardError
end

# An attribute, used internally. This should not be used outside Passenger.
attr_accessor :time

# _app_root_ is the root directory of this application, i.e. the directory
# +app_root+ is the root directory of this application, i.e. the directory
# that contains 'app/', 'public/', etc. If given an invalid directory,
# or a directory that doesn't appear to be a Rails application root directory,
# then an ArgumentError will be raised.
#
# If _lower_privilege_ is true, then ApplicationSpawner will attempt to
# switch to the user who owns the application's <tt>config/environment.rb</tt>,
# If +lower_privilege+ is true, then ApplicationSpawner will attempt to
# switch to the user who owns the application's +config/environment.rb+,
# and to the default group of that user.
#
# If that user doesn't exist on the system, or if that user is root,
# then ApplicationSpawner will attempt to switch to the username given by
# _lowest_user_ (and to the default group of that user).
# If _lowest_user_ doesn't exist either, or if switching user failed
# +lowest_user+ (and to the default group of that user).
# If +lowest_user+ doesn't exist either, or if switching user failed
# (because the current process does not have the privilege to do so),
# then ApplicationSpawner will continue without reporting an error.
def initialize(app_root, lower_privilege = true, lowest_user = "nobody")
Expand Down
4 changes: 2 additions & 2 deletions lib/mod_rails/framework_spawner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def initialize(options = {})
# If the FrameworkSpawner server hasn't already been started, a ServerNotStarted
# will be raised.
# If the RoR application failed to start (which may be a problem in the application,
# or a problem in the Ruby on Rails framework), then an ApplicationSpawner::SpawnError
# or a problem in the Ruby on Rails framework), then a SpawnError
# will be raised. The application's exception message will be printed to standard
# error.
def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody")
Expand All @@ -73,7 +73,7 @@ def spawn_application(app_root, lower_privilege = true, lowest_user = "nobody")
return Application.new(app_root, pid, listen_socket_name,
using_abstract_namespace == "true", owner_pipe)
rescue SystemCallError, IOError, SocketError
raise ApplicationSpawner::SpawnError, "Unable to spawn the application: " <<
raise SpawnError, "Unable to spawn the application: " <<
"either the Ruby on Rails framework failed to load, " <<
"or the application died unexpectedly during initialization."
end
Expand Down
2 changes: 1 addition & 1 deletion test/abstract_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
end

it "should raise a ServerAlreadyStarted if the server is already started" do
lambda { @server.start }.should raise_error(ServerAlreadyStarted)
lambda { @server.start }.should raise_error(AbstractServer::ServerAlreadyStarted)
end
end

0 comments on commit 382f8d5

Please sign in to comment.