Sha256: ca84b477257ea91ae1acb095e459173adf3842831b21833ab0e38e3ee5a9250b

Contents?: true

Size: 1.82 KB

Versions: 27

Compression:

Stored size: 1.82 KB

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Domain
      class ExtensionPoint
        attr_reader :type, :beta, :deprecated, :libraries, :domain

        def initialize(type, config)
          @type = type
          @beta = config["beta"] || false
          @deprecated = config["deprecated"] || false
          @domain = config["domain"] || nil
          @libraries = ExtensionPointLibraries.new(config["libraries"])
        end

        def beta?
          @beta
        end

        def stable?
          !beta?
        end

        def deprecated?
          @deprecated
        end

        def dasherize_type
          @type.gsub("_", "-")
        end

        def library_languages(include_betas: false)
          @libraries.all.map do |library|
            include_betas || library.stable? ? library.language : nil
          end.compact
        end

        class ExtensionPointLibraries
          def initialize(config)
            @config = config
          end

          def all
            @all ||= @config.map do |language, library_config|
              ExtensionPointLibrary.new(language, library_config)
            end
          end

          def for(language)
            all.find { |ep| ep.language == language }
          end
        end

        class ExtensionPointLibrary
          attr_reader :language, :version, :beta, :package, :repo

          def initialize(language, config)
            @language = language
            @beta = config["beta"] || false
            @package = config["package"]
            @version = config["package-version"]
            @repo = config["repo"]
          end

          def beta?
            @beta
          end

          def stable?
            !beta?
          end

          def versioned?
            @version
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
shopify-cli-2.25.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.24.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.23.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.22.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.21.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.20.1 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.20.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.19.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.18.1 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.18.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.17.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.16.1 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.16.0 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.6 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.5 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.4 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.3 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.2 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.1 lib/project_types/script/layers/domain/extension_point.rb
shopify-cli-2.15.0 lib/project_types/script/layers/domain/extension_point.rb