Extract user accounts from different contexts...
Extractors(:twitter).sanitize("http://twitter.com/#!/programmingshit") # => "programmingshit"
Extractors(:twitter).sanitize("programmingshit") # => "programmingshit"
... and format them back
Extractors(:twitter).format("programmingshit") # => "http://twitter.com/#!/programmingshit"
Add your own extractors
Extractors.add :lookatme do
username_regexp = '[a-zA-Z0-9_\\-]{3,20}'
sanitizer [
%r{^(?:http://)?(?:www\.)?lookatme\.ru/users/(#{username_regexp})},
%r{^(#{username_regexp})$}
]
formatter 'http://lookatme.ru/users/%s'
end
List of available extractors
- :googleplus
- :gtalk
- :lastfm
- :livejournal
- :lookatme
- :moikrug
- :myspace
- :skype
- :tumblr
- :vkontakte
- :youtube
Credits
The code itself has been extracted from http://github.com/toy/contacts gem.