keeguon-ruby-ole 1.2.11.7
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.
- checksums.yaml +7 -0
- data/COPYING +20 -0
- data/ChangeLog +140 -0
- data/README +116 -0
- data/Rakefile +91 -0
- data/bin/oletool +40 -0
- data/lib/ole/base.rb +10 -0
- data/lib/ole/file_system.rb +7 -0
- data/lib/ole/ranges_io.rb +267 -0
- data/lib/ole/storage.rb +3 -0
- data/lib/ole/storage/base.rb +945 -0
- data/lib/ole/storage/file_system.rb +394 -0
- data/lib/ole/storage/meta_data.rb +150 -0
- data/lib/ole/storage/version.rb +8 -0
- data/lib/ole/support.rb +248 -0
- data/lib/ole/types.rb +2 -0
- data/lib/ole/types/base.rb +314 -0
- data/lib/ole/types/property_set.rb +202 -0
- data/ruby-ole.gemspec +32 -0
- data/test/oleWithDirs.ole +0 -0
- data/test/test.doc +0 -0
- data/test/test_SummaryInformation +0 -0
- data/test/test_filesystem.rb +932 -0
- data/test/test_mbat.rb +40 -0
- data/test/test_meta_data.rb +43 -0
- data/test/test_property_set.rb +40 -0
- data/test/test_ranges_io.rb +113 -0
- data/test/test_storage.rb +221 -0
- data/test/test_support.rb +155 -0
- data/test/test_types.rb +68 -0
- data/test/test_word_6.doc +0 -0
- data/test/test_word_95.doc +0 -0
- data/test/test_word_97.doc +0 -0
- metadata +92 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
|
3
|
+
$: << File.dirname(__FILE__) + '/../lib'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
require 'ole/support'
|
7
|
+
|
8
|
+
class TestSupport < Test::Unit::TestCase
|
9
|
+
TEST_DIR = File.dirname __FILE__
|
10
|
+
|
11
|
+
def test_file
|
12
|
+
assert_equal 4096, open("#{TEST_DIR}/oleWithDirs.ole") { |f| f.size }
|
13
|
+
# point is to have same interface as:
|
14
|
+
assert_equal 4096, StringIO.open(open("#{TEST_DIR}/oleWithDirs.ole", 'rb', &:read)).size
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_enumerable
|
18
|
+
expect = {0 => [2, 4], 1 => [1, 3]}
|
19
|
+
assert_equal expect, [1, 2, 3, 4].group_by { |i| i & 1 }
|
20
|
+
assert_equal 10, [1, 2, 3, 4].sum
|
21
|
+
assert_equal %w[1 2 3 4], [1, 2, 3, 4].map(&:to_s)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_logger
|
25
|
+
io = StringIO.new
|
26
|
+
log = Logger.new_with_callstack io
|
27
|
+
log.warn 'test'
|
28
|
+
expect = %r{^\[\d\d:\d\d:\d\d .*?test_support\.rb:\d+:test_logger\]\nWARN test$}
|
29
|
+
assert_match expect, io.string.chomp
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_io
|
33
|
+
str = 'a' * 5000 + 'b'
|
34
|
+
src, dst = StringIO.new(str), StringIO.new
|
35
|
+
IO.copy src, dst
|
36
|
+
assert_equal str, dst.string
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_symbol
|
40
|
+
array = (1..10).to_a
|
41
|
+
assert_equal 55, array.inject(&:+)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class TestIOMode < Test::Unit::TestCase
|
46
|
+
def mode s
|
47
|
+
Ole::IOMode.new s
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_parse
|
51
|
+
assert_equal true, mode('r+bbbbb').binary?
|
52
|
+
assert_equal false, mode('r+').binary?
|
53
|
+
|
54
|
+
assert_equal false, mode('r+').create?
|
55
|
+
assert_equal false, mode('r').create?
|
56
|
+
assert_equal true, mode('wb').create?
|
57
|
+
|
58
|
+
assert_equal true, mode('w').truncate?
|
59
|
+
assert_equal false, mode('r').truncate?
|
60
|
+
assert_equal false, mode('r+').truncate?
|
61
|
+
|
62
|
+
assert_equal true, mode('r+').readable?
|
63
|
+
assert_equal true, mode('r+').writeable?
|
64
|
+
assert_equal false, mode('r').writeable?
|
65
|
+
assert_equal false, mode('w').readable?
|
66
|
+
|
67
|
+
assert_equal true, mode('a').append?
|
68
|
+
assert_equal false, mode('w+').append?
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_invalid
|
72
|
+
assert_raises(ArgumentError) { mode 'rba' }
|
73
|
+
assert_raises(ArgumentError) { mode '+r' }
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_inspect
|
77
|
+
assert_equal '#<Ole::IOMode rdonly>', mode('r').inspect
|
78
|
+
assert_equal '#<Ole::IOMode rdwr|creat|trunc|binary>', mode('wb+').inspect
|
79
|
+
assert_equal '#<Ole::IOMode wronly|creat|append>', mode('a').inspect
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class TestRecursivelyEnumerable < Test::Unit::TestCase
|
84
|
+
class Container
|
85
|
+
include RecursivelyEnumerable
|
86
|
+
|
87
|
+
def initialize *children
|
88
|
+
@children = children
|
89
|
+
end
|
90
|
+
|
91
|
+
def each_child(&block)
|
92
|
+
@children.each(&block)
|
93
|
+
end
|
94
|
+
|
95
|
+
def inspect
|
96
|
+
"#<Container>"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def setup
|
101
|
+
@root = Container.new(
|
102
|
+
Container.new(1),
|
103
|
+
Container.new(2,
|
104
|
+
Container.new(
|
105
|
+
Container.new(3)
|
106
|
+
)
|
107
|
+
),
|
108
|
+
4,
|
109
|
+
Container.new()
|
110
|
+
)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_find
|
114
|
+
i = 0
|
115
|
+
found = @root.recursive.find do |obj|
|
116
|
+
i += 1
|
117
|
+
obj == 4
|
118
|
+
end
|
119
|
+
assert_equal found, 4
|
120
|
+
assert_equal 9, i
|
121
|
+
|
122
|
+
i = 0
|
123
|
+
found = @root.recursive(:breadth_first).find do |obj|
|
124
|
+
i += 1
|
125
|
+
obj == 4
|
126
|
+
end
|
127
|
+
assert_equal found, 4
|
128
|
+
assert_equal 4, i
|
129
|
+
|
130
|
+
# this is to make sure we hit the breadth first child cache
|
131
|
+
i = 0
|
132
|
+
found = @root.recursive(:breadth_first).find do |obj|
|
133
|
+
i += 1
|
134
|
+
obj == 3
|
135
|
+
end
|
136
|
+
assert_equal found, 3
|
137
|
+
assert_equal 10, i
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_to_tree
|
141
|
+
assert_equal <<-'end', @root.to_tree
|
142
|
+
- #<Container>
|
143
|
+
|- #<Container>
|
144
|
+
| \- 1
|
145
|
+
|- #<Container>
|
146
|
+
| |- 2
|
147
|
+
| \- #<Container>
|
148
|
+
| \- #<Container>
|
149
|
+
| \- 3
|
150
|
+
|- 4
|
151
|
+
\- #<Container>
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
data/test/test_types.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#! /usr/bin/ruby
|
2
|
+
# encoding: ASCII-8BIT
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__) + '/../lib'
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'ole/types'
|
8
|
+
|
9
|
+
class TestTypes < Test::Unit::TestCase
|
10
|
+
include Ole::Types
|
11
|
+
|
12
|
+
def test_lpwstr
|
13
|
+
assert_equal "t\000e\000s\000t\000", Lpwstr.dump('test')
|
14
|
+
str = Lpwstr.load "t\000e\000s\000t\000"
|
15
|
+
assert_equal 'test', str
|
16
|
+
assert_equal Lpwstr, str.class
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_lpstr
|
20
|
+
# no null byte? probably wrong
|
21
|
+
assert_equal 'test', Lpstr.dump('test')
|
22
|
+
assert_equal 'test', Lpstr.load("test\000")
|
23
|
+
end
|
24
|
+
|
25
|
+
# in actual fact the same code path would be used for systime i expect
|
26
|
+
def test_filetime
|
27
|
+
# for saving, we can use Date, Time, or DateTime.
|
28
|
+
assert_equal "\000\000\260\3077-\307\001", FileTime.dump(Time.gm(2007, 1, 1))
|
29
|
+
time = FileTime.load "\000\000\260\3077-\307\001"
|
30
|
+
assert_equal FileTime, time.class
|
31
|
+
assert_equal '2007-01-01T00:00:00+00:00', time.to_s
|
32
|
+
# note that if we'd used Time.local, instead of gm, we'd get a different value. eg
|
33
|
+
assert_equal "\000\370\331\336\r-\307\001", FileTime.dump(DateTime.parse('2007-01-01 00:00 +0500'))
|
34
|
+
# note that it still loads up as GMT, because there's no associated time zone.
|
35
|
+
# essentially, i'm storing and loading times as GMT. maybe i should add in conversion to local time
|
36
|
+
# zone when loading
|
37
|
+
assert_equal '2006-12-31T19:00:00+00:00', FileTime.load("\000\370\331\336\r-\307\001").to_s
|
38
|
+
# test loading a bogus time
|
39
|
+
assert_equal nil, FileTime.load(0.chr * 8)
|
40
|
+
# this used to be counted as an "unlikely time", and discarded. that has been removed
|
41
|
+
assert_equal '1700-01-01T00:00:00+00:00', FileTime.load(FileTime.dump(Date.new(1700, 1, 1))).to_s
|
42
|
+
assert_equal '#<Ole::Types::FileTime 2006-12-31T19:00:00+00:00>', FileTime.load("\000\370\331\336\r-\307\001").inspect
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_guid
|
46
|
+
assert_equal "\x29\x03\x02\x00\x80\x08\x07\x40\xc0\x01\x12\x34\x56\x78\x90\x46",
|
47
|
+
Clsid.dump('{00020329-0880-4007-c001-123456789046}')
|
48
|
+
assert_equal '#<Ole::Types::Clsid:{00020329-0880-4007-c001-123456789046}>',
|
49
|
+
Clsid.load("\x29\x03\x02\x00\x80\x08\x07\x40\xc0\x01\x12\x34\x56\x78\x90\x46").inspect
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_variant
|
53
|
+
assert_equal "\x29\x03\x02\x00\x80\x08\x07\x40\xc0\x01\x12\x34\x56\x78\x90\x46",
|
54
|
+
Variant.dump(VT_CLSID, '{00020329-0880-4007-c001-123456789046}')
|
55
|
+
assert_equal "2006-12-31T19:00:00+00:00", Variant.load(VT_FILETIME, "\000\370\331\336\r-\307\001").to_s
|
56
|
+
data = Variant.load VT_DATE, 'blahblah'
|
57
|
+
assert_equal Data, data.class
|
58
|
+
assert_equal 'blahblah', Variant.dump(VT_DATE, 'blahblah')
|
59
|
+
end
|
60
|
+
|
61
|
+
# purely for the purposes of coverage, i'll test these old aliases:
|
62
|
+
def test_deprecated_aliases
|
63
|
+
assert_equal '#<Ole::Types::Clsid:{00020329-0880-4007-c001-123456789046}>',
|
64
|
+
Ole::Types.load_guid("\x29\x03\x02\x00\x80\x08\x07\x40\xc0\x01\x12\x34\x56\x78\x90\x46").inspect
|
65
|
+
assert_equal '2006-12-31T19:00:00+00:00', Ole::Types.load_time("\000\370\331\336\r-\307\001").to_s
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: keeguon-ruby-ole
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.11.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Charles Lowe
|
8
|
+
- Félix Bellanger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A library for easy read/write access to OLE compound documents for Ruby.
|
15
|
+
email: aquasync@gmail.com
|
16
|
+
executables:
|
17
|
+
- oletool
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files:
|
20
|
+
- README
|
21
|
+
- ChangeLog
|
22
|
+
files:
|
23
|
+
- README
|
24
|
+
- COPYING
|
25
|
+
- Rakefile
|
26
|
+
- ChangeLog
|
27
|
+
- ruby-ole.gemspec
|
28
|
+
- bin/oletool
|
29
|
+
- lib/ole/base.rb
|
30
|
+
- lib/ole/file_system.rb
|
31
|
+
- lib/ole/ranges_io.rb
|
32
|
+
- lib/ole/storage/base.rb
|
33
|
+
- lib/ole/storage/file_system.rb
|
34
|
+
- lib/ole/storage/meta_data.rb
|
35
|
+
- lib/ole/storage/version.rb
|
36
|
+
- lib/ole/storage.rb
|
37
|
+
- lib/ole/support.rb
|
38
|
+
- lib/ole/types/base.rb
|
39
|
+
- lib/ole/types/property_set.rb
|
40
|
+
- lib/ole/types.rb
|
41
|
+
- test/test_filesystem.rb
|
42
|
+
- test/test_mbat.rb
|
43
|
+
- test/test_meta_data.rb
|
44
|
+
- test/test_property_set.rb
|
45
|
+
- test/test_ranges_io.rb
|
46
|
+
- test/test_storage.rb
|
47
|
+
- test/test_support.rb
|
48
|
+
- test/test_types.rb
|
49
|
+
- test/test.doc
|
50
|
+
- test/test_word_6.doc
|
51
|
+
- test/test_word_95.doc
|
52
|
+
- test/test_word_97.doc
|
53
|
+
- test/oleWithDirs.ole
|
54
|
+
- test/test_SummaryInformation
|
55
|
+
homepage: http://code.google.com/p/ruby-ole
|
56
|
+
licenses: []
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --main
|
61
|
+
- README
|
62
|
+
- --title
|
63
|
+
- keeguon-ruby-ole documentation
|
64
|
+
- --tab-width
|
65
|
+
- '2'
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project: ruby-ole
|
80
|
+
rubygems_version: 2.0.3
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Ruby OLE library.
|
84
|
+
test_files:
|
85
|
+
- test/test_filesystem.rb
|
86
|
+
- test/test_mbat.rb
|
87
|
+
- test/test_meta_data.rb
|
88
|
+
- test/test_property_set.rb
|
89
|
+
- test/test_ranges_io.rb
|
90
|
+
- test/test_storage.rb
|
91
|
+
- test/test_support.rb
|
92
|
+
- test/test_types.rb
|