droxi 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e2082eebfa7309caf39ae23503dacebd697b296
4
- data.tar.gz: df6667fdb18de0438a79c11f990589412a67dae5
3
+ metadata.gz: 9b3d4718e377e5291effa8c95ef8b88f2dd10f8b
4
+ data.tar.gz: b14e7c988a4f40f0e53363c1d45f5257e9c76017
5
5
  SHA512:
6
- metadata.gz: 58ac779ee0ded7200528cc15301da40c6485f3c63fc2cf98ae7282743d31d7e27cbe9c3fedaaabbff5ae6e466f965521ff3a85f506ba1a55c36810ea95da1837
7
- data.tar.gz: c4c44cb264cd3e9ccc046b50535c93e2451f0363fab1ec7beef8947bf6dc4f910d64f330d871edb2f7be8d355ff58a37c42819b6b78a71d838d0b141cafaade8
6
+ metadata.gz: c67954fa6f3ff293c90d88934651dd1c1438cd09461b2cbb5a57dcb72ae094a40d197fecd731fcbfa8fef3838459b2b3185d8cfa52784bf33d97d872b82efccf
7
+ data.tar.gz: 9fab7e390b306c6a8322b52c2a8ec6b3645ac7b6cc35e2ff392e69130e46d7efce8c2cfd8c45fcc9f22f49f4d7b051ea9b7ab83f13adf2f12fd987a8dcf12989
data/droxi.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'droxi'
3
3
  s.version = IO.read('lib/droxi.rb')[/VERSION = '(.+)'/, 1]
4
- s.date = '2014-09-01'
4
+ s.date = '2014-09-11'
5
5
  s.summary = 'ftp-like command-line interface to Dropbox'
6
6
  s.description = "A command-line Dropbox interface inspired by GNU \
7
7
  coreutils, GNU ftp, and lftp. Features include smart tab \
@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.license = 'MIT'
14
14
 
15
15
  s.executables << 'droxi'
16
- s.add_runtime_dependency 'dropbox-sdk', '~> 1.6', '>= 1.6.1'
16
+ s.add_runtime_dependency 'dropbox-sdk', '~> 1.6', '>= 1.6.4'
17
17
  s.required_ruby_version = '>= 2.0.0'
18
18
  end
@@ -387,7 +387,14 @@ module Commands
387
387
  client.file_delete(to_path)
388
388
  state.cache.remove(to_path)
389
389
  end
390
- data = client.put_file(to_path, file)
390
+
391
+ # Chunked upload if file is more than 1M.
392
+ if file.size > 1024 * 1024
393
+ data = chunked_upload(client, to_path, file)
394
+ else
395
+ data = client.put_file(to_path, file)
396
+ end
397
+
391
398
  state.cache.add(data)
392
399
  puts "#{arg} -> #{data['path']}"
393
400
  end
@@ -692,4 +699,40 @@ module Commands
692
699
  fail UsageError, usage
693
700
  end
694
701
  end
702
+
703
+ # Attempts to upload a file to the server in chunks, displaying progress.
704
+ def self.chunked_upload(client, to_path, file)
705
+ uploader = DropboxClient::ChunkedUploader.new(client, file, file.size)
706
+ thread = Thread.new { monitor_upload(uploader, to_path) }
707
+ loop_upload(uploader, thread)
708
+ data = uploader.finish(to_path)
709
+ thread.join
710
+ print "\r" + (' ' * (18 + to_path.rpartition('/')[2].size)) + "\r"
711
+ data
712
+ end
713
+
714
+ # Continuously try to upload until successful or interrupted.
715
+ def self.loop_upload(uploader, monitor_thread)
716
+ while uploader.offset < uploader.total_size
717
+ begin
718
+ uploader.upload(1024 * 1024)
719
+ rescue DropboxError => error
720
+ puts "\n" + error.to_s
721
+ end
722
+ end
723
+ rescue Interrupt => error
724
+ monitor_thread.kill
725
+ raise error
726
+ end
727
+
728
+ # Displays real-time progress for the a being uploaded.
729
+ def self.monitor_upload(uploader, to_path)
730
+ filename = to_path.rpartition('/')[2]
731
+ loop do
732
+ percent = 100.0 * uploader.offset / uploader.total_size
733
+ printf("\rUploading %s: %.1f%%", filename, percent)
734
+ break if uploader.offset == uploader.total_size
735
+ sleep 1
736
+ end
737
+ end
695
738
  end
data/lib/droxi.rb CHANGED
@@ -10,7 +10,7 @@ require_relative 'droxi/text'
10
10
  # Command-line Dropbox client module.
11
11
  module Droxi
12
12
  # Version number of the program.
13
- VERSION = '0.2.1'
13
+ VERSION = '0.2.2'
14
14
 
15
15
  # Message to display when invoked with the --help option.
16
16
  HELP_TEXT =
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droxi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mulcahy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dropbox-sdk
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '1.6'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 1.6.1
22
+ version: 1.6.4
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '1.6'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 1.6.1
32
+ version: 1.6.4
33
33
  description: A command-line Dropbox interface inspired by GNU coreutils, GNU ftp,
34
34
  and lftp. Features include smart tab completion, globbing, and interactive help.
35
35
  email: brandon@jangler.info