Class: Service

Inherits:
Object
  • Object
show all
Defined in:
lib/service.rb

Overview

module Wixgem

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Service

Returns a new instance of Service.



7
8
9
# File 'lib/service.rb', line 7

def initialize(hash)
 @hash = hash
end

Instance Method Details

#create(xml_doc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/service.rb', line 11

def create(xml_doc)
  raise "Service hash is required to have a :service_exe key" unless(@hash.has_key?(:service_exe))
  raise "Service hash is required to have a :service key" unless(@hash.has_key?(:service))
  raise "Service hash is required to have a :name key" unless(@hash[:service].has_key?(:name))

  service_exe = @hash[:service_exe]
  raise "Service #{file} does not exist" unless(File.exist?(service_exe))
  
  file_elements = REXML::XPath.match(xml_doc, "//File[@Source='.\\#{service_exe.gsub(/\//,'\\')}']")
  raise "Service #{@file} does not match a 'File' element with a 'Source' attribute in the wix generated wix file" if(file_elements.length == 0)
    
  service_exe_element = file_elements[0]
  service_exe_element.attributes['KeyPath']='yes'

 create_service_element(xml_doc, service_exe_element)
	
 return xml_doc
end