Sha256: cc8ca0f127e54d2ab6f20b44a66eb98e87633da51d229fc748294e76d408f555

Contents?: true

Size: 1.85 KB

Versions: 34

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

require 'avm/launcher/errors/non_project'
require 'avm/registry'
require 'eac_ruby_utils/speaker/sender'

module Avm
  module Launcher
    module Instances
      module Base
        class << self
          def extend_object(object)
            object.extend ::EacRubyUtils::SimpleCache
            object.extend ::EacRubyUtils::Speaker::Sender
            object.extend ::Avm::Launcher::Instances::Base::Cache
            object.extend ::Avm::Launcher::Instances::Base::Publishing
            super
          end

          def instanciate(path, parent)
            unless path.is_a?(::Avm::Launcher::Instances::Base)
              raise ::Avm::Launcher::Errors::NonProject, path unless path.project?

              path.extend(::Avm::Launcher::Instances::Base)
              path.parent = parent
            end
            path
          end
        end

        require_sub __FILE__

        attr_accessor :parent

        # @return [Avm::Applications::Base]
        def application
          @application ||= ::Avm::Registry.applications.detect(project_name)
        end

        def name
          logical
        end

        def stereotype?(stereotype)
          stereotypes.include?(stereotype)
        end

        def to_parent_path
          return self unless @parent

          logical.gsub(/\A#{Regexp.quote(@parent.logical)}/, '')
        end

        def project?
          stereotypes.any?
        end

        def project_name
          ::File.basename(logical)
        end

        def included?
          ::Avm::Launcher::Context.current.settings.excluded_projects.exclude?(project_name)
        end

        def to_h
          super.to_h.merge(parent: parent&.logical)
        end

        private

        def options_uncached
          ::Avm::Launcher::Context.current.settings.instance_settings(self)
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
avm-0.94.1 lib/avm/launcher/instances/base.rb
eac_tools-0.98.0 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.94.0 lib/avm/launcher/instances/base.rb
eac_tools-0.94.0 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.93.0 lib/avm/launcher/instances/base.rb
eac_tools-0.92.0 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.92.0 lib/avm/launcher/instances/base.rb
eac_tools-0.91.0 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.90.1 lib/avm/launcher/instances/base.rb
eac_tools-0.87.1 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.90.0 lib/avm/launcher/instances/base.rb
eac_tools-0.87.0 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.89.0 lib/avm/launcher/instances/base.rb
eac_tools-0.86.12 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.88.0 lib/avm/launcher/instances/base.rb
eac_tools-0.86.11 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.87.0 lib/avm/launcher/instances/base.rb
eac_tools-0.86.8 sub/avm/lib/avm/launcher/instances/base.rb
avm-0.86.2 lib/avm/launcher/instances/base.rb
eac_tools-0.86.7 sub/avm/lib/avm/launcher/instances/base.rb