Sha256: f825b3d6fbffc98170856e4e124e2a94ffbc66ccde8637fbd92e932edc6d00d7

Contents?: true

Size: 965 Bytes

Versions: 7

Compression:

Stored size: 965 Bytes

Contents

# frozen_string_literal: true

module Script
  module Layers
    module Domain
      class ScriptConfig
        attr_reader :content, :version, :title, :description, :configuration_ui, :configuration, :filename

        REQUIRED_FIELDS = %w(version title)

        def initialize(content:, filename:)
          @filename = filename
          validate_content!(content)
          @content = content
          @version = @content["version"].to_s
          @title = @content["title"]
          @description = @content["description"]
          @configuration_ui = @content.fetch("configurationUi", true)
          @configuration = @content["configuration"]
        end

        private

        def validate_content!(content)
          REQUIRED_FIELDS.each do |field|
            if content[field].nil?
              raise Errors::MissingScriptConfigFieldError.new(field: field, filename: filename)
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shopify-cli-2.12.0 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.11.2 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.11.1 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.11.0 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.10.2 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.10.1 lib/project_types/script/layers/domain/script_config.rb
shopify-cli-2.10.0 lib/project_types/script/layers/domain/script_config.rb