ruby-ole 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,7 +1,12 @@
1
- == 1.2.4 / ...
1
+ == 1.2.5 / 2008-02-16
2
+
3
+ - Make all tests pass on ruby 1.9.
4
+
5
+ == 1.2.4 / 2008-01-09
2
6
 
3
7
  - Make all tests pass on windows (issue #1).
4
8
  - Make all tests pass on a power pc (running ubuntu).
9
+ - Property set convenience access functions.
5
10
 
6
11
  == 1.2.3 / 2007-12-28
7
12
 
data/Rakefile CHANGED
@@ -37,9 +37,11 @@ end
37
37
 
38
38
  Rake::RDocTask.new do |t|
39
39
  t.rdoc_dir = 'doc'
40
+ t.rdoc_files.include 'lib/**/*.rb'
41
+ t.rdoc_files.include 'README'
40
42
  t.title = "#{PKG_NAME} documentation"
41
43
  t.options += %w[--line-numbers --inline-source --tab-width 2]
42
- t.rdoc_files.include 'lib/**/*.rb'
44
+ t.main = 'README'
43
45
  end
44
46
 
45
47
  spec = Gem::Specification.new do |s|
@@ -62,7 +64,7 @@ spec = Gem::Specification.new do |s|
62
64
 
63
65
  s.has_rdoc = true
64
66
  s.rdoc_options += [
65
- '--main', 'Ole::Storage',
67
+ '--main', 'README',
66
68
  '--title', "#{PKG_NAME} documentation",
67
69
  '--tab-width', '2'
68
70
  ]
@@ -27,7 +27,7 @@
27
27
  # need to implement some more IO functions on RangesIO, like #puts, #print
28
28
  # etc, like AbstractOutputStream from zipfile.
29
29
  #
30
- # TODO
30
+ # = TODO
31
31
  #
32
32
  # - check Dir.mkdir, and File.open, and File.rename, to add in filename
33
33
  # length checks (max 32 / 31 or something).
@@ -121,7 +121,7 @@ module Ole
121
121
  end
122
122
 
123
123
  def load_section_list str
124
- @sections = str.scan(/.{#{Section::SIZE}}/m).map { |str| Section.new str, self }
124
+ @sections = str.scan(/.{#{Section::SIZE}}/m).map { |s| Section.new s, self }
125
125
  end
126
126
  end
127
127
  end
@@ -159,8 +159,8 @@ module Ole
159
159
  # maybe taking it one step further, i'd hide the section thing,
160
160
  # and let you use composite keys, like
161
161
  # propset[4, guid] eg in MAPI, and just propset.doc_author.
162
- section = sections.find do |section|
163
- section.guid == Types::PropertySet::FMTID_SummaryInformation
162
+ section = sections.find do |s|
163
+ s.guid == Types::PropertySet::FMTID_SummaryInformation
164
164
  end
165
165
  return PropertySetSectionProxy.new(dirent, sections.index(section))
166
166
  end
@@ -67,7 +67,7 @@ module Ole # :nodoc:
67
67
  class FormatError < StandardError # :nodoc:
68
68
  end
69
69
 
70
- VERSION = '1.2.4'
70
+ VERSION = '1.2.5'
71
71
 
72
72
  # options used at creation time
73
73
  attr_reader :params
@@ -295,7 +295,7 @@ module Ole # :nodoc:
295
295
 
296
296
  # now finally write the bbat, using a not resizable io.
297
297
  # the mode here will be 'r', which allows write atm.
298
- RangesIO.open(@io, :ranges => ranges) { |io| io.write @bbat.to_s }
298
+ RangesIO.open(@io, :ranges => ranges) { |f| f.write @bbat.to_s }
299
299
 
300
300
  # this is the mbat. pad it out.
301
301
  bbat_chain += [AllocationTable::AVAIL] * [109 - bbat_chain.length, 0].max
@@ -308,7 +308,7 @@ module Ole # :nodoc:
308
308
  q = @bbat.block_size / 4
309
309
  mbat_data += [AllocationTable::AVAIL] *((mbat_data.length / q.to_f).ceil * q - mbat_data.length)
310
310
  ranges = @bbat.ranges((0...num_mbat_blocks).map { |i| @header.mbat_start + i })
311
- RangesIO.open(@io, :ranges => ranges) { |io| io.write mbat_data.pack('V*') }
311
+ RangesIO.open(@io, :ranges => ranges) { |f| f.write mbat_data.pack('V*') }
312
312
  end
313
313
 
314
314
  # now seek back and write the header out
@@ -781,6 +781,10 @@ module Ole # :nodoc:
781
781
  self.size = 0 unless @type == :root
782
782
  @children = []
783
783
  end
784
+
785
+ # to silence warnings. used for tree building at load time
786
+ # only.
787
+ @idx = nil
784
788
  end
785
789
 
786
790
  def open mode='r'
@@ -27,17 +27,21 @@ class File # :nodoc:
27
27
  end
28
28
 
29
29
  class Symbol # :nodoc:
30
- def to_proc
31
- proc { |a| a.send self }
30
+ unless :x.respond_to? :to_proc
31
+ def to_proc
32
+ proc { |a| a.send self }
33
+ end
32
34
  end
33
35
  end
34
36
 
35
37
  module Enumerable # :nodoc:
36
- # 1.9 backport
37
- def group_by
38
- hash = Hash.new { |hash, key| hash[key] = [] }
39
- each { |item| hash[yield(item)] << item }
40
- hash
38
+ unless [].respond_to? :group_by
39
+ # 1.9 backport
40
+ def group_by
41
+ hash = Hash.new { |h, key| h[key] = [] }
42
+ each { |item| hash[yield(item)] << item }
43
+ hash
44
+ end
41
45
  end
42
46
 
43
47
  def sum initial=0
@@ -159,23 +163,21 @@ end
159
163
 
160
164
  # can include File::Constants
161
165
  class IO
162
- BINARY = 0x4 unless defined?(BINARY)
163
-
164
166
  # nabbed from rubinius, and modified
165
167
  def self.parse_mode mode
166
168
  ret = 0
167
169
 
168
- case mode[0]
169
- when ?r; ret |= RDONLY
170
- when ?w; ret |= WRONLY | CREAT | TRUNC
171
- when ?a; ret |= WRONLY | CREAT | APPEND
170
+ case mode[0, 1]
171
+ when 'r'; ret |= RDONLY
172
+ when 'w'; ret |= WRONLY | CREAT | TRUNC
173
+ when 'a'; ret |= WRONLY | CREAT | APPEND
172
174
  else raise ArgumentError, "illegal access mode #{mode}"
173
175
  end
174
176
 
175
177
  (1...mode.length).each do |i|
176
- case mode[i]
177
- when ?+; ret = (ret & ~(RDONLY | WRONLY)) | RDWR
178
- when ?b; ret |= BINARY
178
+ case mode[i, 1]
179
+ when '+'; ret = (ret & ~(RDONLY | WRONLY)) | RDWR
180
+ when 'b'; ret |= Mode::BINARY
179
181
  else raise ArgumentError, "illegal access mode #{mode}"
180
182
  end
181
183
  end
@@ -184,6 +186,18 @@ class IO
184
186
  end
185
187
 
186
188
  class Mode
189
+ # ruby 1.9 defines binary as 0, which isn't very helpful.
190
+ # its 4 in rubinius. no longer using
191
+ #
192
+ # BINARY = 0x4 unless defined?(BINARY)
193
+ #
194
+ # for that reason, have my own constants module here
195
+ module Constants
196
+ include File::Constants
197
+ BINARY = 0x4
198
+ end
199
+
200
+ include Constants
187
201
  NAMES = %w[rdonly wronly rdwr creat trunc append binary]
188
202
 
189
203
  attr_reader :flags
@@ -194,28 +208,28 @@ class IO
194
208
  end
195
209
 
196
210
  def writeable?
197
- #(@flags & IO::RDONLY) == 0
198
- (@flags & 0x3) != IO::RDONLY
211
+ #(@flags & RDONLY) == 0
212
+ (@flags & 0x3) != RDONLY
199
213
  end
200
214
 
201
215
  def readable?
202
- (@flags & IO::WRONLY) == 0
216
+ (@flags & WRONLY) == 0
203
217
  end
204
218
 
205
219
  def truncate?
206
- (@flags & IO::TRUNC) != 0
220
+ (@flags & TRUNC) != 0
207
221
  end
208
222
 
209
223
  def append?
210
- (@flags & IO::APPEND) != 0
224
+ (@flags & APPEND) != 0
211
225
  end
212
226
 
213
227
  def create?
214
- (@flags & IO::CREAT) != 0
228
+ (@flags & CREAT) != 0
215
229
  end
216
230
 
217
231
  def binary?
218
- (@flags & IO::BINARY) != 0
232
+ (@flags & BINARY) != 0
219
233
  end
220
234
 
221
235
  =begin
@@ -230,7 +244,7 @@ class IO
230
244
  =end
231
245
 
232
246
  def inspect
233
- names = NAMES.map { |name| name if (flags & IO.const_get(name.upcase)) != 0 }
247
+ names = NAMES.map { |name| name if (flags & Mode.const_get(name.upcase)) != 0 }
234
248
  names.unshift 'rdonly' if (flags & 0x3) == 0
235
249
  "#<#{self.class} #{names.compact * '|'}>"
236
250
  end
@@ -799,8 +799,8 @@ class ZipFsDirectoryTest < Test::Unit::TestCase
799
799
  d.close
800
800
 
801
801
  zf.dir.open("dir1") {
802
- |d|
803
- assert_equal(['.', '..', "dir11", "file11", "file12"].sort, d.entries.sort)
802
+ |d2|
803
+ assert_equal(['.', '..', "dir11", "file11", "file12"].sort, d2.entries.sort)
804
804
  }
805
805
  }
806
806
  end
@@ -8,7 +8,19 @@ require 'digest/sha1'
8
8
  require 'stringio'
9
9
  require 'tempfile'
10
10
  require 'zlib'
11
- require 'base64'
11
+
12
+ begin
13
+ require 'base64'
14
+ rescue LoadError
15
+ # for 1.9 compatability - for now. not sure what
16
+ # advised migration is
17
+ module Base64
18
+ module_function
19
+ def decode64(str)
20
+ str.unpack("m")[0]
21
+ end
22
+ end
23
+ end
12
24
 
13
25
  #
14
26
  # = TODO
metadata CHANGED
@@ -1,33 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: ruby-ole
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.2.4
7
- date: 2008-01-10 00:00:00 +11:00
8
- summary: Ruby OLE library.
9
- require_paths:
10
- - lib
11
- email: aquasync@gmail.com
12
- homepage: http://code.google.com/p/ruby-ole
13
- rubyforge_project: ruby-ole
14
- description: A library for easy read/write access to OLE compound documents for Ruby.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.2.5
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Charles Lowe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-02-16 00:00:00 +11:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A library for easy read/write access to OLE compound documents for Ruby.
17
+ email: aquasync@gmail.com
18
+ executables:
19
+ - oletool
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
31
24
  files:
32
25
  - Rakefile
33
26
  - ChangeLog
@@ -53,28 +46,42 @@ files:
53
46
  - test/test_word_97.doc
54
47
  - test/oleWithDirs.ole
55
48
  - test/test_SummaryInformation
56
- test_files:
57
- - test/test_property_set.rb
58
- - test/test_ranges_io.rb
59
- - test/test_types.rb
60
- - test/test_mbat.rb
61
- - test/test_support.rb
62
- - test/test_storage.rb
63
- - test/test_filesystem.rb
49
+ has_rdoc: true
50
+ homepage: http://code.google.com/p/ruby-ole
51
+ post_install_message:
64
52
  rdoc_options:
65
53
  - --main
66
- - Ole::Storage
54
+ - README
67
55
  - --title
68
56
  - ruby-ole documentation
69
57
  - --tab-width
70
58
  - "2"
71
- extra_rdoc_files: []
72
-
73
- executables:
74
- - oletool
75
- extensions: []
76
-
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
77
73
  requirements: []
78
74
 
79
- dependencies: []
80
-
75
+ rubyforge_project: ruby-ole
76
+ rubygems_version: 1.0.1
77
+ signing_key:
78
+ specification_version: 2
79
+ summary: Ruby OLE library.
80
+ test_files:
81
+ - test/test_property_set.rb
82
+ - test/test_ranges_io.rb
83
+ - test/test_types.rb
84
+ - test/test_mbat.rb
85
+ - test/test_support.rb
86
+ - test/test_storage.rb
87
+ - test/test_filesystem.rb