windows-pr 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ = 1.1.0 - 5-Nov-2010
2
+ * Added the get_volume_type method to the Windows::Volume module.
3
+ * Added more tests for the Windows::Volume module.
4
+ * Removed the non-gem installation task and added a clean task.
5
+
1
6
  = 1.0.9 - 6-Feb-2010
2
7
  * A couple of modules that were checking against $KCODE now check against
3
8
  __ENCODING__ or the string encoding for Ruby 1.9.x.
data/Rakefile CHANGED
@@ -1,55 +1,8 @@
1
1
  require 'rake'
2
+ require 'rake/clean'
2
3
  require 'rake/testtask'
3
- require 'rbconfig'
4
- include Config
5
4
 
6
- desc "Install the windows-pr library (non-gem)"
7
- task :install do
8
- sitelibdir = CONFIG["sitelibdir"]
9
- installdir = File.join(sitelibdir, 'windows')
10
- installdir_msvcrt = File.join(installdir, 'msvcrt')
11
- installdir_gdi = File.join(installdir, 'gdi')
12
- installdir_com = File.join(installdir, 'com')
13
- installdir_network = File.join(installdir, 'network')
14
- installdir_window = File.join(installdir, 'window')
15
- installdir_ntfs = File.join(installdir, 'ntfs')
16
-
17
- FileUtils.mkdir_p(installdir)
18
- FileUtils.mkdir_p(installdir_msvcrt)
19
- FileUtils.mkdir_p(installdir_gdi)
20
- FileUtils.mkdir_p(installdir_com)
21
- FileUtils.mkdir_p(installdir_network)
22
- FileUtils.mkdir_p(installdir_window)
23
- FileUtils.mkdir_p(installdir_ntfs)
24
-
25
- Dir["lib/windows/*.rb"].each{ |file|
26
- FileUtils.cp(file, installdir, :verbose => true)
27
- }
28
-
29
- Dir["lib/windows/msvcrt/*.rb"].each{ |file|
30
- FileUtils.cp(file, installdir_msvcrt, :verbose => true)
31
- }
32
-
33
- Dir["lib/windows/gdi/*.rb"].each{ |file|
34
- FileUtils.cp(file, installdir_gdi, :verbose => true)
35
- }
36
-
37
- Dir["lib/windows/com/*.rb"].each{ |file|
38
- FileUtils.cp(file, installdir_com, :verbose => true)
39
- }
40
-
41
- Dir["lib/windows/network/*.rb"].each{ |file|
42
- FileUtils.cp(file, installdir_network, :verbose => true)
43
- }
44
-
45
- Dir["lib/windows/window/*.rb"].each{ |file|
46
- FileUtils.cp(file, installdir_window, :verbose => true)
47
- }
48
-
49
- Dir["lib/windows/ntfs/*.rb"].each{ |file|
50
- FileUtils.cp(file, installdir_ntfs, :verbose => true)
51
- }
52
- end
5
+ CLEAN << FileList['*.gem']
53
6
 
54
7
  namespace 'gem' do
55
8
  desc 'Build the windows-pr gem'
@@ -82,4 +35,12 @@ namespace 'test' do
82
35
  t.verbose = true
83
36
  t.test_files = FileList['test/tc_unicode.rb']
84
37
  end
38
+
39
+ Rake::TestTask.new('volume') do |t|
40
+ t.warning = true
41
+ t.verbose = true
42
+ t.test_files = FileList['test/tc_volume.rb']
43
+ end
85
44
  end
45
+
46
+ task :default => 'test:all'
@@ -1,48 +1,59 @@
1
1
  require 'windows/api'
2
2
 
3
3
  module Windows
4
- module Volume
5
- API.auto_namespace = 'Windows::Volume'
6
- API.auto_constant = true
7
- API.auto_method = true
8
- API.auto_unicode = true
4
+ module Volume
5
+ API.auto_namespace = 'Windows::Volume'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
9
 
10
- DRIVE_UNKNOWN = 0
11
- DRIVE_NO_ROOT_DIR = 1
12
- DRIVE_REMOVABLE = 2
13
- DRIVE_FIXED = 3
14
- DRIVE_REMOTE = 4
15
- DRIVE_CDROM = 5
16
- DRIVE_RAMDISK = 6
17
-
18
- API.new('DefineDosDevice', 'LSS', 'B')
19
- API.new('DeleteVolumeMountPoint', 'S', 'B')
20
- API.new('FindFirstVolume', 'PL', 'L')
21
- API.new('FindFirstVolumeMountPoint', 'SPL', 'L')
22
- API.new('FindNextVolume', 'LPL', 'B')
23
- API.new('FindNextVolumeMountPoint', 'LPL', 'B')
24
- API.new('FindVolumeClose', 'L', 'B')
25
- API.new('FindVolumeMountPointClose', 'L', 'B')
26
- API.new('GetDriveType', 'S', 'I')
27
- API.new('GetLogicalDrives', 'V', 'L')
28
- API.new('GetLogicalDriveStrings', 'LP', 'L')
29
- API.new('GetVolumeInformation', 'SPLPPPPL', 'B')
30
- API.new('GetVolumeNameForVolumeMountPoint', 'SPL', 'B')
31
- API.new('GetVolumePathName', 'PPL', 'B')
32
- API.new('QueryDosDevice', 'SPL', 'L')
33
- API.new('SetVolumeLabel', 'SS', 'B')
34
- API.new('SetVolumeMountPoint', 'SS', 'B')
10
+ DRIVE_UNKNOWN = 0
11
+ DRIVE_NO_ROOT_DIR = 1
12
+ DRIVE_REMOVABLE = 2
13
+ DRIVE_FIXED = 3
14
+ DRIVE_REMOTE = 4
15
+ DRIVE_CDROM = 5
16
+ DRIVE_RAMDISK = 6
17
+
18
+ API.new('DefineDosDevice', 'LSS', 'B')
19
+ API.new('DeleteVolumeMountPoint', 'S', 'B')
20
+ API.new('FindFirstVolume', 'PL', 'L')
21
+ API.new('FindFirstVolumeMountPoint', 'SPL', 'L')
22
+ API.new('FindNextVolume', 'LPL', 'B')
23
+ API.new('FindNextVolumeMountPoint', 'LPL', 'B')
24
+ API.new('FindVolumeClose', 'L', 'B')
25
+ API.new('FindVolumeMountPointClose', 'L', 'B')
26
+ API.new('GetDriveType', 'S', 'I')
27
+ API.new('GetLogicalDrives', 'V', 'L')
28
+ API.new('GetLogicalDriveStrings', 'LP', 'L')
29
+ API.new('GetVolumeInformation', 'SPLPPPPL', 'B')
30
+ API.new('GetVolumeNameForVolumeMountPoint', 'SPL', 'B')
31
+ API.new('GetVolumePathName', 'PPL', 'B')
32
+ API.new('QueryDosDevice', 'SPL', 'L')
33
+ API.new('SetVolumeLabel', 'SS', 'B')
34
+ API.new('SetVolumeMountPoint', 'SS', 'B')
35
35
 
36
- begin
37
- API.new('GetVolumePathNamesForVolumeName', 'SPLL', 'B')
38
- rescue Win32::API::LoadLibraryError
39
- # Windows XP or later
40
- end
36
+ begin
37
+ API.new('GetVolumePathNamesForVolumeName', 'SPLL', 'B')
38
+ rescue Win32::API::LoadLibraryError
39
+ # Windows XP or later
40
+ end
41
41
 
42
- begin
43
- API.new('GetVolumeInformationByHandleW', 'LPLPPPPL', 'B')
44
- rescue Win32::API::LoadLibraryError
45
- # Windows Vista or later
46
- end
47
- end
42
+ begin
43
+ API.new('GetVolumeInformationByHandleW', 'LPLPPPPL', 'B')
44
+ rescue Win32::API::LoadLibraryError
45
+ # Windows Vista or later
46
+ end
47
+
48
+ # Returns the volume type for +vol+ or the volume of the current
49
+ # process if no volume is specified.
50
+ #
51
+ # Returns nil if the function fails for any reason.
52
+ #
53
+ def get_volume_type(vol = nil)
54
+ buf = 0.chr * 256
55
+ bool = GetVolumeInformation(vol, nil, nil, nil, nil, nil, buf, buf.size)
56
+ bool ? buf.strip : nil
57
+ end
58
+ end
48
59
  end
data/test/tc_volume.rb CHANGED
@@ -6,20 +6,42 @@
6
6
  require 'windows/volume'
7
7
  require 'test/unit'
8
8
 
9
- class VolumeFoo
10
- include Windows::Volume
11
- end
12
-
13
9
  class TC_Windows_Volume < Test::Unit::TestCase
14
- def setup
15
- @foo = VolumeFoo.new
16
- end
17
-
18
- def test_method_constants
19
- assert_not_nil(VolumeFoo::GetVolumeInformation)
20
- end
21
-
22
- def teardown
23
- @foo = nil
24
- end
10
+ include Windows::Volume
11
+
12
+ def test_constants
13
+ assert_equal(0, DRIVE_UNKNOWN)
14
+ assert_equal(1, DRIVE_NO_ROOT_DIR)
15
+ assert_equal(2, DRIVE_REMOVABLE)
16
+ assert_equal(3, DRIVE_FIXED)
17
+ assert_equal(4, DRIVE_REMOTE)
18
+ assert_equal(5, DRIVE_CDROM)
19
+ assert_equal(6, DRIVE_RAMDISK)
20
+ end
21
+
22
+ def test_method_constants
23
+ assert_not_nil(DefineDosDevice)
24
+ assert_not_nil(DeleteVolumeMountPoint)
25
+ assert_not_nil(FindFirstVolume)
26
+ assert_not_nil(FindFirstVolumeMountPoint)
27
+ assert_not_nil(FindNextVolume)
28
+ assert_not_nil(FindNextVolumeMountPoint)
29
+ assert_not_nil(FindVolumeClose)
30
+ assert_not_nil(FindVolumeMountPointClose)
31
+ assert_not_nil(GetDriveType)
32
+ assert_not_nil(GetLogicalDrives)
33
+ assert_not_nil(GetLogicalDriveStrings)
34
+ assert_not_nil(GetVolumeInformation)
35
+ assert_not_nil(GetVolumeNameForVolumeMountPoint)
36
+ assert_not_nil(GetVolumePathName)
37
+ assert_not_nil(QueryDosDevice)
38
+ assert_not_nil(SetVolumeLabel)
39
+ assert_not_nil(SetVolumeMountPoint)
40
+ end
41
+
42
+ def test_get_volume_type
43
+ assert_respond_to(self, :get_volume_type)
44
+ assert_nothing_raised{ get_volume_type }
45
+ assert_kind_of(String, get_volume_type)
46
+ end
25
47
  end
data/windows-pr.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'windows-pr'
5
- spec.version = '1.0.9'
5
+ spec.version = '1.1.0'
6
6
  spec.license = 'Artistic 2.0'
7
7
  spec.authors = ['Daniel J. Berger', 'Park Heesob']
8
8
  spec.email = 'djberg96@gmail.com'
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows-pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Daniel J. Berger
@@ -10,29 +16,41 @@ autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
18
 
13
- date: 2010-02-06 00:00:00 -07:00
19
+ date: 2010-11-05 00:00:00 -06:00
14
20
  default_executable:
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
23
  name: windows-api
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
21
27
  requirements:
22
28
  - - ">="
23
29
  - !ruby/object:Gem::Version
30
+ hash: 19
31
+ segments:
32
+ - 0
33
+ - 3
34
+ - 0
24
35
  version: 0.3.0
25
- version:
36
+ type: :runtime
37
+ version_requirements: *id001
26
38
  - !ruby/object:Gem::Dependency
27
39
  name: win32-api
28
- type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
31
43
  requirements:
32
44
  - - ">="
33
45
  - !ruby/object:Gem::Version
46
+ hash: 13
47
+ segments:
48
+ - 1
49
+ - 4
50
+ - 5
34
51
  version: 1.4.5
35
- version:
52
+ type: :runtime
53
+ version_requirements: *id002
36
54
  description: " The windows-pr library is a collection of Windows functions and constants\n pre-defined for you using the windows-api library. It also autogenerates\n explicit ANSI and Wide character versions of those functions, as well as\n constants that can be used as methods, e.g. CloseHandle() instead of\n CloseHandle.call().\n"
37
55
  email: djberg96@gmail.com
38
56
  executables: []
@@ -162,6 +180,7 @@ files:
162
180
  - test/tc_window_message.rb
163
181
  - test/tc_window_properties.rb
164
182
  - test/tc_window_timer.rb
183
+ - windows-pr-1.1.0.gem
165
184
  - windows-pr.gemspec
166
185
  has_rdoc: true
167
186
  homepage: http://www.rubyforge.org/projects/win32utils
@@ -173,21 +192,27 @@ rdoc_options: []
173
192
  require_paths:
174
193
  - lib
175
194
  required_ruby_version: !ruby/object:Gem::Requirement
195
+ none: false
176
196
  requirements:
177
197
  - - ">="
178
198
  - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
179
202
  version: "0"
180
- version:
181
203
  required_rubygems_version: !ruby/object:Gem::Requirement
204
+ none: false
182
205
  requirements:
183
206
  - - ">="
184
207
  - !ruby/object:Gem::Version
208
+ hash: 3
209
+ segments:
210
+ - 0
185
211
  version: "0"
186
- version:
187
212
  requirements: []
188
213
 
189
214
  rubyforge_project: win32utils
190
- rubygems_version: 1.3.5
215
+ rubygems_version: 1.3.7
191
216
  signing_key:
192
217
  specification_version: 3
193
218
  summary: Windows functions and constants bundled via Win32::API