Interacting with Telegard through jIRB Shell
Ruby developers rely heavily on the IRB or Interactive Ruby shell. Developing for Telegard is no different. It is often very useful when debugging to enter a jIRB console to test functions or interact with the code in a live environment.
Getting started
You should be in the BBS directory, Java and JRuby should be in your path before executing jirb. The H2 database instance should also be running.
Example Session
ctusa@tron /opt/telegard/bbs $ jirb irb(main):001:0> require 'lib/telegard.rb' => true irb(main):002:0> Telegard.init OpenTelegard v0.2 :: Copyright (c) 2008-2010, Chris Tusa All rights reserved. Distributed by LeafScale Systems - see the LICENSE file. Loading Telegard configuration..............................[DONE] Initializing database connection............................[DONE] Initializing Database Models................................[WAIT] DB Model: groups...........................................[DONE] DB Model: users............................................[DONE] DB Model: fileareas........................................[DONE] DB Model: files............................................[DONE] DB Model: messsageareas....................................[DONE] DB Model: messages.........................................[DONE] DB Model: email............................................[DONE] DB Model: chatrooms........................................[DONE] DB Model: extprogs.........................................[DONE] DB Model: sessions.........................................[DONE] DB Model: callhistory......................................[DONE] Database Models Initialized OK..............................[DONE] Loading FreeMarker+TG template engine......................./media/OCZ4-XFS- DEV/devel/jruby/lib/ruby/site_ruby/shared/builtin/javasupport/core_ext/module.rb:35 warning: replacing File with Java::JavaIo::File in constant 'File on class/module JavaIO [DONE] Loading Master Controller...................................[DONE] => nil irb(main):003:0>
Require Telegard's Main Library
In the above example, in IRB line 001:0, we require the master Telegard library. This library is responsible for loading the support for all other subsections (controllers, database, models, templates, etc), as well as providing some important methods.
Initialize the Telegard Runtime
In the above example, IRB line 002:0, we call the init method to load the supporting libraries and get things ready to go.
Interacting with Telegard
You can now call any Modules, Classes or Methods by hand for debugging purposes. For example:
irb(main):008:0> Tgconfig.load
=> {"database"=>{"type"=>"embedded", "driver"=>"jdbc:postgresql", "host"=>"localhost:5432", "name"=>"database", "user"=>"username", "pass"=>"pass"}, "bbs"=>{"name"=>"Telegard/2 BBS", "tagline"=>"Another Installation of OpenTelegard/2", "theme"=>"opentg"}, "login"=>{"attempts"=>5, "lockout"=>8, "usehint"=>true, "allownew"=>true}, "signup"=>{"default_group"=>"users", "ask_address"=>false, "ask_postal"=>false, "ask_country"=>false, "ask_phone"=>false, "ask_gender"=>true, "ask_bday"=>true, "ask_custom1"=>true, "custom1"=>"How did you hear about us? (75 chars max)", "ask_custom2"=>false, "custom2"=>"Where do you work? (75 chars max)", "ask_custom3"=>false, "custom3"=>"How long have you been using BBS'es?"}}
The above example asks Telegard to load the configuration information from the Yaml config file.
Doing More
Refer to the Telegard API RDOCS for more information about how to work with the Telegard interactively.





