Conversation
|
I took some time to investigate a few things while testing the library. Google Drive itself allows multiple files with the same title to coexist in a single folder, but this library’s file_by_title method returns only a single file. While reviewing the download_to_file method, I was initially puzzled by the use of id, which isn’t explicitly defined within the class. def download_to_file(path, params = {})
@session.drive_service.get_file(
id,
**{ download_dest: path, supports_all_drives: true }.merge(params)
)
endThe delegate_api_methods method dynamically defines methods from the api_obj on the target object, unless they’re in the exclusion list: def delegate_api_methods(obj, api_obj, exceptions = [])
sc = get_singleton_class(obj)
names = api_obj.public_methods(false) - exceptions
names.each do |name|
next if name.to_s =~ /=$/
sc.__send__(:define_method, name) do
api_obj.__send__(name)
end
end
endThis allows access to id and other API fields, but can make things slightly harder to trace or debug, especially for new contributors. As a minor note, the fact that a GoogleDrive::File instance is responsible for downloading itself feels slightly non-intuitive to me. Overall, the Spreadsheet side of the code felt clean, but I sensed a bit more complexity and tension in the design of the GoogleDrive side. Hope these reflections are helpful in some way. |
No description provided.