tus-client 0.0.1 → 0.0.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
  SHA256:
3
- metadata.gz: fb181b60fb3adfe8144c63058f5b8041aff99adcc0951c956dd8d33891c7a7b6
4
- data.tar.gz: 98f4f9fccf403e70a49dd3d6ddaa15c9877956db3c43ca69ad0795e90cdfb1ff
3
+ metadata.gz: 24530f6bf4e29af12bb753db0bd417553ae357bb80956aac1bf008df9835f276
4
+ data.tar.gz: cb0db63ef4be6893e97347e5d498360c4566c601f2a8ebdb4b6a63f2b889964a
5
5
  SHA512:
6
- metadata.gz: 05c74eaf8f6bbdcc875488dc5b802c910365beacea32cd8ee41135e5560ab89cd121fc565e693d991fbbefbe75226f287c6a6df90b03d3220cc5903395219701
7
- data.tar.gz: fc4f57f6b8ef4c16f4216ad119d49d1f938f7e213081304c444ae32a6d67549be19bfb2fb9b7d6e159956c03d70da3a9fa06ca806a38cb35227d76871e6110e7
6
+ metadata.gz: 8053eb9c45d03a14684618bc1e45e259414b232b5b3aebec5d9e64959d4cc20b2343df293d8094171832a79cc23e3e73e29ee3effc16cab26af6f53a5e4a6f5c
7
+ data.tar.gz: a4f386ec4a1401f209e1a87f166158d46929e935b09fb05b337ee1a97069255c3593325a1a0e6fbf5759a622031996030f04c4e5e33d50b149b5a7a676884974
data/README.md CHANGED
@@ -6,9 +6,15 @@ TODO: Write the additional info
6
6
 
7
7
  ## Installation
8
8
 
9
- TODO: this gem is not published yet!
9
+ From the command line:
10
+ ```bash
11
+ gem install tus-client
12
+ ```
10
13
 
11
- Just install it from sources
14
+ Or add this line to your `Gemfile`:
15
+ ```rb
16
+ gem "tus-client"
17
+ ```
12
18
 
13
19
  ## Usage
14
20
 
@@ -16,7 +22,7 @@ TODO: Write usage instructions here
16
22
 
17
23
  ## Development
18
24
 
19
- TODO: Write the info
25
+ Just clone the repo and open a pull request when done implementing your feature
20
26
 
21
27
  ## Contributing
22
28
 
@@ -3,7 +3,7 @@
3
3
  require 'net/http'
4
4
  require 'base64'
5
5
 
6
- require 'tus/client/version'
6
+ require_relative 'client/version'
7
7
 
8
8
  module Tus
9
9
  class Client
@@ -24,14 +24,28 @@ module Tus
24
24
  def upload(file_path)
25
25
  raise 'No such file!' unless File.file?(file_path)
26
26
 
27
+ file_name = File.basename(file_path)
28
+ file_size = File.size(file_path)
27
29
  io = File.open(file_path, 'rb')
28
30
 
29
- uri = create_remote(File.basename(file_path), File.size(file_path))
31
+ upload_by_io(file_name: file_name, file_size: file_size, io: io)
32
+ end
33
+
34
+ def upload_by_io(file_name:, file_size:, io:)
35
+ raise 'Cannot upload a stream of unknown size!' unless file_size
36
+
37
+ uri = create_remote(file_name, file_size)
30
38
  # we use only parameters that are known to the server
31
39
  offset, length = upload_parameters(uri)
32
40
 
33
41
  chunks = Enumerator.new do |yielder|
34
- yielder << io.read(CHUNK_SIZE)
42
+ loop do
43
+ chunk = io.read(CHUNK_SIZE)
44
+
45
+ break unless chunk
46
+
47
+ yielder << chunk
48
+ end
35
49
  end
36
50
 
37
51
  begin
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tus
4
4
  class Client
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tus-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Mochalov (factyy)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-08-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: