-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close #247 Test
- Loading branch information
Showing
11 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Heathen | ||
class Processor | ||
def detect_language | ||
executioner.execute( | ||
Colore::C_.tika_path, | ||
"--config=#{Colore::C_.tika_config}", | ||
'--language', | ||
job.content_file, | ||
binary: true | ||
) | ||
raise ConversionFailed.new if executioner.last_exit_status != 0 | ||
|
||
job.content = executioner.stdout | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Heathen::Processor do | ||
let(:content) { fixture('heathen/quickfox.ar.jpg').read } | ||
let(:job) { Heathen::Job.new 'foo', content } | ||
let(:processor) { described_class.new job: job, logger: spec_logger } | ||
|
||
after do | ||
processor.clean_up | ||
end | ||
|
||
describe '#detect_language' do | ||
before do | ||
processor.detect_language | ||
end | ||
|
||
context 'with English documents' do | ||
let(:content) { fixture('heathen/quickfox.jpg').read } | ||
|
||
it 'detects English input file language' do | ||
expect(job.content).to eq 'en' | ||
expect(job.content.mime_type).to eq 'text/plain; charset=us-ascii' | ||
end | ||
end | ||
|
||
context 'with Arabic documents' do | ||
let(:content) { fixture('heathen/quickfox.ar.jpg').read } | ||
|
||
it 'detects Arabic input file language' do | ||
expect(job.content).to eq 'ar' | ||
expect(job.content.mime_type).to eq 'text/plain; charset=us-ascii' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters