Class: Reviewer::Configuration::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/configuration/loader.rb

Overview

Provides a collection of the configured tools

Defined Under Namespace

Classes: InvalidConfigurationError, MissingConfigurationError, MissingReviewCommandError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:) ⇒ Loader

Creates a loader instance for the configuration file

Parameters:

  • file (Pathname)

    the path to the configuration YAML file

Raises:



27
28
29
30
31
32
# File 'lib/reviewer/configuration/loader.rb', line 27

def initialize(file:)
  @file = file
  @configuration = configuration_hash

  validate_configuration
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



18
19
20
# File 'lib/reviewer/configuration/loader.rb', line 18

def configuration
  @configuration
end

#fileObject (readonly)

Returns the value of attribute file.



18
19
20
# File 'lib/reviewer/configuration/loader.rb', line 18

def file
  @file
end

Class Method Details

.configuration(file:) ⇒ Hash

Loads and returns the tools configuration hash

Returns:

  • (Hash)

    the parsed configuration from the YAML file



49
# File 'lib/reviewer/configuration/loader.rb', line 49

def self.configuration(file:) = new(file: file).configuration

Instance Method Details

#review_commands_present?Boolean

Whether all configured tools have a review command

Returns:

  • (Boolean)

    true if every tool has a review command configured



37
38
39
# File 'lib/reviewer/configuration/loader.rb', line 37

def review_commands_present?
  configuration.all? { |_key, value| value[:commands]&.key?(:review) }
end

#to_hHash

Converts the loader to its configuration hash

Returns:

  • (Hash)

    the parsed configuration



44
# File 'lib/reviewer/configuration/loader.rb', line 44

def to_h = configuration