Top Level Namespace

Includes:
Benchmark, FileUtils, WEBrick

Defined Under Namespace

Modules: Commands, Gem, Prof, Rails Classes: AppGenerator, CGI, CodeStatistics, ControllerGenerator, DispatchServlet, HelperGenerator, IntegrationTestGenerator, MailerGenerator, MetalGenerator, MigrationGenerator, ModelGenerator, Object, ObserverGenerator, PerformanceTestGenerator, Plugin, PluginGenerator, RailsEnvironment, RailsFCGIHandler, RecursiveHTTPFetcher, Repositories, Repository, ResourceGenerator, ScaffoldGenerator, SessionMigrationGenerator, SourceAnnotationExtractor

Constant Summary collapse

Dispatcher =
ActionController::Dispatcher
RAILS_ENV =
(ENV['RAILS_ENV'] || 'development').dup
RAILTIES_PATH =
File.join(File.dirname(__FILE__), '..')

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.



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

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

#create_fixtures(*table_names, &block) ⇒ Object



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

def create_fixtures(*table_names, &block)
  Fixtures.create_fixtures(ActiveSupport::TestCase.fixture_path, table_names, {}, &block)
end

#find_cmd(*commands) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/commands/dbconsole.rb', line 33

def find_cmd(*commands)
  dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
  commands += commands.map{|cmd| "#{cmd}.exe"} if RUBY_PLATFORM =~ /win32/

  full_path_command = nil
  found = commands.detect do |cmd|
    dir = dirs_on_path.detect do |path|
      full_path_command = File.join(path, cmd)
      File.executable? full_path_command
    end
  end
  found ? full_path_command : abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.")
end

#helperObject



1
2
3
# File 'lib/console_with_helpers.rb', line 1

def helper
  @helper ||= ApplicationController.helpers
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)


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

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

#reload!Object

reloads the environment



25
26
27
28
29
30
# File 'lib/console_app.rb', line 25

def reload!
  puts "Reloading..."
  Dispatcher.cleanup_application
  Dispatcher.reload_application
  true
end