lib/rubyXL/objects/relationships.rb in rubyXL-2.3.4 vs lib/rubyXL/objects/relationships.rb in rubyXL-2.4.0

- old
+ new

@@ -33,10 +33,14 @@ protected :metadata_relationship def find_by_rid(r_id) relationships.find { |r| r.id == r_id } end + + def find_by_target(target) + relationships.find { |r| r.target == target } + end end class WorkbookRelationships < OOXMLRelationshipsFile @@ -44,11 +48,11 @@ def before_write_xml self.relationships = [] @workbook.worksheets.each_with_index { |sheet, i| - relationships << document_relationship(sheet.filepath.gsub(/^xl\//, ''), sheet.rel_type) + relationships << document_relationship(sheet.xlsx_path.gsub(/^xl\//, ''), sheet.rel_type) } @workbook.external_links.each_key { |k| relationships << document_relationship("externalLinks/#{k}", 'externalLink') } @@ -65,11 +69,11 @@ end true end - def self.filepath + def self.xlsx_path File.join('xl', '_rels', 'workbook.xml.rels') end end @@ -78,17 +82,17 @@ attr_accessor :workbook def before_write_xml self.relationships = [] - relationships << document_relationship('xl/workbook.xml', 'officeDocument') + relationships << document_relationship('xl/workbook.xml', 'officeDocument') relationships << metadata_relationship('docProps/core.xml', 'core-properties') - relationships << document_relationship('docProps/app.xml', 'extended-properties') + relationships << document_relationship('docProps/app.xml', 'extended-properties') true end - def self.filepath + def self.xlsx_path File.join('_rels', '.rels') end end end