browse-everything 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -6
- data/HISTORY.md +5 -0
- data/README.md +27 -30
- data/lib/browse_everything.rb +7 -1
- data/lib/browse_everything/driver/{drop_box.rb → dropbox.rb} +4 -4
- data/lib/browse_everything/engine.rb +4 -6
- data/lib/browse_everything/retriever.rb +1 -1
- data/lib/browse_everything/version.rb +1 -1
- data/lib/generators/browse_everything/config_generator.rb +6 -9
- data/lib/generators/browse_everything/templates/browse_everything_providers.yml.example +1 -1
- data/spec/fixtures/file_system/file 1.pdf +0 -0
- data/spec/fixtures/vcr_cassettes/dropbox.yml +5 -5
- data/spec/spec_helper.rb +3 -3
- data/spec/unit/browser_spec.rb +14 -14
- data/spec/unit/{drop_box_spec.rb → dropbox_spec.rb} +13 -13
- data/spec/unit/file_system_spec.rb +9 -1
- data/spec/unit/retriever_spec.rb +15 -2
- data/spec/views/browse_everything/_file.html.erb_spec.rb +1 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 894c8d28a00f0474da1f807768bb9cccc8add97e
|
4
|
+
data.tar.gz: dcaed8f54b8a79085536dd6a4b0c8743a9e370e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dad070cc647aece52eff80592a4ccaa702d195c87c37641f8b352c6b705db6c91c3b80b4c8132f3d461e22f4336b247e7d3a2594262cc9618bf5d8450bf38024
|
7
|
+
data.tar.gz: 1b8d2de4bc7415b2c504f5df2a979499d7f5142492d67b5e2b2e932395b35298cbd7adc3dcf42185211cad130f38502435424001e3074f3bda5c33c2f049f3c2
|
data/.travis.yml
CHANGED
@@ -2,20 +2,22 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
4
|
rvm:
|
5
|
-
- 2.
|
5
|
+
- 2.2
|
6
6
|
env:
|
7
7
|
global:
|
8
8
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
9
9
|
matrix:
|
10
|
-
- "RAILS_VERSION=4.1.
|
11
|
-
- "RAILS_VERSION=4.2.
|
10
|
+
- "RAILS_VERSION=4.1.10"
|
11
|
+
- "RAILS_VERSION=4.2.1"
|
12
12
|
|
13
13
|
matrix:
|
14
14
|
include:
|
15
|
-
- rvm: 1
|
16
|
-
env: "RAILS_VERSION=4.1
|
15
|
+
- rvm: 2.1
|
16
|
+
env: "RAILS_VERSION=4.2.1"
|
17
17
|
- rvm: 2.0
|
18
|
-
env: "RAILS_VERSION=4.1
|
18
|
+
env: "RAILS_VERSION=4.2.1"
|
19
|
+
- rvm: 1.9.3
|
20
|
+
env: "RAILS_VERSION=4.2.1"
|
19
21
|
|
20
22
|
notifications:
|
21
23
|
irc: "irc.freenode.org#projecthydra"
|
data/HISTORY.md
CHANGED
data/README.md
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
|
4
4
|
# BrowseEverything
|
5
5
|
|
6
|
-
This Gem allows your rails application to access user files from cloud storage.
|
7
|
-
Currently there are drivers implemented for [
|
8
|
-
[Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com),
|
6
|
+
This Gem allows your rails application to access user files from cloud storage.
|
7
|
+
Currently there are drivers implemented for [Dropbox](http://www.dropbox.com),
|
8
|
+
[Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com),
|
9
9
|
[Box](http://www.box.com), and a server-side directory share.
|
10
10
|
|
11
|
-
The gem uses [OAuth](http://oauth.net/) to connect to a user's account and
|
12
|
-
generate a list of single use urls that your application can then use to
|
11
|
+
The gem uses [OAuth](http://oauth.net/) to connect to a user's account and
|
12
|
+
generate a list of single use urls that your application can then use to
|
13
13
|
download the files.
|
14
14
|
|
15
15
|
**This gem does not depend on hydra-head**
|
@@ -27,18 +27,18 @@ And then execute:
|
|
27
27
|
Or install it yourself as:
|
28
28
|
|
29
29
|
$ gem install browse-everything
|
30
|
-
|
30
|
+
|
31
31
|
### Configuring the gem
|
32
|
-
|
32
|
+
|
33
33
|
After installing the gem, run the generator
|
34
34
|
|
35
35
|
$ rails g browse_everything:config
|
36
|
-
|
36
|
+
|
37
37
|
This generator will set up the _config/browse_everything_providers.yml_ file and add the browse-everything engine to your application's routes.
|
38
38
|
|
39
|
-
If you prefer not to use the generator, or need info on how to set up providers in the browse_everything_providers.yml, use the info on [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything).
|
39
|
+
If you prefer not to use the generator, or need info on how to set up providers in the browse_everything_providers.yml, use the info on [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything).
|
40
40
|
|
41
|
-
### Include the CSS and JavaScript
|
41
|
+
### Include the CSS and JavaScript
|
42
42
|
|
43
43
|
Add `@import "browse_everything";` to your application.css.scss
|
44
44
|
|
@@ -47,7 +47,7 @@ Add `//= require browse_everything` to your application.js
|
|
47
47
|
## Usage
|
48
48
|
|
49
49
|
### Adding Providers
|
50
|
-
In order to connect to a provider like [
|
50
|
+
In order to connect to a provider like [Dropbox](http://www.dropbox.com),
|
51
51
|
[Skydrive](https://skydrive.live.com/), [Google Drive](http://drive.google.com), or
|
52
52
|
[Box](http://www.box.com), you must provide API keys in _config/browse_everything_providers.yml_. For info on how to edit this file, see [Configuring browse-everything](https://github.com/projecthydra/browse-everything/wiki/Configuring-browse-everything)
|
53
53
|
|
@@ -57,8 +57,7 @@ browse-everything can be triggered in two ways -- either via data attributes in
|
|
57
57
|
|
58
58
|
#### Options
|
59
59
|
|
60
|
-
|
61
|
-
| Name | Type | Default | Description |
|
60
|
+
| Name | Type | Default | Description |
|
62
61
|
|-----------------|-----------------|-----------------|----------------------------------------------------------------|
|
63
62
|
| route | path (required) | '' | The base route of the browse-everything engine. |
|
64
63
|
| target | xpath or jQuery | null | A form object to add the results to as hidden fields. |
|
@@ -68,7 +67,6 @@ browse-everything can be triggered in two ways -- either via data attributes in
|
|
68
67
|
If a `target` is provided, browse-everything will automatically convert the JSON response to a series of hidden form fields
|
69
68
|
that can be posted back to Rails to re-create the array on the server side.
|
70
69
|
|
71
|
-
|
72
70
|
#### Via data attributes
|
73
71
|
|
74
72
|
To trigger browse-everything using data attributes, set the _data-toggle_ attribute to "browse-everything" on the HTML tag. This tells the javascript where to attach the browse-everything behaviors. Pass in the options using the _data-route_ and _data-target_ attributes, as in `data-target="#myForm"`.
|
@@ -76,13 +74,13 @@ To trigger browse-everything using data attributes, set the _data-toggle_ attrib
|
|
76
74
|
For example:
|
77
75
|
|
78
76
|
```html
|
79
|
-
<button type="button" data-toggle="browse-everything" data-route="<%=browse_everything_engine.root_path%>"
|
77
|
+
<button type="button" data-toggle="browse-everything" data-route="<%=browse_everything_engine.root_path%>"
|
80
78
|
data-target="#myForm" class="btn btn-large btn-success" id="browse">Browse!</button>
|
81
79
|
```
|
82
80
|
|
83
81
|
#### Via JavaScript
|
84
82
|
|
85
|
-
To trigger browse-everything via javascript, use the .browseEverything() method to attach the behaviors to DOM elements.
|
83
|
+
To trigger browse-everything via javascript, use the .browseEverything() method to attach the behaviors to DOM elements.
|
86
84
|
|
87
85
|
```javascript
|
88
86
|
$('#browse').browseEverything(options)
|
@@ -98,20 +96,19 @@ $('#browse').browseEverything({
|
|
98
96
|
|
99
97
|
See [JavaScript Methods](https://github.com/projecthydra/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
|
100
98
|
|
101
|
-
|
102
|
-
### The Results (Data Structure)
|
99
|
+
### The Results (Data Structure)
|
103
100
|
|
104
101
|
browse-everything returns a JSON data structure consisting of an array of URL specifications. Each URL specification
|
105
102
|
is a plain object with the following properties:
|
106
103
|
|
107
|
-
| Property | Description
|
104
|
+
| Property | Description |
|
108
105
|
|--------------------|--------------------------------------------------------------------------------------|
|
109
|
-
| url | The URL of the selected remote file.
|
106
|
+
| url | The URL of the selected remote file. |
|
110
107
|
| auth_header | Any headers that need to be added to the request in order to access the remote file. |
|
111
|
-
| expires | The expiration date/time of the specified URL.
|
108
|
+
| expires | The expiration date/time of the specified URL. |
|
112
109
|
| file_name | The base name (filename.ext) of the selected file. |
|
113
110
|
|
114
|
-
For example, after picking two files from dropbox,
|
111
|
+
For example, after picking two files from dropbox,
|
115
112
|
|
116
113
|
If you initialized browse-everything via JavaScript, the results data passed to the `.done()` callback will look like this:
|
117
114
|
```json
|
@@ -127,19 +124,19 @@ If you initialized browse-everything via JavaScript, the results data passed to
|
|
127
124
|
}
|
128
125
|
]
|
129
126
|
```
|
130
|
-
See [JavaScript Methods](https://github.com/projecthydra/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
|
127
|
+
See [JavaScript Methods](https://github.com/projecthydra/browse-everything/wiki/JavaScript-Methods) for more info on using javascript to trigger browse-everything.
|
131
128
|
|
132
129
|
If you initialized browse-everything via data-attributes and set the _target_ option (via the _data-target_ attribute or via the _target_ option on the javascript method), the results data be written as hidden fields in the `<form>` you've specified as the target. When the user submits that form, the results will look like this:
|
133
130
|
```ruby
|
134
131
|
"selected_files" => {
|
135
132
|
"0"=>{
|
136
|
-
"url"=>"https://dl.dropbox.com/fake/filepicker-demo.txt.txt",
|
137
|
-
"expires"=>"2014-03-31T20:37:36.214Z",
|
133
|
+
"url"=>"https://dl.dropbox.com/fake/filepicker-demo.txt.txt",
|
134
|
+
"expires"=>"2014-03-31T20:37:36.214Z",
|
138
135
|
"file_name"=>"filepicker-demo.txt.txt"
|
139
|
-
},
|
136
|
+
},
|
140
137
|
"1"=>{
|
141
|
-
"url"=>"https://dl.dropbox.com/fake/Getting%20Started.pdf",
|
142
|
-
"expires"=>"2014-03-31T20:37:36.731Z",
|
138
|
+
"url"=>"https://dl.dropbox.com/fake/Getting%20Started.pdf",
|
139
|
+
"expires"=>"2014-03-31T20:37:36.731Z",
|
143
140
|
"file_name"=>"Getting Started.pdf"
|
144
141
|
}
|
145
142
|
}
|
@@ -174,7 +171,7 @@ end
|
|
174
171
|
### Examples
|
175
172
|
|
176
173
|
See `spec/support/app/views/file_handler/index.html` for an example use case. You can also run `rake app:generate` to
|
177
|
-
create a fully-functioning demo app in `spec/internal` (though you will have to create
|
174
|
+
create a fully-functioning demo app in `spec/internal` (though you will have to create
|
178
175
|
`spec/internal/config/browse_everything.providers.yml` file with your own configuration info.)
|
179
176
|
|
180
177
|
## Contributing
|
@@ -185,6 +182,6 @@ create a fully-functioning demo app in `spec/internal` (though you will have to
|
|
185
182
|
4. Push to the branch (`git push origin my-new-feature`)
|
186
183
|
5. Create new Pull Request
|
187
184
|
|
188
|
-
## Help
|
185
|
+
## Help
|
189
186
|
|
190
187
|
For help with Questioning Authority, contact <hydra-tech@googlegroups.com>.
|
data/lib/browse_everything.rb
CHANGED
@@ -11,7 +11,7 @@ module BrowseEverything
|
|
11
11
|
module Driver
|
12
12
|
autoload :Base, 'browse_everything/driver/base'
|
13
13
|
autoload :FileSystem, 'browse_everything/driver/file_system'
|
14
|
-
autoload :
|
14
|
+
autoload :Dropbox, 'browse_everything/driver/dropbox'
|
15
15
|
autoload :SkyDrive, 'browse_everything/driver/sky_drive'
|
16
16
|
autoload :Box, 'browse_everything/driver/box'
|
17
17
|
autoload :GoogleDrive, 'browse_everything/driver/google_drive'
|
@@ -23,6 +23,12 @@ module BrowseEverything
|
|
23
23
|
@config = value
|
24
24
|
elsif value.kind_of?(String)
|
25
25
|
@config = YAML.load(File.read(value))
|
26
|
+
|
27
|
+
if @config.include? 'drop_box'
|
28
|
+
warn "[DEPRECATION] `drop_box` is deprecated. Please use `dropbox` instead."
|
29
|
+
@config['dropbox'] = @config.delete('drop_box')
|
30
|
+
end
|
31
|
+
|
26
32
|
else
|
27
33
|
raise InitializationError, "Unrecognized configuration: #{value.inspect}"
|
28
34
|
end
|
@@ -2,15 +2,15 @@ require 'dropbox_sdk'
|
|
2
2
|
|
3
3
|
module BrowseEverything
|
4
4
|
module Driver
|
5
|
-
class
|
5
|
+
class Dropbox < Base
|
6
6
|
|
7
7
|
def icon
|
8
8
|
'dropbox'
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def validate_config
|
12
12
|
unless [:app_key,:app_secret].all? { |key| config[key].present? }
|
13
|
-
raise BrowseEverything::InitializationError, "
|
13
|
+
raise BrowseEverything::InitializationError, "Dropbox driver requires :app_key and :app_secret"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -46,7 +46,7 @@ module BrowseEverything
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def auth_link
|
49
|
-
[ auth_flow.start('
|
49
|
+
[ auth_flow.start('dropbox'), @csrf ]
|
50
50
|
end
|
51
51
|
|
52
52
|
def connect(params,data)
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module BrowseEverything
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Rails.application.config.assets.precompile += %w{ browse_everything.css }
|
8
|
-
end
|
3
|
+
config.assets.paths << config.root.join('vendor', 'assets', 'javascripts')
|
4
|
+
config.assets.paths << config.root.join('vendor', 'assets', 'stylesheets')
|
5
|
+
config.assets.precompile += %w{ browse_everything.js }
|
6
|
+
config.assets.precompile += %w{ browse_everything.css }
|
9
7
|
end
|
10
8
|
end
|
@@ -8,24 +8,21 @@ class BrowseEverything::ConfigGenerator < Rails::Generators::Base
|
|
8
8
|
2. Modifies your app's routes.rb to mount BrowseEverything at /browse
|
9
9
|
"""
|
10
10
|
source_root File.expand_path('../templates', __FILE__)
|
11
|
-
|
11
|
+
|
12
12
|
def inject_routes
|
13
13
|
insert_into_file "config/routes.rb", :after => ".draw do" do
|
14
14
|
%{
|
15
15
|
mount BrowseEverything::Engine => '/browse'}
|
16
16
|
end
|
17
|
-
end
|
18
|
-
|
17
|
+
end
|
18
|
+
|
19
19
|
def copy_example_config
|
20
20
|
copy_file "browse_everything_providers.yml.example", "config/browse_everything_providers.yml"
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def insert_file_system_path
|
24
|
-
insert_into_file "config/browse_everything_providers.yml", :before => "#
|
24
|
+
insert_into_file "config/browse_everything_providers.yml", :before => "# dropbox:" do
|
25
25
|
YAML.dump({ 'file_system' => { :home => Rails.root.to_s }})
|
26
26
|
end
|
27
27
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# To make browse-everything aware of a provider, uncomment the info for that provider and add your API key information.
|
3
3
|
# The file_system provider can be a path to any directory on the server where your application is running.
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# dropbox:
|
6
6
|
# :app_key: YOUR_DROPBOX_APP_KEY
|
7
7
|
# :app_secret: YOUR_DROPBOX_APP_SECRET
|
8
8
|
# box:
|
Binary file
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri: https://
|
5
|
+
uri: https://DropboxAppKey:DropboxAppSecret@api.dropbox.com/1/oauth2/token
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
8
|
string: grant_type=authorization_code&code=FakeDropboxAuthorizationCodeABCDEFG&redirect_uri=http%3A%2F%2Fbrowse.example.edu%2Fbrowse%2Fconnect
|
@@ -341,7 +341,7 @@ http_interactions:
|
|
341
341
|
X-RequestId: 83bc363934d5a5457cbcbd0fab8b4cfb
|
342
342
|
body:
|
343
343
|
encoding: UTF-8
|
344
|
-
string: ! '{ "revision": 4009, "rev": "fa900cbb190", "thumb_exists": false, "bytes": 20904,
|
344
|
+
string: ! '{ "revision": 4009, "rev": "fa900cbb190", "thumb_exists": false, "bytes": 20904,
|
345
345
|
"modified": "Sat, 09 Apr 2011 18:54:54 +0000", "client_mtime": "Sat, 09 Apr 2011 18:54:54 +0000",
|
346
346
|
"path": "/Writer/Writer FAQ.txt", "is_dir": false, "icon": "page_white_text", "root":
|
347
347
|
"dropbox", "mime_type": "text/plain", "size": "20.4 KB" }'
|
@@ -382,9 +382,9 @@ http_interactions:
|
|
382
382
|
X-RequestId: 83bc363934d5a5457cbcbd0fab8b4cfb
|
383
383
|
body:
|
384
384
|
encoding: UTF-8
|
385
|
-
string: ! '{ "revision": 2754, "rev": "ac200cbb190", "thumb_exists": false,
|
386
|
-
"bytes": 988, "modified": "Thu, 14 Oct 2010 08:32:20 +0000",
|
387
|
-
"client_mtime": "Thu, 14 Oct 2010 08:32:20 +0000",
|
385
|
+
string: ! '{ "revision": 2754, "rev": "ac200cbb190", "thumb_exists": false,
|
386
|
+
"bytes": 988, "modified": "Thu, 14 Oct 2010 08:32:20 +0000",
|
387
|
+
"client_mtime": "Thu, 14 Oct 2010 08:32:20 +0000",
|
388
388
|
"path": "/Writer/Markdown Test.txt", "is_dir": false, "icon": "page_white_text",
|
389
389
|
"root": "dropbox", "mime_type": "text/plain", "size": "988 bytes" }'
|
390
390
|
http_version: '1.1'
|
data/spec/spec_helper.rb
CHANGED
@@ -44,9 +44,9 @@ module BrowserConfigHelper
|
|
44
44
|
client_id: "BoxClientId",
|
45
45
|
client_secret: "BoxClientSecret"
|
46
46
|
},
|
47
|
-
"
|
48
|
-
app_key: "
|
49
|
-
app_secret: "
|
47
|
+
"dropbox" => {
|
48
|
+
app_key: "DropboxAppKey",
|
49
|
+
app_secret: "DropboxAppSecret"
|
50
50
|
},
|
51
51
|
"google_drive" => {
|
52
52
|
client_id: "GoogleClientId",
|
data/spec/unit/browser_spec.rb
CHANGED
@@ -3,24 +3,24 @@ require File.expand_path('../../spec_helper',__FILE__)
|
|
3
3
|
include BrowserConfigHelper
|
4
4
|
|
5
5
|
describe BrowseEverything::Browser do
|
6
|
-
let(:file_config) {
|
6
|
+
let(:file_config) {
|
7
7
|
{
|
8
8
|
file_system: { home: '/file/config/home' },
|
9
|
-
|
9
|
+
dropbox: { app_key: 'FileConfigKey', app_secret: 'FileConfigSecret' }
|
10
10
|
}.to_yaml
|
11
11
|
}
|
12
12
|
|
13
13
|
let(:global_config) {
|
14
14
|
{
|
15
15
|
file_system: { home: '/global/config/home' },
|
16
|
-
|
16
|
+
dropbox: { app_key: 'GlobalConfigKey', app_secret: 'GlobalConfigSecret' }
|
17
17
|
}
|
18
18
|
}
|
19
19
|
|
20
20
|
let(:local_config) {
|
21
21
|
{
|
22
22
|
file_system: { home: '/local/config/home' },
|
23
|
-
|
23
|
+
dropbox: { app_key: 'LocalConfigKey', app_secret: 'LocalConfigSecret' },
|
24
24
|
url_options: url_options
|
25
25
|
}
|
26
26
|
}
|
@@ -30,47 +30,47 @@ describe BrowseEverything::Browser do
|
|
30
30
|
subject { BrowseEverything::Browser.new(url_options) }
|
31
31
|
|
32
32
|
it "should have 2 providers" do
|
33
|
-
expect(subject.providers.keys).to eq([:file_system
|
33
|
+
expect(subject.providers.keys).to eq([:file_system, :dropbox])
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should use the file configuration" do
|
37
|
-
expect(subject.providers[:
|
37
|
+
expect(subject.providers[:dropbox].config[:app_key]).to eq('FileConfigKey')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "global config" do
|
42
42
|
before(:each) { BrowseEverything.configure(global_config) }
|
43
43
|
subject { BrowseEverything::Browser.new(url_options) }
|
44
|
-
|
44
|
+
|
45
45
|
it "should have 2 providers" do
|
46
|
-
expect(subject.providers.keys).to eq([:file_system
|
46
|
+
expect(subject.providers.keys).to eq([:file_system, :dropbox])
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should use the global configuration" do
|
50
|
-
expect(subject.providers[:
|
50
|
+
expect(subject.providers[:dropbox].config[:app_key]).to eq('GlobalConfigKey')
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "local config" do
|
55
55
|
subject { BrowseEverything::Browser.new(local_config) }
|
56
|
-
|
56
|
+
|
57
57
|
it "should have 2 providers" do
|
58
|
-
expect(subject.providers.keys).to eq([:file_system
|
58
|
+
expect(subject.providers.keys).to eq([:file_system, :dropbox])
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should use the local configuration" do
|
62
|
-
expect(subject.providers[:
|
62
|
+
expect(subject.providers[:dropbox].config[:app_key]).to eq('LocalConfigKey')
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "unknown provider" do
|
67
|
-
subject {
|
67
|
+
subject {
|
68
68
|
BrowseEverything::Browser.new(local_config.merge(foo: { key: 'bar', secret: 'baz' }))
|
69
69
|
}
|
70
70
|
|
71
71
|
it "should complain but continue" do
|
72
72
|
allow(Rails.logger).to receive(:warn).with('Unknown provider: foo')
|
73
|
-
expect(subject.providers.keys).to eq([:file_system
|
73
|
+
expect(subject.providers.keys).to eq([:file_system, :dropbox])
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -2,26 +2,26 @@ require File.expand_path('../../spec_helper',__FILE__)
|
|
2
2
|
|
3
3
|
include BrowserConfigHelper
|
4
4
|
|
5
|
-
describe BrowseEverything::Driver::
|
5
|
+
describe BrowseEverything::Driver::Dropbox, vcr: { cassette_name: 'dropbox', record: :none } do
|
6
6
|
before(:all) { stub_configuration }
|
7
7
|
after(:all) { unstub_configuration }
|
8
8
|
|
9
9
|
let(:browser) { BrowseEverything::Browser.new(url_options) }
|
10
|
-
let(:provider) { browser.providers['
|
10
|
+
let(:provider) { browser.providers['dropbox'] }
|
11
11
|
let(:auth_params) { {
|
12
12
|
'code' => 'FakeDropboxAuthorizationCodeABCDEFG',
|
13
|
-
'state' => 'GjDcUhPNZrZzdsw%2FghBy2A%3D%3D|
|
13
|
+
'state' => 'GjDcUhPNZrZzdsw%2FghBy2A%3D%3D|dropbox'
|
14
14
|
} }
|
15
15
|
let(:csrf_data) { {'token' => 'GjDcUhPNZrZzdsw%2FghBy2A%3D%3D'} }
|
16
16
|
|
17
17
|
it "#validate_config" do
|
18
|
-
expect { BrowseEverything::Driver::
|
18
|
+
expect { BrowseEverything::Driver::Dropbox.new({}) }.to raise_error(BrowseEverything::InitializationError)
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "simple properties" do
|
22
22
|
subject { provider }
|
23
|
-
its(:name) { should == '
|
24
|
-
its(:key) { should == '
|
23
|
+
its(:name) { should == 'Dropbox' }
|
24
|
+
its(:key) { should == 'dropbox' }
|
25
25
|
its(:icon) { should be_a(String) }
|
26
26
|
end
|
27
27
|
|
@@ -33,7 +33,7 @@ describe BrowseEverything::Driver::DropBox, vcr: { cassette_name: 'dropbox', rec
|
|
33
33
|
context "#auth_link" do
|
34
34
|
specify { subject.auth_link[0].should start_with('https://www.dropbox.com/1/oauth2/authorize') }
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
it "should authorize" do
|
38
38
|
subject.connect(auth_params,csrf_data)
|
39
39
|
expect(subject).to be_authorized
|
@@ -59,7 +59,7 @@ describe BrowseEverything::Driver::DropBox, vcr: { cassette_name: 'dropbox', rec
|
|
59
59
|
subject { contents[4] }
|
60
60
|
its(:name) { should == 'iPad intro.pdf' }
|
61
61
|
its(:size) { should == 208218 }
|
62
|
-
its(:location) { should == "
|
62
|
+
its(:location) { should == "dropbox:/iPad intro.pdf" }
|
63
63
|
its(:type) { should == "application/pdf" }
|
64
64
|
specify { should_not be_container }
|
65
65
|
end
|
@@ -75,21 +75,21 @@ describe BrowseEverything::Driver::DropBox, vcr: { cassette_name: 'dropbox', rec
|
|
75
75
|
context "[1]" do
|
76
76
|
subject { contents[1] }
|
77
77
|
its(:name) { should == 'About Writer.txt' }
|
78
|
-
its(:location) { should == "
|
78
|
+
its(:location) { should == "dropbox:/Writer/About Writer.txt" }
|
79
79
|
its(:type) { should == "text/plain" }
|
80
80
|
specify { should_not be_container }
|
81
81
|
end
|
82
82
|
context "[2]" do
|
83
83
|
subject { contents[2] }
|
84
84
|
its(:name) { should == 'Markdown Test.txt' }
|
85
|
-
its(:location) { should == "
|
85
|
+
its(:location) { should == "dropbox:/Writer/Markdown Test.txt" }
|
86
86
|
its(:type) { should == "text/plain" }
|
87
87
|
specify { should_not be_container }
|
88
88
|
end
|
89
89
|
context "[3]" do
|
90
90
|
subject { contents[3] }
|
91
91
|
its(:name) { should == 'Writer FAQ.txt' }
|
92
|
-
its(:location) { should == "
|
92
|
+
its(:location) { should == "dropbox:/Writer/Writer FAQ.txt" }
|
93
93
|
its(:type) { should == "text/plain" }
|
94
94
|
specify { should_not be_container }
|
95
95
|
end
|
@@ -104,13 +104,13 @@ describe BrowseEverything::Driver::DropBox, vcr: { cassette_name: 'dropbox', rec
|
|
104
104
|
describe "#link_for" do
|
105
105
|
before(:each) { provider.connect(auth_params,csrf_data) }
|
106
106
|
|
107
|
-
context "[0]" do
|
107
|
+
context "[0]" do
|
108
108
|
subject { provider.link_for('/Writer/Writer FAQ.txt') }
|
109
109
|
specify { subject[0].should == "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Writer%20FAQ.txt" }
|
110
110
|
specify { subject[1].should have_key(:expires) }
|
111
111
|
end
|
112
112
|
|
113
|
-
context "[1]" do
|
113
|
+
context "[1]" do
|
114
114
|
subject { provider.link_for('/Writer/Markdown Test.txt') }
|
115
115
|
specify { subject[0].should == "https://dl.dropboxusercontent.com/1/view/FakeDropboxAccessPath/Writer/Markdown%20Test.txt" }
|
116
116
|
specify { subject[1].should have_key(:expires) }
|
@@ -36,13 +36,21 @@ describe BrowseEverything::Driver::FileSystem do
|
|
36
36
|
end
|
37
37
|
context "[2]" do
|
38
38
|
subject { contents[2] }
|
39
|
+
its(:name) { should == 'file 1.pdf' }
|
40
|
+
its(:size) { should == 2256 }
|
41
|
+
its(:location) { should == "file_system:#{File.join(home,'file 1.pdf')}" }
|
42
|
+
its(:type) { should == "application/pdf" }
|
43
|
+
specify { should_not be_container }
|
44
|
+
end
|
45
|
+
context "[3]" do
|
46
|
+
subject { contents[3] }
|
39
47
|
its(:name) { should == 'file_1.pdf' }
|
40
48
|
its(:size) { should == 2256 }
|
41
49
|
its(:location) { should == "file_system:#{File.join(home,'file_1.pdf')}" }
|
42
50
|
its(:type) { should == "application/pdf" }
|
43
51
|
specify { should_not be_container }
|
44
52
|
end
|
45
|
-
|
53
|
+
end
|
46
54
|
|
47
55
|
context "subdirectory" do
|
48
56
|
let(:contents) { provider.contents('/dir_1') }
|
data/spec/unit/retriever_spec.rb
CHANGED
@@ -3,7 +3,9 @@ require File.expand_path('../../spec_helper',__FILE__)
|
|
3
3
|
describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record: :none, } do
|
4
4
|
subject { BrowseEverything::Retriever.new }
|
5
5
|
let(:datafile) { File.expand_path('../../fixtures/file_system/file_1.pdf',__FILE__) }
|
6
|
+
let(:datafile_with_spaces) { File.expand_path('../../fixtures/file_system/file 1.pdf',__FILE__) }
|
6
7
|
let(:data) { File.open(datafile,'rb',&:read) }
|
8
|
+
let(:data_with_spaces) { File.open(datafile_with_spaces, 'rb', &:read) }
|
7
9
|
let(:size) { File.size(datafile) }
|
8
10
|
|
9
11
|
context 'http://' do
|
@@ -18,7 +20,7 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
18
20
|
}
|
19
21
|
}
|
20
22
|
}
|
21
|
-
|
23
|
+
|
22
24
|
context "#retrieve" do
|
23
25
|
it "content" do
|
24
26
|
content = ''
|
@@ -50,7 +52,12 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
50
52
|
"url"=>"file://#{datafile}",
|
51
53
|
"file_name"=>"file.pdf",
|
52
54
|
"file_size"=>size.to_s
|
53
|
-
}
|
55
|
+
},
|
56
|
+
"1" => {
|
57
|
+
"url" => "file://#{datafile_with_spaces}",
|
58
|
+
"file_name" => "file.pdf",
|
59
|
+
"file_size" => size.to_s
|
60
|
+
}
|
54
61
|
}
|
55
62
|
}
|
56
63
|
|
@@ -61,6 +68,12 @@ describe BrowseEverything::Retriever, vcr: { cassette_name: 'retriever', record:
|
|
61
68
|
expect(content).to eq(data)
|
62
69
|
end
|
63
70
|
|
71
|
+
it "content with spaces" do
|
72
|
+
content = ''
|
73
|
+
subject.retrieve(spec['1']) { |chunk, retrieved, total| content << chunk }
|
74
|
+
expect(content).to eq(data_with_spaces)
|
75
|
+
end
|
76
|
+
|
64
77
|
it "callbacks" do
|
65
78
|
expect { |block| subject.retrieve(spec['0'], &block) }.to yield_with_args(data, data.length, data.length)
|
66
79
|
end
|
@@ -13,6 +13,7 @@ describe 'browse_everything/_file.html.erb', type: :view do
|
|
13
13
|
|
14
14
|
|
15
15
|
before do
|
16
|
+
allow(view).to receive(:browse_everything_engine).and_return(BrowseEverything::Engine.routes.url_helpers)
|
16
17
|
allow(view).to receive(:file).and_return(file)
|
17
18
|
allow(view).to receive(:provider).and_return(provider)
|
18
19
|
allow(view).to receive(:path).and_return("path")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browse-everything
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carolyn Cole
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-
|
16
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rails
|
@@ -383,7 +383,7 @@ files:
|
|
383
383
|
- lib/browse_everything/browser.rb
|
384
384
|
- lib/browse_everything/driver/base.rb
|
385
385
|
- lib/browse_everything/driver/box.rb
|
386
|
-
- lib/browse_everything/driver/
|
386
|
+
- lib/browse_everything/driver/dropbox.rb
|
387
387
|
- lib/browse_everything/driver/file_system.rb
|
388
388
|
- lib/browse_everything/driver/google_drive.rb
|
389
389
|
- lib/browse_everything/driver/sky_drive.rb
|
@@ -397,6 +397,7 @@ files:
|
|
397
397
|
- spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
|
398
398
|
- spec/fixtures/file_system/dir_1/file_2.txt
|
399
399
|
- spec/fixtures/file_system/dir_2/file_4.docx
|
400
|
+
- spec/fixtures/file_system/file 1.pdf
|
400
401
|
- spec/fixtures/file_system/file_1.pdf
|
401
402
|
- spec/fixtures/vcr_cassettes/dropbox.yml
|
402
403
|
- spec/fixtures/vcr_cassettes/retriever.yml
|
@@ -408,7 +409,7 @@ files:
|
|
408
409
|
- spec/unit/base_spec.rb
|
409
410
|
- spec/unit/browse_everything_helper_spec.rb
|
410
411
|
- spec/unit/browser_spec.rb
|
411
|
-
- spec/unit/
|
412
|
+
- spec/unit/dropbox_spec.rb
|
412
413
|
- spec/unit/file_entry_spec.rb
|
413
414
|
- spec/unit/file_system_spec.rb
|
414
415
|
- spec/unit/retriever_spec.rb
|
@@ -438,7 +439,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
438
439
|
version: '0'
|
439
440
|
requirements: []
|
440
441
|
rubyforge_project:
|
441
|
-
rubygems_version: 2.
|
442
|
+
rubygems_version: 2.4.6
|
442
443
|
signing_key:
|
443
444
|
specification_version: 4
|
444
445
|
summary: AJAX/Rails engine file browser for cloud storage services
|
@@ -447,6 +448,7 @@ test_files:
|
|
447
448
|
- spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
|
448
449
|
- spec/fixtures/file_system/dir_1/file_2.txt
|
449
450
|
- spec/fixtures/file_system/dir_2/file_4.docx
|
451
|
+
- spec/fixtures/file_system/file 1.pdf
|
450
452
|
- spec/fixtures/file_system/file_1.pdf
|
451
453
|
- spec/fixtures/vcr_cassettes/dropbox.yml
|
452
454
|
- spec/fixtures/vcr_cassettes/retriever.yml
|
@@ -458,7 +460,7 @@ test_files:
|
|
458
460
|
- spec/unit/base_spec.rb
|
459
461
|
- spec/unit/browse_everything_helper_spec.rb
|
460
462
|
- spec/unit/browser_spec.rb
|
461
|
-
- spec/unit/
|
463
|
+
- spec/unit/dropbox_spec.rb
|
462
464
|
- spec/unit/file_entry_spec.rb
|
463
465
|
- spec/unit/file_system_spec.rb
|
464
466
|
- spec/unit/retriever_spec.rb
|