Module: OpenDirectoryUtils::CleanCheck
- Included in:
- CommandsBase, CommandsGroups, CommandsUserAttribs, CommandsUserCreateRemove
- Defined in:
- lib/open_directory_utils/clean_check.rb
Overview
Instance Method Summary collapse
- #assert(&block) ⇒ Object
- #check_critical_attribute(attrib, key, value = nil) ⇒ Object
- #group_record_name_alternatives(attribs) ⇒ Object
- #tidy_attribs(attribs) ⇒ Object
- #user_record_name_alternatives(attribs) ⇒ Object
Instance Method Details
#assert(&block) ⇒ Object
7 8 9 |
# File 'lib/open_directory_utils/clean_check.rb', line 7 def assert(&block) raise ArgumentError unless block.call end |
#check_critical_attribute(attrib, key, value = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/open_directory_utils/clean_check.rb', line 11 def check_critical_attribute(attrib, key, value=nil) assert{not attrib[key].nil?} attrib[key] = attrib[key].to_s.strip assert{not attrib[key].eql? ''} assert{not attrib[key].eql? '[]'} assert{not attrib[key].eql? '{}'} assert{not attrib[key].include? ' '} if key.eql? :scope assert{not attrib[key].include? ' '} if [:uid, :username, :record_name].include? key rescue NoMethodError, ArgumentError # => error = "#{key}: '#{attrib[key].inspect}' invalid" += ", value_name: :#{value}" unless value.nil? raise ArgumentError, end |
#group_record_name_alternatives(attribs) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/open_directory_utils/clean_check.rb', line 41 def group_record_name_alternatives(attribs) attribs[:record_name] = nil attribs[:record_name] = attribs[:group_membership] attribs[:record_name] = attribs[:record_name] || attribs[:groupmembership] attribs[:record_name] = attribs[:record_name] || attribs[:group_name] attribs[:record_name] = attribs[:record_name] || attribs[:groupname] attribs[:record_name] = attribs[:record_name] || attribs[:gid] return attribs end |
#tidy_attribs(attribs) ⇒ Object
25 26 27 28 29 |
# File 'lib/open_directory_utils/clean_check.rb', line 25 def tidy_attribs(attribs) user_attribs = {} attribs.each{ |k,v| user_attribs[k] = v.to_s.strip } return user_attribs end |
#user_record_name_alternatives(attribs) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/open_directory_utils/clean_check.rb', line 31 def user_record_name_alternatives(attribs) attribs[:record_name] = nil attribs[:record_name] = attribs[:user_name] attribs[:record_name] = attribs[:record_name] || attribs[:short_name] attribs[:record_name] = attribs[:record_name] || attribs[:shortname] attribs[:record_name] = attribs[:record_name] || attribs[:username] attribs[:record_name] = attribs[:record_name] || attribs[:uid] return attribs end |