browse-everything 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +19 -0
  2. data/.travis.yml +6 -0
  3. data/CONTRIBUTING.md +113 -0
  4. data/Gemfile +4 -0
  5. data/HISTORY.md +2 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +164 -0
  8. data/Rakefile +10 -0
  9. data/app/.DS_Store +0 -0
  10. data/app/assets/javascripts/browse_everything.js +3 -0
  11. data/app/assets/javascripts/browse_everything/behavior.js.coffee +110 -0
  12. data/app/assets/stylesheets/browse_everything.css.scss +82 -0
  13. data/app/controllers/browse_everything_controller.rb +74 -0
  14. data/app/helpers/browse_everything_helper.rb +11 -0
  15. data/app/views/.DS_Store +0 -0
  16. data/app/views/browse_everything/_auth.html.erb +3 -0
  17. data/app/views/browse_everything/_files.html.erb +12 -0
  18. data/app/views/browse_everything/_providers.html.erb +10 -0
  19. data/app/views/browse_everything/auth.html.erb +7 -0
  20. data/app/views/browse_everything/index.html.erb +28 -0
  21. data/app/views/browse_everything/resolve.html.erb +1 -0
  22. data/app/views/browse_everything/show.html.erb +9 -0
  23. data/app/views/layouts/browse_everything.html.erb +11 -0
  24. data/browse-everything.gemspec +40 -0
  25. data/config/locales/en_browse_everything.yml +13 -0
  26. data/config/routes.rb +6 -0
  27. data/lib/browse-everything.rb +1 -0
  28. data/lib/browse_everything.rb +37 -0
  29. data/lib/browse_everything/browser.rb +25 -0
  30. data/lib/browse_everything/driver/base.rb +55 -0
  31. data/lib/browse_everything/driver/box.rb +90 -0
  32. data/lib/browse_everything/driver/drop_box.rb +74 -0
  33. data/lib/browse_everything/driver/file_system.rb +62 -0
  34. data/lib/browse_everything/driver/google_drive.rb +103 -0
  35. data/lib/browse_everything/driver/sky_drive.rb +132 -0
  36. data/lib/browse_everything/engine.rb +6 -0
  37. data/lib/browse_everything/file_entry.rb +19 -0
  38. data/lib/browse_everything/version.rb +3 -0
  39. data/spec/fixtures/file_system/dir_1/dir_3/file_3.m4v +0 -0
  40. data/spec/fixtures/file_system/dir_1/file_2.txt +1 -0
  41. data/spec/fixtures/file_system/dir_2/file_4.docx +1 -0
  42. data/spec/fixtures/file_system/file_1.pdf +0 -0
  43. data/spec/fixtures/vcr_cassettes/dropbox.yml +231 -0
  44. data/spec/rake/app_spec.rb +121 -0
  45. data/spec/spec_helper.rb +56 -0
  46. data/spec/spec_helper.rb.orig +47 -0
  47. data/spec/support/app/controllers/file_handler_controller.rb +8 -0
  48. data/spec/support/app/views/file_handler/index.html.erb +22 -0
  49. data/spec/support/config/browse_everything_providers.yml.example +15 -0
  50. data/spec/support/lib/generators/test_app_generator.rb +50 -0
  51. data/spec/unit/base_spec.rb +28 -0
  52. data/spec/unit/browser_spec.rb +76 -0
  53. data/spec/unit/drop_box_spec.rb +119 -0
  54. data/spec/unit/file_entry_spec.rb +44 -0
  55. data/spec/unit/file_system_spec.rb +85 -0
  56. data/spec/unit/sky_drive_spec.rb +58 -0
  57. data/tasks/browse-everything-dev.rake +63 -0
  58. data/tasks/ci.rake +7 -0
  59. metadata +419 -0
@@ -0,0 +1,58 @@
1
+ require File.expand_path('../../spec_helper',__FILE__)
2
+
3
+
4
+
5
+ describe BrowseEverything::Driver::SkyDrive do
6
+ include BrowseEverything::Engine.routes.url_helpers
7
+
8
+ def provider_yml
9
+ {client_id: "CLIENTID", client_secret: "CLIENTSECRET", url_options:{ :port=>"3000", :protocol=>"http://", host:"example.com"}}
10
+ end
11
+
12
+ def redirect_url
13
+ connector_response_url(provider_yml[:url_options])
14
+ end
15
+
16
+ it "can connect" do
17
+ stub_request(:post, "https://login.live.com/oauth20_token.srf").
18
+ with(:body => {"client_id"=>"CLIENTID", "client_secret"=>"CLIENTSECRET", "code"=>"code", "grant_type"=>"authorization_code", "redirect_uri"=>"#{redirect_url}"}).
19
+ to_return(:status => 200,
20
+ :body => {
21
+ "token_type" => "bearer",
22
+ "expires_at" => (Time.now + (60 * 60 * 24)).to_i,
23
+ "scope" => "wl.skydrive_update,wl.offline_access",
24
+ "access_token" => "access_token",
25
+ "refresh_token" => "refresh_token",
26
+ "authentication_token" => "authentication_token"
27
+ }.to_json,
28
+ :headers => {
29
+ "content-type" => "application/json"})
30
+
31
+
32
+ driver = BrowseEverything::Driver::SkyDrive.new(provider_yml)
33
+ driver.connect({code:"code"},{})
34
+ driver.authorized?.should == true
35
+ end
36
+
37
+ it "can connect but expires" do
38
+ stub_request(:post, "https://login.live.com/oauth20_token.srf").
39
+ with(:body => {"client_id"=>"CLIENTID", "client_secret"=>"CLIENTSECRET", "code"=>"code", "grant_type"=>"authorization_code", "redirect_uri"=>"#{redirect_url}"}).
40
+ to_return(:status => 200,
41
+ :body => {
42
+ "token_type" => "bearer",
43
+ "expires_at" => (Time.now - (60 * 60 * 24)).to_i,
44
+ "scope" => "wl.skydrive_update,wl.offline_access",
45
+ "access_token" => "access_token",
46
+ "refresh_token" => "refresh_token",
47
+ "authentication_token" => "authentication_token"
48
+ }.to_json,
49
+ :headers => {
50
+ "content-type" => "application/json"})
51
+
52
+
53
+ driver = BrowseEverything::Driver::SkyDrive.new(provider_yml)
54
+ driver.connect({code:"code"},{})
55
+ driver.authorized?.should == false
56
+ end
57
+
58
+ end
@@ -0,0 +1,63 @@
1
+ namespace :app do
2
+ desc "Create the test rails app"
3
+ task :generate do
4
+ unless File.exists?('spec/internal/Rakefile')
5
+ puts "Generating rails app"
6
+ `rails new spec/internal`
7
+ puts "Updating gemfile"
8
+
9
+ `echo "gem 'browse-everything', :path=>'../../../browse-everything'
10
+ gem 'factory_girl_rails'
11
+ " >> spec/internal/Gemfile`
12
+ puts "Copying generator"
13
+ `cp -r spec/support/lib/generators spec/internal/lib`
14
+ Bundler.with_clean_env do
15
+ within_test_app do
16
+ puts "running test_app_generator"
17
+ system "rails generate test_app"
18
+ puts "Bundle install"
19
+ `bundle install`
20
+ puts "running migrations"
21
+ puts `rake db:migrate db:test:prepare`
22
+ end
23
+ end
24
+ end
25
+ puts "Done generating test app"
26
+ end
27
+
28
+ desc "Clean out the test rails app"
29
+ task :clean do
30
+ Rake::Task["app:stop"].invoke
31
+ puts "Removing sample rails app"
32
+ `rm -rf spec/internal`
33
+ end
34
+
35
+ desc "Start the test rails app"
36
+ task :start do
37
+ Bundler.with_clean_env do
38
+ within_test_app do
39
+ puts "Starting test app"
40
+ system "rails server -d"
41
+ end
42
+ end
43
+ end
44
+
45
+ desc "Stop the test rails app"
46
+ task :stop do
47
+ pid_file = 'tmp/pids/server.pid'
48
+ within_test_app do
49
+ if (File.exists?(pid_file))
50
+ pid = File.read(pid_file)
51
+ puts "Stopping pid #{pid}"
52
+ system "kill -2 #{pid}"
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ def within_test_app
59
+ return unless (File.exists?('spec/internal'))
60
+ FileUtils.cd('spec/internal')
61
+ yield
62
+ FileUtils.cd('../..')
63
+ end
data/tasks/ci.rake ADDED
@@ -0,0 +1,7 @@
1
+ desc "Run all RSpec tests."
2
+ task :ci do
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ Rake::Task["app:clean"].invoke
5
+ Rake::Task["app:generate"].invoke
6
+ Rake::Task["spec"].invoke
7
+ end
metadata ADDED
@@ -0,0 +1,419 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: browse-everything
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Carolyn Cole
9
+ - Jessie Keck
10
+ - Michael B. Klein
11
+ - Thomas Scherz
12
+ - Xiaoming Wang
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+ date: 2013-09-24 00:00:00.000000000 Z
17
+ dependencies:
18
+ - !ruby/object:Gem::Dependency
19
+ name: rails
20
+ requirement: !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirements:
23
+ - - ! '>='
24
+ - !ruby/object:Gem::Version
25
+ version: '3.1'
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ - !ruby/object:Gem::Dependency
35
+ name: sass-rails
36
+ requirement: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ - !ruby/object:Gem::Dependency
51
+ name: bootstrap-sass
52
+ requirement: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ - !ruby/object:Gem::Dependency
67
+ name: font-awesome-rails
68
+ requirement: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: google_drive
84
+ requirement: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: dropbox-sdk
100
+ requirement: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ - !ruby/object:Gem::Dependency
115
+ name: skydrive
116
+ requirement: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ type: :runtime
123
+ prerelease: false
124
+ version_requirements: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ - !ruby/object:Gem::Dependency
131
+ name: ruby-box
132
+ requirement: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ - !ruby/object:Gem::Dependency
147
+ name: google-api-client
148
+ requirement: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ type: :runtime
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ! '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ - !ruby/object:Gem::Dependency
163
+ name: rspec
164
+ requirement: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ type: :development
171
+ prerelease: false
172
+ version_requirements: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ - !ruby/object:Gem::Dependency
179
+ name: rspec-rails
180
+ requirement: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ! '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ - !ruby/object:Gem::Dependency
195
+ name: simplecov
196
+ requirement: !ruby/object:Gem::Requirement
197
+ none: false
198
+ requirements:
199
+ - - ! '>='
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ none: false
206
+ requirements:
207
+ - - ! '>='
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ - !ruby/object:Gem::Dependency
211
+ name: bundler
212
+ requirement: !ruby/object:Gem::Requirement
213
+ none: false
214
+ requirements:
215
+ - - ~>
216
+ - !ruby/object:Gem::Version
217
+ version: '1.3'
218
+ type: :development
219
+ prerelease: false
220
+ version_requirements: !ruby/object:Gem::Requirement
221
+ none: false
222
+ requirements:
223
+ - - ~>
224
+ - !ruby/object:Gem::Version
225
+ version: '1.3'
226
+ - !ruby/object:Gem::Dependency
227
+ name: pry
228
+ requirement: !ruby/object:Gem::Requirement
229
+ none: false
230
+ requirements:
231
+ - - ! '>='
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ type: :development
235
+ prerelease: false
236
+ version_requirements: !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ! '>='
240
+ - !ruby/object:Gem::Version
241
+ version: '0'
242
+ - !ruby/object:Gem::Dependency
243
+ name: rake
244
+ requirement: !ruby/object:Gem::Requirement
245
+ none: false
246
+ requirements:
247
+ - - ! '>='
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ type: :development
251
+ prerelease: false
252
+ version_requirements: !ruby/object:Gem::Requirement
253
+ none: false
254
+ requirements:
255
+ - - ! '>='
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ - !ruby/object:Gem::Dependency
259
+ name: webmock
260
+ requirement: !ruby/object:Gem::Requirement
261
+ none: false
262
+ requirements:
263
+ - - ! '>='
264
+ - !ruby/object:Gem::Version
265
+ version: '0'
266
+ type: :development
267
+ prerelease: false
268
+ version_requirements: !ruby/object:Gem::Requirement
269
+ none: false
270
+ requirements:
271
+ - - ! '>='
272
+ - !ruby/object:Gem::Version
273
+ version: '0'
274
+ - !ruby/object:Gem::Dependency
275
+ name: vcr
276
+ requirement: !ruby/object:Gem::Requirement
277
+ none: false
278
+ requirements:
279
+ - - ! '>='
280
+ - !ruby/object:Gem::Version
281
+ version: '0'
282
+ type: :development
283
+ prerelease: false
284
+ version_requirements: !ruby/object:Gem::Requirement
285
+ none: false
286
+ requirements:
287
+ - - ! '>='
288
+ - !ruby/object:Gem::Version
289
+ version: '0'
290
+ - !ruby/object:Gem::Dependency
291
+ name: sqlite3
292
+ requirement: !ruby/object:Gem::Requirement
293
+ none: false
294
+ requirements:
295
+ - - ! '>='
296
+ - !ruby/object:Gem::Version
297
+ version: '0'
298
+ type: :development
299
+ prerelease: false
300
+ version_requirements: !ruby/object:Gem::Requirement
301
+ none: false
302
+ requirements:
303
+ - - ! '>='
304
+ - !ruby/object:Gem::Version
305
+ version: '0'
306
+ description: AJAX/Rails engine file browser for cloud storage services
307
+ email:
308
+ - cam156@psu.edu
309
+ - jkeck@stanford.edu
310
+ - mbklein@gmail.com
311
+ - scherztc@ucmail.uc.edu
312
+ - xw5d@virginia.edu
313
+ executables: []
314
+ extensions: []
315
+ extra_rdoc_files: []
316
+ files:
317
+ - .gitignore
318
+ - .travis.yml
319
+ - CONTRIBUTING.md
320
+ - Gemfile
321
+ - HISTORY.md
322
+ - LICENSE.txt
323
+ - README.md
324
+ - Rakefile
325
+ - app/.DS_Store
326
+ - app/assets/javascripts/browse_everything.js
327
+ - app/assets/javascripts/browse_everything/behavior.js.coffee
328
+ - app/assets/stylesheets/browse_everything.css.scss
329
+ - app/controllers/browse_everything_controller.rb
330
+ - app/helpers/browse_everything_helper.rb
331
+ - app/views/.DS_Store
332
+ - app/views/browse_everything/_auth.html.erb
333
+ - app/views/browse_everything/_files.html.erb
334
+ - app/views/browse_everything/_providers.html.erb
335
+ - app/views/browse_everything/auth.html.erb
336
+ - app/views/browse_everything/index.html.erb
337
+ - app/views/browse_everything/resolve.html.erb
338
+ - app/views/browse_everything/show.html.erb
339
+ - app/views/layouts/browse_everything.html.erb
340
+ - browse-everything.gemspec
341
+ - config/locales/en_browse_everything.yml
342
+ - config/routes.rb
343
+ - lib/browse-everything.rb
344
+ - lib/browse_everything.rb
345
+ - lib/browse_everything/browser.rb
346
+ - lib/browse_everything/driver/base.rb
347
+ - lib/browse_everything/driver/box.rb
348
+ - lib/browse_everything/driver/drop_box.rb
349
+ - lib/browse_everything/driver/file_system.rb
350
+ - lib/browse_everything/driver/google_drive.rb
351
+ - lib/browse_everything/driver/sky_drive.rb
352
+ - lib/browse_everything/engine.rb
353
+ - lib/browse_everything/file_entry.rb
354
+ - lib/browse_everything/version.rb
355
+ - spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
356
+ - spec/fixtures/file_system/dir_1/file_2.txt
357
+ - spec/fixtures/file_system/dir_2/file_4.docx
358
+ - spec/fixtures/file_system/file_1.pdf
359
+ - spec/fixtures/vcr_cassettes/dropbox.yml
360
+ - spec/rake/app_spec.rb
361
+ - spec/spec_helper.rb
362
+ - spec/spec_helper.rb.orig
363
+ - spec/support/app/controllers/file_handler_controller.rb
364
+ - spec/support/app/views/file_handler/index.html.erb
365
+ - spec/support/config/browse_everything_providers.yml.example
366
+ - spec/support/lib/generators/test_app_generator.rb
367
+ - spec/unit/base_spec.rb
368
+ - spec/unit/browser_spec.rb
369
+ - spec/unit/drop_box_spec.rb
370
+ - spec/unit/file_entry_spec.rb
371
+ - spec/unit/file_system_spec.rb
372
+ - spec/unit/sky_drive_spec.rb
373
+ - tasks/browse-everything-dev.rake
374
+ - tasks/ci.rake
375
+ homepage: https://github.com/mbklein/browse-everything
376
+ licenses:
377
+ - Apache 2
378
+ post_install_message:
379
+ rdoc_options: []
380
+ require_paths:
381
+ - lib
382
+ required_ruby_version: !ruby/object:Gem::Requirement
383
+ none: false
384
+ requirements:
385
+ - - ! '>='
386
+ - !ruby/object:Gem::Version
387
+ version: '0'
388
+ required_rubygems_version: !ruby/object:Gem::Requirement
389
+ none: false
390
+ requirements:
391
+ - - ! '>='
392
+ - !ruby/object:Gem::Version
393
+ version: '0'
394
+ requirements: []
395
+ rubyforge_project:
396
+ rubygems_version: 1.8.23
397
+ signing_key:
398
+ specification_version: 3
399
+ summary: AJAX/Rails engine file browser for cloud storage services
400
+ test_files:
401
+ - spec/fixtures/file_system/dir_1/dir_3/file_3.m4v
402
+ - spec/fixtures/file_system/dir_1/file_2.txt
403
+ - spec/fixtures/file_system/dir_2/file_4.docx
404
+ - spec/fixtures/file_system/file_1.pdf
405
+ - spec/fixtures/vcr_cassettes/dropbox.yml
406
+ - spec/rake/app_spec.rb
407
+ - spec/spec_helper.rb
408
+ - spec/spec_helper.rb.orig
409
+ - spec/support/app/controllers/file_handler_controller.rb
410
+ - spec/support/app/views/file_handler/index.html.erb
411
+ - spec/support/config/browse_everything_providers.yml.example
412
+ - spec/support/lib/generators/test_app_generator.rb
413
+ - spec/unit/base_spec.rb
414
+ - spec/unit/browser_spec.rb
415
+ - spec/unit/drop_box_spec.rb
416
+ - spec/unit/file_entry_spec.rb
417
+ - spec/unit/file_system_spec.rb
418
+ - spec/unit/sky_drive_spec.rb
419
+ has_rdoc: