| Module | ActiveLdap::HumanReadable::ClassMethods |
| In: |
lib/active_ldap/human_readable.rb
|
# File lib/active_ldap/human_readable.rb, line 31
31: def human_attribute_description(attribute_or_name)
32: msgid = human_attribute_description_msgid(attribute_or_name)
33: return nil if msgid.nil?
34: s_(msgid)
35: end
# File lib/active_ldap/human_readable.rb, line 37
37: def human_attribute_description_msgid(attribute_or_name)
38: if attribute_or_name.is_a?(Schema::Attribute)
39: attribute = attribute_or_name
40: else
41: attribute = schema.attribute(attribute_or_name)
42: return nil if attribute.nil?
43: end
44: description = attribute.description
45: return nil if description.nil?
46: "LDAP|Description|Attribute|#{attribute.name}|#{description}"
47: end
# File lib/active_ldap/human_readable.rb, line 9
9: def human_attribute_name(attribute_or_name)
10: msgid = human_attribute_name_msgid(attribute_or_name)
11: msgid ||= human_attribute_name_with_gettext(attribute_or_name)
12: s_(msgid)
13: end
# File lib/active_ldap/human_readable.rb, line 15
15: def human_attribute_name_msgid(attribute_or_name)
16: if attribute_or_name.is_a?(Schema::Attribute)
17: name = attribute_or_name.name
18: else
19: attribute = schema.attribute(attribute_or_name)
20: return nil if attribute.id.nil?
21: if attribute.name == attribute_or_name or
22: attribute.aliases.include?(attribute_or_name)
23: name = attribute_or_name
24: else
25: return nil
26: end
27: end
28: "LDAP|Attribute|#{name}"
29: end
# File lib/active_ldap/human_readable.rb, line 62
62: def human_object_class_description(object_class_or_name)
63: msgid = human_object_class_description_msgid(object_class_or_name)
64: return nil if msgid.nil?
65: s_(msgid)
66: end
# File lib/active_ldap/human_readable.rb, line 68
68: def human_object_class_description_msgid(object_class_or_name)
69: if object_class_or_name.is_a?(Schema::ObjectClass)
70: object_class = object_class_or_name
71: else
72: object_class = schema.object_class(object_class_or_name)
73: return nil if object_class.nil?
74: end
75: description = object_class.description
76: return nil if description.nil?
77: "LDAP|Description|ObjectClass|#{object_class.name}|#{description}"
78: end
# File lib/active_ldap/human_readable.rb, line 49
49: def human_object_class_name(object_class_or_name)
50: s_(human_object_class_name_msgid(object_class_or_name))
51: end
# File lib/active_ldap/human_readable.rb, line 53
53: def human_object_class_name_msgid(object_class_or_name)
54: if object_class_or_name.is_a?(Schema::ObjectClass)
55: name = object_class_or_name.name
56: else
57: name = object_class_or_name
58: end
59: "LDAP|ObjectClass|#{name}"
60: end
# File lib/active_ldap/human_readable.rb, line 111
111: def human_readable_format(object)
112: case object
113: when Array
114: "[#{object.collect {|value| human_readable_format(value)}.join(', ')}]"
115: when Hash
116: formatted_values = []
117: object.each do |key, value|
118: formatted_values << [human_readable_format(key),
119: human_readable_format(value)].join("=>")
120: end
121: "{#{formatted_values.join(', ')}}"
122: else
123: if object.respond_to?(:to_human_readable_format)
124: object.to_human_readable_format
125: else
126: object.inspect
127: end
128: end
129: end
# File lib/active_ldap/human_readable.rb, line 93
93: def human_syntax_description(syntax_or_id)
94: msgid = human_syntax_description_msgid(syntax_or_id)
95: return nil if msgid.nil?
96: s_(msgid)
97: end
# File lib/active_ldap/human_readable.rb, line 99
99: def human_syntax_description_msgid(syntax_or_id)
100: if syntax_or_id.is_a?(Schema::Syntax)
101: syntax = syntax_or_id
102: else
103: syntax = schema.ldap_syntax(syntax_or_id)
104: return nil if syntax.nil?
105: end
106: description = syntax.description
107: return nil if description.nil?
108: "LDAP|Description|Syntax|#{syntax.id}|#{description}"
109: end
# File lib/active_ldap/human_readable.rb, line 80
80: def human_syntax_name(syntax_or_id)
81: s_(human_syntax_name_msgid(syntax_or_id))
82: end