Class: Textus::Action::Rdeps

Inherits:
Base
  • Object
show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/rdeps.rb

Constant Summary collapse

BURN =
:sync

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Contract::DSL

arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view

Methods inherited from Base

#args, inherited

Constructor Details

#initialize(key:) ⇒ Rdeps

Returns a new instance of Rdeps.



16
17
18
19
# File 'lib/textus/action/rdeps.rb', line 16

def initialize(key:)
  super()
  @key = key
end

Class Method Details

.new(*args, **kwargs) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/textus/action/rdeps.rb', line 40

def self.new(*args, **kwargs)
  return super(**kwargs) unless args.any?

  positional = instance_method(:initialize).parameters.slice(:keyreq, :key).map(&:last)
  mapped = positional.zip(args).to_h
  super(**mapped.merge(kwargs))
end

Instance Method Details

#call(container:) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/textus/action/rdeps.rb', line 21

def call(container:, **)
  manifest = container.manifest
  rdeps = manifest.data.entries.each_with_object([]) do |entry, acc|
    next unless entry.derived?

    src = entry.source
    sources =
      if src.projection?
        Array(src.select).compact
      elsif src.external?
        Array(src.sources).compact
      else
        []
      end
    acc << entry.key if sources.any? { |source| source == @key || @key.start_with?("#{source}.") }
  end
  { "key" => @key, "rdeps" => rdeps }
end