Class: Datapimp::Sync::GoogleDriveFolder
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Datapimp::Sync::GoogleDriveFolder
- Defined in:
- lib/datapimp/sync/google_drive_folder.rb
Instance Method Summary collapse
- #api ⇒ Object
- #drawings ⇒ Object
- #local_path ⇒ Object
- #remote_path ⇒ Object
- #run(action, options = {}) ⇒ Object
Instance Method Details
#api ⇒ Object
3 4 5 |
# File 'lib/datapimp/sync/google_drive_folder.rb', line 3 def api @api ||= Datapimp::Sync.google.api end |
#drawings ⇒ Object
15 16 17 |
# 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 ⇒ Object
7 8 9 |
# File 'lib/datapimp/sync/google_drive_folder.rb', line 7 def local_path Pathname(local) end |
#remote_path ⇒ Object
11 12 13 |
# File 'lib/datapimp/sync/google_drive_folder.rb', line 11 def remote_path api.collection_by_title(remote) end |
#run(action, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/datapimp/sync/google_drive_folder.rb', line 19 def run(action, ={}) 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? && ![: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 |