Skip to content

Commit

Permalink
Minor cleanups for new release.
Browse files Browse the repository at this point in the history
git-svn-id: https://ruby-ole.googlecode.com/svn/trunk@27 f297d60c-f930-0410-b1c6-9ffd80c20a0c
  • Loading branch information
aquasync committed Dec 28, 2007
1 parent 54ad915 commit da55a2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
13 changes: 1 addition & 12 deletions README
Expand Up @@ -6,7 +6,7 @@
- more storage tests
* make property sets easier to use, adding in some smarts about the
prop ids, and naming the properties in known sections.
see ideas in other file
see ideas in other data/propids
* audit unpack strings to fix endianness issues.
* fix mode strings - like truncate when using 'w+', supporting append
'a+' modes etc.
Expand All @@ -21,14 +21,3 @@
* supposedly vba does something weird to ole files. test that.
* properly credit all external sources.

idea for fixing mode string stuff. use mode string class to make this work:

Ole::Storage.open('file.doc', 'rb') { |ole| ... } # standard for read
Ole::Storage.open('file.doc', 'rb+') { |ole| ... } # standard for write
Ole::Storage.open('file.doc', 'r') { |ole| ... } # warns due to lack of binary
Ole::Storage.open('file.doc', 'wb') { |ole| ... } # warns due to lack of read. need to read for bat migration, even if only writing

and further, extend it to RangesIO, such that it automatically calls truncate
for 'w' modes, automatically seeks for 'a' modes, etc etc. as for binary, it
will be ignored.

2 changes: 2 additions & 0 deletions lib/ole/support.rb
Expand Up @@ -218,6 +218,7 @@ def binary?
(@flags & IO::BINARY) != 0
end

=begin
# revisit this
def apply io
if truncate?
Expand All @@ -226,6 +227,7 @@ def apply io
io.seek IO::SEEK_END, 0
end
end
=end

def inspect
names = NAMES.map { |name| name if (flags & IO.const_get(name.upcase)) != 0 }
Expand Down
10 changes: 10 additions & 0 deletions test/test_support.rb
Expand Up @@ -55,6 +55,10 @@ def test_parse
assert_equal true, mode('r+bbbbb').binary?
assert_equal false, mode('r+').binary?

assert_equal false, mode('r+').create?
assert_equal false, mode('r').create?
assert_equal true, mode('wb').create?

assert_equal true, mode('w').truncate?
assert_equal false, mode('r').truncate?
assert_equal false, mode('r+').truncate?
Expand All @@ -72,6 +76,12 @@ def test_invalid
assert_raises(ArgumentError) { mode 'rba' }
assert_raises(ArgumentError) { mode '+r' }
end

def test_inspect
assert_equal '#<IO::Mode rdonly>', IO::Mode.new('r').inspect
assert_equal '#<IO::Mode rdwr|creat|trunc|binary>', IO::Mode.new('wb+').inspect
assert_equal '#<IO::Mode wronly|creat|append>', IO::Mode.new('a').inspect
end
end

class TestRecursivelyEnumerable < Test::Unit::TestCase
Expand Down

0 comments on commit da55a2e

Please sign in to comment.