class Dpl::Providers::Gcs

Constants

BOTO
URL

Public Instance Methods

deploy() click to toggle source
# File lib/dpl/providers/gcs.rb, line 67
def deploy
  Dir.chdir(local_dir) do
    files.each { |file| copy(file) }
  end
end
install() click to toggle source
# File lib/dpl/providers/gcs.rb, line 59
def install
  shell :install
end
login() click to toggle source
# File lib/dpl/providers/gcs.rb, line 63
def login
  key_file? ? login_key : login_creds
end

Private Instance Methods

copy(source) click to toggle source
# File lib/dpl/providers/gcs.rb, line 92
def copy(source)
  to = [target.sub(%r{/$}, ''), source].join('/')
  shell :copy, gs_opts: gs_opts(source), source:, target: to
end
copy_opts() click to toggle source
# File lib/dpl/providers/gcs.rb, line 110
def copy_opts
  opts = []
  opts << %(-a "#{acl}") if acl?
  "#{opts.join(' ')} " if opts.any?
end
dirname(path) click to toggle source
# File lib/dpl/providers/gcs.rb, line 97
def dirname(path)
  dir = File.dirname(path)
  dir unless dir.empty? || dir == '.'
end
files() click to toggle source
# File lib/dpl/providers/gcs.rb, line 88
def files
  Dir.glob(*glob_args).select { |path| File.file?(path) }
end
glob_args() click to toggle source
# File lib/dpl/providers/gcs.rb, line 125
def glob_args
  args = [glob]
  args << File::FNM_DOTMATCH if dot_match?
  args
end
gs_opts(path) click to toggle source
# File lib/dpl/providers/gcs.rb, line 102
def gs_opts(path)
  opts = []
  opts << %(-h "Cache-Control:#{cache_control}") if cache_control?
  opts << %(-h "Content-Encoding:#{encoding(path)}") if detect_encoding?
  opts << %(-h "Content-type:#{mime_type(path)}") if mime_type(path)
  "#{opts.join(' ')} " if opts.any?
end
login_creds() click to toggle source
# File lib/dpl/providers/gcs.rb, line 79
def login_creds
  info :login_creds
  write_boto
end
login_key() click to toggle source
# File lib/dpl/providers/gcs.rb, line 75
def login_key
  shell :login_key
end
mime_type(path) click to toggle source
# File lib/dpl/providers/gcs.rb, line 120
def mime_type(path)
  type = MIME::Types.type_for(path).first
  type&.to_s
end
target() click to toggle source
# File lib/dpl/providers/gcs.rb, line 116
def target
  "gs://#{bucket}/#{upload_dir}"
end
write_boto() click to toggle source
# File lib/dpl/providers/gcs.rb, line 84
def write_boto
  write_file '~/.boto', interpolate(BOTO, opts, secure: true), 0600
end