Class: VivlioStarter::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.



653
654
655
656
# File 'lib/vivlio_starter/cli/lint.rb', line 653

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

Instance Method Details

#resolveObject

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



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'lib/vivlio_starter/cli/lint.rb', line 659

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