dbox 0.6.11 → 0.6.12
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.
- data/History.txt +5 -0
- data/VERSION +1 -1
- data/bin/dbox +4 -2
- data/dbox.gemspec +2 -2
- data/lib/dbox.rb +19 -0
- data/lib/dbox/api.rb +1 -0
- data/spec/dbox_spec.rb +39 -0
- metadata +4 -4
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 0.6.12 / 2012-06-01
|
2
|
+
* Minor Enhancements
|
3
|
+
* Added clone_or_pull operation for if you aren't sure if the local folder exists yet or not.
|
4
|
+
* Added delete operation for deleting a remote Dropbox folder as well as the local folder if it exists.
|
5
|
+
|
1
6
|
== 0.6.11 / 2012-04-10
|
2
7
|
* Minor Enhancements
|
3
8
|
* Added operations that failed change calculation to result hash on pull.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.12
|
data/bin/dbox
CHANGED
@@ -16,6 +16,8 @@ Commands:
|
|
16
16
|
push [<local_path>] Push changes to Dropbox
|
17
17
|
sync [<local_path>] Sync changes to Dropbox
|
18
18
|
move <new_remote_path> [<local_path>] Move the remote Dropbox folder to a new location
|
19
|
+
delete <remote_path> [<local_path>] Delete a Dropbox folder (local path optional, it will be deleted too if provided)
|
20
|
+
clone_or_pull <remote_path> [<local_path>] Clone an existing Dropbox folder, or pull if it already exists locally
|
19
21
|
|
20
22
|
Environment varables needed for everything:
|
21
23
|
export DROPBOX_APP_KEY=cmlrrjd3j0gbend
|
@@ -40,9 +42,9 @@ args = ARGV[1..-1]
|
|
40
42
|
case command
|
41
43
|
when "authorize"
|
42
44
|
Dbox.authorize
|
43
|
-
when "create", "clone"
|
45
|
+
when "create", "clone", "clone_or_pull", "delete"
|
44
46
|
unless args.size >= 1
|
45
|
-
puts "Error: Please provide a remote path
|
47
|
+
puts "Error: Please provide a remote path"
|
46
48
|
print_usage_and_quit
|
47
49
|
end
|
48
50
|
|
data/dbox.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dbox"
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ken Pratt"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-06-01"
|
13
13
|
s.description = "An easy-to-use Dropbox client with fine-grained control over syncs."
|
14
14
|
s.email = "ken@kenpratt.net"
|
15
15
|
s.executables = ["dbox"]
|
data/lib/dbox.rb
CHANGED
@@ -47,6 +47,14 @@ module Dbox
|
|
47
47
|
Dbox::Syncer.pull(local_path)
|
48
48
|
end
|
49
49
|
|
50
|
+
def self.clone_or_pull(remote_path, local_path)
|
51
|
+
if exists?(local_path)
|
52
|
+
pull(local_path)
|
53
|
+
else
|
54
|
+
clone(remote_path, local_path)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
50
58
|
def self.push(local_path)
|
51
59
|
log.debug "Pushing (local: #{local_path})"
|
52
60
|
local_path = clean_local_path(local_path)
|
@@ -76,6 +84,17 @@ module Dbox
|
|
76
84
|
Dbox::Database.exists?(local_path)
|
77
85
|
end
|
78
86
|
|
87
|
+
def self.delete(remote_path, local_path = nil)
|
88
|
+
log.debug "Deleting (remote: #{remote_path})"
|
89
|
+
remote_path = clean_remote_path(remote_path)
|
90
|
+
Dbox::Syncer.api.delete_dir(remote_path)
|
91
|
+
if local_path
|
92
|
+
local_path = clean_local_path(local_path)
|
93
|
+
log.debug "Deleting (local_path: #{local_path})"
|
94
|
+
FileUtils.rm_rf(local_path) if File.exists?(local_path)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
79
98
|
private
|
80
99
|
|
81
100
|
def self.clean_remote_path(path)
|
data/lib/dbox/api.rb
CHANGED
data/spec/dbox_spec.rb
CHANGED
@@ -219,6 +219,28 @@ describe Dbox do
|
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
222
|
+
describe "#clone_or_pull" do
|
223
|
+
it "creates the local directory" do
|
224
|
+
Dbox.create(@remote, @local)
|
225
|
+
rm_rf @local
|
226
|
+
@local.should_not exist
|
227
|
+
Dbox.clone_or_pull(@remote, @local).should eql(:created => [], :deleted => [], :updated => [""], :failed => [])
|
228
|
+
@local.should exist
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should fail if the remote does not exist" do
|
232
|
+
expect { Dbox.clone_or_pull(@remote, @local) }.to raise_error(Dbox::RemoteMissing)
|
233
|
+
@local.should_not exist
|
234
|
+
end
|
235
|
+
|
236
|
+
it "shold be able to pull changes on existing repo" do
|
237
|
+
Dbox.create(@remote, @local)
|
238
|
+
@local.should exist
|
239
|
+
Dbox.clone_or_pull(@remote, @local).should eql(:created => [], :deleted => [], :updated => [], :failed => [])
|
240
|
+
@local.should exist
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
222
244
|
describe "#push" do
|
223
245
|
it "should fail if the local dir is missing" do
|
224
246
|
expect { Dbox.push(@local) }.to raise_error(Dbox::DatabaseError)
|
@@ -511,4 +533,21 @@ describe Dbox do
|
|
511
533
|
Dbox.pull(@alternate).should eql(:created => ["subdir", "subdir/one.txt"], :deleted => [], :updated => [""], :failed => [])
|
512
534
|
end
|
513
535
|
end
|
536
|
+
|
537
|
+
describe "#delete" do
|
538
|
+
it "should delete the remote directory" do
|
539
|
+
Dbox.create(@remote, @local)
|
540
|
+
rm_rf @local
|
541
|
+
Dbox.delete(@remote)
|
542
|
+
expect { Dbox.clone(@remote, @local) }.to raise_error(Dbox::RemoteMissing)
|
543
|
+
end
|
544
|
+
|
545
|
+
it "should delete the local directory if given" do
|
546
|
+
Dbox.create(@remote, @local)
|
547
|
+
@local.should exist
|
548
|
+
Dbox.delete(@remote, @local)
|
549
|
+
@local.should_not exist
|
550
|
+
expect { Dbox.clone(@remote, @local) }.to raise_error(Dbox::RemoteMissing)
|
551
|
+
end
|
552
|
+
end
|
514
553
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 12
|
10
|
+
version: 0.6.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Pratt
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-01 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: multipart-post
|