Module: Datapimp::Sync

Defined in:
lib/datapimp/sync.rb,
lib/datapimp/sync/s3_bucket.rb,
lib/datapimp/sync/cloudfront_distribution.rb

Defined Under Namespace

Classes: CloudfrontDistribution, DropboxFolder, GoogleDriveFolder, S3Bucket

Class Method Summary collapse

Class Method Details

.amazon(options = {}) ⇒ Object



55
56
57
58
# File 'lib/datapimp/sync.rb', line 55

def self.amazon(options={})
  require 'datapimp/clients/amazon'
  Datapimp::Clients::Amazon.client(options)
end

.data_source_typesObject



6
7
8
# File 'lib/datapimp/sync.rb', line 6

def self.data_source_types
  %w(dropbox amazon github google pivotal json excel nokogiri)
end

.dispatch_sync_data_action(args, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/datapimp/sync.rb', line 10

def self.dispatch_sync_data_action(args, options)
  source  = Array(args).first
  type    = options[:type]

  result = case type
           when "github"
             Datapimp::Sources::GithubRepository.new(args, options)
           when "google", "google-spreadsheet"
             Datapimp::Sources::GoogleSpreadsheet.new(nil, key: source)
           when "pivotal" then
             Datapimp::Sources::Pivotal.new(args, options)
           when "keen" then
             Datapimp::Sources::Keen.new(args, options)
           end
  result
end

.dispatch_sync_folder_action(local, remote, options) ⇒ Object

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


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/datapimp/sync.rb', line 34

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

.dropbox(options = {}) ⇒ Object



60
61
62
63
# File 'lib/datapimp/sync.rb', line 60

def self.dropbox(options={})
  require 'datapimp/clients/dropbox'
  Datapimp::Clients::Dropbox.client(options)
end

.github(options = {}) ⇒ Object



65
66
67
68
# File 'lib/datapimp/sync.rb', line 65

def self.github(options={})
  require 'datapimp/clients/github'
  Datapimp::Clients::Github.client(options)
end

.google(options = {}) ⇒ Object



70
71
72
73
# File 'lib/datapimp/sync.rb', line 70

def self.google(options={})
  require 'datapimp/clients/google'
  Datapimp::Clients::Google.client(options)
end