instalatron 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/instalatron-record +57 -6
- data/lib/instalatron.rb +1 -1
- metadata +3 -3
data/bin/instalatron-record
CHANGED
@@ -5,6 +5,60 @@ require 'instalatron'
|
|
5
5
|
require 'yaml'
|
6
6
|
require 'mixlib/cli'
|
7
7
|
|
8
|
+
#
|
9
|
+
# From http://www.alecjacobson.com/weblog/?p=75
|
10
|
+
#
|
11
|
+
def read_char
|
12
|
+
begin
|
13
|
+
# save previous state of stty
|
14
|
+
old_state = `stty -g`
|
15
|
+
# disable echoing and enable raw (not having to press enter)
|
16
|
+
system "stty raw -echo"
|
17
|
+
c = STDIN.getc.chr
|
18
|
+
# gather next two characters of special keys
|
19
|
+
if(c=="\e")
|
20
|
+
extra_thread = Thread.new{
|
21
|
+
c = c + STDIN.getc.chr
|
22
|
+
c = c + STDIN.getc.chr
|
23
|
+
}
|
24
|
+
# wait just long enough for special keys to get swallowed
|
25
|
+
extra_thread.join(0.00001)
|
26
|
+
# kill thread so not-so-long special keys don't wait on getc
|
27
|
+
extra_thread.kill
|
28
|
+
end
|
29
|
+
rescue => ex
|
30
|
+
puts "#{ex.class}: #{ex.message}"
|
31
|
+
puts ex.backtrace
|
32
|
+
ensure
|
33
|
+
# restore previous state of stty
|
34
|
+
system "stty #{old_state}"
|
35
|
+
end
|
36
|
+
return c
|
37
|
+
end
|
38
|
+
|
39
|
+
def capture_sequence(vm_name)
|
40
|
+
sequence = ""
|
41
|
+
loop do
|
42
|
+
b = read_char
|
43
|
+
capture = b
|
44
|
+
if b.chomp.empty?
|
45
|
+
capture = "<enter>"
|
46
|
+
elsif b == "\t"
|
47
|
+
capture = "<tab>"
|
48
|
+
elsif b == 32
|
49
|
+
capture = " "
|
50
|
+
elsif b == "$"
|
51
|
+
break
|
52
|
+
else
|
53
|
+
capture = b
|
54
|
+
end
|
55
|
+
Instalatron.command_window(capture, vm_name)
|
56
|
+
print capture
|
57
|
+
sequence << capture
|
58
|
+
end
|
59
|
+
sequence
|
60
|
+
end
|
61
|
+
|
8
62
|
def record_session(vm_name, session_name = "instalatron_rec_" + Time.now.strftime("%F_%H%M"))
|
9
63
|
puts "Recording session #{session_name}\n\n"
|
10
64
|
script = []
|
@@ -24,11 +78,8 @@ def record_session(vm_name, session_name = "instalatron_rec_" + Time.now.strftim
|
|
24
78
|
step[:name] = $stdin.gets.strip.chomp
|
25
79
|
|
26
80
|
# Capture key sequence
|
27
|
-
print "Key sequence: "
|
28
|
-
step[:sequence] =
|
29
|
-
if step[:sequence].empty?
|
30
|
-
step[:sequence] = "<Enter>"
|
31
|
-
end
|
81
|
+
print "Key sequence (press $ to end): "
|
82
|
+
step[:sequence] = capture_sequence(vm_name)
|
32
83
|
|
33
84
|
# Copy screenshot to session dir
|
34
85
|
step[:image] = "#{step[:name].gsub(' ','_').downcase}.png"
|
@@ -36,7 +87,7 @@ def record_session(vm_name, session_name = "instalatron_rec_" + Time.now.strftim
|
|
36
87
|
|
37
88
|
script << step
|
38
89
|
puts
|
39
|
-
|
90
|
+
puts
|
40
91
|
screen_count += 1
|
41
92
|
print "Press ENTER to grab screen (#{screen_count})..."
|
42
93
|
$stdin.gets
|
data/lib/instalatron.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: instalatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Rubio
|