Top Level Namespace

Includes:
Benchmark, FileUtils, WEBrick

Defined Under Namespace

Modules: Breakpoint, Commands, DRb, IRB, Prof, Rails Classes: AppGenerator, Binding, CGI, CodeStatistics, ControllerGenerator, DispatchServlet, Dispatcher, IntegrationTestGenerator, MailerGenerator, MigrationGenerator, ModelGenerator, Module, Object, OrderedHash, OrderedOptions, Plugin, PluginGenerator, ProgramProcess, RailsEnvironment, RailsFCGIHandler, RecursiveHTTPFetcher, Repositories, Repository, ScaffoldGenerator, ScaffoldingSandbox, SessionMigrationGenerator, WebServiceGenerator

Constant Summary collapse

RAILS_ENV =
(ENV['RAILS_ENV'] || 'development').dup
RAILTIES_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
ABSOLUTE_RAILS_ROOT =
File.expand_path(RAILS_ROOT)
OPTIONS =
{
  :port            => 3000,
  :ip              => "0.0.0.0",
  :environment     => (ENV['RAILS_ENV'] || "development").dup,
  :server_root     => File.expand_path(RAILS_ROOT + "/public/"),
  :server_type     => WEBrick::SimpleServer,
  :charset         => "UTF-8",
  :mime_types      => WEBrick::HTTPUtils::DefaultMimeTypes
}

Instance Method Summary collapse

Instance Method Details

#app(create = false) ⇒ Object

reference the global “app” instance, created on demand. To recreate the instance, pass a non-false value as the parameter.



8
9
10
11
12
13
# File 'lib/console_app.rb', line 8

def app(create=false)
  @app_integration_instance = nil if create
  @app_integration_instance ||= new_session do |sess|
    sess.host! "www.example.com"
  end
end

#assert(&block) ⇒ Object

See Breakpoint.assert



519
520
521
522
523
# File 'lib/breakpoint.rb', line 519

def assert(&block)
  Binding.of_caller do |context|
    Breakpoint.assert(context, &block)
  end
end

#breakpoint(id = nil, &block) ⇒ Object

See Breakpoint.breakpoint



512
513
514
515
516
# File 'lib/breakpoint.rb', line 512

def breakpoint(id = nil, &block)
  Binding.of_caller do |context|
    Breakpoint.breakpoint(id, context, &block)
  end
end

#create_fixtures(*table_names) ⇒ Object



16
17
18
# File 'lib/test_help.rb', line 16

def create_fixtures(*table_names)
  Fixtures.create_fixtures(RAILS_ROOT + "/test/fixtures", table_names)
end

#daemonizeObject

:nodoc:



4
5
6
7
8
9
10
11
12
13
# File 'lib/commands/process/spawner.rb', line 4

def daemonize #:nodoc:
  exit if fork                   # Parent exits, child continues.
  Process.setsid                 # Become session leader.
  exit if fork                   # Zap session leader. See [1].
  Dir.chdir "/"                  # Release old working directory.
  File.umask 0000                # Ensure sensible umask. Adjust as needed.
  STDIN.reopen "/dev/null"       # Free file descriptors and
  STDOUT.reopen "/dev/null", "a" # point them somewhere sensible.
  STDERR.reopen STDOUT           # STDOUT/ERR should better go to a logfile.
end

#helperObject



13
14
15
# File 'lib/console_with_helpers.rb', line 13

def helper
  @helper_proxy ||= Object.new 
end

#new_session {|session| ... } ⇒ Object

create a new session. If a block is given, the new session will be yielded to the block before being returned.

Yields:

  • (session)


17
18
19
20
21
# File 'lib/console_app.rb', line 17

def new_session
  session = ActionController::Integration::Session.new
  yield session if block_given?
  session
end

#reload!Object

reloads the environment



24
25
26
27
# File 'lib/console_app.rb', line 24

def reload!
  puts "Reloading..."
  Dispatcher.reset_application!
end

#spawn(port) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/commands/process/spawner.rb', line 15

def spawn(port)
  print "Checking if something is already running on port #{port}..."
  begin
    srv = TCPServer.new('0.0.0.0', port)
    srv.close
    srv = nil
    print "NO\n "
    print "Starting FCGI on port: #{port}\n  "
    system("#{OPTIONS[:spawner]} -f #{OPTIONS[:dispatcher]} -p #{port}")
  rescue
    print "YES\n"
  end
end

#spawn_allObject



29
30
31
# File 'lib/commands/process/spawner.rb', line 29

def spawn_all
  OPTIONS[:instances].times { |i| spawn(OPTIONS[:port] + i) }
end