termdump 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +80 -0
- data/Rakefile +20 -0
- data/bin/termdump +6 -0
- data/etc/Rakefile +19 -0
- data/etc/_termdump +25 -0
- data/etc/man.sh +3 -0
- data/etc/termdump +47 -0
- data/etc/termdump.1 +79 -0
- data/etc/termdump.1.md +61 -0
- data/lib/termdump/command.rb +81 -0
- data/lib/termdump/main.rb +474 -0
- data/lib/termdump/process.rb +19 -0
- data/lib/termdump/session.rb +84 -0
- data/lib/termdump/terminal/base/base.rb +50 -0
- data/lib/termdump/terminal/base/default.rb +6 -0
- data/lib/termdump/terminal/base/mock.rb +50 -0
- data/lib/termdump/terminal/base/terminal_helper.rb +35 -0
- data/lib/termdump/terminal/gnome_terminal.rb +44 -0
- data/lib/termdump/terminal/guake.rb +48 -0
- data/lib/termdump/terminal/terminator.rb +94 -0
- data/lib/termdump/terminal/xterm.rb +22 -0
- data/lib/termdump/version.rb +4 -0
- data/lib/termdump.rb +1 -0
- data/test/run_cmd.sh +8 -0
- data/test/test_basic_terminal.rb +32 -0
- data/test/test_command.rb +66 -0
- data/test/test_gnome_terminal.rb +13 -0
- data/test/test_main.rb +241 -0
- data/test/test_session.rb +112 -0
- data/test/test_terminator.rb +27 -0
- metadata +88 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'termdump/session'
|
4
|
+
|
5
|
+
class TestSession < MiniTest::Test
|
6
|
+
def setup
|
7
|
+
@session = TermDump::Session.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def inject_node_queue actions
|
11
|
+
@session.instance_variable_set(:@node_queue, actions)
|
12
|
+
end
|
13
|
+
|
14
|
+
def node_queue
|
15
|
+
@session.instance_variable_get(:@node_queue)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_fallback_not_support_tab
|
19
|
+
@session.instance_variable_set(:@support_tab, false)
|
20
|
+
@session.instance_variable_set(:@support_split, true)
|
21
|
+
actions = [
|
22
|
+
TermDump::Node.new(:window, 'window', ''),
|
23
|
+
TermDump::Node.new(:tab, 'tab', ''),
|
24
|
+
TermDump::Node.new(:tab, 'tab', ''),
|
25
|
+
TermDump::Node.new(:window, 'window', '')
|
26
|
+
]
|
27
|
+
inject_node_queue actions
|
28
|
+
@session.fallback
|
29
|
+
expected = [
|
30
|
+
TermDump::Node.new(:window, 'window', ''),
|
31
|
+
TermDump::Node.new(:window, 'tab', ''),
|
32
|
+
TermDump::Node.new(:window, 'tab', ''),
|
33
|
+
TermDump::Node.new(:window, 'window', '')
|
34
|
+
]
|
35
|
+
assert_equal expected, node_queue
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_fallback_not_support_split
|
39
|
+
@session.instance_variable_set(:@support_tab, true)
|
40
|
+
@session.instance_variable_set(:@support_split, false)
|
41
|
+
actions = [
|
42
|
+
TermDump::Node.new(:window, 'window', ''),
|
43
|
+
TermDump::Node.new(:tab, 'tab', ''),
|
44
|
+
TermDump::Node.new(:vsplit, 'vsplit', ''),
|
45
|
+
TermDump::Node.new(:vsplit, 'vsplit', '')
|
46
|
+
]
|
47
|
+
inject_node_queue actions
|
48
|
+
@session.fallback
|
49
|
+
expected = [
|
50
|
+
TermDump::Node.new(:window, 'window', ''),
|
51
|
+
TermDump::Node.new(:tab, 'tab', ''),
|
52
|
+
TermDump::Node.new(:tab, 'vsplit', ''),
|
53
|
+
TermDump::Node.new(:tab, 'vsplit', '')
|
54
|
+
]
|
55
|
+
assert_equal expected, node_queue
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_scan
|
59
|
+
node = {
|
60
|
+
'window' => {
|
61
|
+
'cwd' => 'home',
|
62
|
+
'tab' => {
|
63
|
+
'cwd' => 'some',
|
64
|
+
'command' => 'rm -rf /'
|
65
|
+
},
|
66
|
+
'vsplit' => {
|
67
|
+
'cwd' => 'any',
|
68
|
+
'command' => 'ls',
|
69
|
+
'hsplit' => {
|
70
|
+
'cwd' => 'else'
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
@session.scan node
|
76
|
+
expected = [
|
77
|
+
TermDump::Node.new(:window, 'window', 'home'),
|
78
|
+
TermDump::Node.new(:tab, 'tab', 'some', 'rm -rf /'),
|
79
|
+
TermDump::Node.new(:vsplit, 'vsplit', 'any', 'ls'),
|
80
|
+
TermDump::Node.new(:hsplit, 'hsplit', 'else')
|
81
|
+
]
|
82
|
+
assert_equal expected, node_queue
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_replay
|
86
|
+
task = {
|
87
|
+
'window' => {
|
88
|
+
'cwd' => 'home',
|
89
|
+
'tab' => {
|
90
|
+
'cwd' => 'some',
|
91
|
+
'command' => 'rm -rf /'
|
92
|
+
},
|
93
|
+
'vsplit' => {
|
94
|
+
'cwd' => 'any',
|
95
|
+
'command' => 'ls',
|
96
|
+
'hsplit' => {
|
97
|
+
'cwd' => 'else'
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
session = TermDump::Session.new({'terminal' => 'base/mock'})
|
103
|
+
session.replay(task)
|
104
|
+
done_actions = session.instance_variable_get(:@terminal).done_actions
|
105
|
+
expected = [
|
106
|
+
['home'],
|
107
|
+
[:tab, 'tab', 'some', 'rm -rf /'],
|
108
|
+
[:vsplit, 'vsplit', 'any', 'ls'],
|
109
|
+
[:hsplit, 'hsplit', 'else']
|
110
|
+
]
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'termdump/terminal/terminator'
|
4
|
+
|
5
|
+
class TestTerminator < MiniTest::Test
|
6
|
+
ENV['XDG_CONFIG_HOME'] = 'nonexist' # test configure not found
|
7
|
+
@@term = TermDump::Terminal.new({})
|
8
|
+
|
9
|
+
def test_parse_configure
|
10
|
+
lines = [
|
11
|
+
'[global_config]',
|
12
|
+
'[keybindings]',
|
13
|
+
' full_screen = <Ctrl><Shift>F11',
|
14
|
+
' new_tab = <Alt>Up # new tab',
|
15
|
+
' split_vert = <Alt>V',
|
16
|
+
' split_horiz = <Alt># # split horizontally',
|
17
|
+
' zoom_in = <Primary>equal',
|
18
|
+
' prev_tab = <Alt>Left']
|
19
|
+
config = @@term.parse_configure lines
|
20
|
+
expected = {
|
21
|
+
'new_tab' => 'Alt+Up',
|
22
|
+
'new_vsplit' => 'Alt+v',
|
23
|
+
'new_hsplit' => 'Alt+#'
|
24
|
+
}
|
25
|
+
assert_equal expected, config
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: termdump
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- spacewander
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: termdump is a tool which can dump your pty session and replay it
|
14
|
+
email:
|
15
|
+
- spacewanderlzx@gmail.com
|
16
|
+
executables:
|
17
|
+
- termdump
|
18
|
+
extensions:
|
19
|
+
- etc/Rakefile
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- bin/termdump
|
25
|
+
- etc/Rakefile
|
26
|
+
- etc/_termdump
|
27
|
+
- etc/man.sh
|
28
|
+
- etc/termdump
|
29
|
+
- etc/termdump.1
|
30
|
+
- etc/termdump.1.md
|
31
|
+
- lib/termdump.rb
|
32
|
+
- lib/termdump/command.rb
|
33
|
+
- lib/termdump/main.rb
|
34
|
+
- lib/termdump/process.rb
|
35
|
+
- lib/termdump/session.rb
|
36
|
+
- lib/termdump/terminal/base/base.rb
|
37
|
+
- lib/termdump/terminal/base/default.rb
|
38
|
+
- lib/termdump/terminal/base/mock.rb
|
39
|
+
- lib/termdump/terminal/base/terminal_helper.rb
|
40
|
+
- lib/termdump/terminal/gnome_terminal.rb
|
41
|
+
- lib/termdump/terminal/guake.rb
|
42
|
+
- lib/termdump/terminal/terminator.rb
|
43
|
+
- lib/termdump/terminal/xterm.rb
|
44
|
+
- lib/termdump/version.rb
|
45
|
+
- test/run_cmd.sh
|
46
|
+
- test/test_basic_terminal.rb
|
47
|
+
- test/test_command.rb
|
48
|
+
- test/test_gnome_terminal.rb
|
49
|
+
- test/test_main.rb
|
50
|
+
- test/test_session.rb
|
51
|
+
- test/test_terminator.rb
|
52
|
+
homepage: https://github.com/spacewander/termdump
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata: {}
|
56
|
+
post_install_message: |2+
|
57
|
+
|
58
|
+
You can get a bash completion script from [https://github.com/spacewander/termdump/blob/master/etc/termdump]
|
59
|
+
and a zsh completion script from [https://github.com/spacewander/termdump/blob/master/etc/_termdump]
|
60
|
+
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.9'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.2.3
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Dump your (pseudo)terminal session and replay it
|
80
|
+
test_files:
|
81
|
+
- test/test_session.rb
|
82
|
+
- test/run_cmd.sh
|
83
|
+
- test/test_main.rb
|
84
|
+
- test/test_command.rb
|
85
|
+
- test/test_basic_terminal.rb
|
86
|
+
- test/test_terminator.rb
|
87
|
+
- test/test_gnome_terminal.rb
|
88
|
+
has_rdoc:
|