Class: VivlioStarter::CLI::LintCommands::LintRunner::TargetResolver
- Inherits:
-
Object
- Object
- VivlioStarter::CLI::LintCommands::LintRunner::TargetResolver
- Defined in:
- lib/vivlio_starter/cli/lint.rb
Overview
TokenResolver を用いた Markdown 対象ファイルの解決
ゼロ埋め・レンジ展開・カンマ区切りなどの正規化を TokenResolver に委譲し、 lint 対象は contents/ 配下の利用者原稿(*.md)に限定する。
Instance Method Summary collapse
-
#initialize(raw_targets) ⇒ TargetResolver
constructor
A new instance of TargetResolver.
-
#resolve ⇒ Object
プロジェクトルートからの相対 Markdown パスの配列を返す.
Constructor Details
#initialize(raw_targets) ⇒ TargetResolver
Returns a new instance of TargetResolver.
541 542 543 544 |
# File 'lib/vivlio_starter/cli/lint.rb', line 541 def initialize(raw_targets) @raw_targets = Array(raw_targets) @resolver = TokenResolver::Resolver.new end |
Instance Method Details
#resolve ⇒ Object
プロジェクトルートからの相対 Markdown パスの配列を返す
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 |
# File 'lib/vivlio_starter/cli/lint.rb', line 547 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 |