tori 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/lib/tori/backend/filesystem.rb +6 -2
- data/lib/tori/backend/s3.rb +4 -0
- data/lib/tori/file.rb +20 -15
- data/lib/tori/version.rb +1 -1
- data/test/test_tori_backend_chain.rb +6 -0
- data/test/test_tori_backend_filesystem.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d56e52c07a06315670397f3d6e8a247bdc292e35
|
4
|
+
data.tar.gz: 72d150ad6dec4b370910480c9610d92d04480de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77d2cf552e6a0f85cfdfb684d4a5788026255fffad670a096b4d96790cb7fc3e92332f51990e23b9e369a3d002110b27e0298b78ad9732a0838c396eeb9a0e29
|
7
|
+
data.tar.gz: 0881c4547307abec21c2a6b66cdcacfa08b9c6a951ac3b12348316c0758b5eb8e7bc1b015f2bf3f3c4d388b8243da5ecebe298ee3b1b46143726b6c986da9fdf
|
data/.travis.yml
CHANGED
@@ -35,8 +35,8 @@ module Tori
|
|
35
35
|
end
|
36
36
|
alias exists? exist?
|
37
37
|
|
38
|
-
def read(filename)
|
39
|
-
::File.read(path(filename), mode: 'rb')
|
38
|
+
def read(filename, **args)
|
39
|
+
::File.read(path(filename), { mode: 'rb' }.merge(args))
|
40
40
|
end
|
41
41
|
|
42
42
|
def open(filename, *rest, &block)
|
@@ -46,6 +46,10 @@ module Tori
|
|
46
46
|
def path(filename)
|
47
47
|
@root.join filename.to_s
|
48
48
|
end
|
49
|
+
|
50
|
+
def otherwise(backend)
|
51
|
+
Chain.new(self, backend)
|
52
|
+
end
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
data/lib/tori/backend/s3.rb
CHANGED
data/lib/tori/file.rb
CHANGED
@@ -3,22 +3,10 @@ module Tori
|
|
3
3
|
def initialize(model, title: nil, from: nil, to: nil, &block)
|
4
4
|
@model = model
|
5
5
|
@title = title.kind_of?(String) ? title.to_sym : title
|
6
|
-
|
7
|
-
@from_path = if from.respond_to?(:path)
|
8
|
-
from.path
|
9
|
-
else
|
10
|
-
nil
|
11
|
-
end
|
12
|
-
|
13
6
|
@backend = to
|
14
|
-
|
15
|
-
@from = if from.respond_to?(:read) and from.respond_to?(:rewind)
|
16
|
-
from.rewind
|
17
|
-
from.read
|
18
|
-
else
|
19
|
-
from
|
20
|
-
end
|
21
7
|
@filename_callback = block
|
8
|
+
|
9
|
+
self.from = from
|
22
10
|
end
|
23
11
|
|
24
12
|
def name
|
@@ -28,7 +16,24 @@ module Tori
|
|
28
16
|
end
|
29
17
|
alias to_s name
|
30
18
|
|
31
|
-
|
19
|
+
def from
|
20
|
+
@from
|
21
|
+
end
|
22
|
+
|
23
|
+
def from=(file)
|
24
|
+
@from_path = if file.respond_to?(:path)
|
25
|
+
file.path
|
26
|
+
else
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
@from = if file.respond_to?(:read) and file.respond_to?(:rewind)
|
30
|
+
file.rewind
|
31
|
+
file.read
|
32
|
+
else
|
33
|
+
file
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
32
37
|
def from?
|
33
38
|
!@from.nil?
|
34
39
|
end
|
data/lib/tori/version.rb
CHANGED
@@ -13,6 +13,12 @@ class TestToriBackendChain < Test::Unit::TestCase
|
|
13
13
|
@backend = Chain.new(@filesystem1, @filesystem2)
|
14
14
|
end
|
15
15
|
|
16
|
+
test "#initialize" do
|
17
|
+
assert { Chain === Chain.new }
|
18
|
+
assert { [@filesystem1, @filesystem2] === Chain.new(@filesystem1, @filesystem2).backends }
|
19
|
+
assert { Chain === @filesystem1.otherwise(@filesystem2) }
|
20
|
+
end
|
21
|
+
|
16
22
|
test "#backend" do
|
17
23
|
assert { @filesystem1 == @backend.backend("testfile-1") }
|
18
24
|
assert { @filesystem2 == @backend.backend("testfile-2") }
|
@@ -28,6 +28,8 @@ class TestToriBackendFileSystem < Test::Unit::TestCase
|
|
28
28
|
bin = (0..0xFF).to_a.pack("c*")
|
29
29
|
File.open(@filesystem.root.join("binfile"), 'wb'){ |f| f.write bin }
|
30
30
|
assert { bin == @filesystem.read("binfile") }
|
31
|
+
assert { Encoding::ASCII_8BIT == @filesystem.read("binfile").encoding }
|
32
|
+
assert { Encoding::UTF_8 == @filesystem.read("binfile", external_encoding: Encoding::UTF_8).encoding }
|
31
33
|
end
|
32
34
|
|
33
35
|
test "#path" do
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.5.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Simple file uploader
|