Class: Textus::Action::Deps

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

Returns a new instance of Deps.



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

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

Class Method Details

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



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

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

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