Sha256: 18eb6183db368311291affca3dd2a17ecdd97c338634db8ddf1d29654140a76b

Contents?: true

Size: 1.85 KB

Versions: 68

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

require 'avm/launcher/paths/real'
require 'avm/launcher/stereotype'
require 'eac_ruby_utils/core_ext'

module Avm
  module Launcher
    module Paths
      class Logical
        enable_simple_cache

        class << self
          def from_h(context, hash)
            parent_path = hash[:parent_path] ? from_h(context, hash[:parent_path]) : nil
            new(context, parent_path, hash[:real], hash[:logical])
          end
        end

        common_constructor :context, :parent_path, :real, :logical do
          self.real = ::Avm::Launcher::Paths::Real.new(real)
        end

        compare_by :logical, :real

        def to_s
          logical
        end

        def to_h
          { logical: logical, real: real.to_s, parent_path: parent_path ? parent_path.to_h : nil }
        end

        def project?
          stereotypes.any?
        end

        def children
          r = []
          Dir.entries(warped).each do |c|
            c_path = ::File.join(warped, c)
            next unless ::File.directory?(c_path)
            next if c.start_with?('.')

            r << build_child(c)
          end
          r
        end

        def included?
          !context.settings.excluded_paths.include?(logical)
        end

        private

        def stereotypes_uncached
          ::Avm::Launcher::Stereotype.stereotypes.select { |s| s.match?(self) }
        end

        def build_child(name)
          ::Avm::Launcher::Paths::Logical.new(
            context,
            self,
            ::File.join(warped, name),
            ::File.join(logical, name)
          )
        end

        def warped_uncached
          if is_a?(::Avm::Launcher::Instances::Base)
            stereotypes.each do |s|
              return s.warp_class.new(self) if s.warp_class
            end
          end
          real
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 2 rubygems

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