googledrive-easy 0.1.6 → 0.1.7

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/googledrive-easy.rb +17 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bde25654cb7729aa6b698cb13142bea88ed013117cdf4af338e1c4fa65d96593
4
- data.tar.gz: dd6e91d0cfb1a7f54fc265b8da75d043b3c2582aaf6b907e77289c4aade92d06
3
+ metadata.gz: 980d20ae39d421ac858a8ccceabd2d6d7ba95ea9e8e0181ffbf96d068d217b99
4
+ data.tar.gz: 1593952ec9b4d4a4746a95039816eee6cd6cbda6c86757fbeea28688caf84423
5
5
  SHA512:
6
- metadata.gz: 7eca3c50d329df741fece7ec1ddc0188bd938f9e1826374e887192ae405741516e91d794c86d6bd15e68135bda8fbc1c131d6a3e4b28d68e1d2237894fc5b8e6
7
- data.tar.gz: e02255813a9a3e15bdf013eaeed3e71b42767fce79af7c44eda1ecba4ed304bcc5d59e015be2959597b1256dd899676aeec2959134c88c8fdeaeb2e6c681317d
6
+ metadata.gz: 0d2b9e15ea96f2a7eecd9c510463ce4dc5628515aec068c06cc6360260bbb030fe636bfc11f8202f5bf69a9abf48c71d7d705235675c4b5d720f101c0a9b501d
7
+ data.tar.gz: 682e5cf1e0e3ca41518ea3ef55c1b47351519bf1132999418950ea2689c71b8fdf8947b0f0b691456d8fef17e26c332de0a17749f5e4bacb7d6fd7b4fffc5717
@@ -397,7 +397,23 @@ class GoogleDrive
397
397
  # parent folder has to be surrounded by single quotes in query
398
398
  query += " and ('#{parentfolderid}' in parents)" if parentfolderid
399
399
  # filename has to be surrounded by single quotes in query
400
- query += " and (name #{ name =~ /\*/ ? "contains" : "=" } '#{name}')" if name
400
+
401
+ if name
402
+ name.split("*").each_with_index do |part, idx|
403
+ if idx == 0 and name =~ /\*/ and part.size > 0
404
+ # If the above are true, this is the first piece, and it was followed by a *, so we should pass it in the
405
+ # format for prefix matching
406
+ query += " and (name contains '#{part}*')"
407
+ elsif idx == 0 and !(name =~ /\*/ )
408
+ # If the above is true, this is a literal equivalence search, no wildcards should be used.
409
+ query += " and (name = '#{part}')"
410
+ else
411
+ # If we're here, either we had a wildcard prefix, or we're on a later part of the search term. Do a contains.
412
+ query += " and (name contains '#{part}')" if part.size > 0
413
+ end
414
+ end
415
+ end
416
+ @logger.debug("Searching with query: #{query}")
401
417
 
402
418
  files = [ ]
403
419
  next_page_token = nil
@@ -420,7 +436,6 @@ class GoogleDrive
420
436
  processed_files << process_file(file)
421
437
  end
422
438
 
423
- # Todo: Is this still really necessary? I think the list_files function can do this server-side. Need to research.
424
439
  # we have additional processing to do it a wildcard character was passed. Because Google Drive "contains" returns all portions of it.
425
440
  # so we need to filter here
426
441
  if name =~ /\*/ # if name contains wildcard
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googledrive-easy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bullock