lib/yomu.rb in yomu-0.1.6 vs lib/yomu.rb in yomu-0.1.7
- old
+ new
@@ -32,13 +32,13 @@
case type
when :text
result
when :metadata
- YAML.load enclose_metadata_fields(result)
+ YAML.load quote(result)
when :mimetype
- MIME::Types[YAML.load(enclose_metadata_fields(result))['Content-Type']].first
+ MIME::Types[YAML.load(quote(result))['Content-Type']].first
end
end
# Create a new instance of Yomu with a given document.
#
@@ -149,14 +149,13 @@
end
@data
end
- def self.enclose_metadata_fields metadata
- metadata.each_line.map do |l|
- l.gsub(/: (.*)/,': "\1"')
- end.join
+ def self.quote(metadata)
+ metadata.gsub(/: (.*: .*)$/, ': "\1"')
end
+ private_class_method :quote
def self.java
ENV['JAVA_HOME'] ? ENV['JAVA_HOME'] + '/bin/java' : 'java'
end
private_class_method :java