dropbox 0.0.6 → 0.0.7
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/ChangeLog.rdoc +5 -0
- data/README.rdoc +12 -3
- data/VERSION +1 -1
- data/examples/dropbox_spec.rb +1 -0
- data/lib/dropbox/dropbox.rb +19 -1
- metadata +3 -3
data/ChangeLog.rdoc
CHANGED
data/README.rdoc
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
= DropBox
|
|
2
2
|
|
|
3
|
-
A simple Ruby API for DropBox
|
|
3
|
+
A simple Ruby API for DropBox.
|
|
4
|
+
|
|
5
|
+
* Don't have a dropbox account? Well you should! You can "donate" to this project by signing up with this referral url: https://www.dropbox.com/referrals/NTI0MDI3MzU5
|
|
4
6
|
|
|
5
7
|
== INSTALL:
|
|
6
8
|
* sudo gem install dropbox
|
|
7
9
|
|
|
8
10
|
== USAGE:
|
|
9
11
|
|
|
10
|
-
d = DropBox.new("you@email.com","password!")
|
|
11
|
-
|
|
12
|
+
d = DropBox.new("you@email.com","password!") #login
|
|
13
|
+
d.list("/") # show directory contents
|
|
14
|
+
d.create_directory("/testdirectory") # create a remove directory
|
|
15
|
+
d.create("/local/path/to/file.txt","/testdirectory") # upload a file to the directory
|
|
16
|
+
d.rename("/testdirectory/file.txt","file.txt") # rename the file
|
|
17
|
+
d.destroy("file.txt") # remove the file
|
|
18
|
+
|
|
19
|
+
d2 = d = DropBox.new("you@email.com","password!", "optional_namespace") # all actions will happen in /optional_namesapce
|
|
20
|
+
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.7
|
data/examples/dropbox_spec.rb
CHANGED
data/lib/dropbox/dropbox.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require 'rubygems'
|
|
1
2
|
require 'nokogiri'
|
|
2
3
|
require 'mechanize'
|
|
3
4
|
|
|
@@ -142,7 +143,24 @@ class DropBox
|
|
|
142
143
|
# Will give a hash of the amount of space left on the DropBox, the amound used, the calculated amount free (all as a 1 d.p. rounded GB value) and the percentage used (scraped)
|
|
143
144
|
def usage_stats
|
|
144
145
|
login_filter
|
|
145
|
-
|
|
146
|
+
|
|
147
|
+
stats_page = @agent.get("/account")
|
|
148
|
+
|
|
149
|
+
stats = stats_page.at('#usage-percent').content.scan(/(\d+(?:\.\d+)?)%\ used\ \((\d+(?:\.\d+)?)([MG])B of (\d+(?:\.\d+)?)GB\)/).collect{ |d|
|
|
150
|
+
{ :used => d[1].to_f * ((d[2] == "G") ? 1024 : 1),
|
|
151
|
+
:total => d[3].to_f * 1024,
|
|
152
|
+
:free => (d[3].to_f * 1024 - d[1].to_f * ((d[2] == "G") ? 1024 : 1)),
|
|
153
|
+
:percent => Percentage.new(d[0].to_f/100)
|
|
154
|
+
}
|
|
155
|
+
}[0]
|
|
156
|
+
|
|
157
|
+
regular_data = stats_page.at('span.bar-graph-legend.bar-graph-normal').next.content.scan(/\((\d+(?:\.\d+)?)([MG])B/)[0]
|
|
158
|
+
stats[:regular_used] = regular_data[0].to_f * ((regular_data[1] == "G") ? 1024 : 1)
|
|
159
|
+
|
|
160
|
+
shared_data = stats_page.at('span.bar-graph-legend.bar-graph-shared').next.content.scan(/\((\d+(?:\.\d+)?)([MG])B/)[0]
|
|
161
|
+
stats[:shared_used] = shared_data[0].to_f * ((shared_data[1] == "G") ? 1024 : 1)
|
|
162
|
+
|
|
163
|
+
return stats
|
|
146
164
|
end
|
|
147
165
|
|
|
148
166
|
private
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: 0.0.
|
|
8
|
+
- 7
|
|
9
|
+
version: 0.0.7
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Tys von Gaza
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date: 2010-03-
|
|
20
|
+
date: 2010-03-11 00:00:00 -07:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|