Module: Polyrun::Partition::Paths

Defined in:
lib/polyrun/partition/paths.rb

Overview

Shared spec path listing for run-shards, queue init, and plan helpers.

Class Method Summary collapse

Class Method Details

.read_lines(path) ⇒ Object



7
8
9
# File 'lib/polyrun/partition/paths.rb', line 7

def read_lines(path)
  File.read(File.expand_path(path.to_s, Dir.pwd)).split("\n").map(&:strip).reject(&:empty?)
end

.resolve_run_shard_items(paths_file: nil, cwd: Dir.pwd) ⇒ Object

When paths_file is set but missing, returns { error: “…” }. Otherwise returns { items:, source: } (human-readable source label).



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/polyrun/partition/paths.rb', line 13

def resolve_run_shard_items(paths_file: nil, cwd: Dir.pwd)
  if paths_file
    abs = File.expand_path(paths_file.to_s, cwd)
    unless File.file?(abs)
      return {error: "paths file not found: #{abs}"}
    end
    {items: read_lines(abs), source: paths_file.to_s}
  elsif File.file?(File.join(cwd, "spec", "spec_paths.txt"))
    {items: read_lines(File.join(cwd, "spec", "spec_paths.txt")), source: "spec/spec_paths.txt"}
  else
    {items: Dir.glob(File.join(cwd, "spec/**/*_spec.rb")).sort, source: "spec/**/*_spec.rb glob"}
  end
end