DropSync 2.0.0 → 3.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: 964cb8f12ec0047e8eda24ed68dacca46ada4240
4
- data.tar.gz: 0c73f57ef1dab9106df8998c88c8409a014a35a5
3
+ metadata.gz: b7458c88163f53ddb5ee31a1f33a3deaa21ec889
4
+ data.tar.gz: 93081d7995773cf680798634098900fd53f04200
5
5
  SHA512:
6
- metadata.gz: 0fb435843b54a75d83fccfe677648d12d67a2a6c2ff3cf92471c4a84f80c1a7f3d39b83628e0fba9c8889e276e902718645e55b292b5cf7ba71b284face729cf
7
- data.tar.gz: e3d5f47ca80cc01695c4f0d18b7dd3574d13c844a9f577f55b8b39e9379df9aa2ea462d1c89a8ea96397dfbca44a36ae2b18a37577d8ca7339652ae4f8540aa6
6
+ metadata.gz: 196401fa36483d9df3b18ddf7a62bf666894a720d577dae2ee186bb8552597a0ed0c35488cd32497d6f2c561cc20829154733d186b39058188bcd7b727a38897
7
+ data.tar.gz: 57eca858f9ce1818c65767965c7866654ae9df4da959437fecd35cfb6e3940c32614af8d9f5e6d3fd6a75f611c7bb404450d7c8fab2341a05f2c36969f67c22e
@@ -0,0 +1 @@
1
+ pkg/
@@ -1,25 +1,25 @@
1
- # coding: utf-8
1
+
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'dropsync/version'
5
5
 
6
- Gem::Specification.new "dropsync", DropSync::VERSION do |spec|
7
- spec.name = "DropSync"
6
+ Gem::Specification.new 'dropsync', DropSync::VERSION do |spec|
7
+ spec.name = 'DropSync'
8
8
  spec.version = DropSync::VERSION
9
- spec.authors = ["Frank Kair"]
10
- spec.email = ["frankkair@gmail.com"]
9
+ spec.authors = ['Frank Kair']
10
+ spec.email = ['frankkair@gmail.com']
11
11
 
12
- spec.summary = "Simple Dropbox CLI"
13
- spec.description = "Simple Dropbox CLI to download/upload files and folders."
14
- spec.homepage = "https://www.github.com/FrankKair/DropSync"
15
- spec.license = "MIT"
12
+ spec.summary = 'Simple Dropbox CLI'
13
+ spec.description = 'Simple Dropbox CLI to download/upload files and folders.'
14
+ spec.homepage = 'https://www.github.com/FrankKair/DropSync'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f =~ /docs\// }
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.14"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_runtime_dependency 'dropbox-sdk', '= 1.6.5', '= 1.6.5'
21
+ spec.add_development_dependency 'bundler', '~> 1.14'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_runtime_dependency 'dropbox_api', '= 0.1.10', '= 0.1.10'
24
24
  spec.add_runtime_dependency 'mechanize', '= 2.7.5', '= 2.7.5'
25
25
  end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- DropSync (2.0.0)
5
- dropbox-sdk (= 1.6.5)
4
+ DropSync (3.0.0)
5
+ dropbox_api (= 0.1.10)
6
6
  mechanize (= 2.7.5)
7
7
 
8
8
  GEM
@@ -10,11 +10,14 @@ GEM
10
10
  specs:
11
11
  domain_name (0.5.20161129)
12
12
  unf (>= 0.0.5, < 1.0.0)
13
- dropbox-sdk (1.6.5)
14
- json
13
+ dropbox_api (0.1.10)
14
+ faraday (~> 0.9, ~> 0.8)
15
+ oauth2 (~> 1.1)
16
+ faraday (0.9.2)
17
+ multipart-post (>= 1.2, < 3)
15
18
  http-cookie (1.0.3)
16
19
  domain_name (~> 0.5)
17
- json (2.0.2)
20
+ jwt (1.5.4)
18
21
  mechanize (2.7.5)
19
22
  domain_name (~> 0.5, >= 0.5.1)
20
23
  http-cookie (~> 1.0)
@@ -27,12 +30,22 @@ GEM
27
30
  mime-types (3.1)
28
31
  mime-types-data (~> 3.2015)
29
32
  mime-types-data (3.2016.0521)
30
- mini_portile2 (2.1.0)
33
+ mini_portile2 (2.3.0)
34
+ multi_json (1.12.2)
35
+ multi_xml (0.5.5)
36
+ multipart-post (2.0.0)
31
37
  net-http-digest_auth (1.4.1)
32
38
  net-http-persistent (2.9.4)
33
- nokogiri (1.7.1)
34
- mini_portile2 (~> 2.1.0)
39
+ nokogiri (1.8.1)
40
+ mini_portile2 (~> 2.3.0)
35
41
  ntlm-http (0.1.1)
42
+ oauth2 (1.4.0)
43
+ faraday (>= 0.8, < 0.13)
44
+ jwt (~> 1.0)
45
+ multi_json (~> 1.3)
46
+ multi_xml (~> 0.5)
47
+ rack (>= 1.2, < 3)
48
+ rack (2.0.3)
36
49
  rake (10.4.2)
37
50
  unf (0.1.4)
38
51
  unf_ext
data/README.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  A simple Dropbox client to download/upload files and folders.
4
4
 
5
+ ## Status
6
+
7
+ The gem is currently not working because Dropbox discontinued the version 1 of the Ruby API.
8
+ The v2 API does not support Ruby, but there are some people working on this issue.
9
+
10
+ More info: https://blogs.dropbox.com/developers/2017/09/api-v1-shutdown-details/
11
+
5
12
  ## Installation
6
13
 
7
14
  $ gem install DropSync
@@ -24,4 +31,4 @@ This command uploads the given file to the root directory of your Dropbox.
24
31
 
25
32
  $ dropsync access_token upload path_to_file
26
33
 
27
- The path to file may be something like `~/Desktop/my_folder/text_file.txt`
34
+ The path to file may be something like `~/Desktop/my_folder/text_file.txt`
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
2
- task :default => :spec
1
+ require 'bundler/gem_tasks'
2
+ task default: :spec
@@ -1,18 +1,17 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'dropsync'
3
3
 
4
- unless ARGV.count == 3
5
- DropSync::Help.show_message
4
+ if ARGV[0] == '--help'
5
+ DropSync::Help.show_message
6
+ exit(0)
6
7
  end
7
8
 
8
- access_token, command, filename = ARGV[0], ARGV[1], ARGV[2]
9
- dropsync = DropSync::Engine.new(access_token)
9
+ unless ARGV.count == 2
10
+ DropSync::Help.show_message
11
+ exit(0)
12
+ end
10
13
 
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
14
+ access_token = ARGV[0]
15
+ filename = ARGV[1]
16
+ dropsync = DropSync::Engine.new(access_token)
17
+ dropsync.download(filename)
@@ -1,5 +1,5 @@
1
- require 'dropbox_sdk'
1
+ require 'dropbox_api'
2
2
  require 'dropsync/engine'
3
3
  require 'dropsync/help'
4
- require 'dropsync/mecha'
5
- require 'dropsync/version'
4
+ require 'dropsync/auto'
5
+ require 'dropsync/version'
@@ -0,0 +1,40 @@
1
+ require 'mechanize'
2
+ require 'fileutils'
3
+
4
+ module DropSync
5
+ module Auto
6
+ extend self
7
+ def download(path, url)
8
+ agent = Mechanize.new do |agent|
9
+ agent.user_agent_alias = 'Mac Safari'
10
+ end
11
+
12
+ # Gets download link
13
+ page = agent.get(url)
14
+ link = page.uri.to_s.gsub('dl=0', 'dl=1')
15
+
16
+ # Creates directory
17
+ download_path = "#{File.expand_path('~')}/Downloads"
18
+ FileUtils.cd(download_path)
19
+ path.split('/').each do |d|
20
+ begin
21
+ FileUtils.mkdir(d)
22
+ rescue
23
+ puts "> Directory '#{d}' already exists"
24
+ FileUtils.rm_rf(d)
25
+ FileUtils.mkdir(d)
26
+ end
27
+ FileUtils.cd(d)
28
+ end
29
+ filename = path.split('/').pop
30
+
31
+ # Download
32
+ system("curl -L -s -o #{download_path}/#{path}/#{filename}.zip #{link}")
33
+ system("unzip #{download_path}/#{path}/#{filename}.zip > /dev/null 2>&1")
34
+
35
+ # Cleans directory
36
+ FileUtils.rm_rf('__MACOSX')
37
+ FileUtils.rm_rf("#{filename}.zip")
38
+ end
39
+ end
40
+ end
@@ -1,46 +1,48 @@
1
1
  module DropSync
2
- class Engine
3
- def initialize(access_token)
4
- @client = DropboxClient.new(access_token)
5
- end
2
+ class Engine
3
+ def initialize(access_token)
4
+ @client = DropboxApi::Client.new(access_token)
5
+ end
6
6
 
7
- def download(path)
8
- puts '--- DropSync ---'
9
- puts "> Searching for #{path}"
10
- url = get_url(path)
11
- puts "> Downloading file"
12
- Mecha.automatic_download(path, url)
13
- puts '> Download finished!'
14
- logout
15
- end
7
+ def download(path)
8
+ puts '--- DropSync ---'
9
+ puts "> Searching for #{path}"
10
+ url = get_url(path)
11
+ puts '> Downloading file'
12
+ Auto.download(path, url)
13
+ puts '> Download finished'
14
+ logout
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
17
+ private
25
18
 
26
- private
27
- def get_url(path)
28
- filename = path.split('/').pop
29
- resp = @client.search('/', filename)
19
+ def get_url(path)
20
+ filename = path.split('/').pop
21
+ resp = @client.search(filename, '')
22
+ item_path = ''
23
+ resp.matches.each do |res|
24
+ item_path = res.resource.path_lower if res.resource.path_lower.downcase.include?(path.downcase)
25
+ end
30
26
 
31
- for it in resp
32
- if it['path'].downcase.include? path.downcase
33
- item_path = it['path']
34
- end
35
- end
27
+ if item_path.empty?
28
+ puts 'No folder/file path found. Exiting DropSync.'
29
+ exit(0)
30
+ end
36
31
 
37
- @client.shares(item_path)['url']
38
- end
32
+ # Check if there's a shared link already
33
+ links = @client.list_shared_links.links
34
+ links.each do |link|
35
+ return link.url if link.path_lower.include?(item_path)
36
+ end
39
37
 
40
- def logout
41
- @client = nil
42
- exit(0)
43
- end
38
+ # Creates new shared link
39
+ link = @client.create_shared_link_with_settings(item_path)
40
+ link.url
41
+ end
44
42
 
43
+ def logout
44
+ @client = nil
45
+ exit(0)
45
46
  end
47
+ end
46
48
  end
@@ -1,27 +1,14 @@
1
1
  module DropSync
2
- module Help
3
- extend self
2
+ module Help
3
+ extend self
4
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
5
+ def show_message
6
+ puts '--- DropSync ---'
7
+ puts '> To use DropSync you should provide an access_token and a file/folder, like so:'
8
+ puts "\n> Examples:"
9
+ puts '$ dropsync access_token file'
10
+ puts '$ dropsync access_token my_dropbox_folder'
11
+ puts '-------'
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module DropSync
2
- VERSION = "2.0.0"
2
+ VERSION = '3.0.0'.freeze
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: 2.0.0
4
+ version: 3.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-06-03 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: dropbox-sdk
42
+ name: dropbox_api
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.5
47
+ version: 0.1.10
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.5
54
+ version: 0.1.10
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mechanize
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +74,7 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".gitignore"
77
78
  - DropSync.gemspec
78
79
  - Gemfile
79
80
  - Gemfile.lock
@@ -82,9 +83,9 @@ files:
82
83
  - Rakefile
83
84
  - bin/dropsync
84
85
  - lib/dropsync.rb
86
+ - lib/dropsync/auto.rb
85
87
  - lib/dropsync/engine.rb
86
88
  - lib/dropsync/help.rb
87
- - lib/dropsync/mecha.rb
88
89
  - lib/dropsync/version.rb
89
90
  homepage: https://www.github.com/FrankKair/DropSync
90
91
  licenses:
@@ -1,40 +0,0 @@
1
- require 'mechanize'
2
- require 'fileutils'
3
-
4
- module DropSync
5
- class Mecha
6
-
7
- def self.automatic_download(path, url)
8
- agent = Mechanize.new do |agent|
9
- agent.user_agent_alias = 'Mac Safari'
10
- end
11
-
12
- # Gets download link
13
- page = agent.get(url)
14
- link = page.uri.to_s.gsub('dl=0', 'dl=1')
15
-
16
- # Creates directory
17
- download_path = "#{File.expand_path('~')}/Downloads"
18
- FileUtils.cd(download_path)
19
- path.split('/').each do |d|
20
- begin
21
- FileUtils.mkdir(d)
22
- rescue
23
- puts "> Directory '#{d}' already exists"
24
- FileUtils.rm_rf(d)
25
- FileUtils.mkdir(d)
26
- end
27
- FileUtils.cd(d)
28
- end
29
- filename = path.split('/').pop
30
-
31
- # Download
32
- system("curl -L -s -o #{download_path}/#{path}/#{filename}.zip #{link}")
33
- system("unzip #{download_path}/#{path}/#{filename}.zip > /dev/null 2>&1")
34
-
35
- # Cleans directory
36
- FileUtils.rm_rf("__MACOSX")
37
- FileUtils.rm_rf("#{filename}.zip")
38
- end
39
- end
40
- end