Class: Textus::Action::Ingest
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/action/ingest.rb
Constant Summary collapse
- SOURCE_KINDS =
%w[url file asset].freeze
- CONTENT_HASH_ALGO =
"sha256"- TOMBSTONE_RETAIN =
%w[ingested_at].freeze
Instance Method Summary collapse
- #call(container:, call:) ⇒ Object
-
#initialize(kind:, slug:, url: nil, path: nil, zone: nil, label: nil) ⇒ Ingest
constructor
A new instance of Ingest.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Methods inherited from Base
Constructor Details
#initialize(kind:, slug:, url: nil, path: nil, zone: nil, label: nil) ⇒ Ingest
Returns a new instance of Ingest.
29 30 31 32 33 34 35 36 37 |
# File 'lib/textus/action/ingest.rb', line 29 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
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/textus/action/ingest.rb', line 39 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, ) content_hash = compute_content_hash writer = Textus::Envelope::Writer.from(container: container, call: call) mentry = container.manifest.resolver.resolve(key).entry ts = now.iso8601 structured = build_structured(ts, container, now, content_hash) index = Textus::Ports::RawIndex.new(root: container.root) duplicate_key = find_duplicate(index, content_hash) if duplicate_key && duplicate_key != key supersede_entry(duplicate_key, key, structured, container, call, index) else env = write_raw_entry(key, structured, mentry, writer) index.upsert(content_hash: content_hash, url: @url, key: key) env end end |