ruby-ole 1.2.10.1 → 1.2.11

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.
data/COPYING ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-2010 Charles Lowe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
data/ChangeLog CHANGED
@@ -1,3 +1,16 @@
1
+ == 1.2.11 / 2010-10-17
2
+
3
+ - Add COPYING for packaging (issue #7)
4
+ - Make tests pass using home_run (github #1)
5
+ - Make tests pass using mathn.
6
+ - Updates to suppress warnings on 1.9.2.
7
+ - Split out gemspec into separate file and use for Rakefile.
8
+
9
+ == 1.2.10.1 / 2010-03-19
10
+
11
+ - Avoid use of DateTime#new! (issue #4)
12
+ - Remove warning about unexpected root names (issue #5)
13
+
1
14
  == 1.2.10 / 2009-07-20
2
15
 
3
16
  - Mostly more performance enhancements, significantly faster for
@@ -74,3 +87,4 @@
74
87
  == 1.2.1 / 2007-08-20
75
88
 
76
89
  - Separate out from ruby-msg as new project.
90
+
data/README CHANGED
@@ -102,7 +102,6 @@ See the documentation for each class for more details.
102
102
  * case insensitive open mode would be nice
103
103
  * fix property sets a bit more. see TODO in Ole::Storage::MetaData
104
104
  * ability to zero out padding and unused blocks
105
- * case insensitive mode for ole/file_system?
106
105
  * better tests for mbat support.
107
106
  * further doc cleanup
108
107
  * add in place testing for jruby and ruby1.9
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'rake/rdoctask'
2
3
  require 'rake/testtask'
3
4
  require 'rake/packagetask'
@@ -6,12 +7,7 @@ require 'rake/gempackagetask'
6
7
  require 'rbconfig'
7
8
  require 'fileutils'
8
9
 
9
- $:.unshift 'lib'
10
-
11
- require 'ole/storage'
12
-
13
- PKG_NAME = 'ruby-ole'
14
- PKG_VERSION = Ole::Storage::VERSION
10
+ spec = eval File.read('ruby-ole.gemspec')
15
11
 
16
12
  task :default => [:test]
17
13
 
@@ -44,33 +40,6 @@ Rake::RDocTask.new do |t|
44
40
  t.main = 'README'
45
41
  end
46
42
 
47
- spec = Gem::Specification.new do |s|
48
- s.name = PKG_NAME
49
- s.version = PKG_VERSION
50
- s.summary = %q{Ruby OLE library.}
51
- s.description = %q{A library for easy read/write access to OLE compound documents for Ruby.}
52
- s.authors = ['Charles Lowe']
53
- s.email = %q{aquasync@gmail.com}
54
- s.homepage = %q{http://code.google.com/p/ruby-ole}
55
- s.rubyforge_project = %q{ruby-ole}
56
-
57
- s.executables = ['oletool']
58
- s.files = ['README', 'Rakefile', 'ChangeLog', 'data/propids.yaml']
59
- s.files += FileList['lib/**/*.rb']
60
- s.files += FileList['test/test_*.rb', 'test/*.doc']
61
- s.files += FileList['test/oleWithDirs.ole', 'test/test_SummaryInformation']
62
- s.files += FileList['bin/*']
63
- s.test_files = FileList['test/test_*.rb']
64
-
65
- s.has_rdoc = true
66
- s.extra_rdoc_files = ['README', 'ChangeLog']
67
- s.rdoc_options += [
68
- '--main', 'README',
69
- '--title', "#{PKG_NAME} documentation",
70
- '--tab-width', '2'
71
- ]
72
- end
73
-
74
43
  Rake::GemPackageTask.new(spec) do |t|
75
44
  t.gem_spec = spec
76
45
  t.need_tar = false
@@ -82,7 +51,7 @@ desc 'Run various benchmarks'
82
51
  task :benchmark do
83
52
  require 'benchmark'
84
53
  require 'tempfile'
85
- require 'ole/file_system'
54
+ require 'ole/storage'
86
55
 
87
56
  # should probably add some read benchmarks too
88
57
  def write_benchmark opts={}
@@ -1,5 +1,8 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
 
2
4
  require 'ole/support'
5
+ require 'ole/storage/version'
3
6
 
4
7
  module Ole # :nodoc:
5
8
  Log = Logger.new_with_callstack
@@ -1,2 +1,7 @@
1
- # keeping this file around for now, but will delete later on...
2
- require 'ole/storage/file_system'
1
+ warn <<-end
2
+ Use of ole/file_system is deprecated. Use ole/storage (the file_system api
3
+ is recommended and enabled by default).
4
+ end
5
+
6
+ require 'ole/storage'
7
+
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  # need IO::Mode
2
4
  require 'ole/support'
3
5
 
@@ -122,7 +124,7 @@ class RangesIO
122
124
  # do a binary search throuh @offsets to find the active range.
123
125
  a, c, b = 0, 0, @offsets.length
124
126
  while a < b
125
- c = (a + b) / 2
127
+ c = (a + b).div(2)
126
128
  pivot = @offsets[c]
127
129
  if pos == pivot
128
130
  @active = c
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  require 'tempfile'
2
4
 
3
5
  require 'ole/base'
@@ -21,8 +23,6 @@ module Ole # :nodoc:
21
23
  class FormatError < StandardError # :nodoc:
22
24
  end
23
25
 
24
- VERSION = '1.2.10.1'
25
-
26
26
  # options used at creation time
27
27
  attr_reader :params
28
28
  # The top of the ole tree structure
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  #
2
4
  # = Introduction
3
5
  #
@@ -29,8 +31,6 @@
29
31
  # the filesystem api.
30
32
  #
31
33
 
32
- require 'ole/storage'
33
-
34
34
  module Ole # :nodoc:
35
35
  class Storage
36
36
  def file
@@ -51,7 +51,7 @@ module Ole # :nodoc:
51
51
  next if part.empty?
52
52
  return nil if dirent.file?
53
53
  return nil unless dirent = dirent/part
54
- end
54
+ end
55
55
  dirent
56
56
  end
57
57
 
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  require 'ole/types/property_set'
2
4
 
3
5
  module Ole
@@ -0,0 +1,8 @@
1
+ # encoding: ASCII-8BIT
2
+
3
+ module Ole # :nodoc:
4
+ class Storage
5
+ VERSION = '1.2.11'
6
+ end
7
+ end
8
+
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  #
2
4
  # A file with general support functions used by most files in the project.
3
5
  #
@@ -25,13 +27,15 @@ end
25
27
  class File # :nodoc:
26
28
  # for interface consistency with StringIO etc (rather than adding #stat
27
29
  # to them). used by RangesIO.
28
- def size
29
- stat.size
30
+ unless File.instance_methods.include?(:size)
31
+ def size
32
+ stat.size
33
+ end
30
34
  end
31
35
  end
32
36
 
33
37
  class Symbol # :nodoc:
34
- unless :x.respond_to? :to_proc
38
+ unless Symbol.instance_methods.include?(:to_proc)
35
39
  def to_proc
36
40
  proc { |a| a.send self }
37
41
  end
@@ -1,3 +1,5 @@
1
+ # encoding: ASCII-8BIT
2
+
1
3
  require 'iconv'
2
4
  require 'date'
3
5
 
@@ -16,7 +18,7 @@ module Ole # :nodoc:
16
18
  def self.load str
17
19
  new str
18
20
  end
19
-
21
+
20
22
  def self.dump str
21
23
  str.to_s
22
24
  end
@@ -39,17 +41,17 @@ module Ole # :nodoc:
39
41
  class Lpwstr < String
40
42
  FROM_UTF16 = Iconv.new 'utf-8', 'utf-16le'
41
43
  TO_UTF16 = Iconv.new 'utf-16le', 'utf-8'
42
-
44
+
43
45
  def self.load str
44
46
  new FROM_UTF16.iconv(str).chomp(0.chr)
45
47
  end
46
-
48
+
47
49
  def self.dump str
48
50
  # need to append nulls?
49
51
  data = TO_UTF16.iconv str
50
52
  # not sure if this is the recommended way to do it, but I want to treat
51
53
  # the resulting utf16 data as regular bytes, not characters.
52
- data.force_encoding Encoding::US_ASCII if data.respond_to? :encoding
54
+ data.force_encoding Encoding::ASCII_8BIT if data.respond_to? :encoding
53
55
  data
54
56
  end
55
57
  end
@@ -68,13 +70,12 @@ module Ole # :nodoc:
68
70
  end
69
71
  y = year + 4800
70
72
  m = month - 3
71
- jd = day + (153 * m + 2) / 5 + 365 * y + y / 4 - y / 100 + y / 400 - 32045
73
+ jd = day + (153 * m + 2).div(5) + 365 * y + y.div(4) - y.div(100) + y.div(400) - 32045
72
74
  fr = hour / 24.0 + min / 1440.0 + sec / 86400.0
73
- # avoid new!, as it was actually new0 in older versions of ruby (<=1.8.4?)
74
- # see issue #4. this is equivalent, but doesn't rely on the aliasing used
75
- obj = allocate
76
- obj.send :initialize, jd + fr - 0.5, 0, ITALY
77
- obj
75
+ # new! was actually new0 in older versions of ruby (<=1.8.4?)
76
+ # see issue #4.
77
+ msg = respond_to?(:new!) ? :new! : :new0
78
+ send msg, jd + fr - 0.5, 0, ITALY
78
79
  end
79
80
 
80
81
  def self.from_time time
@@ -100,7 +101,10 @@ module Ole # :nodoc:
100
101
  return nil if low == 0 and high == 0
101
102
  # the + 0.00001 here stinks a bit...
102
103
  seconds = (high * (1 << 32) + low) / 1e7 + 0.00001
103
- EPOCH + seconds / 86400 rescue return
104
+ obj = EPOCH + seconds / 86400 rescue return
105
+ # work around home_run not preserving derived class
106
+ obj = new! obj.jd + obj.day_fraction - 0.5, 0, ITALY unless FileTime === obj
107
+ obj
104
108
  end
105
109
 
106
110
  # +time+ should be able to be either a Time, Date, or DateTime.
@@ -120,7 +124,7 @@ module Ole # :nodoc:
120
124
  high, low = nanoseconds.divmod 1 << 32
121
125
  [low, high].pack 'V2'
122
126
  end
123
-
127
+
124
128
  def inspect
125
129
  "#<#{self.class} #{to_s}>"
126
130
  end
@@ -138,13 +142,13 @@ module Ole # :nodoc:
138
142
  def self.load str
139
143
  new str.to_s
140
144
  end
141
-
145
+
142
146
  def self.dump guid
143
147
  return 0.chr * SIZE unless guid
144
148
  # allow use of plain strings in place of guids.
145
149
  guid['-'] ? parse(guid) : guid
146
150
  end
147
-
151
+
148
152
  def self.parse str
149
153
  vals = str.scan(/[a-f\d]+/i).map(&:hex)
150
154
  if vals.length == 5
@@ -160,7 +164,7 @@ module Ole # :nodoc:
160
164
  def format
161
165
  "%08x-%04x-%04x-%02x%02x-#{'%02x' * 6}" % unpack(PACK)
162
166
  end
163
-
167
+
164
168
  def inspect
165
169
  "#<#{self.class}:{#{format}}>"
166
170
  end
@@ -249,12 +253,12 @@ module Ole # :nodoc:
249
253
  module Constants
250
254
  NAMES.each { |num, name| const_set name, num }
251
255
  end
252
-
256
+
253
257
  def self.load type, str
254
258
  type = NAMES[type] or raise ArgumentError, 'unknown ole type - 0x%04x' % type
255
259
  (CLASS_MAP[type] || Data).load str
256
260
  end
257
-
261
+
258
262
  def self.dump type, variant
259
263
  type = NAMES[type] or raise ArgumentError, 'unknown ole type - 0x%04x' % type
260
264
  (CLASS_MAP[type] || Data).dump variant
@@ -262,7 +266,7 @@ module Ole # :nodoc:
262
266
  end
263
267
 
264
268
  include Variant::Constants
265
-
269
+
266
270
  # deprecated aliases, kept mostly for the benefit of ruby-msg, until
267
271
  # i release a new version.
268
272
  def self.load_guid str
@@ -1,4 +1,5 @@
1
- require 'ole/types'
1
+ # encoding: ASCII-8BIT
2
+
2
3
  require 'yaml'
3
4
 
4
5
  module Ole
@@ -163,3 +164,4 @@ module Ole
163
164
  end
164
165
  end
165
166
  end
167
+
@@ -23,7 +23,7 @@
23
23
  TEST_DIR = File.dirname __FILE__
24
24
  $:.unshift "#{TEST_DIR}/../lib"
25
25
 
26
- require 'ole/storage/file_system'
26
+ require 'ole/storage'
27
27
  require 'test/unit'
28
28
 
29
29
  module ExtraAssertions
@@ -873,7 +873,38 @@ class OleFsDirIteratorTest < Test::Unit::TestCase
873
873
 
874
874
  end
875
875
 
876
+ class OleUnicodeTest < Test::Unit::TestCase
877
+ def setup
878
+ @io = StringIO.new ''
879
+ end
880
+
881
+ def test_unicode
882
+ # in ruby-1.8, encoding is assumed to be UTF-8 (and converted with iconv).
883
+ # in ruby-1.9, UTF-8 should work also, but probably shouldn't be using fixed
884
+ # TO_UTF16 iconv for other encodings.
885
+ resume = "R\xc3\xa9sum\xc3\xa9"
886
+ resume.force_encoding Encoding::UTF_8 if resume.respond_to? :encoding
887
+ Ole::Storage.open @io do |ole|
888
+ ole.file.open(resume, 'w') { |f| f.write 'Skills: writing bad unit tests' }
889
+ end
890
+ Ole::Storage.open @io do |ole|
891
+ assert_equal ['.', '..', resume], ole.dir.entries('.')
892
+ # use internal api to verify utf16 encoding
893
+ assert_equal "R\x00\xE9\x00s\x00u\x00m\x00\xE9\x00", ole.root.children[0].name_utf16[0, 6 * 2]
894
+ # FIXME: there is a bug in ruby-1.9 (at least in p376), which makes encoded
895
+ # strings useless as hash keys. identical bytes, identical encodings, identical
896
+ # according to #==, but different hash.
897
+ temp = File.expand_path("/#{resume}").split('/').last
898
+ if resume == temp and resume.hash != temp.hash
899
+ warn 'skipping assertion due to broken String#hash'
900
+ else
901
+ assert_equal 'Skills', ole.file.read(resume).split(': ', 2).first
902
+ end
903
+ end
904
+ end
905
+ end
876
906
 
877
907
  # Copyright (C) 2002, 2003 Thomas Sondergaard
878
908
  # rubyzip is free software; you can redistribute it and/or
879
909
  # modify it under the terms of the ruby license.
910
+
@@ -3,8 +3,7 @@
3
3
  $: << File.dirname(__FILE__) + '/../lib'
4
4
 
5
5
  require 'test/unit'
6
- require 'ole/storage/base'
7
- require 'ole/storage/file_system'
6
+ require 'ole/storage'
8
7
  require 'tempfile'
9
8
 
10
9
  class TestWriteMbat < Test::Unit::TestCase
@@ -3,9 +3,7 @@
3
3
  $: << File.dirname(__FILE__) + '/../lib'
4
4
 
5
5
  require 'test/unit'
6
- require 'ole/storage/base'
7
- require 'ole/storage/meta_data'
8
- require 'ole/storage/file_system'
6
+ require 'ole/storage'
9
7
 
10
8
  class TestMetaData < Test::Unit::TestCase
11
9
  def test_meta_data
@@ -3,7 +3,7 @@
3
3
  $: << File.dirname(__FILE__) + '/../lib'
4
4
 
5
5
  require 'test/unit'
6
- require 'ole/types/property_set'
6
+ require 'ole/types'
7
7
 
8
8
  class TestPropertySet < Test::Unit::TestCase
9
9
  include Ole::Types
@@ -3,7 +3,7 @@
3
3
  $: << File.dirname(__FILE__) + '/../lib'
4
4
 
5
5
  require 'test/unit'
6
- require 'ole/types/base'
6
+ require 'ole/types'
7
7
 
8
8
  class TestTypes < Test::Unit::TestCase
9
9
  include Ole::Types
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ole
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 2
8
- - 10
9
- - 1
10
- version: 1.2.10.1
9
+ - 11
10
+ version: 1.2.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Charles Lowe
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-03-19 00:00:00 -04:00
18
+ date: 2010-10-17 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -30,33 +30,31 @@ extra_rdoc_files:
30
30
  - ChangeLog
31
31
  files:
32
32
  - README
33
+ - COPYING
33
34
  - Rakefile
34
35
  - ChangeLog
35
36
  - data/propids.yaml
36
37
  - bin/oletool
37
- - lib/ole/types.rb
38
38
  - lib/ole/storage.rb
39
+ - lib/ole/storage/file_system.rb
40
+ - lib/ole/storage/base.rb
41
+ - lib/ole/storage/meta_data.rb
42
+ - lib/ole/storage/version.rb
43
+ - lib/ole/types/property_set.rb
44
+ - lib/ole/types/base.rb
45
+ - lib/ole/types.rb
39
46
  - lib/ole/support.rb
47
+ - lib/ole/file_system.rb
40
48
  - lib/ole/base.rb
41
49
  - lib/ole/ranges_io.rb
42
- - lib/ole/file_system.rb
43
- - lib/ole/types/property_set.rb
44
- - lib/ole/types/base.rb
45
- - lib/ole/storage/meta_data.rb
46
- - lib/ole/storage/base.rb
47
- - lib/ole/storage/file_system.rb
48
- - test/test_ranges_io.rb
50
+ - test/test_property_set.rb
49
51
  - test/test_storage.rb
50
- - test/test_filesystem.rb
51
- - test/test_support.rb
52
52
  - test/test_mbat.rb
53
- - test/test_types.rb
54
53
  - test/test_meta_data.rb
55
- - test/test_property_set.rb
56
- - test/test_word_6.doc
57
- - test/test_word_97.doc
58
- - test/test_word_95.doc
59
- - test/test.doc
54
+ - test/test_support.rb
55
+ - test/test_types.rb
56
+ - test/test_ranges_io.rb
57
+ - test/test_filesystem.rb
60
58
  - test/oleWithDirs.ole
61
59
  - test/test_SummaryInformation
62
60
  has_rdoc: true
@@ -74,32 +72,36 @@ rdoc_options:
74
72
  require_paths:
75
73
  - lib
76
74
  required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
77
76
  requirements:
78
77
  - - ">="
79
78
  - !ruby/object:Gem::Version
79
+ hash: 3
80
80
  segments:
81
81
  - 0
82
82
  version: "0"
83
83
  required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
84
85
  requirements:
85
86
  - - ">="
86
87
  - !ruby/object:Gem::Version
88
+ hash: 3
87
89
  segments:
88
90
  - 0
89
91
  version: "0"
90
92
  requirements: []
91
93
 
92
94
  rubyforge_project: ruby-ole
93
- rubygems_version: 1.3.6
95
+ rubygems_version: 1.3.7
94
96
  signing_key:
95
97
  specification_version: 3
96
98
  summary: Ruby OLE library.
97
99
  test_files:
98
- - test/test_ranges_io.rb
100
+ - test/test_property_set.rb
99
101
  - test/test_storage.rb
100
- - test/test_filesystem.rb
101
- - test/test_support.rb
102
102
  - test/test_mbat.rb
103
- - test/test_types.rb
104
103
  - test/test_meta_data.rb
105
- - test/test_property_set.rb
104
+ - test/test_support.rb
105
+ - test/test_types.rb
106
+ - test/test_ranges_io.rb
107
+ - test/test_filesystem.rb
Binary file
Binary file
Binary file
Binary file