Class: Textus::Read::Rdeps

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/read/rdeps.rb

Instance Method Summary collapse

Constructor Details

#initialize(container:, call: nil) ⇒ Rdeps

rubocop:disable Lint/UnusedMethodArgument



4
5
6
# File 'lib/textus/read/rdeps.rb', line 4

def initialize(container:, call: nil) # rubocop:disable Lint/UnusedMethodArgument
  @manifest = container.manifest
end

Instance Method Details

#call(key) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/textus/read/rdeps.rb', line 8

def call(key)
  @manifest.data.entries.each_with_object([]) do |e, acc|
    next unless e.is_a?(Textus::Manifest::Entry::Derived)

    src = e.source
    sources = if src.is_a?(Textus::Manifest::Entry::Derived::Projection)
                Array(src.select).compact
              elsif src.is_a?(Textus::Manifest::Entry::Derived::External)
                Array(src.sources).compact
              else
                []
              end
    acc << e.key if sources.any? { |s| s == key || key.start_with?("#{s}.") }
  end
end