Class: OSC::VNC::ConnView
- Inherits:
-
Mustache
- Object
- Mustache
- OSC::VNC::ConnView
- Defined in:
- lib/osc/vnc/connview.rb
Overview
Provides a view for a variety of connection information templates in templates/conn. Extra options can be passed to this view and accessed directly in the mustache templates.
Instance Attribute Summary collapse
-
#connfile ⇒ Pathname
readonly
The path to the connection file.
-
#script ⇒ ScriptView
readonly
The script object with information about the job setup.
Instance Method Summary collapse
-
#initialize(script, connfile, opts = {}) ⇒ ConnView
constructor
A new instance of ConnView.
-
#method_missing(method_name, *arguments, &block) ⇒ Object
Check if the method call exists on @conn_context or the script object.
-
#refresh ⇒ ConnView
Get connection info from file generated by PBS batch job (read template/script/vnc.mustache).
-
#render(format, context = {}) ⇒ String
Generates a string from a template depending on the format name, current options include (:jnlp, :awesim, :terminal, :txt, :vnc, :yaml) (see templates/conn/*.mustache).
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Checks if the method responds to an instance method, or is able to proxy it to @conn_context or the script object.
-
#sshhost ⇒ String
The host to use for the ssh connection.
-
#sshuser ⇒ String
The user to use for the ssh connection.
Constructor Details
#initialize(script, connfile, opts = {}) ⇒ ConnView
Returns a new instance of ConnView.
20 21 22 23 24 |
# File 'lib/osc/vnc/connview.rb', line 20 def initialize(script, connfile, opts = {}) @script = script @connfile = Pathname.new(connfile.to_s) refresh end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
Check if the method call exists on @conn_context or the script object
62 63 64 65 66 67 68 69 70 |
# File 'lib/osc/vnc/connview.rb', line 62 def method_missing(method_name, *arguments, &block) @conn_context.fetch(method_name) do if script.respond_to? method_name script.send method_name else super end end end |
Instance Attribute Details
#connfile ⇒ Pathname (readonly)
Returns The path to the connection file.
15 16 17 |
# File 'lib/osc/vnc/connview.rb', line 15 def connfile @connfile end |
#script ⇒ ScriptView (readonly)
Returns The script object with information about the job setup.
12 13 14 |
# File 'lib/osc/vnc/connview.rb', line 12 def script @script end |
Instance Method Details
#refresh ⇒ ConnView
Get connection info from file generated by PBS batch job (read template/script/vnc.mustache).
52 53 54 55 |
# File 'lib/osc/vnc/connview.rb', line 52 def refresh _get_file_contents(connfile.to_s) self end |
#render(format, context = {}) ⇒ String
Generates a string from a template depending on the format name, current options include (:jnlp, :awesim, :terminal, :txt, :vnc, :yaml) (see templates/conn/*.mustache).
|
# File 'lib/osc/vnc/connview.rb', line 26
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Checks if the method responds to an instance method, or is able to proxy it to @conn_context or the script object.
77 78 79 |
# File 'lib/osc/vnc/connview.rb', line 77 def respond_to_missing?(method_name, include_private = false) @conn_context.include?(method_name) || script.respond_to?(method_name) || super end |
#sshhost ⇒ String
The host to use for the ssh connection.
42 43 44 |
# File 'lib/osc/vnc/connview.rb', line 42 def sshhost "#{script.cluster}.osc.edu" end |
#sshuser ⇒ String
The user to use for the ssh connection.
36 37 38 |
# File 'lib/osc/vnc/connview.rb', line 36 def sshuser ENV['USER'] end |