class Hyrax::Ingest::Configuration
Attributes
config_file_path[R]
Public Class Methods
new(config_file_path:)
click to toggle source
# File lib/hyrax/ingest/configuration.rb, line 9 def initialize(config_file_path:) @config_file_path = config_file_path.to_s raise Hyrax::Ingest::Errors::NoConfigFileFound.new(@config_file_path) unless File.exist? @config_file_path validate! end
Public Instance Methods
ingester_configs()
click to toggle source
@return [Array] Array of hashes, where each hash is the configuration options
for an Ingester instance
# File lib/hyrax/ingest/configuration.rb, line 17 def ingester_configs @ingester_configs ||= config[:ingest] end
Private Instance Methods
config()
click to toggle source
@return [Hash] The config hash parsed from yaml file, and with keys
converted from strings to symbols.
# File lib/hyrax/ingest/configuration.rb, line 25 def config @config ||= Psych.load_file(config_file_path).deep_symbolize_keys end
validate!()
click to toggle source
Validates the configuration. @raise [Hyrax::Ingest::Errors::InvalidConfig] When the configuration is invalid.
# File lib/hyrax/ingest/configuration.rb, line 31 def validate! validate_top_level_key! validate_ingester_configs_array! validate_ingester_config_hashes! end
validate_ingester_config_hashes!()
click to toggle source
# File lib/hyrax/ingest/configuration.rb, line 47 def validate_ingester_config_hashes! config[:ingest].each do |ingest_config| raise Hyrax::Ingest::Errors::InvalidConfig.new(config_file_path, "Each ingester configuration must be a single key-value pair, where the key is the type of ingester, and the value is a hash containing the configuration for the ingester. But a #{ingester_config.class} was found instead.") unless ingest_config.respond_to? :keys end end
validate_ingester_configs_array!()
click to toggle source
# File lib/hyrax/ingest/configuration.rb, line 43 def validate_ingester_configs_array! raise Hyrax::Ingest::Errors::InvalidConfig.new(config_file_path, "Value under top-level 'ingest' key must be an array containing the configuration for each ingester you want to use.") unless config[:ingest].respond_to?(:each) end
validate_top_level_key!()
click to toggle source
@raise [Hyrax::Ingest::Errors::InvalidConfig] When the top level
'ingest' key is missing.
# File lib/hyrax/ingest/configuration.rb, line 39 def validate_top_level_key! raise Hyrax::Ingest::Errors::InvalidConfig.new(config_file_path, "Top-level key 'ingest' is missing.") unless config[:ingest] end