WindowsInstaller 0.1.0 → 0.1.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +22 -0
  3. data/lib/WindowsInstaller.rb +84 -0
  4. metadata +19 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 850e6284187016e11494693c3258cfca4f948ccd
4
- data.tar.gz: 9727aff1f230bb8a3d50f57c9de67b199b9349a7
3
+ metadata.gz: f2bc6bbcfa69faf7a096fe80764b134b4ba4481e
4
+ data.tar.gz: 1000464788c54f0614b563de9d0666c00c82840a
5
5
  SHA512:
6
- metadata.gz: 4a6afbe95b28449f0efce14a74edcac7c11e1ad4fae9396e1b6a778bddcf788b7a6f22d3fccbf8ebbcbc52dadc152f519e7341d5b976944a10566323e05dc7b7
7
- data.tar.gz: d1ce0a4eecd79184d9ac3485af5f93bd15bed283953357427c68087070ed36a7681ba98911903b27a18b42300bccd01b7959771197f170a38970be5231b10bc2
6
+ metadata.gz: e1985d44fcdcc3415975a274f858bf318c5c2eccecf4974fd6359313709ab7c1494ee1aceaa67d3e3b2a3f58ac219008607493e0306582b589b471b612760f44
7
+ data.tar.gz: 6aa57bf46f704d7b397aca22791bc669379d63d5d55840caf57ff82147779cde4d5c543fbf587ceff2d0553c62f417ed209a0b3fd3e8720a4322634ceb6558b0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kevin-marshall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,84 @@
1
+ require 'win32ole'
2
+ require 'cmd'
3
+
4
+ class WindowsInstaller < Hash
5
+ def initialize(options = {})
6
+ options.each { |key, value| self[key] = value}
7
+ end
8
+
9
+ def msi_installed?(msi_file)
10
+ info = msi_properties(msi_file)
11
+ return product_code_installed?(info['ProductCode'])
12
+ end
13
+
14
+ def product_code_installed?(product_code)
15
+ installer = WIN32OLE.new('WindowsInstaller.Installer')
16
+ installer.Products.each { |installed_product_code| return true if (product_code == installed_product_code) }
17
+ return false
18
+ end
19
+
20
+ def install_msi(msi_file)
21
+ raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
22
+
23
+ msi_file = msi_file.gsub(/\//, '\\')
24
+
25
+ cmd = "msiexec.exe"
26
+ cmd = "#{cmd} /quiet" if(has_key?(:mode) && (self[:mode] == :quiet))
27
+ cmd = "#{cmd} /passive" if(has_key?(:mode) && (self[:mode] == :passive))
28
+ cmd = "#{cmd} /i \"#{msi_file}\""
29
+
30
+ cmd_options = {quiet: true}
31
+ cmd_options[:admin_user] = self[:admin_user] if(has_key?(:admin_user))
32
+ command = CMD.new(cmd, cmd_options)
33
+ command.execute
34
+ end
35
+
36
+ def uninstall_msi(msi_file)
37
+ raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
38
+ info = msi_properties(msi_file)
39
+ uninstall_product_code(info['ProductCode'])
40
+ end
41
+
42
+ def uninstall_product_code(product_code)
43
+ raise "#{product_code} is not installed" unless(product_code_installed?(product_code))
44
+
45
+ cmd = "msiexec.exe"
46
+ cmd = "#{cmd} /quiet" if(has_key?(:mode) && (self[:mode] == :quiet))
47
+ cmd = "#{cmd} /passive" if(has_key?(:mode) && (self[:mode] == :passive))
48
+ cmd = "#{cmd} /x #{product_code}"
49
+
50
+ cmd_options = {quiet: true}
51
+ cmd_options[:admin_user] = self[:admin_user] if(has_key?(:admin_user))
52
+ command = CMD.new(cmd, cmd_options)
53
+ command.execute
54
+ end
55
+
56
+ private
57
+ def msi_properties(msi_file)
58
+ raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
59
+
60
+ properties = {}
61
+
62
+ installer = WIN32OLE.new('WindowsInstaller.Installer')
63
+ sql_query = "SELECT * FROM `Property`"
64
+
65
+ db = installer.OpenDatabase(msi_file, 0)
66
+ view = db.OpenView(sql_query)
67
+ view.Execute(nil)
68
+
69
+ record = view.Fetch()
70
+ return nil if(record == nil)
71
+
72
+ while(!record.nil?)
73
+ properties[record.StringData(1)] = record.StringData(2)
74
+ record = view.Fetch()
75
+ end
76
+ db.ole_free
77
+ db = nil
78
+
79
+ installer.ole_free
80
+ installer = nil
81
+
82
+ return properties
83
+ end
84
+ end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: WindowsInstaller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-08-21 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dev
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: execute
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Class wrapper for Microsoft Windows WindowsInstaller object
@@ -85,7 +85,9 @@ email: KCCKSMarshall@gmail.com
85
85
  executables: []
86
86
  extensions: []
87
87
  extra_rdoc_files: []
88
- files: []
88
+ files:
89
+ - LICENSE
90
+ - lib/WindowsInstaller.rb
89
91
  homepage: http://rubygems.org/gems/execute
90
92
  licenses:
91
93
  - Apache 2.0
@@ -96,18 +98,19 @@ require_paths:
96
98
  - lib
97
99
  required_ruby_version: !ruby/object:Gem::Requirement
98
100
  requirements:
99
- - - ">="
101
+ - - '>='
100
102
  - !ruby/object:Gem::Version
101
103
  version: 1.9.1
102
104
  required_rubygems_version: !ruby/object:Gem::Requirement
103
105
  requirements:
104
- - - ">="
106
+ - - '>='
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.4.5
111
+ rubygems_version: 2.2.0
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: Class wrapper for Microsoft Windows WindowsInstaller object
113
115
  test_files: []
116
+ has_rdoc: