browse-everything 0.10.5 → 0.11.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +16 -0
  4. data/.rubocop_todo.yml +149 -0
  5. data/.travis.yml +5 -6
  6. data/Rakefile +2 -2
  7. data/app/controllers/browse_everything_controller.rb +19 -22
  8. data/app/helpers/bootstrap_version_helper.rb +9 -11
  9. data/app/helpers/browse_everything_helper.rb +11 -22
  10. data/app/views/browse_everything/_file.html.erb +7 -11
  11. data/app/views/browse_everything/_files.html.erb +4 -7
  12. data/app/views/browse_everything/index.html.erb +1 -1
  13. data/browse-everything.gemspec +37 -34
  14. data/config/routes.rb +3 -3
  15. data/lib/browse-everything.rb +1 -1
  16. data/lib/browse_everything.rb +9 -8
  17. data/lib/browse_everything/browser.rb +4 -4
  18. data/lib/browse_everything/driver/base.rb +14 -14
  19. data/lib/browse_everything/driver/box.rb +48 -59
  20. data/lib/browse_everything/driver/dropbox.rb +10 -11
  21. data/lib/browse_everything/driver/file_system.rb +19 -24
  22. data/lib/browse_everything/driver/google_drive.rb +58 -82
  23. data/lib/browse_everything/driver/s3.rb +87 -0
  24. data/lib/browse_everything/driver/sky_drive.rb +41 -47
  25. data/lib/browse_everything/engine.rb +2 -2
  26. data/lib/browse_everything/file_entry.rb +3 -3
  27. data/lib/browse_everything/retriever.rb +19 -20
  28. data/lib/browse_everything/version.rb +1 -1
  29. data/lib/generators/browse_everything/assets_generator.rb +2 -4
  30. data/lib/generators/browse_everything/config_generator.rb +12 -12
  31. data/lib/generators/browse_everything/install_generator.rb +2 -4
  32. data/lib/generators/browse_everything/templates/browse_everything_providers.yml.example +6 -0
  33. data/spec/features/select_files_spec.rb +12 -12
  34. data/spec/features/test_compiling_stylesheets_spec.rb +2 -2
  35. data/spec/helper/browse_everything_controller_helper_spec.rb +8 -8
  36. data/spec/javascripts/jasmine_spec.rb +5 -5
  37. data/spec/javascripts/support/jasmine_helper.rb +9 -9
  38. data/spec/spec_helper.rb +26 -23
  39. data/spec/support/app/controllers/file_handler_controller.rb +3 -3
  40. data/spec/support/rake.rb +1 -1
  41. data/spec/test_app_templates/lib/generators/test_app_generator.rb +21 -22
  42. data/spec/unit/base_spec.rb +6 -6
  43. data/spec/unit/browse_everything_helper_spec.rb +9 -9
  44. data/spec/unit/browser_spec.rb +19 -19
  45. data/spec/unit/dropbox_spec.rb +44 -43
  46. data/spec/unit/file_entry_spec.rb +31 -31
  47. data/spec/unit/file_system_spec.rb +26 -26
  48. data/spec/unit/retriever_spec.rb +42 -43
  49. data/spec/unit/s3_spec.rb +77 -0
  50. data/spec/unit/sky_drive_spec.rb +31 -31
  51. data/spec/views/browse_everything/_file.html.erb_spec.rb +37 -37
  52. data/tasks/ci.rake +3 -3
  53. metadata +52 -7
  54. data/app/.DS_Store +0 -0
  55. data/app/views/.DS_Store +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ecf1f6e239a55eaca19d11c80ba83cb833df9ac
4
- data.tar.gz: 59e99e140a5520feb8345928b7080b90b4ad914b
3
+ metadata.gz: bd86609268e38b37eda9ee75faf2f90e5fef7637
4
+ data.tar.gz: a400f9f867fd8e000161e0af09eed01289c03e7c
5
5
  SHA512:
6
- metadata.gz: b8b0e5d8b7f8705cf017530760bb12a73a23e4217c452c07dc33f5bf1e449085353df70bbf9567fe5d239d5f21cde4abf2a213385874ab2b43c705e5d951430e
7
- data.tar.gz: dc27c56cd04044728ef80665eb8f5c9e500db68904e2b36c98248086c456649fdf8a48378a7a419a899ebc1dad8b75c7aea6ab0f01b58593c8dff0ede70b62bc
6
+ metadata.gz: 49c3014931d7a17505ddc3ce40ea8eff8d8380eeb4f4b3fb6936be68f25f974857fe5b5068e6f44a0bc1d3cf5f3a433a39b77bf39a2fcd0b2648d8d058b21464
7
+ data.tar.gz: 33074434868353d2f5a92bfcdf1cf9deaf97587597a66c97f9e6a76d50a978a922f62c27fd8f5ef71d747f05411a093ca558283c156b030c3aac491f601b1263
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .DS_Store
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - db/migrate/**
6
+ - db/schema.rb
7
+
8
+ Rails:
9
+ Enabled: true
10
+
11
+ # Configuration parameters: AllowURI, URISchemes.
12
+ Metrics/LineLength:
13
+ Max: 180
14
+
15
+ Style/NumericLiterals:
16
+ MinDigits: 7
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,149 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-09-28 11:47:17 -0700 using RuboCop version 0.42.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/Loop:
11
+ Exclude:
12
+ - 'lib/browse_everything/driver/google_drive.rb'
13
+
14
+ # Offense count: 10
15
+ Metrics/AbcSize:
16
+ Max: 32
17
+
18
+ # Offense count: 1
19
+ # Configuration parameters: CountComments.
20
+ Metrics/ClassLength:
21
+ Max: 101
22
+
23
+ # Offense count: 3
24
+ Metrics/CyclomaticComplexity:
25
+ Max: 7
26
+
27
+ # Offense count: 14
28
+ # Configuration parameters: CountComments.
29
+ Metrics/MethodLength:
30
+ Max: 26
31
+
32
+ # Offense count: 1
33
+ # Configuration parameters: CountKeywordArgs.
34
+ Metrics/ParameterLists:
35
+ Max: 7
36
+
37
+ # Offense count: 1
38
+ Metrics/PerceivedComplexity:
39
+ Max: 9
40
+
41
+ # Offense count: 1
42
+ Rails/OutputSafety:
43
+ Exclude:
44
+ - 'app/helpers/browse_everything_helper.rb'
45
+
46
+ # Offense count: 14
47
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
48
+ # SupportedStyles: strict, flexible
49
+ Rails/TimeZone:
50
+ Exclude:
51
+ - 'lib/browse_everything/driver/box.rb'
52
+ - 'lib/browse_everything/driver/dropbox.rb'
53
+ - 'lib/browse_everything/driver/google_drive.rb'
54
+ - 'lib/browse_everything/driver/sky_drive.rb'
55
+ - 'lib/browse_everything/retriever.rb'
56
+ - 'spec/unit/browse_everything_helper_spec.rb'
57
+ - 'spec/unit/file_entry_spec.rb'
58
+ - 'spec/unit/retriever_spec.rb'
59
+ - 'spec/unit/sky_drive_spec.rb'
60
+ - 'spec/views/browse_everything/_file.html.erb_spec.rb'
61
+
62
+ # Offense count: 3
63
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
64
+ # SupportedStyles: nested, compact
65
+ Style/ClassAndModuleChildren:
66
+ Exclude:
67
+ - 'lib/generators/browse_everything/assets_generator.rb'
68
+ - 'lib/generators/browse_everything/config_generator.rb'
69
+ - 'lib/generators/browse_everything/install_generator.rb'
70
+
71
+ # Offense count: 18
72
+ Style/Documentation:
73
+ Enabled: false
74
+
75
+ # Offense count: 1
76
+ # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
77
+ Style/FileName:
78
+ Exclude:
79
+ - 'lib/browse-everything.rb'
80
+
81
+ # Offense count: 5
82
+ # Configuration parameters: MinBodyLength.
83
+ Style/GuardClause:
84
+ Exclude:
85
+ - 'lib/browse_everything/driver/box.rb'
86
+ - 'lib/browse_everything/driver/dropbox.rb'
87
+ - 'lib/browse_everything/driver/file_system.rb'
88
+ - 'lib/browse_everything/driver/google_drive.rb'
89
+ - 'lib/browse_everything/driver/sky_drive.rb'
90
+
91
+ # Offense count: 1
92
+ Style/MultilineBlockChain:
93
+ Exclude:
94
+ - 'lib/browse_everything/driver/google_drive.rb'
95
+
96
+ # Offense count: 1
97
+ # Cop supports --auto-correct.
98
+ Style/MultilineBlockLayout:
99
+ Exclude:
100
+ - 'spec/unit/dropbox_spec.rb'
101
+
102
+ # Offense count: 2
103
+ # Cop supports --auto-correct.
104
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
105
+ # SupportedStyles: symmetrical, new_line, same_line
106
+ Style/MultilineHashBraceLayout:
107
+ Exclude:
108
+ - 'spec/unit/sky_drive_spec.rb'
109
+
110
+ # Offense count: 4
111
+ # Cop supports --auto-correct.
112
+ # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
113
+ # SupportedStyles: aligned, indented, indented_relative_to_receiver
114
+ Style/MultilineMethodCallIndentation:
115
+ Exclude:
116
+ - 'spec/unit/sky_drive_spec.rb'
117
+
118
+ # Offense count: 1
119
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
120
+ # NamePrefix: is_, has_, have_
121
+ # NamePrefixBlacklist: is_, has_, have_
122
+ # NameWhitelist: is_a?
123
+ Style/PredicateName:
124
+ Exclude:
125
+ - 'spec/**/*'
126
+ - 'app/helpers/browse_everything_helper.rb'
127
+
128
+ # Offense count: 2
129
+ # Cop supports --auto-correct.
130
+ # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
131
+ # SupportedStyles: slashes, percent_r, mixed
132
+ Style/RegexpLiteral:
133
+ Exclude:
134
+ - 'lib/browse_everything/driver/box.rb'
135
+ - 'lib/browse_everything/driver/dropbox.rb'
136
+
137
+ # Offense count: 1
138
+ # Cop supports --auto-correct.
139
+ Style/RescueModifier:
140
+ Exclude:
141
+ - 'lib/browse_everything/driver/file_system.rb'
142
+
143
+ # Offense count: 1
144
+ # Cop supports --auto-correct.
145
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
146
+ # SupportedStyles: use_perl_names, use_english_names
147
+ Style/SpecialGlobalVars:
148
+ Exclude:
149
+ - 'browse-everything.gemspec'
data/.travis.yml CHANGED
@@ -4,7 +4,6 @@ cache:
4
4
  bundler: true
5
5
  directories:
6
6
  - "travis_phantomjs"
7
-
8
7
  before_install:
9
8
  - "phantomjs --version"
10
9
  - "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH"
@@ -14,20 +13,20 @@ before_install:
14
13
  - "if [ $(phantomjs --version) != '2.1.1' ]; then tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; fi"
15
14
  - "phantomjs --version"
16
15
  rvm:
17
- - 2.2
16
+ - "2.2.2"
17
+ # rack 2 requires Ruby version >= 2.2.2
18
18
  env:
19
19
  global:
20
20
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
21
21
  matrix:
22
22
  - "RAILS_VERSION=4.1.10"
23
23
  - "RAILS_VERSION=4.2.1"
24
-
24
+ - "RAILS_VERSION=5.0.0.1"
25
25
  matrix:
26
26
  include:
27
+ - rvm: "2.3.0"
28
+ env: "RAILS_VERSION=5.0.0.1"
27
29
  - rvm: 2.1
28
30
  env: "RAILS_VERSION=4.2.1"
29
31
  - rvm: 2.0
30
32
  env: "RAILS_VERSION=4.2.1"
31
-
32
- notifications:
33
- irc: "irc.freenode.org#projecthydra"
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
2
+ require 'bundler/gem_tasks'
3
3
 
4
4
  Dir.glob('tasks/*.rake').each { |r| import r }
5
5
 
@@ -15,4 +15,4 @@ task :setup_test_server do
15
15
  EngineCart.load_application!
16
16
  end
17
17
 
18
- task :default => [:ci]
18
+ task default: [:ci]
@@ -1,36 +1,35 @@
1
- require File.expand_path('../../helpers/browse_everything_helper',__FILE__)
1
+ require File.expand_path('../../helpers/browse_everything_helper', __FILE__)
2
2
 
3
3
  class BrowseEverythingController < ActionController::Base
4
4
  layout 'browse_everything'
5
5
  helper BrowseEverythingHelper
6
6
 
7
- after_filter {session["#{provider_name}_token"] = provider.token unless provider.nil? }
8
-
7
+ after_action { session["#{provider_name}_token"] = provider.token unless provider.nil? }
8
+
9
9
  def index
10
- render :layout => !request.xhr?
10
+ render layout: !request.xhr?
11
11
  end
12
12
 
13
13
  def show
14
- render :layout => !request.xhr?
14
+ render layout: !request.xhr?
15
15
  end
16
-
16
+
17
17
  def auth
18
- code = params[:code]
19
- session["#{provider_name}_token"] = provider.connect(params,session["#{provider_name}_data"])
18
+ session["#{provider_name}_token"] = provider.connect(params, session["#{provider_name}_data"])
20
19
  end
21
20
 
22
21
  def resolve
23
22
  selected_files = params[:selected_files] || []
24
- @links = selected_files.collect { |file|
25
- p,f = file.split(/:/)
26
- (url,extra) = browser.providers[p].link_for(f)
23
+ @links = selected_files.collect do |file|
24
+ p, f = file.split(/:/)
25
+ (url, extra) = browser.providers[p].link_for(f)
27
26
  result = { url: url }
28
27
  result.merge!(extra) unless extra.nil?
29
28
  result
30
- }
31
- respond_to do |format|
32
- format.html { render :layout => false }
33
- format.json { render :json => @links }
29
+ end
30
+ respond_to do |format|
31
+ format.html { render layout: false }
32
+ format.json { render json: @links }
34
33
  end
35
34
  end
36
35
 
@@ -38,13 +37,11 @@ class BrowseEverythingController < ActionController::Base
38
37
 
39
38
  def auth_link
40
39
  @auth_link ||= if provider.present?
41
- link, data = provider.auth_link
42
- session["#{provider_name}_data"] = data
43
- link = "#{link}&state=#{provider.key}" unless link.include?("state")
44
- link
45
- else
46
- nil
47
- end
40
+ link, data = provider.auth_link
41
+ session["#{provider_name}_data"] = data
42
+ link = "#{link}&state=#{provider.key}" unless link.to_s.include?('state')
43
+ link
44
+ end # else nil, implicitly
48
45
  end
49
46
 
50
47
  def browser
@@ -1,35 +1,33 @@
1
1
  module BootstrapVersionHelper
2
-
3
2
  def bootstrap_three?
4
3
  Bundler.environment.specs['bootstrap-sass'].first.version >= Gem::Version.new('3')
5
4
  end
6
5
 
7
6
  def bs2(if2)
8
- bs2or3(if2,'')
7
+ bs2or3(if2, '')
9
8
  end
10
9
 
11
10
  def bs3(if3)
12
- bs2or3('',if3)
11
+ bs2or3('', if3)
13
12
  end
14
13
 
15
- def bs2or3(if2,if3)
14
+ def bs2or3(if2, if3)
16
15
  bootstrap_three? ? if3 : if2
17
16
  end
18
17
 
19
18
  def font_awesome_four?
20
19
  Bundler.environment.specs['font-awesome-rails'].first.version >= Gem::Version.new('4')
21
20
  end
22
-
21
+
23
22
  def fa3(if3)
24
- fa3or4(if3,'')
23
+ fa3or4(if3, '')
25
24
  end
26
-
25
+
27
26
  def fa4(if4)
28
- fa3or4('',if4)
27
+ fa3or4('', if4)
29
28
  end
30
-
31
- def fa3or4(if3,if4)
29
+
30
+ def fa3or4(if3, if4)
32
31
  font_awesome_four? ? if4 : if3
33
32
  end
34
-
35
33
  end
@@ -1,36 +1,25 @@
1
1
  module BrowseEverythingHelper
2
-
3
- def array_to_hidden_fields(array,key)
2
+ def array_to_hidden_fields(array, key)
4
3
  fields = array.to_query(key).split(Rack::Utils::DEFAULT_SEP).collect do |pair|
5
- key,value=pair.split('=', 2).map { |str| Rack::Utils.unescape(str) }
6
- hidden_field_tag(key,value)
4
+ key, value = pair.split('=', 2).map { |str| Rack::Utils.unescape(str) }
5
+ hidden_field_tag(key, value)
7
6
  end
8
7
  fields.join("\n").html_safe
9
8
  end
10
9
 
11
- # Extracted from Rack::Mime 1.5.2 for use with earlier versions
12
- # of Rack/Rails
10
+ # Extracted from Rack::Mime 1.5.2 for use with earlier versions of Rack/Rails
11
+ # @param [String] value
12
+ # @param [String] matcher
13
+ # @return [TrueClass,FalseClass]
13
14
  def mime_match?(value, matcher)
14
15
  v1, v2 = value.split('/', 2)
15
16
  m1, m2 = matcher.split('/', 2)
16
-
17
- if m1 == '*'
18
- if m2.nil? || m2 == '*'
19
- return true
20
- elsif m2 == v2
21
- return true
22
- else
23
- return false
24
- end
25
- end
26
-
27
- return false if v1 != m1
28
-
29
- return true if m2.nil? || m2 == '*'
30
-
31
- m2 == v2
17
+ return false if m1 != '*' && v1 != m1
18
+ m2.nil? || m2 == '*' || m2 == v2
32
19
  end
33
20
 
21
+ # @param [BrowseEverything::FileEntry] file
22
+ # @return [TrueClass,FalseClass]
34
23
  def is_acceptable?(file)
35
24
  acceptable = params[:accept] || '*/*'
36
25
  acceptable_types = acceptable.split(/,\s*/)
@@ -1,13 +1,10 @@
1
- <% unless file.relative_parent_path? %>
2
-
3
- <% if file.container? || provider.config[:max_upload_file_size].blank? #never disable a folder or if no maximum is set
4
- disabled = false
5
- else
6
- max_size = provider.config[:max_upload_file_size].to_i
7
- disabled = file.size > max_size
8
- end
9
- %>
10
-
1
+ <% if file.container? || provider.config[:max_upload_file_size].blank? # never disable a folder or if no maximum is set
2
+ disabled = false
3
+ else
4
+ max_size = provider.config[:max_upload_file_size].to_i
5
+ disabled = file.size > max_size
6
+ end
7
+ %>
11
8
  <tr role="row" tabindex="-1" data-ev-location="<%= file.location %>" data-tt-id="<%=path%>" data-tt-parent-id="<%=parent%>" data-tt-branch="<%=file.container? ? 'true' : 'false'%>">
12
9
  <td role="gridcell" class="<%=file.container? ? 'ev-container' : 'ev-file'%> ev-file-name">
13
10
  <% if disabled %>
@@ -36,4 +33,3 @@
36
33
  <%= file.mtime.strftime('%F %R') %>
37
34
  </td>
38
35
  </tr>
39
- <% end %>
@@ -1,4 +1,3 @@
1
- <% if provider.present? %>
2
1
  <div class="progress" id="loading_progress" aria-live="polite">
3
2
  <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">
4
3
  100% Complete
@@ -14,11 +13,9 @@
14
13
  <th role="columnheader">Modified</th>
15
14
  </tr>
16
15
  </thead>
17
- <% provider.contents(browse_path).each_with_index do |file,index| %>
18
- <% if is_acceptable?(file) %>
19
- <%= render :partial => 'file', :locals => { :file => file, :index => index,
20
- :path => browse_everything_engine.contents_path(provider_name,file.id), :parent => params[:parent] } %>
21
- <% end %>
16
+ <% provider.contents(browse_path).each_with_index do |file, index| %>
17
+ <% next if file.relative_parent_path? %>
18
+ <%= render :partial => 'file', :locals => { :file => file, :index => index,
19
+ :path => browse_everything_engine.contents_path(provider_name, file.id), :parent => params[:parent] } %>
22
20
  <% end %>
23
21
  </table>
24
- <% end %>