dbox 0.4.3 → 0.4.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.
Files changed (6) hide show
  1. data/Rakefile +3 -0
  2. data/VERSION +1 -1
  3. data/dbox.gemspec +11 -2
  4. data/lib/dbox/db.rb +24 -3
  5. data/lib/dbox.rb +5 -0
  6. metadata +53 -6
data/Rakefile CHANGED
@@ -14,6 +14,9 @@ Jeweler::Tasks.new do |gem|
14
14
  gem.email = "ken@kenpratt.net"
15
15
  gem.authors = ["Ken Pratt"]
16
16
  gem.executables = ["dbox"]
17
+ gem.add_dependency "multipart-post", ">= 1.1.2"
18
+ gem.add_dependency "oauth", ">= 0.4.5"
19
+ gem.add_dependency "json", ">= 1.5.3"
17
20
  end
18
21
  Jeweler::RubygemsDotOrgTasks.new
19
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.4
data/dbox.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dbox}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Ken Pratt}]
12
- s.date = %q{2011-05-19}
12
+ s.date = %q{2011-06-28}
13
13
  s.description = %q{An easy-to-use Dropbox client with fine-grained control over syncs.}
14
14
  s.email = %q{ken@kenpratt.net}
15
15
  s.executables = [%q{dbox}]
@@ -52,9 +52,18 @@ Gem::Specification.new do |s|
52
52
  s.specification_version = 3
53
53
 
54
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<multipart-post>, [">= 1.1.2"])
56
+ s.add_runtime_dependency(%q<oauth>, [">= 0.4.5"])
57
+ s.add_runtime_dependency(%q<json>, [">= 1.5.3"])
55
58
  else
59
+ s.add_dependency(%q<multipart-post>, [">= 1.1.2"])
60
+ s.add_dependency(%q<oauth>, [">= 0.4.5"])
61
+ s.add_dependency(%q<json>, [">= 1.5.3"])
56
62
  end
57
63
  else
64
+ s.add_dependency(%q<multipart-post>, [">= 1.1.2"])
65
+ s.add_dependency(%q<oauth>, [">= 0.4.5"])
66
+ s.add_dependency(%q<json>, [">= 1.5.3"])
58
67
  end
59
68
  end
60
69
 
data/lib/dbox/db.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  module Dbox
2
2
  class MissingDatabase < RuntimeError; end
3
+ class CorruptDatabase < RuntimeError; end
3
4
  class BadPath < RuntimeError; end
4
5
 
5
6
  class DB
6
7
  include Loggable
7
8
 
8
9
  DB_FILE = ".dropbox.db"
10
+ DB_TMPFILE = ".dropbox.db.tmp"
9
11
 
10
12
  attr_accessor :local_path
11
13
 
@@ -38,9 +40,19 @@ module Dbox
38
40
  File.exists?(db_file(local_path))
39
41
  end
40
42
 
43
+ def self.corrupt?(local_path)
44
+ begin
45
+ load(local_path)
46
+ false
47
+ rescue CorruptDatabase
48
+ true
49
+ end
50
+ end
51
+
41
52
  def self.load(local_path)
42
53
  if exists?(local_path)
43
54
  db = File.open(db_file(local_path), "r") {|f| YAML::load(f.read) }
55
+ raise CorruptDatabase unless db && db.kind_of?(DB)
44
56
  db.local_path = local_path
45
57
  db
46
58
  else
@@ -60,7 +72,8 @@ module Dbox
60
72
 
61
73
  def save
62
74
  self.class.saving_timestamp(@local_path) do
63
- File.open(db_file, "w") {|f| f << YAML::dump(self) }
75
+ File.open(db_tmpfile, "w") {|f| f << YAML::dump(self) }
76
+ FileUtils.mv(db_tmpfile, db_file)
64
77
  end
65
78
  end
66
79
 
@@ -95,7 +108,7 @@ module Dbox
95
108
  end
96
109
 
97
110
  def relative_to_local_path(path)
98
- if path.any?
111
+ if path && path.length > 0
99
112
  File.join(@local_path, path)
100
113
  else
101
114
  @local_path
@@ -103,7 +116,7 @@ module Dbox
103
116
  end
104
117
 
105
118
  def relative_to_remote_path(path)
106
- if path.any?
119
+ if path && path.length > 0
107
120
  File.join(@remote_path, path)
108
121
  else
109
122
  @remote_path
@@ -128,10 +141,18 @@ module Dbox
128
141
  File.join(local_path, DB_FILE)
129
142
  end
130
143
 
144
+ def self.db_tmpfile(local_path)
145
+ File.join(local_path, DB_TMPFILE)
146
+ end
147
+
131
148
  def db_file
132
149
  self.class.db_file(@local_path)
133
150
  end
134
151
 
152
+ def db_tmpfile
153
+ self.class.db_tmpfile(@local_path)
154
+ end
155
+
135
156
  class DropboxBlob
136
157
  include Loggable
137
158
 
data/lib/dbox.rb CHANGED
@@ -51,6 +51,11 @@ module Dbox
51
51
  Dbox::DB.exists?(local_path)
52
52
  end
53
53
 
54
+ def self.corrupt?(local_path)
55
+ local_path = clean_local_path(local_path)
56
+ Dbox::DB.corrupt?(local_path)
57
+ end
58
+
54
59
  private
55
60
 
56
61
  def self.clean_remote_path(path)
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: 9
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 4
10
+ version: 0.4.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ken Pratt
@@ -15,9 +15,56 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-19 00:00:00 Z
19
- dependencies: []
20
-
18
+ date: 2011-06-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: multipart-post
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 23
29
+ segments:
30
+ - 1
31
+ - 1
32
+ - 2
33
+ version: 1.1.2
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: oauth
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 5
45
+ segments:
46
+ - 0
47
+ - 4
48
+ - 5
49
+ version: 0.4.5
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: json
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 5
61
+ segments:
62
+ - 1
63
+ - 5
64
+ - 3
65
+ version: 1.5.3
66
+ type: :runtime
67
+ version_requirements: *id003
21
68
  description: An easy-to-use Dropbox client with fine-grained control over syncs.
22
69
  email: ken@kenpratt.net
23
70
  executables: