Add support for custom browsers
We use custom user agents for our native mobile clients that we rely on for API versioning and so have historically just monkey-patched Browser. Version 2.0 nearly supports this scenario with its tidy, class-by-class approach to each browser type; however, there is still no way to actually register a custom browser and so we're back to monkey-patching (albeit in a much less invasive manner).
Our custom browser looks like this:
module Browser
class MyCustomBrowser < Base
def id
:my_custom_browser
end
def name
"My Custom Browser"
end
def full_version
ua[%r[CustomBrowser/([\S]+)], 1]
end
def match?
ua =~ /CustomBrowser/
end
end
end
And the API looks like this:
Browser.register Browser::MyCustomBrowser
The Browser.register function just adds the class reference to an array of custom browsers, which are prepended to the hard-coded list that is currently in place.
I'm happy to open a pull request for these changes but I wanted to make sure that this makes sense first.
Cheers!
Thanks for the suggestion. It was an easy change, so I just did it. I took the opportunity and did the same thing for platform, device and meta collections.
This is fantastic. Thanks!