showterm 0.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/showterm +23 -0
- data/lib/showterm.rb +59 -0
- metadata +47 -0
data/bin/showterm
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'showterm'
|
4
|
+
|
5
|
+
if ARGV.include?('-h') || ARGV.include?('--help')
|
6
|
+
puts <<-EOF
|
7
|
+
Usage: showterm <command to run>
|
8
|
+
|
9
|
+
showterm will record the exact output of your session, and upload it to the
|
10
|
+
internet where it can be replayed by anyone to whom you give the URL.
|
11
|
+
EOF
|
12
|
+
end
|
13
|
+
|
14
|
+
sf, tf = Showterm.record! *ARGV
|
15
|
+
begin
|
16
|
+
Showterm.upload! sf, tf
|
17
|
+
rescue => e
|
18
|
+
puts [e] + e.backtrace
|
19
|
+
puts "DON'T PANIC"
|
20
|
+
puts "your script file is: #{sf} and your timing file is: #{tf}"
|
21
|
+
puts "to try uploading again:"
|
22
|
+
puts "ruby -rshowterm -e'Showterm.upload! #{sf.inspect}, #{tf.inspect}'"
|
23
|
+
end
|
data/lib/showterm.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'net/https'
|
4
|
+
|
5
|
+
module Showterm
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def record!(*cmd)
|
9
|
+
|
10
|
+
scriptfile = Tempfile.new('showterm.script')
|
11
|
+
timingfile = Tempfile.new('showterm.time')
|
12
|
+
|
13
|
+
scriptfile.close(false)
|
14
|
+
timingfile.close(false)
|
15
|
+
|
16
|
+
args = []
|
17
|
+
if cmd.size > 0
|
18
|
+
args << '-c' + cmd.join(" ")
|
19
|
+
end
|
20
|
+
|
21
|
+
args << '-q'
|
22
|
+
args << '-t' + timingfile.path
|
23
|
+
args << scriptfile.path
|
24
|
+
|
25
|
+
puts "showterm is recording, quit when you're done."
|
26
|
+
|
27
|
+
unless system('script', *args)
|
28
|
+
raise "Could not run 'script', please check that it's installed"
|
29
|
+
end
|
30
|
+
|
31
|
+
puts 'Recorded'
|
32
|
+
|
33
|
+
[scriptfile.path, timingfile.path]
|
34
|
+
end
|
35
|
+
|
36
|
+
def upload!(scriptfile, timingfile)
|
37
|
+
request = Net::HTTP::Post.new("/scripts")
|
38
|
+
request.set_form_data(:scriptfile => File.read(scriptfile),
|
39
|
+
:timingfile => File.read(timingfile))
|
40
|
+
|
41
|
+
response = http(request)
|
42
|
+
puts response.body
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def http(request)
|
48
|
+
connection = Net::HTTP.new("showterm.herokuapp.com", 443)
|
49
|
+
connection.use_ssl = true
|
50
|
+
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
51
|
+
connection.open_timeout = 10
|
52
|
+
connection.read_timeout = 10
|
53
|
+
connection.start do |http|
|
54
|
+
http.request request
|
55
|
+
end
|
56
|
+
rescue Timeout::Error
|
57
|
+
raise "Could not connect to https://api.github.com/"
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: showterm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.pre.1
|
5
|
+
prerelease: 4
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Conrad Irwin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-08 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Integrates with showterm.io for awesome sharability.
|
15
|
+
email: conrad.irwin@gmail.com
|
16
|
+
executables:
|
17
|
+
- showterm
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/showterm.rb
|
22
|
+
- bin/showterm
|
23
|
+
homepage: http://github.com/Conradirwin/showterm
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>'
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.1
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.24
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Allows you to make screen casts of your terminal really easily
|
47
|
+
test_files: []
|