windows-api 0.1.1 → 0.2.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.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.2.0 - 20-Sep-2007
2
+ * Now requires the win32-api library.
3
+ * Replaced class variables with class instance variables to prevent conflicts.
4
+
1
5
  = 0.1.1 - 25-May-2007
2
6
  * Fixed a void parameter bug.
3
7
 
data/MANIFEST CHANGED
@@ -3,7 +3,5 @@
3
3
  * README
4
4
  * Rakefile
5
5
  * windows-api.gemspec
6
- * ext/extconf.rb
7
- * ext/windows/api.c
8
6
  * lib/windows/api.rb
9
7
  * test/tc_windows_api.rb
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  = Description
2
- This is a wrapper for Win32API that simplifies various idioms typically
3
- used by people who use Win32API.
2
+ This is a wrapper for Win32::API that simplifies various idioms typically
3
+ used by people who use Win32::API.
4
4
 
5
5
  = Synopsis
6
6
  require 'windows/api'
@@ -55,7 +55,7 @@
55
55
  end
56
56
  end
57
57
 
58
- = Advantages over plain Win32API
58
+ = Advantages over plain Win32::API
59
59
  * Automatic constant generation.
60
60
  * Automatic definition of ANSI and Unicode method wrappers, including
61
61
  special handling for boolean methods.
data/Rakefile CHANGED
@@ -19,33 +19,6 @@ task :install_gem do
19
19
  sh "gem install #{file}"
20
20
  end
21
21
 
22
- desc "Clean any build files for Windows::API"
23
- task :clean do
24
- Dir.chdir('ext') do
25
- if File.exists?("api.so") || File.exists?("windows/api.so")
26
- sh "nmake distclean"
27
- rm "api.c" if File.exists?("api.c")
28
- rm "windows/api.so" if File.exists?("windows/api.so")
29
- end
30
- end
31
- end
32
-
33
- desc "Build Windows::API (but don't install it)"
34
- task :build_c => [:clean] do
35
- Dir.chdir('ext') do
36
- cp "windows/api.c", "."
37
- sh "ruby extconf.rb"
38
- sh "nmake"
39
- mv "api.so", "windows"
40
- end
41
- end
42
-
43
- Rake::TestTask.new('test_c') do |test|
44
- task :test_c => [:build_c]
45
- test.libs << 'ext'
46
- test.test_files = FileList['test/tc*']
47
- end
48
-
49
22
  Rake::TestTask.new do |test|
50
23
  test.libs << 'lib'
51
24
  test.warning = true
data/lib/windows/api.rb CHANGED
@@ -1,22 +1,22 @@
1
- require 'Win32API'
1
+ require 'win32/api'
2
2
 
3
3
  module Windows
4
4
  class API
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2.0'
6
6
 
7
7
  class Error < RuntimeError; end
8
8
 
9
- @@auto_constant = false
10
- @@auto_method = false
11
- @@auto_unicode = false
12
- @@auto_namespace = nil
9
+ @auto_constant = false
10
+ @auto_method = false
11
+ @auto_unicode = false
12
+ @auto_namespace = nil
13
13
 
14
- # Returns the value of the @@auto_constant class variable. The default
15
- # is nil, i.e. none. See the Windows::API.auto_constant= documentation
16
- # for more information.
14
+ # Returns the value of the @auto_constant class instance variable. The
15
+ # default is nil, i.e. none. See the Windows::API.auto_constant=
16
+ # documentation for more information.
17
17
  #
18
18
  def self.auto_constant
19
- @@auto_constant
19
+ @auto_constant
20
20
  end
21
21
 
22
22
  # Automatically sets a constant to match the function name.
@@ -52,34 +52,34 @@ module Windows
52
52
  # nesting and all, I'd love to know the solution.
53
53
  #
54
54
  def self.auto_constant=(bool)
55
- @@auto_constant = bool
55
+ @auto_constant = bool
56
56
  end
57
57
 
58
- # Returns the value of the auto_namespace class variable. Used in
59
- # conjunction with API.auto_constant and/or API.auto_method.
58
+ # Returns the value of the auto_namespace class instance variable. Used
59
+ # in conjunction with API.auto_constant and/or API.auto_method.
60
60
  #
61
61
  def self.auto_namespace
62
- @@auto_namespace
62
+ @auto_namespace
63
63
  end
64
64
 
65
- # Sets the value of the auto_namespace class variable. The default is
66
- # nil, i.e. none. Use in conjunction with the auto_constant and/or
67
- # auto_method class variables, this method will automatically set a
68
- # constant and/or method in +namespace+ equal to the function name set
65
+ # Sets the value of the auto_namespace class nstance variable. The
66
+ # default is nil, i.e. none. Use in conjunction with the auto_constant
67
+ # and/or auto_method class variables, this method will automatically set
68
+ # a constant and/or method in +namespace+ equal to the function name set
69
69
  # in the constructor.
70
70
  #
71
71
  # The +namespace+ must refer to an existing module, not a class.
72
72
  #
73
73
  def self.auto_namespace=(namespace)
74
- @@auto_namespace = namespace
74
+ @auto_namespace = namespace
75
75
  end
76
76
 
77
- # Returns the value of the auto_method class variable. Used in
77
+ # Returns the value of the auto_method class instance variable. Used in
78
78
  # conjunction with auto_unicode. See API.auto_method= for more
79
79
  # information.
80
80
  #
81
81
  def self.auto_method
82
- @@auto_method
82
+ @auto_method
83
83
  end
84
84
 
85
85
  # If this option is set to true then a corresponding method is
@@ -122,15 +122,15 @@ module Windows
122
122
  # already ends with 'A' or 'W'.
123
123
  #
124
124
  def self.auto_method=(bool)
125
- @@auto_method = bool
125
+ @auto_method = bool
126
126
  end
127
127
 
128
- # Returns the value of the auto_unicode class variable. This is used
129
- # in conjunction with the auto_method and/or auto_constant class
128
+ # Returns the value of the auto_unicode class instance variable. This
129
+ # is used in conjunction with the auto_method and/or auto_constant class
130
130
  # variables. Not significant if neither of those variables are set.
131
131
  #
132
132
  def self.auto_unicode
133
- @@auto_unicode
133
+ @auto_unicode
134
134
  end
135
135
 
136
136
  # If set to true, and the auto_constant variable is set, then the
@@ -167,7 +167,7 @@ module Windows
167
167
  # already ends with an 'A' or 'W'.
168
168
  #
169
169
  def self.auto_unicode=(bool)
170
- @@auto_unicode = bool
170
+ @auto_unicode = bool
171
171
  end
172
172
 
173
173
  attr_reader :function_name
@@ -208,12 +208,7 @@ module Windows
208
208
  @boolean = rtype == 'B' ? true : false
209
209
 
210
210
  begin
211
- @api = Win32API.new(
212
- @dll_name,
213
- @function_name,
214
- @prototype,
215
- @return_type
216
- )
211
+ @api = Win32::API.new(func, proto, rtype, dll)
217
212
  rescue RuntimeError => err
218
213
  raise Error, err
219
214
  end
@@ -222,21 +217,21 @@ module Windows
222
217
  api_w = nil
223
218
 
224
219
  # If the auto_unicode option is set, and the func is not already
225
- # an explicit ANSI or Unicode function name, generate Win32API
220
+ # an explicit ANSI or Unicode function name, generate Win32::API
226
221
  # objects for those functions as well. Ignore errors because not
227
222
  # all functions have explicit ANSI or Unicode equivalents.
228
223
  #
229
- if @@auto_unicode
224
+ if Windows::API.auto_unicode
230
225
  begin
231
226
  if func[-1].chr != 'A'
232
- api_a = Win32API.new(dll, "#{func}A", proto, rtype)
227
+ api_a = Win32::API.new("#{func}A", proto, rtype, dll)
233
228
  end
234
229
  rescue RuntimeError
235
230
  end
236
231
 
237
232
  begin
238
233
  if func[-1].chr != 'W'
239
- api_w = Win32API.new(dll, "#{func}W", proto, rtype)
234
+ api_w = Win32::API.new("#{func}W", proto, rtype, dll)
240
235
  end
241
236
  rescue RuntimeError
242
237
  end
@@ -245,11 +240,11 @@ module Windows
245
240
  # Automatically define a constant matching the function name if the
246
241
  # auto_constant option is set.
247
242
  #
248
- if @@auto_constant && @@auto_namespace
249
- if @@auto_namespace != 'Windows'
250
- namespace = class_for(@@auto_namespace)
243
+ if Windows::API.auto_constant && Windows::API.auto_namespace
244
+ if Windows::API.auto_namespace != 'Windows'
245
+ namespace = class_for(Windows::API.auto_namespace)
251
246
  else
252
- namespace = @@auto_namespace
247
+ namespace = Windows::API.auto_namespace
253
248
  end
254
249
 
255
250
  namespace.const_set(func, @api)
@@ -257,7 +252,7 @@ module Windows
257
252
  # Automatically define the explicit ANSI and Unicode functions
258
253
  # as constants as well, if appropriate.
259
254
  #
260
- if @@auto_unicode
255
+ if Windows::API.auto_unicode
261
256
  namespace.const_set("#{func}A", api_a) if api_a
262
257
  namespace.const_set("#{func}W", api_w) if api_w
263
258
  end
@@ -267,7 +262,7 @@ module Windows
267
262
  # auto_method option is set. The explicit ANSI and Unicode methods
268
263
  # are added as well if the auto_unicode option is set to true.
269
264
  #
270
- if @@auto_method && @@auto_namespace
265
+ if Windows::API.auto_method && Windows::API.auto_namespace
271
266
  if proto == 'V'
272
267
  proto = ''
273
268
  else
@@ -287,7 +282,7 @@ module Windows
287
282
 
288
283
  if @boolean
289
284
  string = <<-EOC
290
- module #{@@auto_namespace}
285
+ module #{Windows::API.auto_namespace}
291
286
  def #{func}(#{proto})
292
287
  #{func}.call(#{proto}) != 0
293
288
  end
@@ -312,7 +307,7 @@ module Windows
312
307
  string << 'end'
313
308
  else
314
309
  string = <<-EOC
315
- module #{@@auto_namespace}
310
+ module #{Windows::API.auto_namespace}
316
311
  def #{func}(#{proto})
317
312
  #{func}.call(#{proto})
318
313
  end
@@ -43,7 +43,7 @@ class TC_Windows_API < Test::Unit::TestCase
43
43
  end
44
44
 
45
45
  def test_version
46
- assert_equal('0.1.1', API::VERSION)
46
+ assert_equal('0.2.0', API::VERSION)
47
47
  end
48
48
 
49
49
  def test_auto_unicode
@@ -57,7 +57,7 @@ class TC_Windows_API < Test::Unit::TestCase
57
57
  assert_not_nil(Windows::Test::GetCurrentDirectory)
58
58
  assert_not_nil(Windows::Bar::GetUserName)
59
59
 
60
- assert_kind_of(Win32API, Windows::Test::GetCurrentDirectory)
60
+ assert_kind_of(Win32::API, Windows::Test::GetCurrentDirectory)
61
61
  assert_respond_to(Windows::Test::GetCurrentDirectory, :call)
62
62
  end
63
63
 
data/windows-api.gemspec CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "windows-api"
5
- gem.version = "0.1.1"
5
+ gem.version = "0.2.0"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
@@ -15,6 +15,7 @@ spec = Gem::Specification.new do |gem|
15
15
  gem.files.reject! { |fn| fn.include? "CVS" }
16
16
  gem.require_path = "lib"
17
17
  gem.extra_rdoc_files = ["README", "CHANGES", "MANIFEST"]
18
+ gem.add_dependency("win32-api", ">= 1.0.0")
18
19
  end
19
20
 
20
21
  if $0 == __FILE__
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.3
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: windows-api
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-05-24 00:00:00 -06:00
6
+ version: 0.2.0
7
+ date: 2007-09-20 00:00:00 -06:00
8
8
  summary: An easier way to create methods using Win32API
9
9
  require_paths:
10
10
  - lib
@@ -34,7 +34,6 @@ files:
34
34
  - test/tc_windows_api.rb
35
35
  - CHANGES
36
36
  - CVS
37
- - ext
38
37
  - lib
39
38
  - MANIFEST
40
39
  - Rakefile
@@ -55,5 +54,13 @@ extensions: []
55
54
 
56
55
  requirements: []
57
56
 
58
- dependencies: []
59
-
57
+ dependencies:
58
+ - !ruby/object:Gem::Dependency
59
+ name: win32-api
60
+ version_requirement:
61
+ version_requirements: !ruby/object:Gem::Version::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ version: