Skip to content

Commit 2e9425e

Browse files
melchapythonicrubyist
authored andcommitted
Fix for temp image path (#39)
* Fix tmp image path * Fix specs for excel without images
1 parent 75078dd commit 2e9425e

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

lib/creek/drawing.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def images_at(cell_name)
3434
return if pathnames_at_coordinate.empty?
3535

3636
pathnames_at_coordinate.map do |image_pathname|
37-
if image_pathname.exist?
38-
image_pathname
39-
else
40-
excel_image_path = "xl/media/#{image_pathname.to_path.split(tmpdir).last}"
41-
IO.copy_stream(@book.files.file.open(excel_image_path), image_pathname.to_path)
42-
image_pathname
37+
if image_pathname.exist?
38+
image_pathname
39+
else
40+
excel_image_path = "xl/media#{image_pathname.to_path.split(tmpdir).last}"
41+
IO.copy_stream(@book.files.file.open(excel_image_path), image_pathname.to_path)
42+
image_pathname
4343
end
4444
end
4545
end
@@ -87,7 +87,7 @@ def load_images_pathnames_by_cells
8787
next if embed.nil?
8888

8989
rid = embed.value
90-
path = Pathname.new("#{tmpdir}#{extract_drawing_path(rid).slice(/[^\/]*$/)}")
90+
path = Pathname.new("#{tmpdir}/#{extract_drawing_path(rid).slice(/[^\/]*$/)}")
9191

9292
row_from = drawing.xpath(row_from_selector).text.to_i
9393
col_from = drawing.xpath(col_from_selector).text.to_i
@@ -106,4 +106,4 @@ def extract_drawing_path(rid)
106106
@drawings_rels.css("Relationship[@Id=#{rid}]").first.attributes['Target'].value
107107
end
108108
end
109-
end
109+
end

spec/sheet_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def load_cell(rows, cell_name)
5656
context 'with excel without images' do
5757
it 'does not break on with_images' do
5858
rows = sheet_no_images.with_images.rows.map { |r| r }
59-
expect(load_cell(rows, 'A10')).to eq(nil)
59+
expect(load_cell(rows, 'A10')).to eq(0.15)
6060
end
6161
end
6262
end

0 commit comments

Comments
 (0)