Module: Pssh
- Defined in:
- lib/pssh.rb,
lib/pssh/cli.rb,
lib/pssh/client.rb,
lib/pssh/socket.rb,
lib/pssh/console.rb,
lib/pssh/version.rb,
lib/pssh/web_console.rb
Defined Under Namespace
Classes: CLI, Client, Console, Socket, WebConsole
Constant Summary collapse
- DEFAULT_IO_MODE =
'rw'- DEFAULT_SOCKET_PREFIX =
'/tmp/pssh'- DEFAULT_PORT =
8022- VERSION =
"0.2.3"
Class Attribute Summary collapse
-
.client ⇒ Object
Returns the value of attribute client.
-
.command ⇒ Object
Public: This is the tool which we are going to use for our multiplexing.
-
.io_mode ⇒ Object
Public: This sets whether the connecting user can just view or can also write to the screen.
- .open_sessions ⇒ Object
- .port ⇒ Object
-
.prompt ⇒ Object
Public: This is the prompt character that shows up at the beginning of Pssh’s console.
-
.pty ⇒ Object
Returns the value of attribute pty.
-
.socket ⇒ Object
Returns the value of attribute socket.
-
.socket_prefix ⇒ Object
Public: This is the prefix that will be used to set up the socket for tmux or screen.
-
.web ⇒ Object
Returns the value of attribute web.
Class Method Summary collapse
- .base_path ⇒ Object
-
.configure {|_self| ... } ⇒ Object
Public: Allow configuring details of Pssh by making use of a block.
-
.create_session(username = nil) ⇒ Object
Public: Generates a random id for a session and stores it to a list.
-
.default_socket_path ⇒ Object
Public: This is the default socket path that will be used if one is not provided in the command line arguments.
Class Attribute Details
.client ⇒ Object
Returns the value of attribute client.
32 33 34 |
# File 'lib/pssh.rb', line 32 def client @client end |
.command ⇒ Object
Public: This is the tool which we are going to use for our multiplexing. If we’re currently in a tmux or screen session, that is the first option, then it checks if tmux or screen is installed, and then it resorts to a plain old shell.
Returns a Symbol.
78 79 80 81 82 83 84 85 |
# File 'lib/pssh.rb', line 78 def command @command ||= (ENV['TMUX'] && :tmux) || (ENV['STY'] && :screen) || (`which tmux` && :tmux) || (`which screen` && :screen) || :shell end |
.io_mode ⇒ Object
Public: This sets whether the connecting user can just view or can also write to the screen. Values are ‘rw, ’r’, and ‘w’.
Returns a String.
53 54 55 |
# File 'lib/pssh.rb', line 53 def io_mode @io_mode ||= DEFAULT_IO_MODE end |
.open_sessions ⇒ Object
45 46 47 |
# File 'lib/pssh.rb', line 45 def open_sessions @open_sessions ||= {} end |
.port ⇒ Object
41 42 43 |
# File 'lib/pssh.rb', line 41 def port @port ||= DEFAULT_PORT end |
.prompt ⇒ Object
Public: This is the prompt character that shows up at the beginning of Pssh’s console.
Returns a String.
99 100 101 |
# File 'lib/pssh.rb', line 99 def prompt @prompt ||= "\u26a1 " end |
.pty ⇒ Object
Returns the value of attribute pty.
34 35 36 |
# File 'lib/pssh.rb', line 34 def pty @pty end |
.socket ⇒ Object
Returns the value of attribute socket.
33 34 35 |
# File 'lib/pssh.rb', line 33 def socket @socket end |
.socket_prefix ⇒ Object
Public: This is the prefix that will be used to set up the socket for tmux or screen.
Returns a String.
60 61 62 |
# File 'lib/pssh.rb', line 60 def socket_prefix @socket_prefix ||= DEFAULT_SOCKET_PREFIX end |
.web ⇒ Object
Returns the value of attribute web.
35 36 37 |
# File 'lib/pssh.rb', line 35 def web @web end |
Class Method Details
.base_path ⇒ Object
37 38 39 |
# File 'lib/pssh.rb', line 37 def base_path File.dirname(__FILE__) + "/.." end |
.configure {|_self| ... } ⇒ Object
Public: Allow configuring details of Pssh by making use of a block.
Returns True.
90 91 92 93 |
# File 'lib/pssh.rb', line 90 def configure yield self true end |
.create_session(username = nil) ⇒ Object
Public: Generates a random id for a session and stores it to a list.
Returns a String.
106 107 108 109 110 |
# File 'lib/pssh.rb', line 106 def create_session(username=nil) id = SecureRandom.uuid self.open_sessions[id] = username id end |
.default_socket_path ⇒ Object
Public: This is the default socket path that will be used if one is not provided in the command line arguments.
Returns a String.
68 69 70 |
# File 'lib/pssh.rb', line 68 def default_socket_path @socket ||= "#{socket_prefix}-#{SecureRandom.uuid}" end |