Skip to content

Commit 4657a2a

Browse files
committed
compat with jruby
1 parent f203ac2 commit 4657a2a

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

Diff for: Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ gem 'nokogiri'
44
gem 'rubyzip'
55
gem 'htmlentities'
66
gem 'roman-numerals'
7-
gem 'rmagick'
8-
gem 'ruby-prof'
9-
gem 'diff-lcs'
7+
# gem 'rmagick'
8+
# gem 'ruby-prof'
9+
gem 'diff-lcs'

Diff for: bin/docx2html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if $0 == __FILE__
88
end
99

1010
require 'ydocx/command'
11-
require 'ruby-prof'
11+
# require 'ruby-prof'
1212

1313
#RubyProf.start
1414
YDocx::Command.run(:to_html)

Diff for: lib/ydocx/document.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require 'pathname'
55
require 'zip/zip'
6-
require 'RMagick'
6+
# require 'RMagick'
77
require 'ydocx/parser'
88
require 'ydocx/builder'
99

@@ -102,7 +102,7 @@ def read(file)
102102
@zip = Zip::ZipFile.open(@path.realpath)
103103
doc = @zip.find_entry('word/document.xml').get_input_stream
104104
rel = @zip.find_entry('word/_rels/document.xml.rels').get_input_stream
105-
rel_xml = Nokogiri::XML.parse(rel)
105+
rel_xml = Nokogiri::XML.parse(rel.read)
106106
rel_files = []
107107
rel_xml.xpath('/').children.each do |relat|
108108
relat.children.each do |r|

Diff for: lib/ydocx/parser.rb

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require 'htmlentities'
66
require 'ydocx/markup_method'
77
require 'roman-numerals'
8-
require 'RMagick'
8+
# require 'RMagick'
99

1010
module YDocx
1111
Style = Struct.new(:b, :u, :i, :strike, :caps, :smallCaps, :font, :sz, :color, :valign, :ilvl, :numid)
@@ -294,8 +294,8 @@ def to_markup
294294
class Parser
295295
attr_accessor :images, :result, :space
296296
def initialize(doc, rel, rel_files, output_dir)
297-
@doc = Nokogiri::XML.parse(doc)
298-
@rel = Nokogiri::XML.parse(rel)
297+
@doc = Nokogiri::XML.parse(doc.read)
298+
@rel = Nokogiri::XML.parse(rel.read)
299299
@rel_files = rel_files
300300
@style_nodes = {}
301301
@styles = {}
@@ -430,7 +430,7 @@ def compute_style(id)
430430

431431
def parse
432432
if settings_file = @rel_files.select { |file| file[:type] =~ /relationships\/settings$/ }.first
433-
settings_xml = Nokogiri::XML.parse(settings_file[:stream])
433+
settings_xml = Nokogiri::XML.parse(settings_file[:stream].read)
434434
if fpr = settings_xml.at_xpath('//w:settings//w:footnotePr')
435435
if start = fpr.at_xpath('w:numStart')
436436
@cur_footnote = start['w:val'].to_i
@@ -450,7 +450,7 @@ def parse
450450
end
451451

452452
if theme_file = @rel_files.select { |file| file[:type] =~ /relationships\/theme$/ }.first
453-
theme_xml = Nokogiri::XML.parse(theme_file[:stream])
453+
theme_xml = Nokogiri::XML.parse(theme_file[:stream].read)
454454
['major', 'minor'].each do |type|
455455
if font = theme_xml.at_xpath(".//a:#{type}Font//a:latin")
456456
@theme_fonts[type] = font['typeface']
@@ -459,7 +459,7 @@ def parse
459459
end
460460

461461
if style_file = @rel_files.select { |file| file[:type] =~ /relationships\/styles$/ }.first
462-
style_xml = Nokogiri::XML.parse(style_file[:stream])
462+
style_xml = Nokogiri::XML.parse(style_file[:stream].read)
463463
style_xml.xpath('//w:styles//w:style').each do |style|
464464
@style_nodes[style['w:styleId']] = style
465465
end
@@ -474,7 +474,7 @@ def parse
474474
end
475475

476476
if num_file = @rel_files.select { |file| file[:type] =~ /relationships\/numbering$/ }.first
477-
num_xml = Nokogiri::XML.parse(num_file[:stream])
477+
num_xml = Nokogiri::XML.parse(num_file[:stream].read)
478478
abstract_nums = {}
479479
num_xml.xpath('//w:numbering//w:abstractNum').each do |abstr|
480480
abstract_nums[abstr['w:abstractNumId']] = abstr

0 commit comments

Comments
 (0)