Class: Ramaze::Bin::Console
Overview
Allows the user to enter an IRB like session that takes advantage of everything provided by Ramaze.
Usage
ramaze console ramaze console /path/to/app/start.rb
Constant Summary
- Description =
String containing the description of this command.
'Starts an IRB session with Ramaze loaded into the session'- Banner =
The banner that is displayed when the -h or --help option is specified.
"Starts an IRB session and loads Ramaze into the session. All specified Rack\noptions are ignored and environment variables are passed to IRB.\n\nUsage:\nramaze console [DIR] [OPTIONS]\n\nExample:\nramaze console\nramaze console /home/foobar/ramaze/start.rb\n".strip
Instance Method Summary (collapse)
-
- (Console) initialize
constructor
Creates a new instance of the command and sets all the options.
-
- (Object) run(argv = [])
Runs the command based on the given command line arguments.
Constructor Details
- (Console) initialize
Creates a new instance of the command and sets all the options.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ramaze/bin/console.rb', line 43 def initialize = OptionParser.new do |opt| opt. = Banner opt.summary_indent = ' ' opt.separator "\nOptions:\n" opt.on('-h', '--help', 'Shows this help message') do puts exit end end end |
Instance Method Details
- (Object) run(argv = [])
Runs the command based on the given command line arguments.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ramaze/bin/console.rb', line 64 def run(argv = []) .parse!(argv) start_file = argv.delete_at(0) start_file = File.join(Dir.pwd, 'start.rb') if start_file.nil? if File.directory?(start_file) start_file = File.join(start_file, 'start.rb') end if !File.exist?(start_file) abort "The file #{start_file} does not exist" end start_file = Pathname.new(start_file).realpath.to_s Ramaze..started = true require(start_file) IRB.start puts 'Ramazement has ended, go in peace.' end |