win32ole-pp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.txt +3 -0
- data/History.txt +4 -0
- data/Manifest.txt +28 -0
- data/README.txt +100 -0
- data/Rakefile +93 -0
- data/examples/test.rb +84 -0
- data/lib/win32ole_pp/extentions/common.rb +61 -0
- data/lib/win32ole_pp/extentions/win32ole.rb +40 -0
- data/lib/win32ole_pp/extentions/win32ole_event.rb +38 -0
- data/lib/win32ole_pp/extentions/win32ole_method.rb +27 -0
- data/lib/win32ole_pp/extentions/win32ole_param.rb +44 -0
- data/lib/win32ole_pp/extentions/win32ole_type.rb +29 -0
- data/lib/win32ole_pp/extentions/win32ole_variable.rb +29 -0
- data/lib/win32ole_pp/extentions.rb +28 -0
- data/lib/win32ole_pp/init.rb +1 -0
- data/lib/win32ole_pp/pp.rb +1 -0
- data/lib/win32ole_pp/to_s.rb +1 -0
- data/lib/win32ole_pp/version.rb +9 -0
- data/lib/win32ole_pp.rb +8 -0
- data/setup.rb +1585 -0
- data/test/helper.rb +16 -0
- data/test/test_version.rb +19 -0
- data/test/test_win32ole.rb +54 -0
- data/test/test_win32ole_event.rb +28 -0
- data/test/test_win32ole_method.rb +84 -0
- data/test/test_win32ole_param.rb +65 -0
- data/test/test_win32ole_type.rb +57 -0
- data/test/test_win32ole_variable.rb +46 -0
- metadata +87 -0
data/CHANGELOG.txt
ADDED
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
CHANGELOG.txt
|
2
|
+
History.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
examples/test.rb
|
7
|
+
lib/win32ole_pp.rb
|
8
|
+
lib/win32ole_pp/extentions.rb
|
9
|
+
lib/win32ole_pp/extentions/common.rb
|
10
|
+
lib/win32ole_pp/extentions/win32ole.rb
|
11
|
+
lib/win32ole_pp/extentions/win32ole_event.rb
|
12
|
+
lib/win32ole_pp/extentions/win32ole_method.rb
|
13
|
+
lib/win32ole_pp/extentions/win32ole_param.rb
|
14
|
+
lib/win32ole_pp/extentions/win32ole_type.rb
|
15
|
+
lib/win32ole_pp/extentions/win32ole_variable.rb
|
16
|
+
lib/win32ole_pp/init.rb
|
17
|
+
lib/win32ole_pp/pp.rb
|
18
|
+
lib/win32ole_pp/to_s.rb
|
19
|
+
lib/win32ole_pp/version.rb
|
20
|
+
setup.rb
|
21
|
+
test/helper.rb
|
22
|
+
test/test_version.rb
|
23
|
+
test/test_win32ole.rb
|
24
|
+
test/test_win32ole_event.rb
|
25
|
+
test/test_win32ole_method.rb
|
26
|
+
test/test_win32ole_param.rb
|
27
|
+
test/test_win32ole_type.rb
|
28
|
+
test/test_win32ole_variable.rb
|
data/README.txt
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
== win32ole-pp
|
2
|
+
|
3
|
+
* Author: MIYAMUKO Katsuyuki <mailto:miyamuko@gmail.com>
|
4
|
+
* URL: http://win32ole-pp.rubyforge.org/
|
5
|
+
|
6
|
+
=== DESCRIPTION:
|
7
|
+
|
8
|
+
win32ole_pp - provide pretty printer for WIN32OLE and smart #to_s.
|
9
|
+
|
10
|
+
=== FEATURES/PROBLEMS:
|
11
|
+
|
12
|
+
* add WIN32OLE#pretty_print method for pp.
|
13
|
+
* overwrite WIN32OLE#to_s.
|
14
|
+
|
15
|
+
=== SYNOPSIS:
|
16
|
+
|
17
|
+
require "pp"
|
18
|
+
require "win32ole"
|
19
|
+
require "win32ole_pp"
|
20
|
+
|
21
|
+
fs = WIN32OLE.new("Scripting.FileSystemObject")
|
22
|
+
|
23
|
+
puts fs #=> #<WIN32OLE:0x14c9270: IFileSystem3>
|
24
|
+
pp fs #=> #<WIN32OLE:0x14c9270: IFileSystem3
|
25
|
+
# Drives=#<WIN32OLE:0x14c8e4c: IDriveCollection>>
|
26
|
+
|
27
|
+
m = fs.ole_method("DeleteFolder")
|
28
|
+
|
29
|
+
puts m #=> #<WIN32OLE_METHOD:0x14c6638: VOID DeleteFolder([in] BSTR FolderSpec, [in, optional] BOOL Force)>
|
30
|
+
pp m #=> #<WIN32OLE_METHOD:0x14c6638: DeleteFolder
|
31
|
+
# dispid=1201,
|
32
|
+
# event?=false,
|
33
|
+
# event_interface=nil,
|
34
|
+
# helpcontext=2182037,
|
35
|
+
# helpfile="C:\\WINDOWS\\system32\\VBENLR98.CHM",
|
36
|
+
# helpstring="Delete a folder",
|
37
|
+
# invkind=1,
|
38
|
+
# invoke_kind="FUNC",
|
39
|
+
# name="DeleteFolder",
|
40
|
+
# offset_vtbl=96,
|
41
|
+
# params=
|
42
|
+
# [#<WIN32OLE_PARAM:0x14c08d2: FolderSpec
|
43
|
+
# default=nil,
|
44
|
+
# input?=true,
|
45
|
+
# name="FolderSpec",
|
46
|
+
# ole_type="BSTR",
|
47
|
+
# ole_type_detail=["BSTR"],
|
48
|
+
# optional?=false,
|
49
|
+
# output?=false,
|
50
|
+
# retval?=false>,
|
51
|
+
# #<WIN32OLE_PARAM:0x14c08be: Force
|
52
|
+
# default=false,
|
53
|
+
# input?=true,
|
54
|
+
# name="Force",
|
55
|
+
# ole_type="BOOL",
|
56
|
+
# ole_type_detail=["BOOL"],
|
57
|
+
# optional?=true,
|
58
|
+
# output?=false,
|
59
|
+
# retval?=false>],
|
60
|
+
# return_type="VOID",
|
61
|
+
# return_type_detail=["VOID"],
|
62
|
+
# return_vtype=24,
|
63
|
+
# size_opt_params=0,
|
64
|
+
# size_params=2,
|
65
|
+
# visible?=true>
|
66
|
+
|
67
|
+
|
68
|
+
=== REQUIREMENTS:
|
69
|
+
|
70
|
+
* pp (standard library)
|
71
|
+
* win32ole (standard library)
|
72
|
+
|
73
|
+
=== INSTALL:
|
74
|
+
|
75
|
+
gem install win32ole-pp
|
76
|
+
|
77
|
+
=== LICENSE:
|
78
|
+
|
79
|
+
win32ole-pp is released under the MIT license.
|
80
|
+
|
81
|
+
Copyright (c) 2007 MIYAMUKO Katsuyuki.
|
82
|
+
|
83
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
84
|
+
a copy of this software and associated documentation files (the
|
85
|
+
'Software'), to deal in the Software without restriction, including
|
86
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
87
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
88
|
+
permit persons to whom the Software is furnished to do so, subject to
|
89
|
+
the following conditions:
|
90
|
+
|
91
|
+
The above copyright notice and this permission notice shall be
|
92
|
+
included in all copies or substantial portions of the Software.
|
93
|
+
|
94
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
95
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
96
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
97
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
98
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
99
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
100
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require 'rake/contrib/rubyforgepublisher'
|
6
|
+
require './lib/win32ole_pp/version.rb'
|
7
|
+
|
8
|
+
|
9
|
+
RUBYFORGE_PROJECT = 'win32ole-pp'
|
10
|
+
|
11
|
+
# command filter hack.
|
12
|
+
$shell_command_filter = []
|
13
|
+
alias sh_original sh
|
14
|
+
def sh(*cmd, &block)
|
15
|
+
cmd = $shell_command_filter.inject(cmd){|c,filter| filter(c) or c }
|
16
|
+
sh_original(*cmd, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
# rake publish_docs SCP=pscp
|
20
|
+
if ENV["SCP"] and ENV["SCP"] != "scp"
|
21
|
+
$shell_command_filter << lambda {|cmd|
|
22
|
+
cmd[0] = cmd[0].sub(/\Ascp/, ENV["SCP"]).sub(/-rq/, "-r") if cmd[0] =~ /\Ascp /
|
23
|
+
cmd
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove_task(task_name)
|
28
|
+
Rake.application.instance_eval {
|
29
|
+
@tasks.delete(task_name.to_s)
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
def with_temporary_rename(from, to)
|
34
|
+
mv from, to
|
35
|
+
yield
|
36
|
+
ensure
|
37
|
+
mv to, from
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
Hoe.new(RUBYFORGE_PROJECT, WIN32OLE_PP::VERSION::STRING) do |p|
|
42
|
+
p.rubyforge_name = RUBYFORGE_PROJECT
|
43
|
+
p.summary = 'pretty printer for WIN32OLE'
|
44
|
+
|
45
|
+
p.author = ["MIYAMUKO Katsuyuki"]
|
46
|
+
p.email = "miyamuko@gmail.com"
|
47
|
+
p.url = "http://win32ole-pp.rubyforge.org/"
|
48
|
+
|
49
|
+
p.description = p.paragraphs_of('README.txt', 3..3).join("\n\n")
|
50
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
51
|
+
|
52
|
+
p.need_zip = true
|
53
|
+
p.need_tar = false
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
#
|
58
|
+
# new task
|
59
|
+
#
|
60
|
+
|
61
|
+
desc 'Uninstall the gem package'
|
62
|
+
task :uninstall_gem do
|
63
|
+
sh "gem.bat uninstall #{RUBYFORGE_PROJECT}"
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
#
|
68
|
+
# overwrite hoe defined tasks for Windows
|
69
|
+
#
|
70
|
+
|
71
|
+
remove_task(:install_gem)
|
72
|
+
desc 'Install the package as a gem'
|
73
|
+
task :install_gem => [:clean, :package] do
|
74
|
+
sh "gem.bat install pkg/*.gem"
|
75
|
+
end
|
76
|
+
|
77
|
+
remove_task(:ridocs)
|
78
|
+
desc "Generate ri locally for testing"
|
79
|
+
task :ridocs => :clean do
|
80
|
+
sh "rdoc.bat --ri -o ri ."
|
81
|
+
end
|
82
|
+
|
83
|
+
remove_task(:publish_docs)
|
84
|
+
desc 'Publish RDoc to RubyForge'
|
85
|
+
task :publish_docs => [:clean, :docs] do
|
86
|
+
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
87
|
+
with_temporary_rename("doc", "html") {
|
88
|
+
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, config["username"]).upload
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# vim: syntax=Ruby
|
data/examples/test.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require "pp"
|
2
|
+
require "win32ole"
|
3
|
+
|
4
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
|
5
|
+
require "win32ole_pp"
|
6
|
+
|
7
|
+
def h(banner)
|
8
|
+
puts
|
9
|
+
puts "-" * 79
|
10
|
+
puts banner
|
11
|
+
puts "-" * 79
|
12
|
+
puts
|
13
|
+
end
|
14
|
+
|
15
|
+
def olep(banner, obj)
|
16
|
+
puts "========== #{banner} (to_s_original, to_s, inspect, p, pp)"
|
17
|
+
puts obj.to_s_original
|
18
|
+
puts obj.to_s
|
19
|
+
puts obj.inspect
|
20
|
+
p obj
|
21
|
+
pp obj
|
22
|
+
end
|
23
|
+
|
24
|
+
def arrp(banner, obj)
|
25
|
+
puts "========== #{banner} (p, pp)"
|
26
|
+
pp obj
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
h("WIN32OLE")
|
31
|
+
|
32
|
+
current_drive = Dir.pwd[/\A([a-z]):/i, 1]
|
33
|
+
fs = WIN32OLE.new("Scripting.FileSystemObject")
|
34
|
+
drives = fs.Drives
|
35
|
+
drive = fs.Drives.Item(current_drive)
|
36
|
+
|
37
|
+
olep("fs", fs)
|
38
|
+
olep("drives", drives)
|
39
|
+
olep("drive", drive)
|
40
|
+
|
41
|
+
|
42
|
+
h("WIN32OLE_METHOD")
|
43
|
+
|
44
|
+
m_drives = fs.ole_method("Drives")
|
45
|
+
m_create_folder = fs.ole_method("CreateFolder")
|
46
|
+
m_delete_folder = fs.ole_method("DeleteFolder")
|
47
|
+
|
48
|
+
olep("m_drives", m_drives)
|
49
|
+
olep("m_create_folder", m_create_folder)
|
50
|
+
olep("m_delete_folder", m_delete_folder)
|
51
|
+
|
52
|
+
|
53
|
+
h("WIN32OLE_PARAM")
|
54
|
+
|
55
|
+
param_create_folder = m_create_folder.params
|
56
|
+
param_delete_folder = m_delete_folder.params
|
57
|
+
|
58
|
+
olep("param_create_folder[0]", param_create_folder[0])
|
59
|
+
arrp("param_create_folder", param_create_folder)
|
60
|
+
|
61
|
+
olep("param_delete_folder[0]", param_delete_folder[0])
|
62
|
+
arrp("param_delete_folder", param_delete_folder)
|
63
|
+
|
64
|
+
|
65
|
+
h("WIN32OLE_TYPE")
|
66
|
+
|
67
|
+
types = WIN32OLE_TYPE.ole_classes("Microsoft Script Control 1.0")
|
68
|
+
types.extend(Enumerable)
|
69
|
+
constants = types.find{|e| e.name =~ /Constants/ }
|
70
|
+
olep("script constants type", constants)
|
71
|
+
|
72
|
+
|
73
|
+
h("WIN32OLE_VARIABLE")
|
74
|
+
|
75
|
+
vars = constants.variables
|
76
|
+
olep("script constants vars[0]", vars[0])
|
77
|
+
arrp("script constants vars", vars)
|
78
|
+
|
79
|
+
|
80
|
+
h("WIN32OLE_EVENT")
|
81
|
+
|
82
|
+
ie = WIN32OLE.new('InternetExplorer.Application')
|
83
|
+
event = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
|
84
|
+
olep("web browser events", event)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module Common
|
4
|
+
|
5
|
+
module Utils
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def address_banner(subname = nil)
|
9
|
+
if subname
|
10
|
+
"%s:0x%x: %s" % [self.class, object_id, subname]
|
11
|
+
else
|
12
|
+
"%s:0x%x" % [self.class, object_id]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module PrettyPrint
|
18
|
+
module_function
|
19
|
+
|
20
|
+
def property_group(q, banner, props, value_block = nil)
|
21
|
+
value_block ||= lambda {|q,v| q.pp v }
|
22
|
+
q.group(2, "#<#{banner}", '>') {
|
23
|
+
q.seplist(props, lambda { q.text "," }) {|prop|
|
24
|
+
k, v = prop
|
25
|
+
q.breakable
|
26
|
+
q.text k
|
27
|
+
q.text '='
|
28
|
+
q.group(1) {
|
29
|
+
q.breakable ''
|
30
|
+
value_block.call(q, v)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module ToStringHook
|
38
|
+
def self.included(klass)
|
39
|
+
klass.class_eval {
|
40
|
+
def self.included(klass)
|
41
|
+
klass.send(:alias_method, :to_s_original, :to_s)
|
42
|
+
klass.send(:alias_method, :to_s, :to_s_ext)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module InitializeHook
|
49
|
+
def self.included(klass)
|
50
|
+
klass.class_eval {
|
51
|
+
def self.included(klass)
|
52
|
+
klass.send(:alias_method, :initialize_original, :initialize)
|
53
|
+
klass.send(:alias_method, :initialize, :initialize_ext)
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE
|
4
|
+
|
5
|
+
module SmartToString
|
6
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
7
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
8
|
+
|
9
|
+
def to_s_ext
|
10
|
+
"#<#{address_banner(ole_obj_help.name)}>"
|
11
|
+
rescue
|
12
|
+
to_s_original
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module PrettyPrint
|
17
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
18
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
19
|
+
|
20
|
+
def pretty_print(q)
|
21
|
+
props = ole_properties.map{|e| [e.name, self[e.name]] rescue nil }.compact
|
22
|
+
property_group(q, address_banner(ole_obj_help.name), props, lambda {|q,v|
|
23
|
+
if ::WIN32OLE === v
|
24
|
+
q.text v.to_s
|
25
|
+
else
|
26
|
+
q.pp v
|
27
|
+
end
|
28
|
+
})
|
29
|
+
end
|
30
|
+
|
31
|
+
def ole_properties
|
32
|
+
ole_get_methods.select{|e| e.params.empty? }.sort_by{|e| e.name }
|
33
|
+
end
|
34
|
+
module_function :ole_properties
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE_EVENT
|
4
|
+
|
5
|
+
module Initializer
|
6
|
+
include WIN32OLE_PP::Extentions::Common::InitializeHook
|
7
|
+
|
8
|
+
def initialize_ext(ole, event = nil)
|
9
|
+
@ole_class = ole.ole_obj_help.name
|
10
|
+
@event = event
|
11
|
+
initialize_original(ole, event)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module SmartToString
|
16
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
17
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
18
|
+
|
19
|
+
def to_s_ext
|
20
|
+
"#<%s: %s.%s>" % [address_banner, @ole_class, @event]
|
21
|
+
rescue
|
22
|
+
to_s_original
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module PrettyPrint
|
27
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
28
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
29
|
+
|
30
|
+
def pretty_print(q)
|
31
|
+
props = [["ole_class", @ole_class], ["event_interface", @event]]
|
32
|
+
property_group(q, address_banner(@event), props)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE_METHOD
|
4
|
+
|
5
|
+
module SmartToString
|
6
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
7
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
8
|
+
|
9
|
+
def to_s_ext
|
10
|
+
"#<%s: %s %s(%s)>" % [address_banner, return_type, name, params.map{|e| e.to_s_simple} * ', ']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module PrettyPrint
|
15
|
+
PROPERTIES = (::WIN32OLE_METHOD.instance_methods - Object.instance_methods).sort
|
16
|
+
|
17
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
18
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
19
|
+
|
20
|
+
def pretty_print(q)
|
21
|
+
property_group(q, address_banner(name), PROPERTIES.map{|e| [e, send(e)] })
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE_PARAM
|
4
|
+
|
5
|
+
module SmartToString
|
6
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
7
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
8
|
+
|
9
|
+
def to_s_ext
|
10
|
+
"#<%s: %s>" % [address_banner, to_s_simple]
|
11
|
+
rescue
|
12
|
+
to_s_original
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s_simple
|
16
|
+
type = []
|
17
|
+
type << "in" if input?
|
18
|
+
type << "out" if output?
|
19
|
+
type << "retval" if retval?
|
20
|
+
type << "optional" if optional?
|
21
|
+
if type.empty?
|
22
|
+
"%s %s" % [ole_type, name]
|
23
|
+
else
|
24
|
+
"[%s] %s %s" % [type * ", ", ole_type, name]
|
25
|
+
end
|
26
|
+
rescue
|
27
|
+
to_s_original
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module PrettyPrint
|
32
|
+
PROPERTIES = (::WIN32OLE_PARAM.instance_methods - Object.instance_methods).sort
|
33
|
+
|
34
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
35
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
36
|
+
|
37
|
+
def pretty_print(q)
|
38
|
+
property_group(q, address_banner(name), PROPERTIES.map{|e| [e, send(e)] })
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE_TYPE
|
4
|
+
|
5
|
+
module SmartToString
|
6
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
7
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
8
|
+
|
9
|
+
def to_s_ext
|
10
|
+
"#<#{address_banner(name)}>"
|
11
|
+
rescue
|
12
|
+
to_s_original
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module PrettyPrint
|
17
|
+
PROPERTIES = (::WIN32OLE_TYPE.instance_methods - Object.instance_methods).sort
|
18
|
+
|
19
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
20
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
21
|
+
|
22
|
+
def pretty_print(q)
|
23
|
+
property_group(q, address_banner(name), PROPERTIES.map{|e| [e, send(e)] })
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module WIN32OLE_PP
|
2
|
+
module Extentions
|
3
|
+
module WIN32OLE_VARIABLE
|
4
|
+
|
5
|
+
module SmartToString
|
6
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
7
|
+
include WIN32OLE_PP::Extentions::Common::ToStringHook
|
8
|
+
|
9
|
+
def to_s_ext
|
10
|
+
"#<%s: %s=%s>" % [address_banner, name, value.inspect]
|
11
|
+
rescue
|
12
|
+
to_s_original
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module PrettyPrint
|
17
|
+
PROPERTIES = (::WIN32OLE_VARIABLE.instance_methods - Object.instance_methods).sort
|
18
|
+
|
19
|
+
include WIN32OLE_PP::Extentions::Common::Utils
|
20
|
+
include WIN32OLE_PP::Extentions::Common::PrettyPrint
|
21
|
+
|
22
|
+
def pretty_print(q)
|
23
|
+
property_group(q, address_banner(name), PROPERTIES.map{|e| [e, send(e)] })
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "win32ole"
|
2
|
+
|
3
|
+
require "win32ole_pp/extentions/common.rb"
|
4
|
+
require "win32ole_pp/extentions/win32ole.rb"
|
5
|
+
require "win32ole_pp/extentions/win32ole_type.rb"
|
6
|
+
require "win32ole_pp/extentions/win32ole_variable.rb"
|
7
|
+
require "win32ole_pp/extentions/win32ole_method.rb"
|
8
|
+
require "win32ole_pp/extentions/win32ole_param.rb"
|
9
|
+
require "win32ole_pp/extentions/win32ole_event.rb"
|
10
|
+
|
11
|
+
module WIN32OLE_PP
|
12
|
+
|
13
|
+
WIN32OLE_CLASSES = [
|
14
|
+
WIN32OLE,
|
15
|
+
WIN32OLE_TYPE,
|
16
|
+
WIN32OLE_VARIABLE,
|
17
|
+
WIN32OLE_METHOD,
|
18
|
+
WIN32OLE_PARAM,
|
19
|
+
WIN32OLE_EVENT,
|
20
|
+
]
|
21
|
+
|
22
|
+
def self.include_extentions(plugin)
|
23
|
+
WIN32OLE_CLASSES.each do |klass|
|
24
|
+
ext = eval("WIN32OLE_PP::Extentions::#{klass.name}::#{plugin}") rescue nil
|
25
|
+
klass.class_eval { include ext } if ext
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
WIN32OLE_PP::include_extentions(:Initializer)
|
@@ -0,0 +1 @@
|
|
1
|
+
WIN32OLE_PP::include_extentions(:PrettyPrint)
|
@@ -0,0 +1 @@
|
|
1
|
+
WIN32OLE_PP::include_extentions(:SmartToString)
|