Class: Textus::Action::Deps

Inherits:
Base
  • Object
show all
Extended by:
Contract::DSL
Defined in:
lib/textus/action/deps.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:) ⇒ Deps

Returns a new instance of Deps.



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

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

Class Method Details

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



25
26
27
28
29
30
31
# File 'lib/textus/action/deps.rb', line 25

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
# File 'lib/textus/action/deps.rb', line 19

def call(container:, **)
  entry = container.manifest.data.entries.find { |e| e.key == @key }
  deps = entry&.external? ? Array(entry.source&.sources).compact : []
  { "key" => @key, "deps" => deps.uniq }
end