class Reviewer::Loader
Provides a collection of the configured tools
Attributes
configuration[R]
file[R]
Public Class Methods
configuration()
click to toggle source
# File lib/reviewer/loader.rb, line 27 def self.configuration new.configuration end
new(file = Reviewer.configuration.file)
click to toggle source
# File lib/reviewer/loader.rb, line 16 def initialize(file = Reviewer.configuration.file) @file = file @configuration = configuration_hash validate_configuration! end
Public Instance Methods
to_h()
click to toggle source
# File lib/reviewer/loader.rb, line 23 def to_h configuration end
Private Instance Methods
configuration_hash()
click to toggle source
# File lib/reviewer/loader.rb, line 51 def configuration_hash @configuration_hash ||= Psych.safe_load_file(@file, symbolize_names: true) rescue Errno::ENOENT raise MissingConfigurationError, "Tools configuration file couldn't be found at `#{file}`" rescue Psych::SyntaxError => e raise InvalidConfigurationError, "Tools configuration file (#{file}) has a syntax error: #{e.message}" end
require_review_commands!()
click to toggle source
# File lib/reviewer/loader.rb, line 38 def require_review_commands! configuration.each do |key, value| commands = value[:commands] next if commands.key?(:review) # Ideally, folks would want to fill out everything to receive the most benefit, # but realistically, the 'review' command is the only required value. If the key # is missing, or maybe there was a typo, fail right away. raise MissingReviewCommandError, "'#{key}' does not have a 'review' key under 'commands' in `#{file}`" end end
validate_configuration!()
click to toggle source
# File lib/reviewer/loader.rb, line 33 def validate_configuration! # Any additional guidance for configuration issues will live here require_review_commands! end