dragonfly-dropbox_data_store 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +130 -0
- data/Rakefile +3 -0
- data/dragonfly-dropbox_data_store.gemspec +27 -0
- data/lib/dragonfly/dropbox_data_store/railtie.rb +9 -0
- data/lib/dragonfly/dropbox_data_store/rake.rb +41 -0
- data/lib/dragonfly/dropbox_data_store/tasks.rake +15 -0
- data/lib/dragonfly/dropbox_data_store/version.rb +5 -0
- data/lib/dragonfly/dropbox_data_store.rb +100 -0
- data/spec/config.example.yml +6 -0
- data/spec/dropbox_data_store_spec.rb +116 -0
- data/spec/fixtures/piglets.jpg +0 -0
- data/spec/spec_helper.rb +38 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 065750e9175d0182bc6efdc75c752b80ab47a823
|
4
|
+
data.tar.gz: 2c4403f42eb29490ce3069cf15da786c55d6f279
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dabb8699df8c8d0e241af30ede930c618d099cfacff1c33a2f59dc8ffbfdb5e178632f4f32898d8f8accc516c03a3357628e0cdde5360bc5868b5daf29e2b29f
|
7
|
+
data.tar.gz: 10603b9be488a4a7b0bcf2ccfe40961952a4d1fb77fd307af1ba524f47f9bb3a21adc5ff56316f53b785dfe95b329c938800c5cc0857cfc77fea90266ca6a0e4
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Daniel Leavitt
|
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,130 @@
|
|
1
|
+
# Dragonfly::DropboxDataStore
|
2
|
+
|
3
|
+
[Dropbox](https://www.dropbox.com/developers) data store for [Dragonfly](https://github.com/markevans/dragonfly) uploads.
|
4
|
+
|
5
|
+
Ganked from [here](https://github.com/markevans/dragonfly-s3_data_store) and [here](https://github.com/robin850/carrierwave-dropbox) and then sort of mashed together.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Gem
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'dragonfly-dropbox_data_store'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install dragonfly-dropbox_data_store
|
22
|
+
|
23
|
+
### Dropbox app setup
|
24
|
+
|
25
|
+
Go here and create a new app: https://www.dropbox.com/developers/apps
|
26
|
+
|
27
|
+
Select "Dropbox API App" and then "Datastores only."
|
28
|
+
|
29
|
+
The latter option means the app can only access files within its application sandbox rather than your whole Dropbox. This sandbox is located in `Apps/{your-app-name}` within your Dropbox.
|
30
|
+
|
31
|
+
Once you've created your app, you can use the supplied rake task to generate the rest of your credentials.
|
32
|
+
|
33
|
+
$ rake dropbox:authorize APP_KEY=your_app_key APP_SECRET=your_app_secret
|
34
|
+
|
35
|
+
If you're using Rails it should just work. Otherwise you'll have to add something like this to your Rakefile:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
# Rakefile
|
39
|
+
load "dragonfly/dropbox_data_store/tasks.rake"
|
40
|
+
```
|
41
|
+
|
42
|
+
Hold on to these creds for the next step.
|
43
|
+
|
44
|
+
## Useage
|
45
|
+
|
46
|
+
### Configuration
|
47
|
+
|
48
|
+
In your Dragonfly config file:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require 'dragonfly/dropbox_data_store'
|
52
|
+
|
53
|
+
Dragonfly.app.configure do
|
54
|
+
# ...
|
55
|
+
|
56
|
+
datastore :dropbox,
|
57
|
+
app_key: ENV['DROPBOX_APP_KEY'],
|
58
|
+
app_secret: ENV['DROPBOX_APP_SECRET'],
|
59
|
+
access_token: ENV['DROPBOX_ACCESS_TOKEN'],
|
60
|
+
access_token_secret: ENV['DROPBOX_ACCESS_TOKEN_SECRET'],
|
61
|
+
user_id: ENV['DROPBOX_USER_ID'],
|
62
|
+
root_path: Rails.env # optional
|
63
|
+
|
64
|
+
# ...
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
68
|
+
### All config options
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
:app_key
|
72
|
+
:app_secret
|
73
|
+
:access_token
|
74
|
+
:access_token_secret
|
75
|
+
:user_id
|
76
|
+
:access_type # only app_folder for now.
|
77
|
+
:store_meta # whether to store file metadata. default: true
|
78
|
+
:root_path # where inside your app dir to put this stuff. default: '/'
|
79
|
+
```
|
80
|
+
|
81
|
+
### Per-storage options
|
82
|
+
|
83
|
+
You can set the path for the uploaded file:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
Dragonfly.app.store(some_file, path: 'some/path.txt')
|
87
|
+
```
|
88
|
+
|
89
|
+
This is _not_ relative to your `root_path`. Dropbox will automatically name files so as to avoid conflicts.
|
90
|
+
|
91
|
+
### Dropbox Image URLs
|
92
|
+
|
93
|
+
You can get direct Dropbox links to your uploads like so:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
Dragonfly.app.remote_url_for('some/uid')
|
97
|
+
```
|
98
|
+
|
99
|
+
or
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
my_model.attachment.remote_url
|
103
|
+
```
|
104
|
+
|
105
|
+
By default these return a "share" URL - a nice shortened permalink to the item in question. If you want expiring links, you can generate them like this:
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
my_model.attachment.remote_url(expires: true)
|
109
|
+
```
|
110
|
+
|
111
|
+
They'll expire in about four hours.
|
112
|
+
|
113
|
+
## Contributing
|
114
|
+
|
115
|
+
Fork & PR.
|
116
|
+
|
117
|
+
## To Do
|
118
|
+
|
119
|
+
- Get it to work with "dropbox-style" (full permissions) apps. Maybe.
|
120
|
+
- Wipe out empty directories.
|
121
|
+
- Make the path generation method customizable.
|
122
|
+
- See if we can do something useful with Dropbox's metadata.
|
123
|
+
|
124
|
+
### Testing
|
125
|
+
|
126
|
+
Check the setup instructions to get your creds. Then make a config file:
|
127
|
+
|
128
|
+
$ cp spec/config.sample.yml spec/config.yml
|
129
|
+
|
130
|
+
Fill the new config file in with your creds. The tests only run against the live Dropbox API for now, so you'll need real creds, and you'll want to make sure there's nothing in your app's `/dragonfly_test` dir (it gets wiped out every run.)
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dragonfly/dropbox_data_store/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dragonfly-dropbox_data_store"
|
8
|
+
spec.version = Dragonfly::DropboxDataStore::VERSION
|
9
|
+
spec.authors = ["Daniel Leavitt"]
|
10
|
+
spec.email = ["daniel.leavitt@gmail.com"]
|
11
|
+
spec.summary = %q{Dropbox data store for Dragonfly}
|
12
|
+
spec.description = %q{Dragonfly plugin for storing attachments on Dropbox}
|
13
|
+
spec.homepage = "https://github.com/dleavitt/dragonfly-dropbox_data_store"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.0"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "dragonfly", "~> 1.0"
|
26
|
+
spec.add_runtime_dependency "dropbox-sdk", "~> 1.6"
|
27
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Ganked verbatim from: https://github.com/janko-m/paperclip-dropbox
|
2
|
+
|
3
|
+
require "dropbox_sdk"
|
4
|
+
|
5
|
+
module Dragonfly
|
6
|
+
class DropboxDataStore
|
7
|
+
module Rake
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def authorize(app_key, app_secret, access_type)
|
11
|
+
session = create_new_session(app_key, app_secret)
|
12
|
+
|
13
|
+
puts "Visit this URL: #{session.get_authorize_url}"
|
14
|
+
print "And after you approved the authorization confirm it here (y/n): "
|
15
|
+
|
16
|
+
assert_answer!
|
17
|
+
session.get_access_token
|
18
|
+
dropbox_client = DropboxClient.new(session, access_type)
|
19
|
+
account_info = dropbox_client.account_info
|
20
|
+
|
21
|
+
puts <<-MESSAGE
|
22
|
+
|
23
|
+
Authorization was successful. Here you go:
|
24
|
+
|
25
|
+
access_token: #{session.access_token.key}
|
26
|
+
access_token_secret: #{session.access_token.secret}
|
27
|
+
user_id: #{account_info["uid"]}
|
28
|
+
MESSAGE
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_new_session(app_key, app_secret)
|
32
|
+
DropboxSession.new(app_key, app_secret)
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert_answer!
|
36
|
+
answer = STDIN.gets.strip
|
37
|
+
exit if answer == "n"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Ganked verbatim from: https://github.com/janko-m/paperclip-dropbox
|
2
|
+
|
3
|
+
require "dragonfly/dropbox_data_store/rake"
|
4
|
+
|
5
|
+
namespace :dropbox do
|
6
|
+
desc "Obtains your Dropbox credentials"
|
7
|
+
task :authorize do
|
8
|
+
if ENV["APP_KEY"].nil? or ENV["APP_SECRET"].nil?
|
9
|
+
puts "USAGE: `rake dropbox:authorize APP_KEY=your_app_key APP_SECRET=your_app_secret`"
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
Dragonfly::DropboxDataStore::Rake.authorize(ENV["APP_KEY"], ENV["APP_SECRET"], 'app_folder')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'dragonfly'
|
2
|
+
require 'dropbox_sdk'
|
3
|
+
require 'dragonfly/dropbox_data_store/version'
|
4
|
+
require 'dragonfly/dropbox_data_store/railtie' if defined?(Rails)
|
5
|
+
|
6
|
+
Dragonfly::App.register_datastore(:dropbox) { Dragonfly::DropboxDataStore }
|
7
|
+
|
8
|
+
module Dragonfly
|
9
|
+
class DropboxDataStore
|
10
|
+
attr_accessor :app_key, :app_secret, :access_token, :access_token_secret,
|
11
|
+
:user_id, :access_type, :store_meta, :root_path
|
12
|
+
|
13
|
+
def initialize(opts = {})
|
14
|
+
@app_key = opts[:app_key]
|
15
|
+
@app_secret = opts[:app_secret]
|
16
|
+
@access_token = opts[:access_token]
|
17
|
+
@access_token_secret = opts[:access_token_secret]
|
18
|
+
@user_id = opts[:user_id]
|
19
|
+
@access_type = opts[:access_type] || 'app_folder' # dropbox|app_folder
|
20
|
+
|
21
|
+
@store_meta = opts[:store_meta]
|
22
|
+
# TODO: this should default to 'dragonfly' for dropbox access type
|
23
|
+
@root_path = opts[:root_path] || ''
|
24
|
+
|
25
|
+
# TODO: path for access_type=dropbox
|
26
|
+
# TODO: how is path typically specified in dragonfly? leading slash?
|
27
|
+
end
|
28
|
+
|
29
|
+
def write(content, opts = {})
|
30
|
+
# TODO: deal with dropbox vs. app_folder stuff
|
31
|
+
# figure out how paths work for each
|
32
|
+
path = opts[:path] || absolute(relative_path_for(content.name || 'file'))
|
33
|
+
data_path = storage.put_file(path, content.file)['path']
|
34
|
+
storage.put_file(meta_path(data_path), YAML.dump(content.meta)) if store_meta?
|
35
|
+
relative(data_path)
|
36
|
+
end
|
37
|
+
|
38
|
+
def read(path)
|
39
|
+
path = absolute(path)
|
40
|
+
# TODO: possibly return some of dropbox's native metadata automatically
|
41
|
+
wrap_error do
|
42
|
+
[ storage.get_file(path),
|
43
|
+
store_meta? && YAML.load(storage.get_file(meta_path(path))) ]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy(path)
|
48
|
+
path = absolute(path)
|
49
|
+
# TODO: purge empty directories
|
50
|
+
wrap_error { storage.file_delete(meta_path(path)) } if store_meta?
|
51
|
+
wrap_error { storage.file_delete(path) }
|
52
|
+
end
|
53
|
+
|
54
|
+
# Only option is "expires" and it's a boolean
|
55
|
+
def url_for(path, opts = {})
|
56
|
+
path = absolute(path)
|
57
|
+
(opts[:expires] ? storage.media(path) : storage.shares(path))['url']
|
58
|
+
end
|
59
|
+
|
60
|
+
# TODO: thumbnail data-uri
|
61
|
+
|
62
|
+
def store_meta?
|
63
|
+
@store_meta != false # Default to true if not set
|
64
|
+
end
|
65
|
+
|
66
|
+
def storage
|
67
|
+
@storage ||= begin
|
68
|
+
session = DropboxSession.new(app_key, app_secret)
|
69
|
+
session.set_access_token(access_token, access_token_secret)
|
70
|
+
DropboxClient.new(session, access_type)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
protected
|
75
|
+
|
76
|
+
def wrap_error
|
77
|
+
yield
|
78
|
+
rescue DropboxError
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
|
82
|
+
def absolute(relative_path)
|
83
|
+
relative_path.to_s == '.' ? root_path : File.join(root_path, relative_path)
|
84
|
+
end
|
85
|
+
|
86
|
+
def relative(absolute_path)
|
87
|
+
absolute_path[/^\/?#{Regexp.escape root_path}\/?(.*)$/, 1]
|
88
|
+
end
|
89
|
+
|
90
|
+
def meta_path(data_path)
|
91
|
+
"#{data_path}.meta.yml"
|
92
|
+
end
|
93
|
+
|
94
|
+
# TODO: make this overrideable via param
|
95
|
+
def relative_path_for(filename)
|
96
|
+
time = Time.now
|
97
|
+
"#{time.strftime('%Y/%m/%d/')}#{rand(1e15).to_s(36)}_#{filename.gsub(/[^\w.]+/,'_')}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dragonfly::DropboxDataStore do
|
4
|
+
|
5
|
+
def assert_exists(path)
|
6
|
+
path = absolute_path(path)
|
7
|
+
expect { @data_store.storage.get_file(path) }.not_to raise_error
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_does_not_exist(path)
|
11
|
+
path = absolute_path(path)
|
12
|
+
expect { @data_store.storage.get_file(path) }.to raise_error(DropboxError)
|
13
|
+
end
|
14
|
+
|
15
|
+
def absolute_path(path)
|
16
|
+
File.join(@root_path, path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def fixture(name)
|
20
|
+
File.open(File.join(File.dirname(__FILE__), 'fixtures', "#{name}"))
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:app) { Dragonfly.app }
|
24
|
+
let(:content) { content1 }
|
25
|
+
let(:content1) { Dragonfly::Content.new(app, "pigbot") }
|
26
|
+
let(:content2) { Dragonfly::Content.new(app, "pigbot2") }
|
27
|
+
let(:new_content) { Dragonfly::Content.new(app) }
|
28
|
+
|
29
|
+
it_should_behave_like 'data_store'
|
30
|
+
|
31
|
+
describe "registering with a symbol" do
|
32
|
+
it "registers a symbol for configuring" do
|
33
|
+
app.configure { datastore :dropbox }
|
34
|
+
app.datastore.should be_a(Dragonfly::DropboxDataStore)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "write" do
|
39
|
+
it "doesn't overwrite duplicate files" do
|
40
|
+
path = absolute_path("thepath")
|
41
|
+
path1 = @data_store.write(content1, :path => path)
|
42
|
+
path2 = @data_store.write(content2, :path => path)
|
43
|
+
expect(@data_store.read(path1)[0]).to eq content1.data
|
44
|
+
expect(@data_store.read(path2)[0]).to eq content2.data
|
45
|
+
expect(path1).not_to eq path2
|
46
|
+
end
|
47
|
+
|
48
|
+
# yanked wholecloth from: https://github.com/markevans/dragonfly-s3_data_store
|
49
|
+
it "should use the name from the content if set" do
|
50
|
+
content1.name = 'doobie.doo'
|
51
|
+
uid = @data_store.write(content1)
|
52
|
+
uid.should =~ /doobie\.doo$/
|
53
|
+
new_content.update(*@data_store.read(uid))
|
54
|
+
new_content.data.should == 'pigbot'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should work ok with files with funny names" do
|
58
|
+
content.name = "A Picture with many spaces in its name (at 20:00 pm).png"
|
59
|
+
uid = @data_store.write(content)
|
60
|
+
uid.should =~ /A_Picture_with_many_spaces_in_its_name_at_20_00_pm_\.png$/
|
61
|
+
new_content.update(*@data_store.read(uid))
|
62
|
+
new_content.data.should == 'pigbot'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should allow for setting the path manually" do
|
66
|
+
uid = @data_store.write(content, :path => absolute_path('hello/there'))
|
67
|
+
uid.should =~ /hello\/there/
|
68
|
+
new_content.update(*@data_store.read(uid))
|
69
|
+
new_content.data.should == 'pigbot'
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'writes a metadata file' do
|
73
|
+
uid = @data_store.write(content)
|
74
|
+
assert_exists("#{uid}.meta.yml")
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'metadata disabled' do
|
78
|
+
before { @data_store.store_meta = false }
|
79
|
+
|
80
|
+
it 'does not write a metadata file' do
|
81
|
+
uid = @data_store.write(content)
|
82
|
+
assert_does_not_exist("#{uid}.meta.yml")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe 'url_for' do
|
88
|
+
let(:content) { Dragonfly::Content.new(app, fixture('piglets.jpg')) }
|
89
|
+
let(:uid) { @data_store.write(content) }
|
90
|
+
|
91
|
+
it "returns a URL" do
|
92
|
+
expect(@data_store.url_for(uid)).to start_with 'http'
|
93
|
+
end
|
94
|
+
|
95
|
+
context "without the expires option" do
|
96
|
+
it "returns a shortened URL" do
|
97
|
+
expect(@data_store.url_for(uid)).to start_with 'https://db.tt'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "with the expires option set" do
|
102
|
+
it "returns a full URL" do
|
103
|
+
expect(@data_store.url_for(uid, expires: true)).to start_with 'https://dl.dropboxusercontent.com'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe 'destroy' do
|
109
|
+
it 'destroys the metadata file' do
|
110
|
+
uid = @data_store.write(content)
|
111
|
+
assert_exists("#{uid}.meta.yml")
|
112
|
+
@data_store.destroy(uid)
|
113
|
+
assert_does_not_exist("#{uid}.meta.yml")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'dragonfly/dropbox_data_store'
|
3
|
+
require 'dragonfly/spec/data_store_examples'
|
4
|
+
|
5
|
+
config_path = "#{File.dirname(__FILE__)}/config.yml"
|
6
|
+
|
7
|
+
if File.exist?(config_path)
|
8
|
+
CREDS = YAML.load_file(config_path)
|
9
|
+
else
|
10
|
+
raise 'Please create a config file at spec/config.yml'
|
11
|
+
end
|
12
|
+
|
13
|
+
raise 'Please use an app_folder app' if CREDS['access_type'] == 'dropbox'
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.order = 'random'
|
17
|
+
|
18
|
+
config.before(:each) do
|
19
|
+
@root_path = 'dragonfly_test'
|
20
|
+
|
21
|
+
@data_store = Dragonfly::DropboxDataStore.new(
|
22
|
+
:app_key => CREDS['app_key'],
|
23
|
+
:app_secret => CREDS['app_secret'],
|
24
|
+
:access_token => CREDS['access_token'],
|
25
|
+
:access_token_secret => CREDS['access_token_secret'],
|
26
|
+
:user_id => CREDS['user_id'],
|
27
|
+
:access_type => CREDS['access_type'],
|
28
|
+
:root_path => @root_path
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
config.after(:all) do
|
33
|
+
begin
|
34
|
+
@data_store.storage.file_delete(@root_path)
|
35
|
+
rescue DropboxError
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dragonfly-dropbox_data_store
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Leavitt
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-04 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dragonfly
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dropbox-sdk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.6'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.6'
|
83
|
+
description: Dragonfly plugin for storing attachments on Dropbox
|
84
|
+
email:
|
85
|
+
- daniel.leavitt@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- dragonfly-dropbox_data_store.gemspec
|
96
|
+
- lib/dragonfly/dropbox_data_store.rb
|
97
|
+
- lib/dragonfly/dropbox_data_store/railtie.rb
|
98
|
+
- lib/dragonfly/dropbox_data_store/rake.rb
|
99
|
+
- lib/dragonfly/dropbox_data_store/tasks.rake
|
100
|
+
- lib/dragonfly/dropbox_data_store/version.rb
|
101
|
+
- spec/config.example.yml
|
102
|
+
- spec/dropbox_data_store_spec.rb
|
103
|
+
- spec/fixtures/piglets.jpg
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
homepage: https://github.com/dleavitt/dragonfly-dropbox_data_store
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.0.3
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Dropbox data store for Dragonfly
|
129
|
+
test_files:
|
130
|
+
- spec/config.example.yml
|
131
|
+
- spec/dropbox_data_store_spec.rb
|
132
|
+
- spec/fixtures/piglets.jpg
|
133
|
+
- spec/spec_helper.rb
|