module MultiIndex::ConfigValidation
Constants
- ALLOWED_VALUES
- MAPPING_FORMAT
Public Instance Methods
get_password(prompt="Password: ")
click to toggle source
# File lib/multi_index/validation.rb, line 48 def get_password(prompt="Password: ") print prompt result = STDIN.noecho(&:gets).chomp puts result end
get_plain(prompt)
click to toggle source
# File lib/multi_index/validation.rb, line 62 def get_plain(prompt) print prompt STDIN.gets.chomp end
validate_config_parameters(options)
click to toggle source
# File lib/multi_index/validation.rb, line 67 def validate_config_parameters(options) profile = options['profile'] profile = HashWithIndifferentAccess.new(YAML.load_file(profile)) if profile profile ||= { google_drive: {}, ldap: {} } LOG.info '*** Google Drive Credentials/Access Info ****' profile[:google_drive][:email] ||= get_plain('Google Email: ') profile[:google_drive][:password] ||= encrypt(get_password('Google password: ')) profile[:google_drive][:key] ||= get_plain('Document Key: ') profile[:google_drive][:sheet] ||= get_plain('Sheet Index: ') if (options['output'] == 'CONFIG_SERVICE' && profile[:ldap].empty?) LOG.info '*** LDAP Credentials (for Config Service): ****' profile[:ldap][:email] ||= get_plain('LDAP Username: ') profile[:ldap][:password] ||= encrypt(get_password('LDAP Password: ')) profile[:ldap][:key] ||= get_plain('Config Key: ') end options.merge!({profile: profile}) options end
validate_write_parameters(options)
click to toggle source
# File lib/multi_index/validation.rb, line 23 def validate_write_parameters(options) output, format = options['output'], options['format'] #Check preconditions check_argument(ALLOWED_VALUES[:output].include?(output), "Output must be one of #{ALLOWED_VALUES[:output]}") if (MAPPING_FORMAT[output]) format = MAPPING_FORMAT[output] LOG.info "Format is automatically set to #{format} for #{output}" end check_argument(ALLOWED_VALUES[:format].include?(format), "Format must be one of #{ALLOWED_VALUES[:format]}") { output: output, format: format } end