Class: DocsKit::Generators::Migration

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/docs_kit/install/migration.rb

Overview

One ordered, versioned upgrade step between two docs-kit releases. to is the version the migration belongs to (the release that introduced the change); the registry runs it when a site's last-synced version is BELOW to. The block receives the site's (destination_root, generator) so it can read/rewrite files via the generator's helpers, and returns the list of manual-cleanup warnings it could NOT safely automate.

Warn-only-safe by contract (the #24 drift pattern): a migration does what it can idempotently — never a destructive rewrite of a hand-edited line — and hands back strings for whatever needs a human. A nil return means "nothing to warn about".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to:, description:, &block) ⇒ Migration

Returns a new instance of Migration.



19
20
21
22
23
# File 'lib/generators/docs_kit/install/migration.rb', line 19

def initialize(to:, description:, &block)
  @to = Gem::Version.new(to.to_s)
  @description = description
  @block = block
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



17
18
19
# File 'lib/generators/docs_kit/install/migration.rb', line 17

def description
  @description
end

#toObject (readonly)

Returns the value of attribute to.



17
18
19
# File 'lib/generators/docs_kit/install/migration.rb', line 17

def to
  @to
end

Instance Method Details

#call(root, generator) ⇒ Object

Run the transform against the site. Returns the (possibly empty) list of manual-cleanup warnings — never nil, so callers can flat-map safely.



27
28
29
# File 'lib/generators/docs_kit/install/migration.rb', line 27

def call(root, generator)
  Array(@block.call(root, generator))
end