-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebase of #397 Merge branch 'images' of https://github.com/esergion/roo into esergion-images
- Loading branch information
Showing
6 changed files
with
68 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'roo/excelx/extractor' | ||
|
||
module Roo | ||
class Excelx | ||
class Images < Excelx::Extractor | ||
|
||
# Returns: Hash { id1: extracted_file_name1 }, | ||
# Example: { "rId1"=>"roo_media_image1.png", | ||
# "rId2"=>"roo_media_image2.png", | ||
# "rId3"=>"roo_media_image3.png" } | ||
def list | ||
@images ||= extract_images_names | ||
end | ||
|
||
private | ||
|
||
def extract_images_names | ||
return {} unless doc_exists? | ||
|
||
Hash[doc.xpath('/Relationships/Relationship').map do |rel| | ||
[rel['Id'], "roo" + rel['Target'].gsub(/\.\.\/|\//, '_')] | ||
end] | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.