Class: Torikago::PackageApiUpdater

Inherits:
Object
  • Object
show all
Defined in:
lib/torikago/package_api_updater.rb

Overview

Regenerates package_api.yml from files under a module’s public API entrypoint while preserving caller permissions already chosen by humans.

Instance Method Summary collapse

Constructor Details

#initialize(configuration:) ⇒ PackageApiUpdater

Returns a new instance of PackageApiUpdater.



8
9
10
# File 'lib/torikago/package_api_updater.rb', line 8

def initialize(configuration:)
  @configuration = configuration
end

Instance Method Details

#call(module_name = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/torikago/package_api_updater.rb', line 12

def call(module_name = nil)
  definitions_for(module_name).each_with_object({}) do |definition, updates|
    manifest_path = definition.root.join("package_api.yml")
    existing_manifest = load_manifest(manifest_path)
    updated_manifest = build_manifest(definition, existing_manifest)

    manifest_path.write(render_manifest(updated_manifest))
    updates[definition.name] = manifest_path
  end
end