Class: DPL::Provider::GCS
- Inherits:
-
DPL::Provider
- Object
- DPL::Provider
- DPL::Provider::GCS
- Defined in:
- lib/dpl/provider/gcs.rb
Instance Method Summary collapse
- #check_auth ⇒ Object
- #client ⇒ Object
- #needs_key? ⇒ Boolean
- #push_app ⇒ Object
- #upload_path(filename) ⇒ Object
Instance Method Details
#check_auth ⇒ Object
19 20 21 |
# File 'lib/dpl/provider/gcs.rb', line 19 def check_auth log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}" end |
#client ⇒ Object
12 13 14 15 16 17 |
# File 'lib/dpl/provider/gcs.rb', line 12 def client @client ||= GStore::Client.new( :access_key => option(:access_key_id), :secret_key => option(:secret_access_key) ) end |
#needs_key? ⇒ Boolean
8 9 10 |
# File 'lib/dpl/provider/gcs.rb', line 8 def needs_key? false end |
#push_app ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dpl/provider/gcs.rb', line 27 def push_app glob_args = ["**/*"] glob_args << File::FNM_DOTMATCH if [:dot_match] Dir.chdir(.fetch(:local_dir, Dir.pwd)) do Dir.glob(*glob_args) do |filename| next if File.directory?(filename) content_type = MIME::Types.type_for(filename).first.to_s opts = { :"Content-Type" => content_type }.merge(encoding_option_for(filename)) opts["Cache-Control"] = [:cache_control] if [:cache_control] opts["x-goog-acl"] = [:acl] if [:acl] client.put_object( option(:bucket), upload_path(filename), { :data => File.read(filename), :headers => opts } ) end end end |
#upload_path(filename) ⇒ Object
23 24 25 |
# File 'lib/dpl/provider/gcs.rb', line 23 def upload_path(filename) [[:upload_dir], filename].compact.join("/") end |