showterm 0.2.1.pre.1 → 0.2.1.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/showterm.rb +41 -3
- data/showterm.gemspec +1 -1
- metadata +23 -41
data/lib/showterm.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'tempfile'
|
2
|
+
require 'shellwords'
|
2
3
|
require 'net/https'
|
3
4
|
|
4
5
|
module Showterm
|
@@ -12,6 +13,45 @@ module Showterm
|
|
12
13
|
# @param [*String] cmd
|
13
14
|
# @return [scriptfile, timingfile] the two halves of a termshow
|
14
15
|
def record!(*cmd)
|
16
|
+
if use_script?
|
17
|
+
puts 'showterm recording with script, quit when done'
|
18
|
+
ret = record_with_script(*cmd)
|
19
|
+
else
|
20
|
+
puts 'showterm recording with , quit when done'
|
21
|
+
ret = record_with_ttyrec(*cmd)
|
22
|
+
end
|
23
|
+
puts 'showterm recording finished'
|
24
|
+
|
25
|
+
ret
|
26
|
+
end
|
27
|
+
|
28
|
+
def temp_file
|
29
|
+
f = Tempfile.new('showterm')
|
30
|
+
f.close(false)
|
31
|
+
at_exit{ f.close(true) }
|
32
|
+
f
|
33
|
+
end
|
34
|
+
|
35
|
+
def record_with_script(*cmd)
|
36
|
+
scriptfile, timingfile = [temp_file, temp_file]
|
37
|
+
|
38
|
+
args = ['script']
|
39
|
+
args << '-c' + cmd.join(" ") if cmd.size > 0
|
40
|
+
args << '-t'
|
41
|
+
args << scriptfile.path
|
42
|
+
|
43
|
+
system("#{args.map{ |x| Shellwords.escape(x) }.join(" ")} 2>#{Shellwords.escape(timingfile.path)}")
|
44
|
+
|
45
|
+
[scriptfile.open.read, timingfile.open.read]
|
46
|
+
end
|
47
|
+
|
48
|
+
def use_script?
|
49
|
+
scriptfile, timingfile = record_with_script('echo', 'foo')
|
50
|
+
|
51
|
+
scriptfile =~ /foo/ && timingfile =~ /^[0-9]/
|
52
|
+
end
|
53
|
+
|
54
|
+
def record_with_ttyrec(*cmd)
|
15
55
|
scriptfile = Tempfile.new('showterm.script')
|
16
56
|
scriptfile.close(false)
|
17
57
|
|
@@ -21,9 +61,7 @@ module Showterm
|
|
21
61
|
end
|
22
62
|
args << scriptfile.path
|
23
63
|
|
24
|
-
|
25
|
-
system(*args) or raise "showterm recording failed"
|
26
|
-
puts 'showterm recording finished'
|
64
|
+
system(*args)
|
27
65
|
|
28
66
|
ret = scriptfile.open.read
|
29
67
|
scriptfile.close(true)
|
data/showterm.gemspec
CHANGED
metadata
CHANGED
@@ -1,34 +1,24 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: showterm
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
- pre
|
10
|
-
- 1
|
11
|
-
version: 0.2.1.pre.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1.pre.2
|
5
|
+
prerelease: 6
|
12
6
|
platform: ruby
|
13
|
-
authors:
|
7
|
+
authors:
|
14
8
|
- Conrad Irwin
|
15
9
|
autorequire:
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
|
-
|
19
|
-
date: 2012-10-09 00:00:00 -07:00
|
20
|
-
default_executable:
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
21
13
|
dependencies: []
|
22
|
-
|
23
14
|
description: Integrates with showterm.io for awesome sharability.
|
24
15
|
email: conrad.irwin@gmail.com
|
25
|
-
executables:
|
16
|
+
executables:
|
26
17
|
- showterm
|
27
|
-
extensions:
|
18
|
+
extensions:
|
28
19
|
- ext/extconf.rb
|
29
20
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- LICENSE.MIT
|
33
23
|
- README.md
|
34
24
|
- bin/showterm
|
@@ -46,37 +36,29 @@ files:
|
|
46
36
|
- ext/ttytime.c
|
47
37
|
- lib/showterm.rb
|
48
38
|
- showterm.gemspec
|
49
|
-
has_rdoc: true
|
50
39
|
homepage: http://github.com/Conradirwin/showterm
|
51
40
|
licenses: []
|
52
|
-
|
53
41
|
post_install_message:
|
54
42
|
rdoc_options: []
|
55
|
-
|
56
|
-
require_paths:
|
43
|
+
require_paths:
|
57
44
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
segments:
|
70
|
-
- 1
|
71
|
-
- 3
|
72
|
-
- 1
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>'
|
55
|
+
- !ruby/object:Gem::Version
|
73
56
|
version: 1.3.1
|
74
57
|
requirements: []
|
75
|
-
|
76
58
|
rubyforge_project:
|
77
|
-
rubygems_version: 1.
|
59
|
+
rubygems_version: 1.8.24
|
78
60
|
signing_key:
|
79
61
|
specification_version: 3
|
80
62
|
summary: Allows you to make screen casts of your terminal really easily
|
81
63
|
test_files: []
|
82
|
-
|
64
|
+
has_rdoc:
|