Sha256: e039fc6679a20b3f2e98a187770fdc9f33c9cfe819be4ce807c6847aaaa2cf46

Contents?: true

Size: 1.67 KB

Versions: 14

Compression:

Stored size: 1.67 KB

Contents

require_relative 'storage/interface'
require_relative 'storage/git_storage'
require_relative 'storage/google_cloud_storage'
require_relative 'storage/s3_storage'
require_relative 'storage/gitlab_secure_files'

module Match
  module Storage
    class << self
      def backends
        @backends ||= {
          "git" => lambda { |params|
            return Storage::GitStorage.configure(params)
          },
          "google_cloud" => lambda { |params|
            return Storage::GoogleCloudStorage.configure(params)
          },
          "s3" => lambda { |params|
            return Storage::S3Storage.configure(params)
          },
          "gitlab_secure_files" => lambda { |params|
            return Storage::GitLabSecureFiles.configure(params)
          }
        }
      end

      def register_backend(type: nil, storage_class: nil, &configurator)
        UI.user_error!("No type specified for storage backend") if type.nil?

        normalized_name = type.to_s
        UI.message("Replacing Match::Encryption backend for type '#{normalized_name}'") if backends.include?(normalized_name)

        if configurator
          @backends[normalized_name] = configurator
        elsif storage_class
          @backends[normalized_name] = ->(params) { return storage_class.configure(params) }
        else
          UI.user_error!("Specify either a `storage_class` or a configuration block when registering a storage backend")
        end
      end

      def for_mode(storage_mode, params)
        configurator = backends[storage_mode.to_s]
        return configurator.call(params) if configurator

        UI.user_error!("No storage backend for storage mode '#{storage_mode}'")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
fastlane-mercafacil-2.214.0 match/lib/match/storage.rb
fastlane-2.214.0 match/lib/match/storage.rb
fastlane-2.213.0 match/lib/match/storage.rb
fastlane-2.212.2 match/lib/match/storage.rb
fastlane_pricing_fix-2.212.1 match/lib/match/storage.rb
fastlane-2.212.1 match/lib/match/storage.rb
fastlane-2.212.0 match/lib/match/storage.rb
fastlane-2.211.0 match/lib/match/storage.rb
fastlane-2.210.1 match/lib/match/storage.rb
fastlane-2.210.0 match/lib/match/storage.rb
fastlane-2.209.1 match/lib/match/storage.rb
fastlane-2.209.0 match/lib/match/storage.rb
fastlane-2.208.0 match/lib/match/storage.rb
fastlane-2.207.0 match/lib/match/storage.rb