com 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/com.rb +16 -15
- data/lib/com/instantiable.rb +8 -1
- data/lib/com/methodinvocationerror.rb +1 -1
- data/lib/com/standarderror.rb +2 -2
- data/lib/com/version.rb +1 -1
- data/lib/com/wrapper.rb +7 -2
- metadata +6 -6
data/lib/com.rb
CHANGED
@@ -6,14 +6,6 @@ WIN32OLE.codepage = WIN32OLE::CP_UTF8
|
|
6
6
|
# COM is an object-oriented wrapper around WIN32OLE. COM makes it easy to add
|
7
7
|
# behavior to WIN32OLE objects, making them easier to work with from Ruby.
|
8
8
|
module COM
|
9
|
-
autoload :Error, 'com/error'
|
10
|
-
autoload :Events, 'com/events'
|
11
|
-
autoload :Instantiable, 'com/instantiable'
|
12
|
-
autoload :Object, 'com/object'
|
13
|
-
autoload :PatternError, 'com/patternerror'
|
14
|
-
autoload :Version, 'com/version'
|
15
|
-
autoload :Wrapper, 'com/wrapper'
|
16
|
-
|
17
9
|
class << self
|
18
10
|
# Gets the iconv character set equivalent of the current COM code page.
|
19
11
|
#
|
@@ -59,15 +51,24 @@ module COM
|
|
59
51
|
end
|
60
52
|
end
|
61
53
|
|
62
|
-
private
|
63
|
-
|
64
54
|
# @private
|
65
55
|
COMCodePageToIconvCharset = {
|
66
56
|
WIN32OLE::CP_UTF8 => 'UTF-8'
|
67
57
|
}.freeze
|
68
|
-
end
|
69
58
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
59
|
+
%w'com/error.rb
|
60
|
+
com/object.rb
|
61
|
+
com/patternerror.rb
|
62
|
+
|
63
|
+
com/events.rb
|
64
|
+
com/instantiable.rb
|
65
|
+
com/methodinvocationerror.rb
|
66
|
+
com/pathname.rb
|
67
|
+
com/standarderror.rb
|
68
|
+
com/win32ole.rb
|
69
|
+
com/wrapper.rb'.each do |file|
|
70
|
+
load File.expand_path('../%s' % file, __FILE__)
|
71
|
+
end
|
72
|
+
|
73
|
+
autoload :Version, 'com/version.rb'
|
74
|
+
end
|
data/lib/com/instantiable.rb
CHANGED
@@ -64,6 +64,13 @@ class COM::Instantiable < COM::Object
|
|
64
64
|
@constants
|
65
65
|
end
|
66
66
|
|
67
|
+
# Typelib to use for loading constants, if it can’t be determined
|
68
|
+
# automatically.
|
69
|
+
def typelib(typelib = nil)
|
70
|
+
@typelib = typelib if typelib
|
71
|
+
@typelib ||= nil
|
72
|
+
end
|
73
|
+
|
67
74
|
# Loads constants associated with COM object _com_. This is an internal
|
68
75
|
# method that shouldn’t be called outside of this class.
|
69
76
|
#
|
@@ -72,7 +79,7 @@ class COM::Instantiable < COM::Object
|
|
72
79
|
def load_constants(com)
|
73
80
|
return if constants_loaded?
|
74
81
|
modul = nesting[-2]
|
75
|
-
com.load_constants modul
|
82
|
+
com.load_constants modul, typelib
|
76
83
|
@constants_loaded = true
|
77
84
|
end
|
78
85
|
|
data/lib/com/standarderror.rb
CHANGED
@@ -11,7 +11,7 @@ module COM::StandardError
|
|
11
11
|
Class.new(COM::Error) do
|
12
12
|
extend COM::PatternError
|
13
13
|
|
14
|
-
pattern %r{^\s*(.*)\n\s*HRESULT\serror\scode:(0x(?i:#{code.to_s(16)}))}
|
14
|
+
pattern %r{^\s*(.*)\n\s*HRESULT\serror\scode:(0x(?i:#{code.to_s(16)}))}x
|
15
15
|
|
16
16
|
(class << self; self; end).class_eval do
|
17
17
|
define_method :replace do |error|
|
@@ -44,7 +44,7 @@ module COM::HResultError
|
|
44
44
|
COM.const_set error, Class.new(COM::Error){
|
45
45
|
extend COM::PatternError
|
46
46
|
|
47
|
-
pattern %r{^\s*(.*)\n\s*HRESULT\serror\scode:(0x(?i:#{code.to_s(16)}))}
|
47
|
+
pattern %r{^\s*(.*)\n\s*HRESULT\serror\scode:(0x(?i:#{code.to_s(16)}))}x
|
48
48
|
|
49
49
|
(class << self; self; end).class_eval do
|
50
50
|
define_method :replace do |e|
|
data/lib/com/version.rb
CHANGED
data/lib/com/wrapper.rb
CHANGED
@@ -42,13 +42,18 @@ class COM::Wrapper
|
|
42
42
|
raise COM::Wrapper.raise_in('%s=' % property, e)
|
43
43
|
end
|
44
44
|
|
45
|
-
def load_constants(into)
|
45
|
+
def load_constants(into, typelib = nil)
|
46
46
|
saved_verbose, $VERBOSE = $VERBOSE, nil
|
47
47
|
begin
|
48
48
|
begin
|
49
49
|
WIN32OLE.const_load @ole, into
|
50
50
|
rescue RuntimeError
|
51
|
-
|
51
|
+
begin
|
52
|
+
@ole.ole_typelib
|
53
|
+
rescue RuntimeError
|
54
|
+
raise unless typelib
|
55
|
+
WIN32OLE_TYPELIB.new(typelib)
|
56
|
+
end.ole_types.select{ |e| e.visible? and e.ole_type == 'Enum' }.each do |enum|
|
52
57
|
enum.constants.each do |constant|
|
53
58
|
into.const_set constant.const_name, constant.value
|
54
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: com
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: lookout
|
16
|
-
requirement: &
|
16
|
+
requirement: &15646116 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15646116
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yard
|
27
|
-
requirement: &
|
27
|
+
requirement: &15645576 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.6.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *15645576
|
36
36
|
description: ! "# COM #\n\nCOM is an object-oriented wrapper around WIN32OLE. COM
|
37
37
|
makes it easy to add\nbehavior to WIN32OLE objects, making them easier to work with
|
38
38
|
from Ruby.\n\n\n## Usage ##\n\nUsing COM is rather straightforward. There’s basically
|