Top Level Namespace

Includes:
Benchmark, FileUtils, WEBrick

Defined Under Namespace

Modules: AuthoRails, Breakpoint, Commands, DRb, Handlers, IRB, Prof, Rails Classes: AppGenerator, Binding, CGI, CodeStatistics, ControllerGenerator, DispatchServlet, Inspector, IntegrationTestGenerator, Killer, MailerGenerator, MigrationGenerator, ModelGenerator, Module, Object, ObserverGenerator, Plugin, PluginGenerator, RailsEnvironment, RailsFCGIHandler, RecursiveHTTPFetcher, Repositories, Repository, ResourceGenerator, ScaffoldGenerator, ScaffoldResourceGenerator, ScaffoldingSandbox, SessionMigrationGenerator, WebServiceGenerator

Constant Summary collapse

RAILS_ENV =
(ENV['RAILS_ENV'] || 'development').dup
RAILTIES_PATH =
File.expand_path(File.join(File.dirname(__FILE__), '..'))
Options =
{
  :ClientURI  => nil,
  :ServerURI  => "druby://localhost:42531",
  :RetryDelay => 2,
  :Permanent  => true,
  :Verbose    => false
}
OPTIONS =
{
  :pid_path => File.expand_path(RAILS_ROOT + '/tmp/pids'),
  :pattern  => "dispatch.*.pid",
  :ps       => "ps -o pid,state,user,start,time,pcpu,vsz,majflt,command -p %s"
}

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



549
550
551
552
553
# File 'lib/breakpoint.rb', line 549

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

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

See Breakpoint.breakpoint



542
543
544
545
546
# File 'lib/breakpoint.rb', line 542

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

#create_fixtures(*table_names) ⇒ Object



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

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

#daemonizeObject

:nodoc:



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

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

#tail(log_file) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/commands/servers/base.rb', line 1

def tail(log_file)
  cursor = File.size(log_file)
  last_checked = Time.now
  tail_thread = Thread.new do
    File.open(log_file, 'r') do |f|
      loop do
        f.seek cursor
        if f.mtime > last_checked
          last_checked = f.mtime
          contents = f.read
          cursor += contents.length
          print contents
        end
        sleep 1
      end
    end
  end
  tail_thread
end