wixgem 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c6c4bf74500b9f10eec0c52a9a283d029d70ded
4
- data.tar.gz: 2b625201bff5d279c7a96c43df6e21ce5b75fafd
3
+ metadata.gz: dcab5b805971c3bd561d29a61cdb4e65df483482
4
+ data.tar.gz: cc14dbc41912184286544ce90319ada1ab3829cb
5
5
  SHA512:
6
- metadata.gz: 60dcb625ecc13322753115c515c8558d5dc4da2d26111046e95012db57d94d8ba67cc791a1e6f7f3f94aee5310515fb3fe5e34946014f1b8ef1e50dda34c42ba
7
- data.tar.gz: 5cc1bf1ea120eb9aeb47cd7d61335d1e45a230346f0fd20d00f15826c9c544243fd21039035741b0eba78a3f0d03bb0151fdba876ecf9d840dd0f08ceaab5898
6
+ metadata.gz: 16c8423f29f4b45b5f4ba5007a2c8f2d5e7084eca375cd3928774085b540cfb29bfa5f174c36f1467c2e1b7008c6031b7793f5231e41fc0ddc3887b4c17cc22e
7
+ data.tar.gz: a402219a160d556a391be7912be1b4f6da0a8d45254a37444238eefaa034361f5b2897c8e0aef870e525a11b0524b199ddb215b3b58e390435a62d7bbf0d9f0f
data/lib/wixgem.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'SecureRandom'
3
3
  require 'tmpdir.rb'
4
+ require 'rexml/document'
4
5
 
5
6
  class Wix
6
7
  def self.initialize
@@ -32,65 +33,75 @@ class Wix
32
33
  end
33
34
 
34
35
  private
35
- def self.manage_upgrade(wxs_text, input)
36
+ def self.manage_upgrade(xml_doc, input)
37
+ product = REXML::XPath.match(xml_doc, '//Wix/Product')
38
+ return xml_doc if(product.length == 0)
39
+
40
+ manufacturer = 'Not Set'
41
+ manufacturer = input[:manufacturer] if(input.kind_of?(Hash) && input.has_key?(:manufacturer))
42
+
36
43
  if(input.kind_of?(Hash) &&
37
44
  input.has_key?(:remove_existing_products) &&
38
45
  input[:remove_existing_products])
39
46
 
40
47
  raise 'Hash must have a version key if the hash has a :remove_existing_products key' unless(input.has_key?(:version))
41
48
  raise 'Hash must have an upgrade_code key if the hash has a :remove_existing_products key' unless(input.has_key?(:upgrade_code))
42
-
43
- upgrade = "
44
- <Upgrade Id=\"#{input[:upgrade_code]}\">
45
- <UpgradeVersion Minimum=\"#{input[:version]}\"
46
- OnlyDetect='yes'
47
- Property='NEWPRODUCTFOUND' />
48
- <UpgradeVersion Minimum='1.0.0'
49
- IncludeMinimum='yes'
50
- Maximum=\"#{input[:version]}\"
51
- IncludeMaximum='no'
52
- Property='UPGRADEFOUND' />
53
- </Upgrade>
54
- <CustomAction"
55
- wxs_text = wxs_text.gsub(/<CustomAction/, upgrade)
56
-
57
- remove_existing_products = " <RemoveExistingProducts After='InstallValidate' />
58
- </InstallExecuteSequence>"
59
- wxs_text = wxs_text.gsub(/<\/InstallExecuteSequence>/, remove_existing_products)
49
+
50
+
51
+ upgrade = product[0].add_element 'Upgrade', { 'Id' => input[:upgrade_code] }
52
+ upgrade.add_element 'UpgradeVersion', { 'Minimum' => input[:version], 'OnlyDetect'=>'yes', 'Property'=>'NEWPRODUCTFOUND' }
53
+ upgrade.add_element 'UpgradeVersion', { 'Minimum' => '1.0.0', 'IncludeMinimum'=>'yes','Maximum'=>input[:version],'IncludeMaximum'=>'no','Property'=>'UPGRADEFOUND' }
54
+
55
+ install_and_execute = REXML::XPath.match(xml_doc, '//Wix/Product/InstallExecuteSequence')
56
+ install_and_execute[0].add_element 'RemoveExistingProducts', { 'After'=>'InstallValidate' }
60
57
  end
61
58
 
62
- return wxs_text
59
+ return xml_doc
63
60
  end
64
-
65
- def self.manage_msm_files(wxs_text)
66
- indent_merge = ' '
67
- indent_directory = ' '
61
+
62
+ def self.manage_custom_actions(xml_doc, input)
63
+ manufacturer = 'Not Set'
64
+ manufacturer = input[:manufacturer] if(input.kind_of?(Hash) && input.has_key?(:manufacturer))
68
65
 
69
- merge_ids = ''
70
- merge_refs = ''
71
- remove_components = []
66
+ install_path = '[ProgramFilesFolder][ProductName]'
67
+ install_path = "[ProgramFilesFolder][Manufacturer]\\[ProductName]" unless(manufacturer == 'Not Set')
68
+
69
+ product = REXML::XPath.match(xml_doc, '//Wix/Product')
70
+ return xml_doc if(product.length == 0)
72
71
 
73
- component = 0
74
- id = 1
75
- file = 2
76
- wxs_text.scan(/(?<component><Component Id=\"(?<id>[^\"]+)\".+Source=\"(?<file>.+\.msm)\".+Component>)/m) { |match|
77
- merge_id = match[id].gsub('cmp','merge')
78
- merge_ids = "#{merge_ids}#{indent_merge}<Merge Id='#{merge_id}' Language='1033' SourceFile='#{match[file]}' DiskId='1' />\n"
79
- merge_refs = "#{indent_merge}#{merge_refs}<MergeRef Id='#{merge_id}' />\n#{indent_merge}"
80
-
81
- remove_components.insert(remove_components.length, match[component])
72
+ product[0].add_element 'CustomAction', { 'Id' => 'SetTARGETDIR', 'Directory' => 'TARGETDIR', 'Value' => "#{install_path}", 'Return' => 'check'}
73
+
74
+ install_execute_sequence = product[0].add_element 'InstallExecuteSequence'
75
+ custom_action = install_execute_sequence.add_element 'Custom', { 'Action' => 'SetTARGETDIR', 'After'=>'InstallValidate' }
76
+
77
+ return xml_doc
78
+ end
79
+
80
+ def self.manage_msm_files(xml_doc)
81
+ merge_modules = {}
82
+ component_group = REXML::XPath.match(xml_doc, '//Wix/Fragment/ComponentGroup')
83
+ component_group.each { |component_group|
84
+ component_group.each_element('Component') { |component|
85
+ component.each_element('File') { |file|
86
+ merge_modules[component] = file if(File.extname(file.attributes['Source']) == '.msm')
87
+ }
88
+ }
82
89
  }
83
90
 
84
- remove_components.each { |cmp| wxs_text = wxs_text.gsub(cmp, '') }
85
-
86
- directory_element = "<Directory Id='TARGETDIR' Name='SourceDir'>\n#{merge_ids}#{indent_directory}</Directory>"
87
- wxs_text = wxs_text.gsub('<Directory Id="TARGETDIR" Name="SourceDir" />', directory_element)
88
-
89
- wxs_text = wxs_text.gsub(/\s+<\/Feature>/, "\n#{merge_refs} </Feature>")
91
+ directory_root = REXML::XPath.match(xml_doc, '//Wix/Product/Directory')
92
+ default_feature = REXML::XPath.match(xml_doc, '//Wix/Product/Feature')
90
93
 
91
- return wxs_text
94
+ merge_modules.each { |component,file|
95
+ id = component.attributes['Id'].gsub('cmp','merge')
96
+ directory_root[0].add_element 'Merge', { 'Id' => id, 'SourceFile' => file.attributes['Source'], 'Language' => '1033', 'DiskId' => '1'}
97
+ default_feature[0].add_element 'MergeRef', { 'Id' => id }
98
+
99
+ component_group[0].delete_element(component)
100
+ }
101
+
102
+ return xml_doc
92
103
  end
93
-
104
+
94
105
  def self.copy_install_files(directory, input)
95
106
  files = input
96
107
  files = input[:files] if(input.kind_of?(Hash))
@@ -110,7 +121,7 @@ class Wix
110
121
  end
111
122
 
112
123
  def self.create_wxs_file(wxs_file, input, ext)
113
- @debug = input[:debug] if(!@debug && input.kind_of?(Hash) && input.has_key?(:debug))
124
+ @debug = input[:debug] if(!@debug && input.kind_of?(Hash) && input.has_key?(:debug))
114
125
 
115
126
  template_option = "-template product"
116
127
  template_option = "-template module" unless(ext == ".msi")
@@ -144,29 +155,18 @@ class Wix
144
155
  wxs_text = wxs_text.gsub(/Version=\"1.0.0.0\"/) { |s| s = "Version=\"#{product_version}\"" } unless(product_version.empty?)
145
156
  wxs_text = wxs_text.gsub(/Product Id=\"[^\"]+\"/) { |s| s = "Product Id=\"#{product_code}\"" } unless(product_code.empty?)
146
157
  wxs_text = wxs_text.gsub(/UpgradeCode=\"[^\"]+\"/) { |s| s = "UpgradeCode=\"#{upgrade_code}\"" } unless(upgrade_code.empty?)
147
-
148
- install_path = '[ProgramFilesFolder][ProductName]'
149
- install_path = "[ProgramFilesFolder][Manufacturer]\\[ProductName]" unless(manufacturer == 'Not Set')
150
158
 
151
- custom_action = "
152
- <CustomAction Id='SetTARGETDIR' Property='TARGETDIR' Value='#{install_path}' Execute='firstSequence' />
153
-
154
- <InstallUISequence>
155
- <!-- Set TARGETDIR if it wasn't set on the command line -->
156
- <Custom Action='SetTARGETDIR' Before='CostFinalize'>TARGETDIR=\"\"</Custom>
157
- </InstallUISequence>
158
-
159
- <InstallExecuteSequence>
160
- <!-- Set TARGETDIR if it wasn't set on the command line -->
161
- <Custom Action='SetTARGETDIR' Before='CostFinalize'>TARGETDIR=\"\"</Custom>
162
- </InstallExecuteSequence>
163
- </Product>"
164
- wxs_text = wxs_text.gsub(/<\/Product>/) { |s| s = custom_action }
165
-
166
- wxs_text = manage_upgrade(wxs_text,input)
167
- wxs_text = manage_msm_files(wxs_text)
168
-
169
- File.open(wxs_file, 'w') { |f| f.puts(wxs_text) }
159
+ xml_doc = REXML::Document.new(wxs_text)
160
+ xml_doc = manage_custom_actions(xml_doc, input)
161
+ xml_doc = manage_upgrade(xml_doc,input)
162
+ xml_doc = manage_msm_files(xml_doc)
163
+
164
+ File.open(wxs_file, 'w') { |f| f.puts(xml_doc.to_s) }
165
+ #formatter = REXML::Formatters::Pretty.new(2)
166
+ #formatter.compact = true # This is the magic line that does what you need!
167
+ #wxs_text = ''
168
+ #formatter.write(xml, wxs_text)
169
+ #File.open(wxs_file, 'w') { |f| f.puts(wxs_text) }
170
170
  end
171
171
 
172
172
  def self.create_output(wxs_file, output)
data/spec/execute.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'dev_tasks'
2
+
3
+ def execute(cmd)
4
+ command = Command.new(cmd)
5
+ command.execute
6
+
7
+ raise "Failed: #{cmd} Status: #{command[:exit_code]}\nStdout: #{command[:output]}\nStderr: #{command[:error]}" unless(command[:exit_code] == 0)
8
+ end
@@ -0,0 +1,51 @@
1
+ require 'rspec'
2
+ require './lib/wixgem.rb'
3
+ require './spec/wixpath.rb'
4
+ require './spec/test_install.rb'
5
+ require './spec/test_files_exist.rb'
6
+ require 'json'
7
+
8
+ describe 'Wixgem' do
9
+ #Wix.debug = true
10
+ describe 'Installation' do
11
+ test_arguments = {
12
+ test1: ['test/wixgem_install_test1.msi', ['rakefile.rb']],
13
+ test2: ['test/wixgem_install_test2.msi', {manufacturer: 'musco', files: ['Gemfile']}],
14
+ test3: ['test/wixgem_install_test3.msi', ['rakefile.rb', 'Gemfile']],
15
+ test4: ['test/wixgem_install_test4.msi', {version: '1.1.2.3', files: ['Gemfile']}],
16
+ test5: ['test/wixgem_install_test5.msi', {product_code: '{4528ae5a-c7fa-40a6-a70e-ac8135f1114c}', files: ['Gemfile']}],
17
+ test6: ['test/wixgem_install_test6.msi', {upgrade_code: '{1d5df00a-c18d-4897-95e6-8c936dd19647}', files: ['Gemfile']}],
18
+ test7: ['test/wixgem_install_test7.msi', {product_name: 'test_productname', files: ['Gemfile']}],
19
+ test8: ['test/wixgem_install_test8.msi', {modify_file_paths: {/\Atest_files\// => ''}, files: Dir.glob("test_files/**/*")}]
20
+ }
21
+
22
+ test_arguments.each { |key, value|
23
+ it "should create an installation file using: #{value[0]}" do
24
+ Wix.make_installation(value[0], value[1])
25
+ expect(File.exists?(value[0])).to be(true)
26
+ end
27
+
28
+ it "should install and uninstall: #{value[0]}" do
29
+ execute = "test_files_exist('#{value[0]}', #{value[1]})"
30
+ execute = value[2] if(value.length == 3)
31
+ test_install(key, value[0], value[1], execute)
32
+ end
33
+ }
34
+
35
+ test_arguments.each { |key, value| FileUtils.rm(value[0]) if(File.exists?(value[0])) }
36
+ end
37
+
38
+ describe 'Packaging excptions' do
39
+ exception_test_arguments = {
40
+ test1: ['test/wixgem_install_test1.msi', nil],
41
+ test1: ['test/wixgem_install_test1.msi', []],
42
+ test2: ['test/wixgem_install_test1.msi', ['does_not_exist.txt']]
43
+ }
44
+
45
+ exception_test_arguments.each { |key, value|
46
+ it "should raise an exception" do
47
+ expect { Wix.make_installation(value[0], value[1]) }.to raise_error
48
+ end
49
+ }
50
+ end
51
+ end
@@ -0,0 +1,67 @@
1
+ require 'rspec'
2
+ require './lib/wixgem.rb'
3
+ require './spec/wixpath.rb'
4
+ require './spec/test_install.rb'
5
+ require './spec/execute.rb'
6
+ require './admin.rb'
7
+
8
+ Wix.debug=true
9
+
10
+ describe 'Wixgem' do
11
+ describe 'Merge Module' do
12
+ test_arguments = {
13
+ #test1: ['test/wixgem_merge_test1.msm', ['rakefile.rb']],
14
+ #test2: ['test/wixgem_merge_test2.msm', {files: ['Gemfile']}],
15
+ #test3: ['test/wixgem_merge_test3.msm', ['rakefile.rb', 'Gemfile']],
16
+ #test4: ['test/wixgem_merge_test4.msm', Dir.glob("test_files/**/*")]
17
+ }
18
+
19
+ test_arguments.each { |key, value|
20
+ it "should create merge module: #{value[0]}" do
21
+ Wix.make_mergemodule(value[0], value[1])
22
+ raise "#{key}: #{value[0]} does not exist" unless(File.exists?(value[0]))
23
+ end
24
+
25
+ install_file = value[0].gsub(/msm/) { |s| s = 'msi' }
26
+ it "should be able to create an installation file using: #{value[0]}" do
27
+ Wix.make_installation(install_file, ["#{value[0]}"])
28
+
29
+ expect(File.exists?(install_file)).to be(true)
30
+ end
31
+
32
+ it "should install and uninstall: #{install_file}" do
33
+ test_install(key, install_file, value[1])
34
+ end
35
+ }
36
+ end
37
+ if(admin?)
38
+ describe 'Multiple merge Module' do
39
+ msi_file='test\\wixgem_multiple_merge_test1.msi'
40
+ merge1='test\\wixgem_multiple_merge_test1.msm'
41
+ merge2='test\\wixgem_multiple_merge_test2.msm'
42
+ it "should be able to create two merge modules" do
43
+ Wix.make_mergemodule(merge1, ['rakefile.rb'])
44
+ expect(File.exists?(merge1)).to be(true)
45
+ Wix.make_mergemodule(merge2, ['Gemfile'])
46
+ expect(File.exists?(merge2)).to be(true)
47
+ end
48
+
49
+ it "should be able to create an installation file using: #{msi_file}" do
50
+ Wix.make_installation(msi_file, [merge1, merge2])
51
+ expect(File.exists?(msi_file)).to be(true)
52
+ end
53
+
54
+ it "should install contents of merge module" do
55
+ begin
56
+ execute("msiexec.exe /i #{msi_file}")
57
+
58
+ install_dir = "C:/Program Files (x86)/#{File.basename(msi_file, '.msi')}"
59
+ expect(File.exists?("#{install_dir}/rakefile.rb")).to be(true)
60
+ expect(File.exists?("#{install_dir}/Gemfile")).to be(true)
61
+ ensure
62
+ execute("msiexec.exe /quiet /x #{msi_file}")
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,71 @@
1
+ require 'rspec'
2
+ require './lib/wixgem.rb'
3
+ require './spec/wixpath.rb'
4
+ require './admin.rb'
5
+ require './spec/test_install.rb'
6
+ require './spec/test_files_exist.rb'
7
+ require 'json'
8
+
9
+ if(admin?)
10
+ describe 'Wixgem' do
11
+ describe 'Side by side installations' do
12
+ product1='wixgem_multiple 1.0'
13
+ product2='wixgem_multiple 1.1'
14
+ begin
15
+ Wix.make_installation("test/wixgem_multiple.1.0.0.msi", {version: '1.0.0.0', product_name: product1, upgrade_code: '{face46ab-74ce-44eb-a2b7-81a8cfad5bab}', files: ['Gemfile']})
16
+ Wix.make_installation("test/wixgem_multiple.1.1.0.msi", {version: '1.1.0.0', product_name: product2, upgrade_code: '{face46ab-74ce-44eb-a2b7-81a8cfad5bab}', files: ['rakefile.rb']})
17
+
18
+ it "should install version 1.0.0" do
19
+ execute("msiexec.exe /i test\\wixgem_multiple.1.0.0.msi")
20
+ expect(WindowsInstaller.installed?(product1)).to be(true)
21
+ expect(WindowsInstaller.version?(product1)).to eq('1.0.0.0')
22
+ end
23
+
24
+ it "should install version 1.1.0" do
25
+ execute("msiexec.exe /i test\\wixgem_multiple.1.1.0.msi")
26
+ expect(WindowsInstaller.installed?(product2)).to be(true)
27
+ expect(WindowsInstaller.version?(product2)).to eq('1.1.0.0')
28
+ end
29
+
30
+ it "version 1.0.0 should still be installed" do
31
+ expect(WindowsInstaller.installed?(product1)).to be(true)
32
+ end
33
+
34
+ it "product codes for version 1.0.0 and 1.0.0 should be different" do
35
+ expect(WindowsInstaller.product_code?(product1)).not_to eq(WindowsInstaller.product_code?(product2))
36
+ end
37
+ ensure
38
+ execute("msiexec.exe /quiet /x #{WindowsInstaller.product_code?(product1)}") while(WindowsInstaller.installed?(product1))
39
+ raise "Failed to uninstall product #{product1}" if(WindowsInstaller.installed?(product1))
40
+ execute("msiexec.exe /quiet /x #{WindowsInstaller.product_code?(product2)}") while(WindowsInstaller.installed?(product2))
41
+ raise "Failed to uninstall product #{product2}" if(WindowsInstaller.installed?(product2))
42
+ end
43
+ end
44
+
45
+ describe 'remove previous version' do
46
+ product1='wixgem_install 1.0'
47
+ product2='wixgem_install 1.1'
48
+ begin
49
+ Wix.make_installation("test/wixgem_install.1.0.0.msi", {version: '1.0.0.0', product_name: product1, upgrade_code: '{face46ab-74ce-44eb-a2b7-81a8cfad5bab}', files: ['Gemfile']})
50
+ Wix.make_installation("test/wixgem_install.1.1.0.msi", {version: '1.1.0.0', product_name: product2, remove_existing_products: true, upgrade_code: '{face46ab-74ce-44eb-a2b7-81a8cfad5bab}', files: ['rakefile.rb']})
51
+
52
+ it "should install version 1.0.0" do
53
+ execute("msiexec.exe /i test\\wixgem_install.1.0.0.msi")
54
+ expect(WindowsInstaller.installed?(product1)).to be(true)
55
+ end
56
+
57
+ it "should install version 1.1.0" do
58
+ execute("msiexec.exe /i test\\wixgem_install.1.1.0.msi")
59
+ expect(WindowsInstaller.installed?(product2)).to be(true)
60
+ end
61
+
62
+ it "the version 1.0.0 should have been uninstalled" do
63
+ expect(WindowsInstaller.installed?(product1)).to be(false)
64
+ end
65
+ ensure
66
+ execute("msiexec.exe /quiet /x #{WindowsInstaller.product_code?(product2)}") while(WindowsInstaller.installed?(product2))
67
+ raise "Failed to uninstall product #{product2}" if(WindowsInstaller.installed?(product2))
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,35 @@
1
+ def files(data)
2
+ files = data
3
+ if(data.kind_of?(Hash))
4
+ files = data[:files]
5
+
6
+ if(data.has_key?(:modify_file_paths))
7
+ modify_paths = data[:modify_file_paths]
8
+ files.each_index do |index|
9
+ file_path = files[index]
10
+ modify_paths.each { |regex, replacement_string| file_path = file_path.gsub(regex, replacement_string) }
11
+ files[index] = file_path
12
+ end
13
+ end
14
+ end
15
+ return files
16
+ end
17
+
18
+ def test_files_exist(msi_file, data)
19
+ files = files(data)
20
+
21
+ product_name = File.basename(msi_file, File.extname(msi_file))
22
+ product_name = data[:product_name] if(data.kind_of?(Hash) && data.has_key?(:product_name))
23
+
24
+ manufacturer = ''
25
+ manufacturer = data[:manufacturer] if(data.kind_of?(Hash) && data.has_key?(:manufacturer))
26
+
27
+ relative_install_dir = product_name
28
+ raise "#{name}: relative_install_dir should be set to the product name" if(relative_install_dir.length == 0)
29
+ relative_install_dir = "#{manufacturer}/#{relative_install_dir}" if(manufacturer.length > 0)
30
+
31
+ files.each { |file|
32
+ full_path = "C:/Program Files (x86)/#{relative_install_dir}/#{file}"
33
+ raise "#{full_path} not installed." unless(File.exists?(full_path))
34
+ }
35
+ end
@@ -0,0 +1,68 @@
1
+ require './WindowsInstaller.rb'
2
+ require './admin.rb'
3
+ require './spec/execute.rb'
4
+
5
+ def get_product_name(msi_file, arg2)
6
+ product_name = File.basename(msi_file, File.extname(msi_file))
7
+ product_name = arg2[:product_name] if(arg2.kind_of?(Hash) && arg2.has_key?(:product_name))
8
+
9
+ return product_name
10
+ end
11
+
12
+ def test_msi(msi_file, arg2)
13
+ product_name = get_product_name(msi_file, arg2)
14
+
15
+ msi_info = WindowsInstaller.msi_records(msi_file)
16
+ #puts msi_info.to_s
17
+
18
+ if(arg2.kind_of?(Hash) && arg2.has_key?(:product_name))
19
+ raise "ProductName is #{msi_info['ProductName']} expected #{product_name}" unless(product_name == msi_info['ProductName'])
20
+ end
21
+
22
+ if(arg2.kind_of?(Hash) && arg2.has_key?(:product_code))
23
+ expected = arg2[:product_code].upcase
24
+ raise "ProductCode is #{msi_info['ProductCode']} expected #{expected}" unless(expected == msi_info['ProductCode'])
25
+ end
26
+
27
+ if(arg2.kind_of?(Hash) && arg2.has_key?(:upgrade_code))
28
+ expected = arg2[:upgrade_code].upcase
29
+ raise "UpgradeCode is #{msi_info['UpgradeCode']} expected #{expected}" unless(expected == msi_info['UpgradeCode'])
30
+ end
31
+
32
+ expected_product_version = '1.0.0.0'
33
+ expected_product_version = arg2[:version] if(arg2.kind_of?(Hash) && arg2.has_key?(:version))
34
+ raise "Invalid product version #{msi_info['ProductVersion']}" if(msi_info['ProductVersion'] != expected_product_version)
35
+
36
+ expected_manufacturer = 'Not Set'
37
+ expected_manufacturer = arg2[:manufacturer] if(arg2.kind_of?(Hash) && arg2.has_key?(:manufacturer))
38
+ raise "Invalid Manufacturer #{msi_info['Manufacturer']}" if(msi_info['Manufacturer'] != expected_manufacturer)
39
+ end
40
+
41
+ def test_install(name, msi_file, arg2, callback=nil)
42
+ msi_file = msi_file.gsub(/\//) { |s| s = '\\' }
43
+
44
+ test_msi(msi_file, arg2)
45
+
46
+ msi_info = WindowsInstaller.msi_records(msi_file)
47
+
48
+ product_name = msi_info['ProductName']
49
+
50
+ if(admin?)
51
+ while(WindowsInstaller.installed?(product_name))
52
+ execute("msiexec.exe /quiet /x #{WindowsInstaller.product_code?(product_name)}")
53
+ end
54
+ raise "#{name}: Uninstall #{product_name} before running tests" if(WindowsInstaller.installed?(product_name))
55
+
56
+ begin
57
+ execute("msiexec.exe /i #{msi_file}")
58
+ #WindowsInstaller.dump_info(product_name)
59
+
60
+ raise "#{name}: Product name #{product_name} is not installed" unless(WindowsInstaller.installed?(product_name))
61
+
62
+ eval callback unless(callback == nil)
63
+ ensure
64
+ execute("msiexec.exe /quiet /x #{msi_file}") if(WindowsInstaller.installed?(product_name))
65
+ raise "Failed to uninstall product #{product_name}" if(WindowsInstaller.installed?(product_name))
66
+ end
67
+ end
68
+ end
data/spec/wixpath.rb ADDED
@@ -0,0 +1,3 @@
1
+ WIX_PATH='C:/Development/dep/OpenSource/WixToolset/3.8'
2
+
3
+ Wix.install_path = WIX_PATH
@@ -0,0 +1 @@
1
+ Number File
@@ -0,0 +1 @@
1
+ Test File
@@ -0,0 +1 @@
1
+ Hello World
@@ -0,0 +1 @@
1
+ Test file
@@ -0,0 +1 @@
1
+ Test it
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wixgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,9 +66,8 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: 'Simple Ruby interface to facilitate creating and compiling windows installation
70
- files with the Wix Toolset.\n\nNote: This gem currently does not handle registration
71
- of COM objects or registry entries.'
69
+ description: Simple Ruby interface to facilitate creating and compiling windows installation
70
+ files with the Wix Toolset.
72
71
  email: KCCKSMarshall@gmail.com
73
72
  executables: []
74
73
  extensions: []
@@ -77,6 +76,18 @@ files:
77
76
  - LICENSE
78
77
  - README.md
79
78
  - lib/wixgem.rb
79
+ - spec/execute.rb
80
+ - spec/installation_spec.rb
81
+ - spec/mergemodule_spec.rb
82
+ - spec/multiple_product_installation_spec.rb
83
+ - spec/test_files_exist.rb
84
+ - spec/test_install.rb
85
+ - spec/wixpath.rb
86
+ - test_files/32145.txt
87
+ - test_files/8.0/File With Space.txt
88
+ - test_files/9.0/File With Space.txt
89
+ - test_files/9.0/test_files/a_file.txt
90
+ - test_files/File-With-Hyphen.txt
80
91
  homepage: http://rubygems.org/gems/wixgem
81
92
  licenses:
82
93
  - Apache 2.0