Sha256: 0a6ab8109bfb47865a2fcde52acd547e187daabe08a45a9bb1b99fa30eec2e0b

Contents?: true

Size: 1003 Bytes

Versions: 34

Compression:

Stored size: 1003 Bytes

Contents

module Datapimp
  class Sync::GoogleDriveFolder < Hashie::Mash
    def api
      @api ||= Datapimp::Sync.google.api
    end

    def local_path
      Pathname(local)
    end

    def remote_path
      api.collection_by_title(remote)
    end

    def drawings
      remote_path.files.select {|file| file.mime_type == "application/vnd.google-apps.drawing" }
    end

    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
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
datapimp-1.2.11 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.10 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.9 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.8 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.7 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.6 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.5 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.4 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.3 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.2 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.1 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.2.0 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.1.1 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.1.0 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.29 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.28 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.27 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.26 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.25 lib/datapimp/sync/google_drive_folder.rb
datapimp-1.0.24 lib/datapimp/sync/google_drive_folder.rb