lib/yomu.rb in yomu-0.1.9 vs lib/yomu.rb in yomu-0.1.10
- old
+ new
@@ -4,11 +4,11 @@
require 'mime/types'
require 'yaml'
class Yomu
GEMPATH = File.dirname(File.dirname(__FILE__))
- JARPATH = File.join(Yomu::GEMPATH, 'jar', 'tika-app-1.*.jar')
+ JARPATH = File.join(Yomu::GEMPATH, 'jar', 'tika-app-1.5.jar')
# Read text or metadata from a data buffer.
#
# data = File.read 'sample.pages'
# text = Yomu.read :text, data
@@ -16,10 +16,12 @@
def self.read(type, data)
switch = case type
when :text
'-t'
+ when :html
+ '-h'
when :metadata
'-m'
when :mimetype
'-m'
end
@@ -31,10 +33,12 @@
end
case type
when :text
result
+ when :html
+ result
when :metadata
YAML.load quote(result)
when :mimetype
MIME::Types[YAML.load(quote(result))['Content-Type']].first
end
@@ -77,9 +81,20 @@
def text
return @text if defined? @text
@text = Yomu.read :text, data
+ end
+
+ # Returns the text content of the Yomu document in HTML.
+ #
+ # yomu = Yomu.new 'sample.pages'
+ # yomu.html
+
+ def html
+ return @text if defined? @text
+
+ @text = Yomu.read :html, data
end
# Returns the metadata hash of the Yomu document.
#
# yomu = Yomu.new 'sample.pages'