Module: ExtractTtc
- Extended by:
- FFI::Library
- Defined in:
- lib/extract_ttc.rb,
lib/extract_ttc/version.rb
Defined Under Namespace
Classes: Error, InvalidFileError, ReadFileError, UnknownResultError, WriteFileError
Constant Summary
collapse
- VERSION =
"0.3.6".freeze
Class Method Summary
collapse
Class Method Details
.capture3 ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/extract_ttc.rb', line 51
def self.capture3
stderr = status = nil
stdout = capture_stream($stdout) do
stderr = capture_stream($stderr) do
status = yield
end
end
[stdout, stderr, status]
end
|
.capture_stream(stream_io) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/extract_ttc.rb', line 63
def self.capture_stream(stream_io)
origin_stream = stream_io.dup
Tempfile.open("captured_stream") do |captured_stream|
stream_io.reopen(captured_stream)
yield
captured_stream.rewind
return captured_stream.read
end
ensure
stream_io.reopen(origin_stream)
end
|
28
29
30
31
32
33
34
35
36
|
# File 'lib/extract_ttc.rb', line 28
def self.(path)
stdout, stderr, code = capture3 do
handlefile(path)
end
return handle_error(code, stderr) unless code.zero?
fetch_filenames(stdout)
end
|
.fetch_filenames(stdout) ⇒ Object
76
77
78
|
# File 'lib/extract_ttc.rb', line 76
def self.fetch_filenames(stdout)
stdout.split("=>").last.split
end
|
.handle_error(code, stderr) ⇒ Object