Class: RubyTikaApp
- Inherits:
-
Object
show all
- Defined in:
- lib/ruby_tika_app.rb
Defined Under Namespace
Classes: CommandFailedError, Error
Constant Summary
collapse
- TIKA_APP_VERSION =
'1.23'
Instance Method Summary
collapse
Constructor Details
#initialize(document) ⇒ RubyTikaApp
Returns a new instance of RubyTikaApp.
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/ruby_tika_app.rb', line 21
def initialize(document)
@document = if (document =~ %r{https?:\/\/[\S]+}) == 0
document
else
"file://#{document}"
end
java_cmd = 'java'
java_args = '-server -Djava.awt.headless=true -Dfile.encoding=UTF-8'
ext_dir = File.join(File.dirname(__FILE__))
tika_path = "#{ext_dir}/../ext/tika-app-#{TIKA_APP_VERSION}.jar"
tika_config_path = "#{ext_dir}/../ext/tika-config.xml"
@tika_cmd = "#{java_cmd} #{java_args} -jar '#{tika_path}' --config='#{tika_config_path}'"
end
|
Instance Method Details
#to_html ⇒ Object
41
42
43
|
# File 'lib/ruby_tika_app.rb', line 41
def to_html
run_tika('--html')
end
|
#to_json(*_args) ⇒ Object
45
46
47
|
# File 'lib/ruby_tika_app.rb', line 45
def to_json(*_args)
run_tika('--json')
end
|
57
58
59
|
# File 'lib/ruby_tika_app.rb', line 57
def to_metadata
run_tika('--metadata')
end
|
#to_text ⇒ Object
49
50
51
|
# File 'lib/ruby_tika_app.rb', line 49
def to_text
run_tika('--text')
end
|
#to_text_main ⇒ Object
53
54
55
|
# File 'lib/ruby_tika_app.rb', line 53
def to_text_main
run_tika('--text-main')
end
|
#to_xml ⇒ Object
37
38
39
|
# File 'lib/ruby_tika_app.rb', line 37
def to_xml
run_tika('--xml')
end
|