Class: Shelr::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/shelr/recorder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRecorder

Returns a new instance of Recorder.



11
12
13
# File 'lib/shelr/recorder.rb', line 11

def initialize
  @meta = {}
end

Instance Attribute Details

#metaObject

Returns the value of attribute meta.



5
6
7
# File 'lib/shelr/recorder.rb', line 5

def meta
  @meta
end

#user_columnsObject

Returns the value of attribute user_columns.



5
6
7
# File 'lib/shelr/recorder.rb', line 5

def user_columns
  @user_columns
end

#user_rowsObject

Returns the value of attribute user_rows.



5
6
7
# File 'lib/shelr/recorder.rb', line 5

def user_rows
  @user_rows
end

Class Method Details

.record!(options = {}) ⇒ Object



7
8
9
# File 'lib/shelr/recorder.rb', line 7

def self.record!(options = {})
  new.record!(options)
end

Instance Method Details

#record!(options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/shelr/recorder.rb', line 15

def record!(options = {})
  ensure_terminal_has_good_size
  check_record_dir
  with_lock_file do
    init_terminal
    
    Shelr.terminal.puts_line
    STDOUT.puts "=> Your session started"
    STDOUT.puts "=> Please, do not resize your terminal while recording"
    STDOUT.puts "=> Press Ctrl+D or 'exit' to finish recording"
    Shelr.terminal.puts_line
    start_sound_recording if options[:sound]
    system(recorder_cmd)
    stop_sound_recording if options[:sound]
    save_as_typescript if Shelr.backend == 'ttyrec'
    Shelr.terminal.puts_line
    STDOUT.puts "=> Session finished"
    STDOUT.puts
    STDOUT.puts "Replay  : #{Shelr::APP_NAME} play last"
    STDOUT.puts "Publish : #{Shelr::APP_NAME} push last"
  end
end

#request_metadataObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/shelr/recorder.rb', line 38

def 
  STDOUT.print "Provide some title for your record: "
  @meta["title"] = STDIN.gets.strip
  @meta["recorded_at"] = record_id
  @meta["columns"] = @user_columns
  @meta["rows"] = @user_rows
  @meta["uname"] = `uname -a`
  @meta["shell"] = ENV['SHELL']
  @meta["term"] = ENV['TERM']
  @meta["xdg_current_desktop"] = ENV['XDG_CURRENT_DESKTOP']
  STDOUT.puts record_file('meta')
  File.open(record_file('meta'), 'w+') do |meta|
    meta.puts @meta.to_json
  end
end