dropbox-utility 0.0.4
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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/bin/dropbox-utility +35 -0
- data/dropbox_utility.gemspec +24 -0
- data/lib/dropbox_utility.rb +30 -0
- data/lib/dropbox_utility/client.rb +17 -0
- data/lib/dropbox_utility/config.rb +14 -0
- data/lib/dropbox_utility/files.rb +29 -0
- data/lib/dropbox_utility/session.rb +41 -0
- data/lib/dropbox_utility/version.rb +3 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 53aaed46cc53f78c3ddecb139af7bc7f74265ef0
|
4
|
+
data.tar.gz: 672b454ea693ba6c3811d96ab748806bb5e0dcab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75739619e46d7b4e81995e3e89617cfc89622ef24516c85043fa191cc87a14e0fe5475af4a24ab447c42272b23e45a5699705160eba5b69ffae17ee6e2efee8b
|
7
|
+
data.tar.gz: 8cdb21ac3ab49e5f560f82b750070bfda69cd8b3d0c292eb7b2e1d69651fd0f5342c824702eadc5692f5bf329d58cdb7ceb573d8efb642c559db8453dc836fbc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Casey Scarborough
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Dropbox Utility
|
2
|
+
|
3
|
+
This application is a simple command-line RubyGem utility for interacting with Dropbox. The application is in the
|
4
|
+
beginning stages of development, and more features are planned.
|
5
|
+
|
6
|
+
The current features are listed below:
|
7
|
+
|
8
|
+
* Display user information
|
9
|
+
* Upload single files
|
10
|
+
* List directory contents
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
The following is the usage instructions for the application.
|
16
|
+
|
17
|
+
```
|
18
|
+
Usage: dropbox-utility [options]
|
19
|
+
-i, --info Displays user information
|
20
|
+
-u, --upload FILENAME Specifies filename to upload
|
21
|
+
-l, --list [PATH] Lists contents of PATH specified.
|
22
|
+
Uses root directory if PATH not given.
|
23
|
+
```
|
24
|
+
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
|
29
|
+
If you'd like to use the application, you can install it by running the following command from the command
|
30
|
+
line on your machine.
|
31
|
+
```
|
32
|
+
gem install dropbox-utility
|
33
|
+
```
|
34
|
+
|
35
|
+
After the installation finishes, run <code>bundle
|
36
|
+
If you'd like to contribute, you can begin by cloning the repository or
|
37
|
+
[downloading the zip archive](https://github.com/caseyscarborough/dropbox-utility/archive/master.zip) and
|
38
|
+
extracting it.
|
39
|
+
|
40
|
+
For the application to work, you must add your Dropbox Developer application key and secret to the file located at
|
41
|
+
<code>lib/dropbox-utility/config.rb</code>, as well as the save location for your configuration file, shown below.
|
42
|
+
```ruby
|
43
|
+
APP_KEY = 'your-app-key'
|
44
|
+
APP_SECRET = 'your-app-secret'
|
45
|
+
ACCESS_TYPE = :dropbox
|
46
|
+
AUTH_FILE = Dir.home + '/.dropbox-utility'
|
47
|
+
```
|
48
|
+
|
49
|
+
If you do not have an application key and secret, you can begin by going to [https://www.dropbox.com/developers/apps](https://www.dropbox.com/developers/apps)
|
50
|
+
and creating an app.
|
51
|
+
|
52
|
+
After completing this, run <code>bundle install</code> and then the executable file located in the <code>bin</code> directory.
|
53
|
+
|
54
|
+
```
|
55
|
+
$ bundle install
|
56
|
+
$ ruby bin/dropbox-utility
|
57
|
+
```
|
58
|
+
|
59
|
+
The first time you run the application, you will need to authenticate the application by clicking 'Allow' in
|
60
|
+
the browser window that appears. After that, your session will be saved in your user directory in a file named
|
61
|
+
<code>.dropbox-utility</code>.
|
62
|
+
|
63
|
+
## To-do
|
64
|
+
|
65
|
+
* Add more features.
|
66
|
+
* Possibly refactor to be more intuitive.
|
67
|
+
* Add tests using Rspec.
|
68
|
+
* Create documentation.
|
69
|
+
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Please feel free to contribute to the application by following the steps below:
|
74
|
+
|
75
|
+
1. Fork it
|
76
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
77
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
78
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
79
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/dropbox-utility
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require_relative '../lib/dropbox_utility'
|
5
|
+
|
6
|
+
|
7
|
+
DropboxUtility::authenticate
|
8
|
+
|
9
|
+
options = {}
|
10
|
+
help = nil
|
11
|
+
|
12
|
+
OptionParser.new do |o|
|
13
|
+
o.banner = "Usage: #{o.program_name} [options]"
|
14
|
+
|
15
|
+
o.on('-i','--info','Displays user information') { |o| options[:user_info] = o }
|
16
|
+
o.on('-u FILENAME','--upload FILENAME','Specifies filename to upload') { |o| options[:filename] = o }
|
17
|
+
o.on('-l [PATH]','--list [PATH]', 'Lists contents of PATH specified.',
|
18
|
+
'Uses root directory if PATH not given.') { |o| options[:folder] = o ? o : '/' }
|
19
|
+
|
20
|
+
help = o.to_s
|
21
|
+
|
22
|
+
if ARGV.length == 0 then puts help; exit end
|
23
|
+
|
24
|
+
begin
|
25
|
+
o.parse!
|
26
|
+
rescue Exception => e
|
27
|
+
puts e.message
|
28
|
+
abort help
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:user_info] then DropboxUtility::client.get_info end
|
34
|
+
if options[:filename] then DropboxUtility::Files::upload(options[:filename]) end
|
35
|
+
if options[:folder] then DropboxUtility::Files::list(options[:folder]) end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dropbox_utility/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dropbox-utility"
|
8
|
+
spec.version = DropboxUtility::VERSION
|
9
|
+
spec.authors = ["Casey Scarborough"]
|
10
|
+
spec.email = ["caseyscarborough@gmail.com"]
|
11
|
+
spec.description = %q{A Ruby client for Dropbox.}
|
12
|
+
spec.summary = %q{A command-line utility that allows users to
|
13
|
+
interact with their Dropbox accounts.}
|
14
|
+
spec.homepage = "https://github.com/caseyscarborough/dropbox-utility"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require 'dropbox_sdk'
|
3
|
+
require 'launchy'
|
4
|
+
rescue Exception => e
|
5
|
+
puts "Some gems are missing."
|
6
|
+
abort e.message
|
7
|
+
end
|
8
|
+
|
9
|
+
require_relative'dropbox_utility/config'
|
10
|
+
require_relative 'dropbox_utility/version'
|
11
|
+
require_relative 'dropbox_utility/session'
|
12
|
+
require_relative 'dropbox_utility/client'
|
13
|
+
require_relative 'dropbox_utility/files'
|
14
|
+
|
15
|
+
|
16
|
+
module DropboxUtility
|
17
|
+
|
18
|
+
@@session = nil
|
19
|
+
@@client = nil
|
20
|
+
|
21
|
+
def self.authenticate
|
22
|
+
@@session = Session::exists? ? Session::retrieve : Session::create
|
23
|
+
@@client = Client.new(@@session, Config::ACCESS_TYPE)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.client
|
27
|
+
@@client
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DropboxUtility
|
2
|
+
class Client < DropboxClient
|
3
|
+
|
4
|
+
def get_info
|
5
|
+
client_info = self.account_info()
|
6
|
+
puts "\n" + client_info["display_name"]
|
7
|
+
puts client_info["email"]
|
8
|
+
puts "Referral Link: " + client_info["referral_link"]
|
9
|
+
puts "\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_directory_contents(directory)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DropboxUtility
|
2
|
+
module Config
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_accessor :APP_KEY, :APP_SECRET, :ACCESS_TYPE, :AUTH_FILE
|
6
|
+
end
|
7
|
+
|
8
|
+
APP_KEY = 'eaqsgu2lehyemly'
|
9
|
+
APP_SECRET = 'wpjhl7ouzais0hb'
|
10
|
+
ACCESS_TYPE = :dropbox
|
11
|
+
AUTH_FILE = Dir.home + '/.dropbox-utility'
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module DropboxUtility
|
2
|
+
module Files
|
3
|
+
|
4
|
+
def self.upload(filename)
|
5
|
+
begin
|
6
|
+
file = open(filename)
|
7
|
+
DropboxUtility::client.put_file('/' + filename, file)
|
8
|
+
puts "File #{filename} successfully uploaded."
|
9
|
+
rescue Exception => e
|
10
|
+
abort e.message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.list(folder = '/')
|
15
|
+
begin
|
16
|
+
files_metadata = DropboxUtility::client.metadata(folder)
|
17
|
+
files_metadata["contents"].each do |f|
|
18
|
+
path = f["path"]
|
19
|
+
name = File.basename(path)
|
20
|
+
if (f["is_dir"]) then name += '/' end
|
21
|
+
puts name
|
22
|
+
end
|
23
|
+
rescue Exception => e
|
24
|
+
abort e.message
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DropboxUtility
|
2
|
+
module Session
|
3
|
+
|
4
|
+
def self.retrieve
|
5
|
+
File.open(DropboxUtility::Config::AUTH_FILE, 'r') do |f|
|
6
|
+
DropboxSession::deserialize(f.read)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.save(session)
|
11
|
+
File.open(DropboxUtility::Config::AUTH_FILE, 'w') do |f|
|
12
|
+
f.write session.serialize
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.exists?
|
17
|
+
File.exists?(DropboxUtility::Config::AUTH_FILE)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create
|
21
|
+
session = DropboxSession.new(DropboxUtility::Config::APP_KEY, DropboxUtility::Config::APP_SECRET)
|
22
|
+
|
23
|
+
session.get_request_token
|
24
|
+
authorize_url = session.get_authorize_url("")
|
25
|
+
|
26
|
+
Launchy.open(authorize_url)
|
27
|
+
puts "After authorizing the application, press the 'Enter' key."
|
28
|
+
STDIN.gets
|
29
|
+
|
30
|
+
begin
|
31
|
+
session.get_access_token
|
32
|
+
puts "Authorization successful. Saving session..."
|
33
|
+
save(session)
|
34
|
+
session
|
35
|
+
rescue Exception => e
|
36
|
+
abort e.message
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dropbox-utility
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Casey Scarborough
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-28 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: A Ruby client for Dropbox.
|
42
|
+
email:
|
43
|
+
- caseyscarborough@gmail.com
|
44
|
+
executables:
|
45
|
+
- dropbox-utility
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/dropbox-utility
|
55
|
+
- dropbox_utility.gemspec
|
56
|
+
- lib/dropbox_utility.rb
|
57
|
+
- lib/dropbox_utility/client.rb
|
58
|
+
- lib/dropbox_utility/config.rb
|
59
|
+
- lib/dropbox_utility/files.rb
|
60
|
+
- lib/dropbox_utility/session.rb
|
61
|
+
- lib/dropbox_utility/version.rb
|
62
|
+
homepage: https://github.com/caseyscarborough/dropbox-utility
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.0.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A command-line utility that allows users to interact with their Dropbox accounts.
|
86
|
+
test_files: []
|