class Datapimp::Sync::GoogleDriveFolder
Public Instance Methods
api()
click to toggle source
# File lib/datapimp/sync/google_drive_folder.rb, line 3 def api @api ||= Datapimp::Sync.google.api end
drawings()
click to toggle source
# File lib/datapimp/sync/google_drive_folder.rb, line 15 def drawings remote_path.files.select {|file| file.mime_type == "application/vnd.google-apps.drawing" } end
local_path()
click to toggle source
# File lib/datapimp/sync/google_drive_folder.rb, line 7 def local_path Pathname(local) end
remote_path()
click to toggle source
# File lib/datapimp/sync/google_drive_folder.rb, line 11 def remote_path api.collection_by_title(remote) end
run(action, options={})
click to toggle source
# File lib/datapimp/sync/google_drive_folder.rb, line 19 def run(action, options={}) action = action.to_sym if action == :push elsif action == :pull elsif action == :svgs drawings.each do |drawing| filename = drawing.title.parameterize + '.svg' local_file = local_path.join(filename) if local_file.exist? && !options[:overwrite] puts "== #{ filename } already exists. skipping. pass --overwrite to overwrite" else puts "== Downloading to svg: #{ filename }" drawing.export_as_file(local_path.join(filename), 'image/svg+xml') end end end end