[BioRuby-cvs] bioruby/lib/bio/shell/rails/app/controllers application.rb, NONE, 1.1 shell_controller.rb, NONE, 1.1
Katayama Toshiaki
k at pub.open-bio.org
Mon Feb 27 11:16:23 UTC 2006
Update of /home/repository/bioruby/bioruby/lib/bio/shell/rails/app/controllers
In directory pub.open-bio.org:/tmp/cvs-serv2240/app/controllers
Added Files:
application.rb shell_controller.rb
Log Message:
* BioRuby shell on Rails kit
* main original files are - app/controllers/shell_controller.rb,
app/models/shell_connection.rb, app/views/layouts/shell.rhtml,
app/views/shell/show.rhtml, (app/views/shell/history.rhtml),
(config/database.yml), public/images/icon.png, public/stylesheets/main.css,
script/server
--- NEW FILE: application.rb ---
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
end
--- NEW FILE: shell_controller.rb ---
class DocumentRegistry
@@registry = []
def self.[](class_name)
@@registry.each do |block|
url = block.call(class_name)
return url if url
end
""
end
def self.register &block
@@registry.push(block)
end
end
DocumentRegistry.register() do |class_name|
if m = /Bio::(.+)/.match(class_name)
"http://bioruby.org/rdoc/classes/Bio/#{m[1].split('::').join('/')}.html"
else
false
end
end
DocumentRegistry.register do |class_name|
if m = /Chem::(.+)/.match(class_name)
"http://chemruby.org/rdoc/classes/Chem/#{m[1].split('::').join('/')}.html"
else
false
end
end
DocumentRegistry.register do |class_name|
"http://www.ruby-doc.org/core/classes/#{class_name.split('::').join('/')}.html"
end
class ShellController < ApplicationController
layout 'shell' #, :except => [:rss_feed, :rss_with_content]
def index
setup
end
def show
setup
@obj = $drb_server[params[:id]]
if @obj.nil?
@inheritance = "<h1>Unknown local variable! : #{params[:var]}</h1>"
else
@inheritance = get_inheritance @obj.class
if @obj.respond_to?(:to_html)
@contents = @obj.to_html
else
@contents = "Undefined :to_html"
end
end
@title = params[:id]
end
=begin
def history
setup
@history = File.read("session/history")
end
=end
private
def setup
@local_vars = $drb_server.registry
end
def get_inheritance obj
# mods = obj.included_modules - [PP::ObjectMixin, Bio::Shell, WEBrick]
mods = obj.included_modules
module_links = mods.collect{|m|
" [<a href=#{DocumentRegistry[m.to_s]}>#{m.to_s}</a>] "
}.join("|")
inherit = []
loop do
inherit.push(" [<a href=#{DocumentRegistry[obj.to_s]}>#{obj.to_s}</a>] ")
break if obj == Object
obj = obj.superclass
end
"<table><tr><th>Inheritance</th><td>" + inherit.join(" < ") + "</td></tr>" +
"<tr><th>Mix-in</th><td>" + module_links + "</td</tr></table>"
end
end
More information about the bioruby-cvs
mailing list