Sha256: 55c534b7d92b35b5f2f7894e19436dc64e7d2cb283171265e61c8e781b5d2bc7

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

# frozen_string_literal: true

require 'serverkit/resources/base'

module Serverkit
  module Resources
    class VscodePackage < Base
      attribute :name, required: true, type: String
      attribute :version, type: String

      # @note Override
      def apply
        run_command("code -install-extension #{name_with_version}")
      end

      # @note Override
      def check
        check_command("code --list-extensions --show-versions | grep -E '#{name_pattern_with_version}'")
      end

      private

      # @note Override
      def default_id
        name
      end

      # @return [String]
      # @example "^git-plus@4.4.11$"
      def name_pattern_with_version
        if version
          "^#{name}@#{version}$"
        else
          "^#{name}@"
        end
      end

      # @return [String]
      # @example "git-plus@4.4.11"
      def name_with_version
        if version
          "#{name}@#{version}"
        else
          name
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
serverkit-vscode-0.1.0 lib/serverkit/resources/vscode_package.rb