Class: Quiver::Adapter::Dropbox
- Inherits:
-
Object
- Object
- Quiver::Adapter::Dropbox
- Defined in:
- lib/quiver/adapter/dropbox.rb
Instance Method Summary collapse
- #client ⇒ Object
- #each(path) ⇒ Object
-
#image_url(path) ⇒ Object
Don’t include this url direct on your site.
-
#initialize(root, access_key) ⇒ Dropbox
constructor
A new instance of Dropbox.
- #load(path) ⇒ Object
- #save(path, content) ⇒ Object
Constructor Details
Instance Method Details
#client ⇒ Object
12 13 14 |
# File 'lib/quiver/adapter/dropbox.rb', line 12 def client @client ||= ::DropboxApi::Client.new(@access_key) end |
#each(path) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/quiver/adapter/dropbox.rb', line 21 def each(path) = client.(normalize_path(path)) ['contents'].each do |content| next unless content['is_dir'] yield Pathname.new(content['path']) end end |
#image_url(path) ⇒ Object
Don’t include this url direct on your site. Use via cdn.
17 18 19 20 |
# File 'lib/quiver/adapter/dropbox.rb', line 17 def image_url(path) @@image_url_cache ||= {} @@image_url_cache[path] ||= client.get_temporary_link(normalize_path(path)).link end |
#load(path) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/quiver/adapter/dropbox.rb', line 28 def load(path) content = nil = client.download(normalize_path(path)) do |con| content = con end [content, ] end |
#save(path, content) ⇒ Object
35 36 37 |
# File 'lib/quiver/adapter/dropbox.rb', line 35 def save(path, content) client.upload normalize_path(path), content end |