lib/shortcut.rb in wixgem-0.90.0 vs lib/shortcut.rb in wixgem-0.93.0

- old
+ new

@@ -5,53 +5,53 @@ class Shortcut def initialize(file, hash) @file = file - @hash = hash + @hash = hash end def create(xml_doc) - raise "Shortcut #{@file} does not exist" unless(File.exists?(@file)) + raise "Shortcut #{@file} does not exist" unless(File.exists?(@file)) - file_elements = REXML::XPath.match(xml_doc, "//File[@Source='.\\#{@file.gsub(/\//,'\\')}']") - raise "Shortcut #{@file} does not match an installation file" if(file_elements.length == 0) - create_shortcut_element(file_elements[0]) - create_directory(xml_doc, @hash[:directory]) if(@hash.has_key?(:directory)) + file_elements = REXML::XPath.match(xml_doc, "//File[@Source='.\\#{@file.gsub(/\//,'\\')}']") + raise "Shortcut #{@file} does not match a 'File' element with a 'Source' attribute in the wix generated wix file" if(file_elements.length == 0) + create_shortcut_element(file_elements[0]) + create_directory(xml_doc, @hash[:directory]) if(@hash.has_key?(:directory)) - return xml_doc + return xml_doc end private def create_shortcut_element(file_element) shortcut_element = file_element.add_element 'Shortcut' - shortcut_element.attributes['Id'] = "Shortcut_#{SecureRandom.uuid.gsub(/-/,'')}" - shortcut_element.attributes['Arguments'] = @hash[:arguments] if(@hash.has_key?(:arguments)) + shortcut_element.attributes['Id'] = "Shortcut_#{SecureRandom.uuid.gsub(/-/,'')}" + shortcut_element.attributes['Arguments'] = @hash[:arguments] if(@hash.has_key?(:arguments)) - shortcut_name = File.basename(@file) - if(@hash.has_key?(:name)) - shortcut_name = @hash[:name] - else - @hash[:name] = shortcut_name - end - shortcut_element.attributes['Name'] = shortcut_name + shortcut_name = File.basename(@file) + if(@hash.has_key?(:name)) + shortcut_name = @hash[:name] + else + @hash[:name] = shortcut_name + end + shortcut_element.attributes['Name'] = shortcut_name - shortcut_element.attributes['Description'] = @hash[:description] if(@hash.has_key?(:description)) - shortcut_element.attributes['Directory'] = 'DesktopFolder' + shortcut_element.attributes['Description'] = @hash[:description] if(@hash.has_key?(:description)) + shortcut_element.attributes['Directory'] = 'DesktopFolder' - shortcut_element.attributes['Advertise']="yes" - shortcut_element.attributes['Advertise'] = "no" if(@hash.has_key?(:advertise) && !@hash[:advertise]) - create_icon_element(shortcut_element) if(@hash.has_key?(:icon)) + shortcut_element.attributes['Advertise']="yes" + shortcut_element.attributes['Advertise'] = "no" if(@hash.has_key?(:advertise) && !@hash[:advertise]) + create_icon_element(shortcut_element) if(@hash.has_key?(:icon)) - return shortcut_element + return shortcut_element end def create_icon_element(shortcut_element) icon_element = shortcut_element.add_element 'Icon' - icon_element.attributes['Id'] = File.basename(@hash[:icon]) + icon_element.attributes['Id'] = File.basename(@hash[:icon]) icon_element.attributes['SourceFile'] = ".\\#{@hash[:icon].gsub(/\//, '\\')}" - return icon_element + return icon_element end def create_directory(xml_doc, directory) raise 'Currently only supporting desktop shortcuts' unless(directory == :desktop) if(directory == :desktop)