Sha256: 95dc563e207b877ef16d2ae1a58f7d794314aca47f2d76f6f48154d9bf336fb2

Contents?: true

Size: 936 Bytes

Versions: 12

Compression:

Stored size: 936 Bytes

Contents

module TerraspacePluginGoogle::Interfaces
  class Summary
    include Terraspace::Plugin::Summary::Interface
    include TerraspacePluginGoogle::Clients

    # interface method
    def key_field
      'prefix'
    end

    # interface method
    def download
      bucket = storage.bucket(@bucket)
      unless bucket
        logger.error "ERROR: bucket #{@bucket} does not exist".color(:red)
        exit 1
      end
      bucket.files(prefix: @folder).all do |f|
        file = bucket.file(f.name)
        next if file.nil? # in case file has been removed since .files
        # Note the f.name already includes the folder
        local_path = "#{@dest}/#{f.name}"
        FileUtils.mkdir_p(File.dirname(local_path))
        file.download(local_path)
      end
    end

    # interface method
    def delete_empty_statefile(key)
      bucket = storage.bucket(@bucket)
      file = bucket.file(key)
      file.delete
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
terraspace_plugin_google-0.5.0 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.4.2 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.4.1 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.4.0 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.5 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.4 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.3 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.2 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.1 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.3.0 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.2.2 lib/terraspace_plugin_google/interfaces/summary.rb
terraspace_plugin_google-0.2.1 lib/terraspace_plugin_google/interfaces/summary.rb