Class BiorubyController
In: lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb
Parent: ApplicationController

Methods

Constants

HIDE_METHODS = Object.methods + [ "singleton_method_added" ]
HIDE_MODULES = [ Base64::Deprecated, Base64, PP::ObjectMixin, Bio::Shell, ]
HIDE_VARIABLES = [ "_", "irb", "_erbout", ]
SECURITY_NOTICE = "For security purposes, this functionality is only available to local requests."

Public Instance methods

[Source]

     # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 135
135:   def commands
136:     @bioruby_commands = Bio::Shell.private_instance_methods.sort
137:   end

[Source]

    # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 22
22:   def evaluate
23:     if local_request?
24:       begin
25:         @script = params[:script].strip
26: 
27:         # write out to history
28:         Bio::Shell.store_history(@script)
29: 
30:         # evaluate ruby script
31:         @result = eval(@script, Bio::Shell.cache[:binding])
32: 
33:         # *TODO* need to handle with output of print/puts/p/pp etc. here
34:         @output = nil
35:       rescue
36:         @result = $!
37:         @output = nil
38:       end
39:     else
40:       @result = SECURITY_NOTICE
41:       @output = nil
42:     end
43: 
44:     @number = Bio::Shell.cache[:results].store(@script, @result, @output)
45: 
46:     render :update do |page|
47:       render_log(page)
48:     end
49:   end

[Source]

     # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 139
139:   def history
140:     @history = File.readlines(Bio::Shell.history_file)
141:   end

[Source]

    # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 16
16:   def index
17:     unless local_request?
18:       flash[:notice] = SECURITY_NOTICE
19:     end
20:   end

[Source]

    # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 64
64:   def list_classes
65:     number = params[:number].to_i
66: 
67:     script, result, output = Bio::Shell.cache[:results].restore(number)
68:     class_name = result.class
69:     @class = class_name
70:     @classes = []
71:     loop do
72:       @classes.unshift(class_name)
73:       if class_name == Object
74:         break
75:       else
76:         class_name = class_name.superclass
77:       end
78:     end
79: 
80:     render :update do |page|
81:       page.replace_html "classes_#{number}", :partial => "classes"
82:       page.visual_effect :toggle_blind, "classes_#{number}", :duration => 0.5
83:     end
84:   end

[Source]

    # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 51
51:   def list_methods
52:     number = params[:number].to_i
53: 
54:     script, result, output = Bio::Shell.cache[:results].restore(number)
55:     @class = result.class
56:     @methods = (result.methods - HIDE_METHODS).sort
57: 
58:     render :update do |page|
59:       page.replace_html "methods_#{number}", :partial => "methods"
60:       page.visual_effect :toggle_blind, "methods_#{number}", :duration => 0.5
61:     end
62:   end

[Source]

    # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 86
86:   def list_modules
87:     number = params[:number].to_i
88: 
89:     script, result, output = Bio::Shell.cache[:results].restore(number)
90:     @class = result.class
91:     @modules = result.class.included_modules - HIDE_MODULES
92: 
93:     render :update do |page|
94:       page.replace_html "modules_#{number}", :partial => "modules"
95:       page.visual_effect :toggle_blind, "modules_#{number}", :duration => 0.5
96:     end
97:   end

[Source]

     # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 99
 99:   def reload_script
100:     number = params[:number].to_i
101: 
102:     script, result, output = Bio::Shell.cache[:results].restore(number)
103: 
104:     render :update do |page|
105:       page.replace_html :script, script
106:     end
107:   end

[Source]

     # File lib/bio/shell/rails/vendor/plugins/bioruby/generators/bioruby/templates/bioruby_controller.rb, line 109
109:   def results
110:     if Bio::Shell.cache[:results].number > 0
111:       limit = params[:limit].to_i
112:       max_num = Bio::Shell.cache[:results].number
113:       min_num = [ max_num - limit + 1, 1 ].max
114:       min_num = 1 if limit == 0
115: 
116:       render :update do |page|
117:         # delete all existing results in the current DOM for clean up
118:         page.select(".log").each do |element|
119:           #page.hide element
120:           page.remove element
121:         end
122: 
123:         # add selected results to the current DOM
124:         min_num.upto(max_num) do |@number|
125:           #page.show "log_#{@number}"
126:           @script, @result, @output = Bio::Shell.cache[:results].restore(@number)
127:           if @script
128:             render_log(page)
129:           end
130:         end
131:       end
132:     end
133:   end

[Validate]