Class: Textus::Action::Rdeps

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

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.



14
15
16
17
# File 'lib/textus/action/rdeps.rb', line 14

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

Class Method Details

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



30
31
32
33
34
35
36
# File 'lib/textus/action/rdeps.rb', line 30

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



19
20
21
22
23
24
25
26
27
28
# File 'lib/textus/action/rdeps.rb', line 19

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

    sources = Array(entry.source&.sources).compact
    acc << entry.key if sources.any? { |source| source == @key || @key.start_with?("#{source}.") }
  end
  { "key" => @key, "rdeps" => rdeps }
end