Class: AssLauncher::Support::Shell::AssOutFile Private

Inherits:
Object
  • Object
show all
Includes:
Platforms
Defined in:
lib/ass_launcher/support/shell.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

Fucking 1C not work with stdout and stderr For out 1C use /OUT“file” parameter and write message into. Message encoding ‘cp1251’ for windows and ‘utf-8’ for Linux

Hold, read and encode 1C output

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Platforms

cygwin?, env, glob, linux?, path, path_class, windows?

Constructor Details

#initialize(encoding = nil) ⇒ AssOutFile

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of AssOutFile.



376
377
378
379
380
381
# File 'lib/ass_launcher/support/shell.rb', line 376

def initialize(encoding = nil)
  @file = Tempfile.new('ass_out')
  @file.close
  @path = platform.path(@file.path)
  @encoding = encoding || Encoding::CP1251
end

Instance Attribute Details

#encodingObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



375
376
377
# File 'lib/ass_launcher/support/shell.rb', line 375

def encoding
  @encoding
end

#fileObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



375
376
377
# File 'lib/ass_launcher/support/shell.rb', line 375

def file
  @file
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



375
376
377
# File 'lib/ass_launcher/support/shell.rb', line 375

def path
  @path
end

Instance Method Details

#readObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



387
388
389
390
391
392
393
394
395
396
397
# File 'lib/ass_launcher/support/shell.rb', line 387

def read
  begin
    @file.open
    s = @file.read
    s.encode! Encoding::UTF_8, encoding unless linux?
  ensure
    @file.close
    @file.unlink
  end
  s.to_s
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



383
384
385
# File 'lib/ass_launcher/support/shell.rb', line 383

def to_s
  @path.to_s
end