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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0860a5b2a95c5bd92c5064c468688493ae765511
4
- data.tar.gz: 97a4aced93b66300b731705a45df60fbb1b1be1e
3
+ metadata.gz: d56e52c07a06315670397f3d6e8a247bdc292e35
4
+ data.tar.gz: 72d150ad6dec4b370910480c9610d92d04480de3
5
5
  SHA512:
6
- metadata.gz: f606846b2e54e652f5fbba5143e8823ad798cc20c8870b6cdcaaba1f68b8001d22535d9824d9e2d327d09c1f8a35a20c83c3abd5b5409595b1b105c750b9ddec
7
- data.tar.gz: 10bf3e48938ae58055cdf189865502b18a4158c1d53a9059324b64a59a9335ab485e0cd8c772e93436bd47d8e03a25e9823a17913565d46ec644a00ffd980012
6
+ metadata.gz: 77d2cf552e6a0f85cfdfb684d4a5788026255fffad670a096b4d96790cb7fc3e92332f51990e23b9e369a3d002110b27e0298b78ad9732a0838c396eeb9a0e29
7
+ data.tar.gz: 0881c4547307abec21c2a6b66cdcacfa08b9c6a951ac3b12348316c0758b5eb8e7bc1b015f2bf3f3c4d388b8243da5ecebe298ee3b1b46143726b6c986da9fdf
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2
3
+ - 2.1.8
4
+ - 2.2.4
5
+ - 2.3.0
5
6
  notifications:
6
7
  email: false
@@ -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
@@ -146,6 +146,10 @@ module Tori
146
146
  end
147
147
  end
148
148
 
149
+ def otherwise(backend)
150
+ Chain.new(self, backend)
151
+ end
152
+
149
153
  def get_object(opts={})
150
154
  client.get_object bucket: @bucket, **opts
151
155
  end
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
- attr_reader :from
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
@@ -1,3 +1,3 @@
1
1
  module Tori
2
- VERSION = "0.6.3"
2
+ VERSION = "0.6.4"
3
3
  end
@@ -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.3
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: 2015-11-29 00:00:00.000000000 Z
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.4.5.1
135
+ rubygems_version: 2.5.1
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Simple file uploader