Module: Showterm
Instance Method Summary collapse
-
#delete!(url, secret = shared_secret) ⇒ Object
Delete from showterm.io.
-
#record!(*cmd) ⇒ scriptfile, timingfile
Record a terminal session.
-
#terminal_height ⇒ Integer
Get the current height of the terminal.
-
#terminal_width ⇒ Integer
Get the current width of the terminal.
-
#upload!(scriptfile, timingfile, cols = terminal_width, lines = terminal_height, secret = shared_secret) ⇒ Object
Upload the termshow to showterm.io.
Instance Method Details
#delete!(url, secret = shared_secret) ⇒ Object
Delete from showterm.io
67 68 69 70 71 72 73 74 75 |
# File 'lib/showterm.rb', line 67 def delete!(url, secret=shared_secret) request = Net::HTTP::Delete.new(URI(url).path) request.set_form_data(:secret => secret) response = http(request) raise response.body unless Net::HTTPSuccess === response response.body end |
#record!(*cmd) ⇒ scriptfile, timingfile
Record a terminal session.
If a command is given, use that command; otherwise the current user’s login shell will be used.
16 17 18 19 20 21 22 23 |
# File 'lib/showterm.rb', line 16 def record!(*cmd) ret = if use_script? record_with_script(*cmd) else record_with_ttyrec(*cmd) end ret end |
#terminal_height ⇒ Integer
Get the current height of the terminal
37 38 39 40 |
# File 'lib/showterm.rb', line 37 def terminal_height guess = `tput lines`.to_i guess == 0 ? 25 : guess end |
#terminal_width ⇒ Integer
Get the current width of the terminal
28 29 30 31 |
# File 'lib/showterm.rb', line 28 def terminal_width guess = `tput cols`.to_i guess == 0 ? 80 : guess end |
#upload!(scriptfile, timingfile, cols = terminal_width, lines = terminal_height, secret = shared_secret) ⇒ Object
Upload the termshow to showterm.io
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/showterm.rb', line 48 def upload!(scriptfile, timingfile, cols=terminal_width, lines=terminal_height, secret=shared_secret) with_retry do request = Net::HTTP::Post.new("/scripts") request.set_form_data(:scriptfile => scriptfile, :timingfile => timingfile, :cols => cols, :lines => lines, :secret => secret) response = http(request) raise response.body unless Net::HTTPSuccess === response response.body end end |