Sha256: 53b5a1c17203e0e3d849ef6581422312dc4a7f9da6a9df6ad8352b9fc8738b5f

Contents?: true

Size: 1.36 KB

Versions: 337

Compression:

Stored size: 1.36 KB

Contents

require_relative 'storage/interface'
require_relative 'storage/git_storage'
require_relative 'storage/google_cloud_storage'

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)
          }
        }
      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

337 entries across 337 versions & 2 rubygems

Version Path
fastlane-2.121.0.beta.20190412200021 match/lib/match/storage.rb
fastlane-2.121.0.beta.20190411200023 match/lib/match/storage.rb
fastlane-2.121.0.beta.20190410200018 match/lib/match/storage.rb
fastlane-2.120.0 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190409200021 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190408200017 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190407200059 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190406200021 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190405200012 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190404200009 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190403200039 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190402200013 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190401200056 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190331200023 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190330200100 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190329200012 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190328200010 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190327200117 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190326200014 match/lib/match/storage.rb
fastlane-2.120.0.beta.20190325200020 match/lib/match/storage.rb