lib/shelr/recorder.rb in shelr-0.11.9 vs lib/shelr/recorder.rb in shelr-0.12.0
- old
+ new
@@ -1,58 +1,43 @@
# encoding: utf-8
module Shelr
class Recorder
- HEADER = <<-EOH
- ____ _ _
-| _ \ ___ ___ ___ _ __ __| (_)_ __ __ _
-| |_) / _ \/ __/ _ \| '__/ _` | | '_ \ / _` |
-| _ < __/ (_| (_) | | | (_| | | | | | (_| |
-|_| \_\___|\___\___/|_| \__,_|_|_| |_|\__, |
- |___/
- EOH
+ attr_accessor :meta, :user_rows, :user_columns
- FOOTER = <<-EOF
- _____ _ _ _ _
-| ___(_)_ __ (_)___| |__ ___ __| |
-| |_ | | '_ \| / __| '_ \ / _ \/ _` |
-| _| | | | | | \__ \ | | | __/ (_| |
-|_| |_|_| |_|_|___/_| |_|\___|\__,_|
-
- EOF
-
def self.record!
new.record!
end
def initialize
@meta = {}
end
def record!
check_record_dir
+ init_terminal
request_metadata
- puts HEADER
- puts "Your session started"
- puts "Press Ctrl+D or 'exit' to finish recording"
+ STDOUT.puts "-=" * (Shelr.terminal.size[:width] / 2)
+ 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"
system(recorder_cmd)
- restore_terminal
save_as_typescript if Shelr.backend == 'ttyrec'
- puts FOOTER
- puts
- puts "Replay : #{Shelr::APP_NAME} play last"
- puts "Publish : #{Shelr::APP_NAME} push last"
+ STDOUT.puts "-=" * (Shelr.terminal.size[:width] / 2)
+ STDOUT.puts "=> Session finished"
+ STDOUT.puts
+ STDOUT.puts "Replay : #{Shelr::APP_NAME} play last"
+ STDOUT.puts "Publish : #{Shelr::APP_NAME} push last"
end
def request_metadata
- init_terminal
- print "Provide HUMAN NAME for Your record: "
+ STDOUT.print "Provide HUMAN NAME for Your record: "
@meta["title"] = STDIN.gets.strip
@meta["created_at"] = record_id
@meta["columns"] = @user_columns
@meta["rows"] = @user_rows
- puts record_file('meta')
+ STDOUT.puts record_file('meta')
File.open(record_file('meta'), 'w+') do |meta|
meta.puts @meta.to_json
end
end
@@ -75,14 +60,11 @@
def check_record_dir
FileUtils.mkdir_p(record_dir) unless File.exists?(record_dir)
end
def init_terminal
- @user_rows, @user_columns = `stty size`.split(' ')
- end
-
- def restore_terminal
- # system("stty columns #{@user_columns} rows #{@user_rows}")
+ @user_rows, @user_columns =
+ Shelr.terminal.size[:height], Shelr.terminal.size[:width]
end
def record_dir
@record_dir ||= Shelr.data_dir(record_id)
end