settings_validation_wrapper.rb revision 87a46b6e4db760590780a339528decb20e0c2d8b
525421c923d798cdea9e5691bcee1e5e5530491dStéphane Graber class DataPathsValidator < ActiveModel::Validator
fd5c4f905861964cb473cf3df3336447a9365962Stéphane Graber [Settings.paths[key], PathsInitializer::DEFAULT_PATHS[key]]
afeecbba0359d2b4404cdf896e6b6d0b5a8443b0Serge Hallyn setting.nil? && !File.directory?(set_directory(key))
20ab58c777136a449b3199e0733b62fa87ecfa61Serge Hallyn PathsInitializer::DEFAULT_PATHS.each do |key, _default_value|
b494d2ddf769220da1ef75fd24275ce68cdf297cSerge Hallyn "Implicitly set data directory path '#{dir}' is not a directory."
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber record.errors["yml__paths__#{key}".to_sym] = 'Is not a String value.'
72d0e1cb2facaa4b8ba2f15e311d6bb9491badb7Stéphane Graber record.errors["yml__paths__#{key}".to_sym] = 'Is not a directory.'
16216c83297543692b8dede52c9dd8a998758e9cStéphane Graber include SettingsValidationWrapper::Validators
f5dd1d532a76a1b57cf341db821eae85ea1118c5Serge Hallyn # We assume that deployment is done on a linux machine that has 'nproc'.
2aa123185e055bbe2506a6210e795e0b9375e477Serge Hallyn # Counting processors is different on other machines. For them, we would need
2aa123185e055bbe2506a6210e795e0b9375e477Serge Hallyn # to use a gem.
20ab58c777136a449b3199e0733b62fa87ecfa61Serge Hallyn NPROC_AVAILABLE = NPROC_PATH.present? && File.executable?(NPROC_PATH)
9be53773792fc9e8bd173edc3b7ac7e144875387Serge Hallyn yml__git__push_priority__changed_files_per_commit
validates field, directory: true, if: :in_production?
presence: true,
if: :in_production?
if: :in_production?
elements_are_email: true
validates :yml__max_read_filesize, numericality: {greater_than: 1024}
validates :yml__hets__executable_path, executable: true, if: :in_production?
numericality: {greater_than: 0,
if: :in_production?
numericality: {greater_than: 0},
if: :in_production?
case first_portion
key_chain.each do |key|
return nil
if object == :error || key_chain.blank?