Module: YARD::CodeObjects::NamespaceMapper
- Included in:
- YARD::CodeObjects, RegistryResolver
- Defined in:
- lib/yard/code_objects/namespace_mapper.rb
Overview
This module controls registration and accessing of namespace separators for Registry lookup.
Registering a Separator for a Namespace collapse
-
#clear_separators ⇒ void
Clears the map of separators.
-
#default_separator(value = nil) ⇒ Object
Gets or sets the default separator value to use when no separator for the namespace can be determined.
-
#register_separator(sep, *valid_types) ⇒ Object
Registers a separator with an optional set of valid types that must follow the separator lexically.
Separator and Type Lookup Helpers collapse
-
#separators ⇒ Array<String>
All of the registered separators.
-
#separators_for_type(type) ⇒ Array<Symbol>
A list of separators registered to a type.
-
#separators_match ⇒ Regexp
The regexp match of all separators.
-
#types_for_separator(sep) ⇒ Array<Symbol>
A list of types registered to a separator.
Instance Method Details
#clear_separators ⇒ void
This method returns an undefined value.
Clears the map of separators.
37 38 39 40 41 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 37 def clear_separators NamespaceMapper.invalidate NamespaceMapper.map = {} NamespaceMapper.rev_map = {} end |
#default_separator(value = nil) ⇒ Object
Gets or sets the default separator value to use when no separator for the namespace can be determined.
50 51 52 53 54 55 56 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 50 def default_separator(value = nil) if value NamespaceMapper.default_separator = Regexp.quote value else NamespaceMapper.default_separator end end |
#register_separator(sep, *valid_types) ⇒ Object
Registers a separator with an optional set of valid types that must follow the separator lexically.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 22 def register_separator(sep, *valid_types) NamespaceMapper.invalidate valid_types.each do |t| NamespaceMapper.rev_map[t] ||= [] NamespaceMapper.rev_map[t] << sep end NamespaceMapper.map[sep] ||= [] NamespaceMapper.map[sep] += valid_types end |
#separators ⇒ Array<String>
Returns all of the registered separators.
61 62 63 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 61 def separators NamespaceMapper.map.keys end |
#separators_for_type(type) ⇒ Array<Symbol>
Returns a list of separators registered to a type.
78 79 80 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 78 def separators_for_type(type) NamespaceMapper.rev_map[type] end |
#separators_match ⇒ Regexp
Returns the regexp match of all separators.
66 67 68 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 66 def separators_match NamespaceMapper.map_match end |
#types_for_separator(sep) ⇒ Array<Symbol>
Returns a list of types registered to a separator.
72 73 74 |
# File 'lib/yard/code_objects/namespace_mapper.rb', line 72 def types_for_separator(sep) NamespaceMapper.map[sep] end |