Sha256: 3491fe89473d35e29f7b7391ec81aa43275371f9d8febde79031de706ddf46be

Contents?: true

Size: 980 Bytes

Versions: 4

Compression:

Stored size: 980 Bytes

Contents

require 'kconv'

module DPL
  class Provider
    class GCS < Provider
      requires 'gstore'
      experimental 'Google Cloud Storage'

      def needs_key?
        false
      end

      def client
        @client ||= GStore::Client.new(
          :access_key => option(:access_key_id),
          :secret_key => option(:secret_access_key)
        )
      end

      def check_auth
        log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
      end

      def push_app
        glob_args = ["**/*"]
        glob_args << File::FNM_DOTMATCH if options[:dot_match]
        Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
          Dir.glob(*glob_args) do |filename|
            next if File.directory?(filename)

            log "Push: #{filename}"

            client.put_object(
              option(:bucket),
              filename,
              :data => File.read(filename)
            )
          end
        end
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dpl-1.6.6.travis.492.1 lib/dpl/provider/gcs.rb
dpl-1.6.6.travis.491.1 lib/dpl/provider/gcs.rb
dpl-1.6.6.travis.487.1 lib/dpl/provider/gcs.rb
dpl-1.6.6.travis.484.1 lib/dpl/provider/gcs.rb