Class: Embulk::TextGuessPlugin
Instance Method Summary
collapse
Methods inherited from GuessPlugin
from_java, new_java
Instance Method Details
#guess(config, sample) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/embulk/guess_plugin.rb', line 47
def guess(config, sample)
begin
task = config.load_config(Java::LineDecoder::DecoderTask)
rescue
p $!
p $!.backtrace
return DataSource.new
end
decoder = Java::LineDecoder.new(Java::ListFileInput.new([[sample.to_java]]), task)
sample_text = ''
while decoder.nextFile
first = true
while line = decoder.poll
if first
first = false
else
sample_text << task.getNewline().getString()
end
sample_text << line
end
end
return guess_text(config, sample_text);
end
|
#guess_text(config, sample_text) ⇒ Object
75
76
77
|
# File 'lib/embulk/guess_plugin.rb', line 75
def guess_text(config, sample_text)
raise NotImplementedError, "TextGuessPlugin#guess_text(config, sample_text) must be implemented"
end
|