Class: Textus::Action::Ingest

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

Constant Summary collapse

SOURCE_KINDS =
%w[url file asset].freeze

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(kind:, slug:, url: nil, path: nil, zone: nil, label: nil) ⇒ Ingest

Returns a new instance of Ingest.



26
27
28
29
30
31
32
33
34
# File 'lib/textus/action/ingest.rb', line 26

def initialize(kind:, slug:, url: nil, path: nil, zone: nil, label: nil)
  super()
  @kind  = kind
  @slug  = slug
  @url   = url
  @path  = path
  @zone  = zone
  @label = label
end

Instance Method Details

#call(container:, call:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/textus/action/ingest.rb', line 36

def call(container:, call:)
  validate_inputs!

  now = Time.now.utc
  key = derive_key(now)

  Textus::Gate::Auth.new(container).check_action!(
    action: :ingest, actor: call.role, key: key,
  )

  write_raw_entry(key, now, container, call)
end