Class: Textus::Infra::Port::Publisher
- Inherits:
-
Object
- Object
- Textus::Infra::Port::Publisher
- Includes:
- Interface
- Defined in:
- lib/textus/infra/port/publisher.rb
Overview
Publishes built artifacts from the store to repo-relative consumer paths. Publish = copy + sentinel. The in-store file is already the consumer-shaped artifact; no parsing or stripping.
Sentinel I/O is delegated to Textus::Infra::Port::SentinelStore. Sentinels live
under <store_root>/track/sentinels/ (runtime, git-ignored — ADR 0070) and
mirror the target's repo-relative layout so consumer directories aren't
polluted with .textus-managed.json siblings.
An instantiable class (ADR 0109).
Defined Under Namespace
Modules: Interface
Instance Method Summary collapse
-
#initialize(file_system: Infra::FileSystem.new) ⇒ Publisher
constructor
A new instance of Publisher.
- #publish(source:, target:, store_root:, provenance_source: source) ⇒ Object
-
#unpublish(target:, store_root:) ⇒ Object
Removes a previously-published file and its sentinel.
Constructor Details
#initialize(file_system: Infra::FileSystem.new) ⇒ Publisher
Returns a new instance of Publisher.
21 22 23 |
# File 'lib/textus/infra/port/publisher.rb', line 21 def initialize(file_system: Infra::FileSystem.new) @file_system = file_system end |
Instance Method Details
#publish(source:, target:, store_root:, provenance_source: source) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/textus/infra/port/publisher.rb', line 25 def publish(source:, target:, store_root:, provenance_source: source) @file_system.mkdir_p(File.dirname(target)) guard_clobber(source, target, store_root) @file_system.delete(target) if @file_system.symlink?(target) @file_system.copy(source, target) Textus::Infra::Port::SentinelStore.new(file_system: @file_system).write!(target: target, source: provenance_source, store_root: store_root) end |
#unpublish(target:, store_root:) ⇒ Object
Removes a previously-published file and its sentinel. No-op unless the target is textus-managed — never deletes an unmanaged file.
36 37 38 39 40 41 42 |
# File 'lib/textus/infra/port/publisher.rb', line 36 def unpublish(target:, store_root:) return unless managed?(target, store_root) @file_system.delete(target) sentinel = Textus::Infra::Port::SentinelStore.new(file_system: @file_system).sentinel_path(target, store_root) @file_system.delete(sentinel) end |