tori 0.6.2 → 0.6.3

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: ef22b0bed2a470cd73649e4b670b4367f62bf54b
4
- data.tar.gz: 5c2091a805f0523332f1899311b152895d0480a0
3
+ metadata.gz: 0860a5b2a95c5bd92c5064c468688493ae765511
4
+ data.tar.gz: 97a4aced93b66300b731705a45df60fbb1b1be1e
5
5
  SHA512:
6
- metadata.gz: d1aaf455fec43764adeb11cce85fe032e86497233fa7bbbced114960a39c8ba559732d7328e74248270c3af4600f8ccddf47e3d2b32a32b3391d4c2c49a053a4
7
- data.tar.gz: 1e8a4198727bed9e08ba4e32c2a7081fbf72df7563590e59c91cfd6a74bb4ad3122bee46584c6c09e8778d49a5ffa4d0b5c3fe2360529e04798fc053aea7bf9b
6
+ metadata.gz: f606846b2e54e652f5fbba5143e8823ad798cc20c8870b6cdcaaba1f68b8001d22535d9824d9e2d327d09c1f8a35a20c83c3abd5b5409595b1b105c750b9ddec
7
+ data.tar.gz: 10bf3e48938ae58055cdf189865502b18a4158c1d53a9059324b64a59a9335ab485e0cd8c772e93436bd47d8e03a25e9823a17913565d46ec644a00ffd980012
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.6
4
- - 2.2.2
3
+ - 2.1
4
+ - 2.2
5
5
  notifications:
6
6
  email: false
@@ -19,6 +19,8 @@ module Tori
19
19
  class ExistError < StandardError
20
20
  end
21
21
 
22
+ attr_accessor :backends
23
+
22
24
  def initialize(*backends)
23
25
  @backends = backends
24
26
  end
@@ -97,19 +97,19 @@ module Tori
97
97
  end
98
98
  alias exists? exist?
99
99
 
100
- def read(filename)
101
- body(filename).read
100
+ def read(filename, **opts)
101
+ body(filename, **opts).read
102
102
  end
103
103
 
104
- def get(filename)
105
- get_object(key: filename)
104
+ def body(filename, **opts)
105
+ get(filename, **opts)[:body]
106
106
  end
107
107
 
108
- def body(filename)
109
- get(filename)[:body]
108
+ def get(filename, **opts)
109
+ get_object(key: filename, **opts)
110
110
  end
111
111
 
112
- def put(filename, body, opts={})
112
+ def put(filename, body, **opts)
113
113
  put_object key: filename, body: body, **opts
114
114
  end
115
115
 
data/lib/tori/file.rb CHANGED
@@ -28,6 +28,7 @@ module Tori
28
28
  end
29
29
  alias to_s name
30
30
 
31
+ attr_reader :from
31
32
  def from?
32
33
  !@from.nil?
33
34
  end
@@ -53,6 +54,10 @@ module Tori
53
54
  @backend || Tori.config.backend
54
55
  end
55
56
 
57
+ def backend=(new_backend)
58
+ @backend = new_backend
59
+ end
60
+
56
61
  private
57
62
 
58
63
  def respond_to_missing?(sym, include_private)
data/lib/tori/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tori
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
@@ -93,6 +93,7 @@ class TestToriBackendS3 < Test::Unit::TestCase
93
93
 
94
94
  test "#read" do
95
95
  assert_equal "text", @backend.read("testfile")
96
+ assert_raise(Aws::S3::Errors::NoSuchKey) { @backend.read("testfile", key: "nothing") }
96
97
  end
97
98
 
98
99
  test "#exists?" do
@@ -42,6 +42,10 @@ class TestToriFile < Test::Unit::TestCase
42
42
  assert { false == Tori::File.new("nothing_file").exist? }
43
43
  end
44
44
 
45
+ test "#from" do
46
+ assert { __FILE__ == Tori::File.new(__FILE__, from: From.new).from }
47
+ end
48
+
45
49
  test "#from?" do
46
50
  assert { false == Tori::File.new(__FILE__).from? }
47
51
  assert { true == Tori::File.new(__FILE__, from: From.new).from? }
@@ -53,6 +57,17 @@ class TestToriFile < Test::Unit::TestCase
53
57
  assert { true == File.exist?("test/tmp/copy") }
54
58
  end
55
59
 
60
+ test "backend" do
61
+ assert { Tori.config.backend == Tori::File.new(nil).backend }
62
+ end
63
+
64
+ test "backend=" do
65
+ o = Object.new
66
+ t = Tori::File.new(nil)
67
+ assert { o == (t.backend = (o)) }
68
+ assert { o == t.backend }
69
+ end
70
+
56
71
  test "write with closed file" do
57
72
  tori_file = nil
58
73
  path = nil
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.2
4
+ version: 0.6.3
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-19 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core