Class: Vivlio::Starter::CLI::LintCommands::LintRunner::TargetResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio/starter/cli/lint.rb

Overview

TokenResolver を用いた Markdown 対象ファイルの解決

ゼロ埋め・レンジ展開・カンマ区切りなどの正規化を TokenResolver に委譲し、lint 対象は contents/ 配下の利用者原稿(*.md)に限定する。

Instance Method Summary collapse

Constructor Details

#initialize(raw_targets) ⇒ TargetResolver

Returns a new instance of TargetResolver.



392
393
394
395
# File 'lib/vivlio/starter/cli/lint.rb', line 392

def initialize(raw_targets)
  @raw_targets = Array(raw_targets)
  @resolver = TokenResolver::Resolver.new
end

Instance Method Details

#resolveObject

プロジェクトルートからの相対 Markdown パスの配列を返す



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/vivlio/starter/cli/lint.rb', line 398

def resolve
  entries = resolve_entries

  # --- Phase: Validation ---
  reject_invalid_entries!(entries)
  reject_unknown_entries!(entries)

  # --- Phase: contents/ 配下のみに限定 ---
  content_entries = entries.select { it.path.start_with?(Common::CONTENTS_DIR) }
  existing, missing = content_entries.partition(&:exists?)
  missing.each { Common.log_warn("見つかりません: #{it.path}") }

  # --- Phase: 相対パス化 ---
  root = Pathname.new('.')
  existing.map { Pathname.new(it.path).cleanpath.relative_path_from(root).to_s }.sort
end