DropSync 1.0.1.pre

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c7a6903992529ecc2c8c1bf00fee3a3bc2fd2e36
4
+ data.tar.gz: f8e0607ee547df63618421d364d1c1f2db7ca9fc
5
+ SHA512:
6
+ metadata.gz: 9b2d50c21a0ccccc564aea2837f691163b22d769029e168b1fd8a7b53d486a7cccd2695278690aefaf76469983ea5dd0c3fba35a510624b13af22bb09f43d95b
7
+ data.tar.gz: 3215f81094f886939f88e365e8024f42c0c7427ffdd0657d5400117a04f86e72d01bbe3638d692c242f0f16b40e657f640d4bdfc725c1720924a2abecf00f61a
data/DropSync.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dropsync/version'
5
+
6
+ Gem::Specification.new "dropsync", DropSync::VERSION do |spec|
7
+ spec.name = "DropSync"
8
+ spec.version = DropSync::VERSION
9
+ spec.authors = ["Frank Kair"]
10
+ spec.email = ["frankkair@gmail.com"]
11
+
12
+ spec.summary = "Simple Dropbox CLI"
13
+ spec.description = "Simple Dropbox CLI to download files and folders."
14
+ spec.homepage = "https://www.github.com/FrankKair/DropSync"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f =~ /docs\// }
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
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'
24
+ spec.add_runtime_dependency 'mechanize', '= 2.7.5', '= 2.7.5'
25
+ end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in DropSync.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ DropSync (1.0.1.pre)
5
+ dropbox-sdk (= 1.6.5)
6
+ mechanize (= 2.7.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ domain_name (0.5.20161129)
12
+ unf (>= 0.0.5, < 1.0.0)
13
+ dropbox-sdk (1.6.5)
14
+ json
15
+ http-cookie (1.0.3)
16
+ domain_name (~> 0.5)
17
+ json (2.0.2)
18
+ mechanize (2.7.5)
19
+ domain_name (~> 0.5, >= 0.5.1)
20
+ http-cookie (~> 1.0)
21
+ mime-types (>= 1.17.2)
22
+ net-http-digest_auth (~> 1.1, >= 1.1.1)
23
+ net-http-persistent (~> 2.5, >= 2.5.2)
24
+ nokogiri (~> 1.6)
25
+ ntlm-http (~> 0.1, >= 0.1.1)
26
+ webrobots (>= 0.0.9, < 0.2)
27
+ mime-types (3.1)
28
+ mime-types-data (~> 3.2015)
29
+ mime-types-data (3.2016.0521)
30
+ mini_portile2 (2.1.0)
31
+ net-http-digest_auth (1.4.1)
32
+ net-http-persistent (2.9.4)
33
+ nokogiri (1.7.1)
34
+ mini_portile2 (~> 2.1.0)
35
+ ntlm-http (0.1.1)
36
+ rake (10.4.2)
37
+ unf (0.1.4)
38
+ unf_ext
39
+ unf_ext (0.0.7.2)
40
+ webrobots (0.1.2)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ DropSync!
47
+ bundler (~> 1.14)
48
+ rake (~> 10.0)
49
+
50
+ BUNDLED WITH
51
+ 1.14.6
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Gérson Mendes de Souza
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # DropSync
2
+
3
+ A simple Dropbox client to download files or folders.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'DropSync'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install DropSync
20
+
21
+ ## Usage
22
+
23
+ On your terminal, call:
24
+
25
+ `./dropsync access_token filename`
26
+
27
+ The access token can be found at [Dropbox Developers](https://www.dropbox.com/developers).
28
+
29
+ That's it :)
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/DropSync.
40
+
41
+
42
+ ## License
43
+
44
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
45
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/dropsync ADDED
@@ -0,0 +1,12 @@
1
+ # !/usr/bin/env ruby
2
+ require 'dropsync'
3
+
4
+ unless ARGV.count == 2
5
+ puts "Enter your access token and filename"
6
+ raise "Wrong input arguments"
7
+ end
8
+
9
+ access_token, filename = ARGV[0], ARGV[1]
10
+
11
+ drop_sync = DropSync::Engine.new(access_token)
12
+ drop_sync.download(filename)
data/lib/dropsync.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'dropsync/dropsync'
2
+ require 'dropsync/version'
3
+ require 'dropsync/mecha'
4
+ require 'dropbox_sdk'
@@ -0,0 +1,36 @@
1
+ module DropSync
2
+ class Engine
3
+ def initialize(access_token)
4
+ puts '--- DropSync ---'
5
+ @client = DropboxClient.new(access_token)
6
+ end
7
+
8
+ def download(filename)
9
+ puts "> Searching for #{filename}"
10
+ url = get_url(filename)
11
+ puts '> Downloading file'
12
+ Mecha.automatic_download(filename, url)
13
+ puts '> Download finished!'
14
+ logout
15
+ end
16
+
17
+ private
18
+ def get_url(filename)
19
+ resp = @client.search('/', clean_up(filename))
20
+ for item in resp
21
+ path = item['path']
22
+ end
23
+ @client.shares(path)['url']
24
+ end
25
+
26
+ def logout
27
+ @client = nil
28
+ exit(0)
29
+ end
30
+
31
+ def clean_up(str)
32
+ return str.gsub(/^\/+/, '') if str
33
+ str
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,23 @@
1
+ require 'mechanize'
2
+ require 'fileutils'
3
+
4
+ module DropSync
5
+ class Mecha
6
+
7
+ def self.automatic_download(filename, url)
8
+ agent = Mechanize.new do |agent|
9
+ agent.user_agent_alias = 'Mac Safari'
10
+ end
11
+
12
+ page = agent.get(url)
13
+ link = page.uri.to_s.gsub('dl=0', 'dl=1')
14
+ download_path = "#{File.expand_path('~')}/Downloads"
15
+ FileUtils.cd(download_path)
16
+ FileUtils.mkdir(filename)
17
+ FileUtils.cd(filename)
18
+ system("curl -L -s -o #{download_path}/#{filename}/#{filename}.zip #{link}")
19
+ system("unzip #{download_path}/#{filename}/#{filename}.zip > /dev/null 2>&1")
20
+ system("rmdir __MACOSX | rm #{filename}.zip")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module DropSync
2
+ VERSION = "1.0.1.pre"
3
+ end
Binary file
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: DropSync
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Frank Kair
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dropbox-sdk
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: mechanize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.7.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.7.5
69
+ description: Simple Dropbox CLI to download files and folders.
70
+ email:
71
+ - frankkair@gmail.com
72
+ executables:
73
+ - dropsync
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - DropSync.gemspec
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/dropsync
84
+ - lib/dropsync.rb
85
+ - lib/dropsync/dropsync.rb
86
+ - lib/dropsync/mecha.rb
87
+ - lib/dropsync/version.rb
88
+ - pkg/DropSync-1.0.1.pre.gem
89
+ homepage: https://www.github.com/FrankKair/DropSync
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">"
105
+ - !ruby/object:Gem::Version
106
+ version: 1.3.1
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Simple Dropbox CLI
113
+ test_files: []