Class: Avm::Launcher::Context::InstanceDiscovery::SourceWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/launcher/context/instance_discovery/source_wrapper.rb

Instance Method Summary collapse

Instance Method Details

#parent_project_for_subAvm::Launcher::Instances::Base?



16
17
18
# File 'lib/avm/launcher/context/instance_discovery/source_wrapper.rb', line 16

def parent_project_for_sub
  self_project.presence || parent_project
end

#projectsEnumerable<Avm::Launcher::Instances::Base>

Returns:



21
22
23
24
# File 'lib/avm/launcher/context/instance_discovery/source_wrapper.rb', line 21

def projects
  self_project.if_present([]) { |v| [v] } +
    subs.flat_map(&:projects)
end

#self_projectAvm::Launcher::Instances::Base?



27
28
29
30
31
32
# File 'lib/avm/launcher/context/instance_discovery/source_wrapper.rb', line 27

def self_project
  return nil unless logical_path.project?

  ::Avm::Launcher::Instances::Base.instanciate(logical_path,
                                               parent_project)
end

#sub_wrapper(sub) ⇒ Avm::Launcher::Context::InstanceDiscovery::SourceWrapper

Parameters:

  • sub (Avm::Sources::base)

Returns:



36
37
38
39
40
41
42
# File 'lib/avm/launcher/context/instance_discovery/source_wrapper.rb', line 36

def sub_wrapper(sub)
  ::Avm::Launcher::Context::InstanceDiscovery::SourceWrapper.new(
    owner,
    logical_path.build_child(sub.relative_path),
    parent_project_for_sub
  )
end

#subsEnumerable<Avm::Launcher::Instances::Base>

Returns:



45
46
47
48
49
50
# File 'lib/avm/launcher/context/instance_discovery/source_wrapper.rb', line 45

def subs
  warped_source.subs.map { |sub| sub_wrapper(sub) }
rescue StandardError => e
  warn("#{logical_path}: #{e}")
  []
end