Class: ScripTTY::Apps::DumpScreensApp
- Inherits:
-
Object
- Object
- ScripTTY::Apps::DumpScreensApp
- Defined in:
- lib/scriptty/apps/dump_screens_app.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ DumpScreensApp
constructor
A new instance of DumpScreensApp.
- #main ⇒ Object
Constructor Details
#initialize(argv) ⇒ DumpScreensApp
Returns a new instance of DumpScreensApp.
29 30 31 |
# File 'lib/scriptty/apps/dump_screens_app.rb', line 29 def initialize(argv) @options = (argv) end |
Instance Method Details
#main ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/scriptty/apps/dump_screens_app.rb', line 33 def main @term = ScripTTY::Term.new(@options[:term]) @term.on_unknown_sequence :ignore # DEBUG FIXME #@term.on_unknown_sequence do |seq| # puts "Unknown escape sequence: #{seq.inspect}" # DEBUG FIXME #end @screen_pattern_digests = Set.new @prev_screen = nil @next_num = 1 @output_file = File.open(@options[:output], "w") if @options[:output] if @options[:output_dir] @output_dir = @options[:output_dir] @next_num = Dir.entries(@output_dir).map{|e| e =~ /\Ap(\d+)\.txt\Z/ && $1.to_i }.select{|e| e}.sort.last || 1 end begin @options[:input_files].each do |input_filename| File.open(input_filename, "r") do |input_file| reader = ScripTTY::Util::Transcript::Reader.new(input_file) while (entry = reader.next_entry) , type, args = entry case type when :from_server handle_bytes_from_server(args[0]) when :server_parsed handle_bytes_from_server(args[1]) when :from_client handle_bytes_from_client(args[0], ) end end end end ensure @output_file.close if @output_file @output_file = nil end end |