DropSync 1.0.3 → 2.0.0

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: ea0b1fe4f638f066122fb058652d89453430b162
4
- data.tar.gz: f8198ed274fc4aa6cea440069106719902773cb9
3
+ metadata.gz: 964cb8f12ec0047e8eda24ed68dacca46ada4240
4
+ data.tar.gz: 0c73f57ef1dab9106df8998c88c8409a014a35a5
5
5
  SHA512:
6
- metadata.gz: 7ec176e4194616443a1ddf048c205de6155dfed7191522fafb4208bd69c8f5752a4b5be3d368229d19b4948f3f3e4e69ee175c079e2a0f5447b5f5187096a188
7
- data.tar.gz: d076715e9aacf8e98588f7a6fb50bf986a24d8c542acd92656fa883cb6a1888a12b3fca113e3b3996ea65c1df2b7a076ff220bcdbca325ba3f49d264145ded5f
6
+ metadata.gz: 0fb435843b54a75d83fccfe677648d12d67a2a6c2ff3cf92471c4a84f80c1a7f3d39b83628e0fba9c8889e276e902718645e55b292b5cf7ba71b284face729cf
7
+ data.tar.gz: e3d5f47ca80cc01695c4f0d18b7dd3574d13c844a9f577f55b8b39e9379df9aa2ea462d1c89a8ea96397dfbca44a36ae2b18a37577d8ca7339652ae4f8540aa6
@@ -10,7 +10,7 @@ Gem::Specification.new "dropsync", DropSync::VERSION do |spec|
10
10
  spec.email = ["frankkair@gmail.com"]
11
11
 
12
12
  spec.summary = "Simple Dropbox CLI"
13
- spec.description = "Simple Dropbox CLI to download files and folders."
13
+ spec.description = "Simple Dropbox CLI to download/upload files and folders."
14
14
  spec.homepage = "https://www.github.com/FrankKair/DropSync"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- DropSync (1.0.2)
4
+ DropSync (2.0.0)
5
5
  dropbox-sdk (= 1.6.5)
6
6
  mechanize (= 2.7.5)
7
7
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # DropSync
2
2
 
3
- A simple Dropbox client to download files and folders.
3
+ A simple Dropbox client to download/upload files and folders.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,21 +8,20 @@ A simple Dropbox client to download files and folders.
8
8
 
9
9
  ## Usage
10
10
 
11
- On your terminal, call:
11
+ ### Access token
12
12
 
13
- $ dropsync access_token filename
13
+ Your access token can be found at [Dropbox Developers](https://www.dropbox.com/developers).
14
14
 
15
- The access token can be found at [Dropbox Developers](https://www.dropbox.com/developers).
15
+ ### Download
16
16
 
17
- That's it :)
17
+ This command downloads the given file to your ~/Downloads directory.
18
18
 
19
- ## Developing and Contributing
19
+ $ dropsync access_token download filename
20
20
 
21
- To install this gem onto your local machine, run `bundle exec rake install`.
21
+ ### Upload
22
22
 
23
- Bug reports and pull requests are welcome!
23
+ This command uploads the given file to the root directory of your Dropbox.
24
24
 
25
- ## Next steps
25
+ $ dropsync access_token upload path_to_file
26
26
 
27
- 1) Error handling
28
- 2) Tests
27
+ The path to file may be something like `~/Desktop/my_folder/text_file.txt`
@@ -1,12 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'dropsync'
3
3
 
4
- unless ARGV.count == 2
5
- puts "Enter your access token and filename"
6
- raise "Wrong input arguments"
4
+ unless ARGV.count == 3
5
+ DropSync::Help.show_message
7
6
  end
8
7
 
9
- access_token, filename = ARGV[0], ARGV[1]
8
+ access_token, command, filename = ARGV[0], ARGV[1], ARGV[2]
9
+ dropsync = DropSync::Engine.new(access_token)
10
10
 
11
- drop_sync = DropSync::Engine.new(access_token)
12
- drop_sync.download(filename)
11
+ case command
12
+ when 'download'
13
+ dropsync.download(filename)
14
+ when 'upload'
15
+ dropsync.upload(filename)
16
+ else
17
+ DropSync::Help.invalid_command
18
+ end
@@ -1,4 +1,5 @@
1
+ require 'dropbox_sdk'
1
2
  require 'dropsync/engine'
2
- require 'dropsync/version'
3
+ require 'dropsync/help'
3
4
  require 'dropsync/mecha'
4
- require 'dropbox_sdk'
5
+ require 'dropsync/version'
@@ -1,11 +1,11 @@
1
1
  module DropSync
2
2
  class Engine
3
3
  def initialize(access_token)
4
- puts '--- DropSync ---'
5
4
  @client = DropboxClient.new(access_token)
6
5
  end
7
6
 
8
7
  def download(path)
8
+ puts '--- DropSync ---'
9
9
  puts "> Searching for #{path}"
10
10
  url = get_url(path)
11
11
  puts "> Downloading file"
@@ -14,6 +14,15 @@ module DropSync
14
14
  logout
15
15
  end
16
16
 
17
+ def upload(path_to_file)
18
+ puts '--- DropSync ---'
19
+ filename = File.basename(path_to_file)
20
+ puts "> Uploading #{filename}"
21
+ @client.put_file(filename, open(path_to_file))
22
+ puts '> Upload finished!'
23
+ logout
24
+ end
25
+
17
26
  private
18
27
  def get_url(path)
19
28
  filename = path.split('/').pop
@@ -0,0 +1,27 @@
1
+ module DropSync
2
+ module Help
3
+ extend self
4
+
5
+ def show_message
6
+ puts '--- DropSync ---'
7
+ puts '> To use DropSync you should provide an access_token, a command and a file, like so:'
8
+ puts '$ dropsync access_token command file'
9
+ puts "\n> Commands:"
10
+ puts "> download argument -> file/folder"
11
+ puts "> upload argument -> path to file"
12
+ puts "\n> Examples:"
13
+ puts "$ dropsync access_token download my_dropbox_folder"
14
+ puts "$ dropsync access_token upload ~/Desktop/my_stuff/my_file.txt"
15
+ puts "-------"
16
+ end
17
+
18
+ def invalid_command
19
+ puts '--- DropSync ---'
20
+ puts '> Please enter a valid command: download or upload'
21
+ puts '> Need help?'
22
+ puts '$ dropsync help'
23
+ puts '-------'
24
+ end
25
+
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module DropSync
2
- VERSION = "1.0.3"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: DropSync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Kair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-12 00:00:00.000000000 Z
11
+ date: 2017-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.7.5
69
- description: Simple Dropbox CLI to download files and folders.
69
+ description: Simple Dropbox CLI to download/upload files and folders.
70
70
  email:
71
71
  - frankkair@gmail.com
72
72
  executables:
@@ -83,9 +83,9 @@ files:
83
83
  - bin/dropsync
84
84
  - lib/dropsync.rb
85
85
  - lib/dropsync/engine.rb
86
+ - lib/dropsync/help.rb
86
87
  - lib/dropsync/mecha.rb
87
88
  - lib/dropsync/version.rb
88
- - pkg/DropSync-1.0.1.pre.gem
89
89
  homepage: https://www.github.com/FrankKair/DropSync
90
90
  licenses:
91
91
  - MIT
Binary file