tori 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tori/backend/s3.rb +7 -11
- data/lib/tori/file.rb +2 -2
- data/lib/tori/version.rb +1 -1
- data/test/test_tori_backend_s3.rb +4 -2
- data/test/test_tori_file.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef22b0bed2a470cd73649e4b670b4367f62bf54b
|
4
|
+
data.tar.gz: 5c2091a805f0523332f1899311b152895d0480a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1aaf455fec43764adeb11cce85fe032e86497233fa7bbbced114960a39c8ba559732d7328e74248270c3af4600f8ccddf47e3d2b32a32b3391d4c2c49a053a4
|
7
|
+
data.tar.gz: 1e8a4198727bed9e08ba4e32c2a7081fbf72df7563590e59c91cfd6a74bb4ad3122bee46584c6c09e8778d49a5ffa4d0b5c3fe2360529e04798fc053aea7bf9b
|
data/lib/tori/backend/s3.rb
CHANGED
@@ -130,22 +130,18 @@ module Tori
|
|
130
130
|
signer.presigned_url(method, bucket: @bucket, key: filename)
|
131
131
|
end
|
132
132
|
|
133
|
-
def open(filename)
|
134
|
-
|
135
|
-
|
133
|
+
def open(filename, opts = {})
|
134
|
+
names = [::File.basename(filename), ::File.extname(filename)]
|
135
|
+
tmpdir = opts.delete(:tmpdir)
|
136
136
|
|
137
137
|
if block_given?
|
138
|
-
Tempfile.create(
|
139
|
-
f.
|
140
|
-
f.fsync
|
141
|
-
f.rewind
|
138
|
+
Tempfile.create(names, tmpdir, opts) do |f|
|
139
|
+
get_object(key: filename, response_target: f.path)
|
142
140
|
yield f
|
143
141
|
end
|
144
142
|
else
|
145
|
-
f = Tempfile.open(
|
146
|
-
f.
|
147
|
-
f.fsync
|
148
|
-
f.rewind
|
143
|
+
f = Tempfile.open(names, tmpdir, opts)
|
144
|
+
get_object(key: filename, response_target: f.path)
|
149
145
|
f
|
150
146
|
end
|
151
147
|
end
|
data/lib/tori/file.rb
CHANGED
@@ -59,9 +59,9 @@ module Tori
|
|
59
59
|
backend.respond_to?(sym, include_private)
|
60
60
|
end
|
61
61
|
|
62
|
-
def method_missing(sym, *args)
|
62
|
+
def method_missing(sym, *args, &block)
|
63
63
|
if respond_to_missing?(sym, false)
|
64
|
-
backend.__send__ sym, name, *args
|
64
|
+
backend.__send__ sym, name, *args, &block
|
65
65
|
else
|
66
66
|
fail NameError, "undefined method `#{sym}' for #{Tori.config.backend.inspect}"
|
67
67
|
end
|
data/lib/tori/version.rb
CHANGED
@@ -115,17 +115,19 @@ class TestToriBackendS3 < Test::Unit::TestCase
|
|
115
115
|
path = nil
|
116
116
|
@backend.open("testfile") do |f|
|
117
117
|
assert_instance_of File, f
|
118
|
+
assert { "text" == f.read }
|
118
119
|
path = f.path
|
119
120
|
end
|
120
121
|
assert { false == File.exist?(path) }
|
121
|
-
f = @backend.open("testfile")
|
122
|
+
f = @backend.open("testfile", tmpdir: "test/tmp")
|
122
123
|
assert_instance_of Tempfile, f
|
124
|
+
assert { f.path =~ %r{test/tmp/.*} }
|
123
125
|
f.close!
|
124
126
|
|
125
127
|
@backend.write("path/to/file", @testfile_path)
|
126
128
|
@backend.open("path/to/file") do |f|
|
127
129
|
assert_instance_of File, f
|
128
|
-
|
130
|
+
assert { "text" == f.read }
|
129
131
|
end
|
130
132
|
end
|
131
133
|
end
|
data/test/test_tori_file.rb
CHANGED
@@ -81,5 +81,6 @@ class TestToriFile < Test::Unit::TestCase
|
|
81
81
|
test "#method_missing" do
|
82
82
|
assert { true == Tori::File.new(nil).respond_to?(:read) }
|
83
83
|
assert_raise(NameError) { Tori::File.new(nil).undefined }
|
84
|
+
assert { [true, Encoding.find('utf-8'), 'test/tmp'] == Tori::File.new(nil).open('rb', external_encoding: 'utf-8'){ |f| [f.binmode?, f.external_encoding, f.path] } }
|
84
85
|
end
|
85
86
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|