shelr 0.15.2 → 0.16.0
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/shelr +3 -2
- data/lib/shelr/player.rb +30 -20
- data/lib/shelr/recorder.rb +21 -3
- data/lib/shelr/version.rb +1 -1
- metadata +4 -4
data/bin/shelr
CHANGED
@@ -15,6 +15,7 @@ HELP = <<-HELP
|
|
15
15
|
Recording:
|
16
16
|
|
17
17
|
record - record new shellcast
|
18
|
+
record --sound - record new shellcast with sound
|
18
19
|
|
19
20
|
Publishing:
|
20
21
|
|
@@ -48,7 +49,7 @@ case ARGV[0]
|
|
48
49
|
when '-h', '--help'
|
49
50
|
puts HELP
|
50
51
|
when 'record'
|
51
|
-
Shelr::Recorder.record!
|
52
|
+
Shelr::Recorder.record!(sound: ARGV[1] == '--sound')
|
52
53
|
when 'list'
|
53
54
|
Shelr::Player.list
|
54
55
|
when 'play'
|
@@ -58,7 +59,7 @@ when 'play'
|
|
58
59
|
elsif ARGV[1] =~ /.*\.json$/ # local file
|
59
60
|
Shelr::Player.play_dump(ARGV[1])
|
60
61
|
else
|
61
|
-
Shelr::Player.play(ARGV[1])
|
62
|
+
Shelr::Player.play(:record_id => ARGV[1])
|
62
63
|
end
|
63
64
|
else
|
64
65
|
puts "Missing id for shellcast"
|
data/lib/shelr/player.rb
CHANGED
@@ -8,8 +8,8 @@ require 'pathname'
|
|
8
8
|
module Shelr
|
9
9
|
class Player
|
10
10
|
|
11
|
-
def self.play(
|
12
|
-
new(
|
11
|
+
def self.play(options)
|
12
|
+
new.play(options)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.play_remote(url)
|
@@ -28,9 +28,9 @@ module Shelr
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.list
|
31
|
-
Dir[File.join(Shelr::DATA_DIR, "**", '
|
32
|
-
metadata = JSON.parse(IO.read(
|
33
|
-
puts "#{metadata["recorded_at"]}: #{metadata["title"]}"
|
31
|
+
(Dir[File.join(Shelr::DATA_DIR, "**")] - ['.', '..']).sort.each do |dir|
|
32
|
+
metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
|
33
|
+
puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -40,26 +40,32 @@ module Shelr
|
|
40
40
|
%w(typescript timing).each do |type|
|
41
41
|
File.open(File.join(dir, type), 'w') { |f| f.puts(parts[type]) }
|
42
42
|
end
|
43
|
-
|
44
|
-
puts "=> Title: #{parts['title']}"
|
45
|
-
puts "=> Description: #{parts['description']}t"
|
46
|
-
Shelr.terminal.puts_line
|
47
|
-
scriptreplay File.join(dir, 'typescript'), File.join(dir, 'timing')
|
48
|
-
Shelr.terminal.puts_line
|
49
|
-
puts "=> Title: #{parts['title']}"
|
50
|
-
puts "=> Description: #{parts['description']}t"
|
51
|
-
Shelr.terminal.puts_line
|
43
|
+
play(:record_dir => dir)
|
52
44
|
end
|
53
45
|
end
|
54
46
|
|
55
|
-
def
|
56
|
-
@
|
57
|
-
|
58
|
-
|
59
|
-
def play
|
47
|
+
def play(options = {})
|
48
|
+
@options = options
|
49
|
+
start_sound_player
|
60
50
|
Shelr.terminal.puts_line
|
61
51
|
self.class.scriptreplay record_file('typescript'), record_file('timing')
|
62
52
|
Shelr.terminal.puts_line
|
53
|
+
stop_sound_player
|
54
|
+
end
|
55
|
+
|
56
|
+
def start_sound_player
|
57
|
+
return unless File.exist?(record_file('sound.ogg'))
|
58
|
+
at_exit { system('stty echo') }
|
59
|
+
STDOUT.puts "=> Starting sound player..."
|
60
|
+
@sox_pid = fork do
|
61
|
+
`play #{record_file('sound.ogg')} 2>&1`
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def stop_sound_player
|
66
|
+
return unless File.exist?(record_file('sound.ogg'))
|
67
|
+
STDOUT.puts "=> Stopping sound player..."
|
68
|
+
Process.kill("HUP", @sox_pid)
|
63
69
|
end
|
64
70
|
|
65
71
|
def self.scriptreplay(typescript_file, timing_file)
|
@@ -78,7 +84,11 @@ module Shelr
|
|
78
84
|
private
|
79
85
|
|
80
86
|
def record_file(name)
|
81
|
-
File.join(
|
87
|
+
File.join(record_dir, name)
|
88
|
+
end
|
89
|
+
|
90
|
+
def record_dir
|
91
|
+
@options[:record_id] ? Shelr.data_dir(@options[:record_id]) : @options[:record_dir]
|
82
92
|
end
|
83
93
|
end
|
84
94
|
end
|
data/lib/shelr/recorder.rb
CHANGED
@@ -4,15 +4,15 @@ module Shelr
|
|
4
4
|
|
5
5
|
attr_accessor :meta, :user_rows, :user_columns
|
6
6
|
|
7
|
-
def self.record!
|
8
|
-
new.record!
|
7
|
+
def self.record!(options = {})
|
8
|
+
new.record!(options)
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@meta = {}
|
13
13
|
end
|
14
14
|
|
15
|
-
def record!
|
15
|
+
def record!(options = {})
|
16
16
|
ensure_terminal_has_good_size
|
17
17
|
check_record_dir
|
18
18
|
with_lock_file do
|
@@ -23,7 +23,9 @@ module Shelr
|
|
23
23
|
STDOUT.puts "=> Please, do not resize your terminal while recording"
|
24
24
|
STDOUT.puts "=> Press Ctrl+D or 'exit' to finish recording"
|
25
25
|
Shelr.terminal.puts_line
|
26
|
+
start_sound_recording if options[:sound]
|
26
27
|
system(recorder_cmd)
|
28
|
+
stop_sound_recording if options[:sound]
|
27
29
|
save_as_typescript if Shelr.backend == 'ttyrec'
|
28
30
|
Shelr.terminal.puts_line
|
29
31
|
STDOUT.puts "=> Session finished"
|
@@ -107,6 +109,22 @@ module Shelr
|
|
107
109
|
File.join(Shelr.data_dir(record_id), name)
|
108
110
|
end
|
109
111
|
|
112
|
+
def start_sound_recording
|
113
|
+
STDOUT.puts "Sound file stored in #{record_file('sound.ogg')}"
|
114
|
+
@sox_pid = fork do
|
115
|
+
Signal.trap("HUP") { puts "Sound recording finished!"; exit }
|
116
|
+
run_sound_recorder
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def stop_sound_recording
|
121
|
+
Process.kill("HUP", @sox_pid)
|
122
|
+
end
|
123
|
+
|
124
|
+
def run_sound_recorder
|
125
|
+
`rec -C 1 --channels 1 --rate 8k --comment 'Recorded for http://shelr.tv/' #{record_file('sound.ogg')} 2>&1`
|
126
|
+
end
|
127
|
+
|
110
128
|
def recorder_cmd
|
111
129
|
case Shelr.backend
|
112
130
|
when 'script'
|
data/lib/shelr/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-05-
|
15
|
+
date: 2012-05-05 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: json
|
@@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
88
88
|
version: '0'
|
89
89
|
segments:
|
90
90
|
- 0
|
91
|
-
hash: -
|
91
|
+
hash: -611569918164860445
|
92
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
93
|
none: false
|
94
94
|
requirements:
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
segments:
|
99
99
|
- 0
|
100
|
-
hash: -
|
100
|
+
hash: -611569918164860445
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
103
|
rubygems_version: 1.8.21
|