Sha256: 1d22d25dafa0d0cade17cf36c245435e67cae11b07cb4a2c4982b99ae074cf32

Contents?: true

Size: 1.78 KB

Versions: 39

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require 'avm/instances/ids'
require 'avm/with/application_stereotype'
require 'avm/with/extra_subcommands'
require 'eac_ruby_utils/require_sub'
require 'eac_ruby_utils/simple_cache'
require 'avm/entries/base'

module Avm
  module Instances
    class Base
      enable_abstract_methods
      enable_listable
      enable_simple_cache
      include ::Avm::Entries::Base
      require_sub __FILE__, include_modules: true
      include ::Avm::With::ExtraSubcommands
      include ::Avm::With::ApplicationStereotype

      lists.add_string :access, :local, :ssh

      ID_PATTERN = /\A([a-z0-9]+(?:\-[a-z0-9]+)*)_(.+)\z/.freeze

      class << self
        def by_id(id)
          parsed_id = ::Avm::Instances::Ids.parse!(id)
          require 'avm/applications/base'
          new(::Avm::Applications::Base.new(parsed_id.application_id), parsed_id.instance_suffix)
        end
      end

      common_constructor :application, :suffix do
        self.suffix = suffix.to_s
      end

      # @return [Avm::Instances::Data::Package]
      def data_package
        @data_package ||= data_package_create
      end

      # @return [Avm::Instances::Data::Package]
      def data_package_create
        ::Avm::Instances::Data::Package.new(self)
      end

      # @return [String]
      def id
        ::Avm::Instances::Ids.build(application.id, suffix)
      end

      def to_s
        id
      end

      def host_env_uncached
        case install_scheme
        when 'file' then ::EacRubyUtils::Envs.local
        when 'ssh' then ::EacRubyUtils::Envs.ssh(install_url)
        else raise("Unmapped access value: \"#{install_scheme}\"")
        end
      end

      private

      def source_instance_uncached
        ::Avm::Instances::Base.by_id(source_instance_id)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
avm-0.84.0 lib/avm/instances/base.rb
eac_tools-0.83.0 sub/avm/lib/avm/instances/base.rb
avm-0.83.0 lib/avm/instances/base.rb
eac_tools-0.82.0 sub/avm/lib/avm/instances/base.rb
avm-0.82.0 lib/avm/instances/base.rb
eac_tools-0.81.0 sub/avm/lib/avm/instances/base.rb
eac_tools-0.80.0 sub/avm/lib/avm/instances/base.rb
avm-0.81.0 lib/avm/instances/base.rb
eac_tools-0.79.0 sub/avm/lib/avm/instances/base.rb
avm-0.80.0 lib/avm/instances/base.rb
eac_tools-0.78.0 sub/avm/lib/avm/instances/base.rb
eac_tools-0.77.1 sub/avm/lib/avm/instances/base.rb
eac_tools-0.77.0 sub/avm/lib/avm/instances/base.rb
eac_tools-0.76.1 sub/avm/lib/avm/instances/base.rb
eac_tools-0.76.0 sub/avm/lib/avm/instances/base.rb
eac_tools-0.75.2 sub/avm/lib/avm/instances/base.rb
eac_tools-0.75.1 sub/avm/lib/avm/instances/base.rb
eac_tools-0.75.0 sub/avm/lib/avm/instances/base.rb
eac_tools-0.74.1 sub/avm/lib/avm/instances/base.rb
eac_tools-0.74.0 sub/avm/lib/avm/instances/base.rb