Class: Polyrun::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/polyrun/config.rb,
lib/polyrun/config/resolver.rb,
lib/polyrun/config/effective.rb,
lib/polyrun/config/dotted_path.rb,
sig/polyrun/config.rbs

Overview

Loads polyrun.yml (or path from POLYRUN_CONFIG / --config).

Defined Under Namespace

Modules: DottedPath, Effective, Resolver

Constant Summary collapse

DEFAULT_FILENAMES =

Returns:

  • (Array[String])
%w[polyrun.yml config/polyrun.yml].freeze
DEFAULT_PARALLEL_WORKERS =

Parallel worker defaults (+run-shards+, POLYRUN_WORKERS); single source with Resolver and Effective.

5
MAX_PARALLEL_WORKERS =
10

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, raw:) ⇒ Config

Returns a new instance of Config.

Parameters:

  • path: (String, nil)
  • raw: (Object)


35
36
37
38
# File 'lib/polyrun/config.rb', line 35

def initialize(path:, raw:)
  @path = path
  @raw = raw.freeze
end

Instance Attribute Details

#pathString? (readonly)

Returns the value of attribute path.

Returns:

  • (String, nil)


12
13
14
# File 'lib/polyrun/config.rb', line 12

def path
  @path
end

#rawObject (readonly)

Returns the value of attribute raw.

Returns:

  • (Object)


12
13
14
# File 'lib/polyrun/config.rb', line 12

def raw
  @raw
end

Class Method Details

.load(path: nil) ⇒ Config

Parameters:

  • path: (String, nil) (defaults to: nil)

Returns:



14
15
16
17
18
19
20
21
22
23
# File 'lib/polyrun/config.rb', line 14

def self.load(path: nil)
  path = resolve_path(path)
  raw =
    if path && File.file?(path)
      YAML.safe_load_file(path, permitted_classes: [Symbol], aliases: true) || {}
    else
      {}
    end
  new(path: path, raw: raw)
end

.resolve_path(explicit) ⇒ String?

Parameters:

  • explicit (String, nil)

Returns:

  • (String, nil)


25
26
27
28
29
30
31
32
33
# File 'lib/polyrun/config.rb', line 25

def self.resolve_path(explicit)
  return File.expand_path(explicit) if explicit && !explicit.empty?

  DEFAULT_FILENAMES.each do |name|
    full = File.expand_path(name, Dir.pwd)
    return full if File.file?(full)
  end
  nil
end

Instance Method Details

#coverageObject

Returns:

  • (Object)


48
49
50
# File 'lib/polyrun/config.rb', line 48

def coverage
  raw["coverage"] || raw[:coverage] || {}
end

#databasesObject

Returns:

  • (Object)


52
53
54
# File 'lib/polyrun/config.rb', line 52

def databases
  raw["databases"] || raw[:databases] || {}
end

#hooksObject

Optional hooks: block for run-shards / parallel-rspec / ci-shard-* (see Hooks).



66
67
68
# File 'lib/polyrun/config.rb', line 66

def hooks
  raw["hooks"] || raw[:hooks] || {}
end

#partitionObject

Returns:

  • (Object)


40
41
42
# File 'lib/polyrun/config.rb', line 40

def partition
  raw["partition"] || raw[:partition] || {}
end

#prepareObject

Returns:

  • (Object)


44
45
46
# File 'lib/polyrun/config.rb', line 44

def prepare
  raw["prepare"] || raw[:prepare] || {}
end

#reportingObject

Optional reporting: block (merge-failures output paths, etc.).



71
72
73
# File 'lib/polyrun/config.rb', line 71

def reporting
  raw["reporting"] || raw[:reporting] || {}
end

#start_configObject

Optional start: block: prepare / databases booleans override auto-detection for polyrun start.

Returns:

  • (Object)


57
58
59
# File 'lib/polyrun/config.rb', line 57

def start_config
  raw["start"] || raw[:start] || {}
end

#versionObject

Returns:

  • (Object)


61
62
63
# File 'lib/polyrun/config.rb', line 61

def version
  raw["version"] || raw[:version]
end