Class: AssLauncher::Support::Shell::AssOutFile Private
- Inherits:
-
Object
- Object
- AssLauncher::Support::Shell::AssOutFile
- 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.
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
- #encoding ⇒ Object readonly private
- #file ⇒ Object readonly private
- #path ⇒ Object readonly private
Instance Method Summary collapse
- #detect_ass_encoding ⇒ Object private
-
#initialize(encoding = nil) ⇒ AssOutFile
constructor
private
A new instance of AssOutFile.
- #read ⇒ Object private
- #to_s ⇒ Object private
-
#try_unlink ⇒ Object
private
File can be busy.
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.
390 391 392 393 394 395 |
# File 'lib/ass_launcher/support/shell.rb', line 390 def initialize(encoding = nil) @file = Tempfile.new('ass_out') @file.close @path = platform.path(@file.path) @encoding = encoding || detect_ass_encoding end |
Instance Attribute Details
#encoding ⇒ Object (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.
389 390 391 |
# File 'lib/ass_launcher/support/shell.rb', line 389 def encoding @encoding end |
#file ⇒ Object (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.
389 390 391 |
# File 'lib/ass_launcher/support/shell.rb', line 389 def file @file end |
#path ⇒ Object (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.
389 390 391 |
# File 'lib/ass_launcher/support/shell.rb', line 389 def path @path end |
Instance Method Details
#detect_ass_encoding ⇒ Object
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.
It’s stub returns the CP1251 encoding but requires to detect 1C out encoding automatically
399 400 401 |
# File 'lib/ass_launcher/support/shell.rb', line 399 def detect_ass_encoding Encoding::CP1251 end |
#read ⇒ Object
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.
407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/ass_launcher/support/shell.rb', line 407 def read begin @file.open s = @file.read s.encode! Encoding::UTF_8, encoding unless linux? ensure @file.close try_unlink end s.to_s end |
#to_s ⇒ Object
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.
403 404 405 |
# File 'lib/ass_launcher/support/shell.rb', line 403 def to_s @path.to_s end |
#try_unlink ⇒ Object
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.
File can be busy
420 421 422 423 424 |
# File 'lib/ass_launcher/support/shell.rb', line 420 def try_unlink @file.unlink if @file rescue Errno::EBUSY # NOP end |