lib/datapimp/sync.rb in datapimp-1.0.26 vs lib/datapimp/sync.rb in datapimp-1.0.27
- old
+ new
@@ -5,9 +5,37 @@
module Sync
def self.data_source_types
%w(dropbox amazon github google json excel nokogiri)
end
+ # Create any type of syncable folder and dispatch a run call to it
+ # with whatever options you want.
+ #
+ # options:
+ # - local: relative path to th local version of this folder
+ # - remote: an identifier for the remote folder in the remote system
+ # - action: push, pull, etc
+ def self.dispatch_sync_folder_action(local, remote, options)
+ options = options.to_mash
+ action = options.action
+
+ folder = case
+ when options.type == "dropbox"
+ Datapimp::Sync::DropboxFolder.new(local: local, remote: remote)
+ when options.type == "google"
+ # Return the folders
+ # collection = Datapimp::Sync.google.api.collections.first
+ #
+ # svg = collection.files.first
+ # svg.export_as_file(/download/path, "image/svg+xml")
+ Datapimp::Sync::GoogleDriveFolder.new(local: local, remote: remote)
+ when options.type == "aws" || options.type == "s3"|| options.type == "amazon"
+ Datapimp::Sync::S3Bucket.new(local: local, remote: remote)
+ end
+
+ folder.run(action, options)
+ end
+
def self.amazon(options={})
require 'datapimp/clients/amazon'
Datapimp::Clients::Amazon.client(options)
end