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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 954188d945ed7e2571b4f9d3acb4658bf1b8d36a
4
- data.tar.gz: e1b66fb27490fd05f5744efe1f8b1ffb5a78671f
3
+ metadata.gz: ef22b0bed2a470cd73649e4b670b4367f62bf54b
4
+ data.tar.gz: 5c2091a805f0523332f1899311b152895d0480a0
5
5
  SHA512:
6
- metadata.gz: 2e2ede21685e50eb023c0a8ddb7158ef55667832ab46d0a5638793ec563ea19e19821ad3649b057f81c0f7d6d14e133ede37cf18d94cb71c36d3f0745435ead6
7
- data.tar.gz: efae86ba56f3864370475dc346dac71377f47034e60ab88db730ef02b8b2fa0ca90fe6f45e54f0515d722e7d2ce3ed0f26138f444f2e9ec3b91fc6b5a9d6da2e
6
+ metadata.gz: d1aaf455fec43764adeb11cce85fe032e86497233fa7bbbced114960a39c8ba559732d7328e74248270c3af4600f8ccddf47e3d2b32a32b3391d4c2c49a053a4
7
+ data.tar.gz: 1e8a4198727bed9e08ba4e32c2a7081fbf72df7563590e59c91cfd6a74bb4ad3122bee46584c6c09e8778d49a5ffa4d0b5c3fe2360529e04798fc053aea7bf9b
@@ -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
- blob = read(filename)
135
- opt = [::File.basename(filename), ::File.extname(filename)]
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(opt) do |f|
139
- f.write blob
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(opt)
146
- f.write blob
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
@@ -1,3 +1,3 @@
1
1
  module Tori
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -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
- path = f.path
130
+ assert { "text" == f.read }
129
131
  end
130
132
  end
131
133
  end
@@ -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.1
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-10 00:00:00.000000000 Z
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