external 0.3.0 → 0.3.1
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/History +5 -0
- data/lib/external/base.rb +8 -3
- data/lib/external/utils.rb +21 -13
- data/lib/external_archive.rb +10 -4
- metadata +9 -7
data/History
CHANGED
data/lib/external/base.rb
CHANGED
@@ -24,9 +24,14 @@ module External
|
|
24
24
|
# used (in which case mode gets ignored as Tempfiles always open
|
25
25
|
# in 'r+' mode).
|
26
26
|
def open(path=nil, mode="rb", *argv)
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
begin
|
28
|
+
io = path == nil ? nil : File.open(path, mode)
|
29
|
+
base = new(io, *argv)
|
30
|
+
rescue(Errno::ENOENT)
|
31
|
+
io.close if io
|
32
|
+
raise
|
33
|
+
end
|
34
|
+
|
30
35
|
if block_given?
|
31
36
|
begin
|
32
37
|
yield(base)
|
data/lib/external/utils.rb
CHANGED
@@ -13,15 +13,15 @@ module External
|
|
13
13
|
# Nested classes have '::' replaced by '_'. Thus to add support
|
14
14
|
# for Some::Unknown::IO, extend External::IO as below:
|
15
15
|
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
16
|
+
# module External::IO
|
17
|
+
# def some_unknown_io_mode(io)
|
18
|
+
# ...
|
19
|
+
# end
|
20
20
|
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
21
|
+
# def some_unknown_io_length(io)
|
22
|
+
# ...
|
23
|
+
# end
|
24
|
+
# end
|
25
25
|
#
|
26
26
|
# See stringio_mode and stringio_length for more details.
|
27
27
|
def try_handle(io, method)
|
@@ -78,9 +78,9 @@ module External
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
# Returns an array of bools determining if the input
|
81
|
+
# Returns an array of bools determining if the input Io
|
82
82
|
# is readable and writable.
|
83
|
-
def
|
83
|
+
def io_mode(io)
|
84
84
|
begin
|
85
85
|
dup = io.dup
|
86
86
|
|
@@ -104,10 +104,18 @@ module External
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
# Returns the length of the input
|
108
|
-
def
|
107
|
+
# Returns the length of the input IO
|
108
|
+
def io_length(io)
|
109
109
|
io.fsync
|
110
|
-
|
110
|
+
io.stat.size
|
111
|
+
end
|
112
|
+
|
113
|
+
def file_mode(io)
|
114
|
+
io_mode(io)
|
115
|
+
end
|
116
|
+
|
117
|
+
def file_length(io)
|
118
|
+
io_length(io)
|
111
119
|
end
|
112
120
|
|
113
121
|
# Returns an array of bools determining if the input Tempfile
|
data/lib/external_archive.rb
CHANGED
@@ -76,12 +76,18 @@ class ExternalArchive < External::Base
|
|
76
76
|
FileUtils.touch(index) unless File.exists?(index)
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
begin
|
80
|
+
io = path == nil ? nil : File.open(path, mode)
|
81
|
+
io_index = case index
|
82
|
+
when Array, ExternalIndex then index
|
83
|
+
else ExternalIndex.open(index, 'r+', :format => 'II')
|
84
|
+
end
|
85
|
+
rescue(Errno::ENOENT)
|
86
|
+
io.close if io
|
87
|
+
io_index.close if io_index
|
88
|
+
raise
|
82
89
|
end
|
83
90
|
|
84
|
-
io = path == nil ? nil : File.open(path, mode)
|
85
91
|
extarc = new(io, io_index)
|
86
92
|
|
87
93
|
# reindex if necessary
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: external
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Chiang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-06-29 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.18.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mspec
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.5
|
33
|
+
version: "1.5"
|
34
34
|
version:
|
35
35
|
description:
|
36
36
|
email: simon.a.chiang@gmail.com
|
@@ -60,6 +60,8 @@ files:
|
|
60
60
|
- History
|
61
61
|
has_rdoc: true
|
62
62
|
homepage: http://rubyforge.org/projects/external/
|
63
|
+
licenses: []
|
64
|
+
|
63
65
|
post_install_message:
|
64
66
|
rdoc_options: []
|
65
67
|
|
@@ -80,9 +82,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
82
|
requirements: []
|
81
83
|
|
82
84
|
rubyforge_project: external
|
83
|
-
rubygems_version: 1.
|
85
|
+
rubygems_version: 1.3.4
|
84
86
|
signing_key:
|
85
|
-
specification_version:
|
87
|
+
specification_version: 3
|
86
88
|
summary: array-like access to external data files
|
87
89
|
test_files: []
|
88
90
|
|