Sha256: 1263d8c5c819f92f437e520046242ab303e1567bebc257f7b5a7a7856432a22d

Contents?: true

Size: 808 Bytes

Versions: 6

Compression:

Stored size: 808 Bytes

Contents

module Paperclip
  module Storage
    module Gcs
      module CredentialsResolver
        module_function

        def resolve(credentials)
          cred = case credentials
                 when File
                   YAML.load(ERB.new(File.read(credentials.path)).result)
                 when String, Pathname
                   YAML.load(ERB.new(File.read(credentials)).result)
                 when Hash
                   credentials
                 when NilClass
                   {}
                 else
                   raise ArgumentError, ":gcs_credentials is not a path, file, nor a hash"
                 end
          (cred.stringify_keys[env] || cred).symbolize_keys
        end

        def env
          (defined?(Rails) ? Rails.env : nil).to_s
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
paperclip-gcs-0.3.3 lib/paperclip/storage/gcs/credentials_resolver.rb
paperclip-gcs-0.3.2 lib/paperclip/storage/gcs/credentials_resolver.rb
paperclip-gcs-0.3.1 lib/paperclip/storage/gcs/credentials_resolver.rb
paperclip-gcs-0.3.0 lib/paperclip/storage/gcs/credentials_resolver.rb
paperclip-gcs-0.2.0 lib/paperclip/storage/gcs/credentials_resolver.rb
paperclip-gcs-0.1.0 lib/paperclip/storage/gcs/credentials_resolver.rb