browse-everything 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef33c2e0a8c1c1206dce56eedad11b136195a6d094ce585ff4799323a442cb34
4
- data.tar.gz: 76a840d66d3fc96fb6a1193515889980aba59a2469cbe76bdbabb4a7bc8bd204
3
+ metadata.gz: 5c44e6fe17fdd953916e2e9daee9dc2923123e3aa8b16e1b2413714e5c7e10a0
4
+ data.tar.gz: 05656d696be1683da78311011c2274ab422186d072c4005b32ceee87b63d3264
5
5
  SHA512:
6
- metadata.gz: fc3f2a4506d217583eb05c32e1b632578772c13eb21accf2f40eea87d104c06228f38d172e110c0f2e5524697ef7560aa54164ca92536e010c8746f9b7aeb397
7
- data.tar.gz: 86ef8ad24edeec846bf81c1887f038befcdcb06c3cc6c0730ca2beb8834cb67ea9e86167067913feab7fa84a5c45a898de79280a66b9725391c6437f274965a8
6
+ metadata.gz: cb7a332399ae1928ea4883ea8931b72410edd3f5b2ce59527f50b3df6c2b0e620812e58c742f09f0386c8f077ef3ae836bf379227287c82d94a32274b1f759c0
7
+ data.tar.gz: a036a93cb63e5880323cbe5bf9a505e5f7289926ab392029254f463b62993eb88f4c40351238ad98af299f5612727dee47d00419128c5cc79d6c6a4f9850bc88
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ lib/bundler/man
13
13
  pkg
14
14
  rdoc
15
15
  spec/reports
16
+ spec/fixtures/Getting Started.pdf
16
17
  test/tmp
17
18
  test/version_tmp
18
19
  tmp
@@ -9,6 +9,7 @@
9
9
  </tr>
10
10
  </thead>
11
11
  <% provider_contents.each_with_index do |file, index| %>
12
+ <% next if file.nil? %>
12
13
  <% path = browse_everything_engine.contents_path(provider_name, file.id) %>
13
14
  <% parent = params[:parent] %>
14
15
  <% if file.container? || provider.config[:max_upload_file_size].blank? %>
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'typhoeus'
33
33
 
34
34
  spec.add_development_dependency 'bixby', '>= 1.0'
35
- spec.add_development_dependency 'bundler', '~> 1.3'
35
+ spec.add_development_dependency 'bundler', '>= 1.3'
36
36
  spec.add_development_dependency 'capybara'
37
37
  spec.add_development_dependency 'chromedriver-helper', '~> 2.1'
38
38
  spec.add_development_dependency 'coveralls'
@@ -33,15 +33,18 @@ module BrowseEverything
33
33
  raise InitializationError, 'Box driver requires both :client_id and :client_secret argument'
34
34
  end
35
35
 
36
+ # Retrieves the file entry objects for a given path to Box resource
36
37
  # @param [String] id of the file or folder in Box
37
- # @return [Array<RubyBox::File>]
38
+ # @return [Array<BrowseEverything::FileEntry>]
38
39
  def contents(id = '')
39
40
  folder = id.empty? ? box_client.root_folder : box_client.folder_by_id(id)
40
- @entries = []
41
+ values = []
41
42
 
42
43
  folder.items(ITEM_LIMIT, 0, %w[name size created_at]).collect do |f|
43
- @entries << directory_entry(f)
44
+ values << directory_entry(f)
44
45
  end
46
+ @entries = values.compact
47
+
45
48
  @sorter.call(@entries)
46
49
  end
47
50
 
@@ -133,6 +136,10 @@ module BrowseEverything
133
136
  @token.fetch('expires_at', nil).to_i
134
137
  end
135
138
 
139
+ # Constructs a BrowseEverything::FileEntry object for a Box file
140
+ # resource
141
+ # @param file [String] ID to the file resource
142
+ # @return [BrowseEverything::File]
136
143
  def directory_entry(file)
137
144
  BrowseEverything::FileEntry.new(file.id, "#{key}:#{file.id}", file.name, file.size, file.created_at, file.type == 'folder')
138
145
  end
@@ -83,7 +83,8 @@ module BrowseEverything
83
83
  def contents(path = '')
84
84
  path = '/' + path unless path == ''
85
85
  response = client.list_folder(path)
86
- @entries = response.entries.map { |entry| FileEntryFactory.build(metadata: entry, key: key) }
86
+ values = response.entries.map { |entry| FileEntryFactory.build(metadata: entry, key: key) }
87
+ @entries = values.compact
87
88
  @sorter.call(@entries)
88
89
  end
89
90
 
@@ -11,13 +11,17 @@ module BrowseEverything
11
11
  raise BrowseEverything::InitializationError, 'FileSystem driver requires a :home argument' if config[:home].blank?
12
12
  end
13
13
 
14
+ # Retrieve the contents of a directory
15
+ # @param path [String] the path to a file system resource
16
+ # @return [Array<BrowseEverything::FileEntry>]
14
17
  def contents(path = '')
15
18
  real_path = File.join(config[:home], path)
16
- @entries = if File.directory?(real_path)
17
- make_directory_entry real_path
18
- else
19
- [details(real_path)]
20
- end
19
+ values = if File.directory?(real_path)
20
+ make_directory_entry real_path
21
+ else
22
+ [details(real_path)]
23
+ end
24
+ @entries = values.compact
21
25
 
22
26
  @sorter.call(@entries)
23
27
  end
@@ -32,6 +36,10 @@ module BrowseEverything
32
36
  true
33
37
  end
34
38
 
39
+ # Construct a FileEntry objects for a file-system resource
40
+ # @param path [String] path to the file
41
+ # @param display [String] display label for the resource
42
+ # @return [BrowseEverything::FileEntry]
35
43
  def details(path, display = File.basename(path))
36
44
  return nil unless File.exist? path
37
45
  info = File::Stat.new(path)
@@ -47,6 +55,10 @@ module BrowseEverything
47
55
 
48
56
  private
49
57
 
58
+ # Construct an array of FileEntry objects for the contents of a
59
+ # directory
60
+ # @param real_path [String] path to the file system directory
61
+ # @return [Array<BrowseEverything::FileEntry>]
50
62
  def make_directory_entry(real_path)
51
63
  entries = []
52
64
  entries + Dir[File.join(real_path, '*')].collect { |f| details(f) }
@@ -79,9 +79,10 @@ module BrowseEverything
79
79
  raise error
80
80
  end
81
81
 
82
- @entries += file_list.files.map do |gdrive_file|
82
+ values = file_list.files.map do |gdrive_file|
83
83
  details(gdrive_file, path)
84
84
  end
85
+ @entries += values.compact
85
86
 
86
87
  request_params.page_token = file_list.next_page_token
87
88
  end
@@ -113,23 +113,39 @@ module BrowseEverything
113
113
  @client ||= authenticate
114
114
  end
115
115
 
116
+ # Construct a BrowseEverything::FileEntry object
117
+ # @param name [String]
118
+ # @param size [String]
119
+ # @param date [DateTime]
120
+ # @param dir [String]
121
+ # @return [BrowseEverything::FileEntry]
116
122
  def entry_for(name, size, date, dir)
117
123
  BrowseEverything::FileEntry.new(name, [key, name].join(':'), File.basename(name), size, date, dir)
118
124
  end
119
125
 
126
+ # Populate the entries with FileEntry objects from an S3 listing
127
+ # @param listing [Seahorse::Client::Response]
120
128
  def add_directories(listing)
121
129
  listing.common_prefixes.each do |prefix|
122
- @entries << entry_for(from_base(prefix.prefix), 0, Time.current, true)
130
+ new_entry = entry_for(from_base(prefix.prefix), 0, Time.current, true)
131
+ @entries << new_entry unless new_entry.nil?
123
132
  end
124
133
  end
125
134
 
135
+ # Given a listing and a S3 listing and path, populate the entries
136
+ # @param listing [Seahorse::Client::Response]
137
+ # @param path [String]
126
138
  def add_files(listing, path)
127
139
  listing.contents.each do |entry|
128
140
  key = from_base(entry.key)
129
- @entries << entry_for(key, entry.size, entry.last_modified, false) unless strip(key) == strip(path)
141
+ new_entry = entry_for(key, entry.size, entry.last_modified, false)
142
+ @entries << new_entry unless strip(key) == strip(path) || new_entry.nil?
130
143
  end
131
144
  end
132
145
 
146
+ # For a given path to a S3 resource, retrieve the listing object and
147
+ # construct the file entries
148
+ # @param path [String]
133
149
  def generate_listing(path)
134
150
  client
135
151
  listing = client.list_objects(bucket: config[:bucket], delimiter: '/', prefix: full_path(path))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BrowseEverything
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
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: 1.0.0
4
+ version: 1.0.1
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: 2019-03-13 00:00:00.000000000 Z
16
+ date: 2019-04-23 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: addressable
@@ -187,14 +187,14 @@ dependencies:
187
187
  name: bundler
188
188
  requirement: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - "~>"
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '1.3'
193
193
  type: :development
194
194
  prerelease: false
195
195
  version_requirements: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - "~>"
197
+ - - ">="
198
198
  - !ruby/object:Gem::Version
199
199
  version: '1.3'
200
200
  - !ruby/object:Gem::Dependency