Module: Rails::Hyperdrive::ManifestLint

Defined in:
lib/rails/hyperdrive/manifest_lint.rb

Overview

Author-side check of a companion gem's hyperdrive.yml, run in the companion's own repo. Where the installer warns and falls open — so that a manifest written for a newer schema never blocks an install — this fails, and unknown keys fail outright: the author's own rails-hyperdrive is the one that knows the whole schema. A manifest that passes draws no gating warning at install time.

Defined Under Namespace

Classes: RepoSpec, Result

Constant Summary collapse

Error =
GemspecLocator::Error
GATE_KEYS =
%w[gem gems hyperdrive_version].freeze
DIR_KEYS =
GemManifest::DIR_KEYS
ROOT_KEYS =
(GATE_KEYS + DIR_KEYS + InstallLayout.content_kinds.map(&:section)).freeze
SKILL_ENTRY_KEYS =
(GATE_KEYS + %w[conditional]).freeze
CONDITIONAL_ENTRY_KEYS =
%w[gem gems].freeze
RETIRED_VERSION_KEYS =
%w[versions version].freeze
RETIRED_VERSION_HINT =
"is not a gating key; put the requirement on the gem: member, " \
"e.g. `- name: \">= 1.0\"`".freeze

Class Method Summary collapse

Class Method Details

.check(gemspec: nil, dir: Dir.pwd) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/rails/hyperdrive/manifest_lint.rb', line 36

def check(gemspec: nil, dir: Dir.pwd)
  spec, gem_root = GemspecLocator.load_spec(gemspec, dir)
  relpath = GemManifest.manifest_relpath(spec)
  path = File.join(gem_root, relpath)
  return missing_manifest(spec, relpath) unless File.file?(path)

  repo_spec = RepoSpec.new(name: spec.name, full_gem_path: gem_root, metadata: spec. || {})
  Result.new(manifest: relpath, problems: problems_in(path, repo_spec))
end