Module: Browser
- Defined in:
- lib/browser/qq.rb,
lib/browser/bot.rb,
lib/browser/base.rb,
lib/browser/edge.rb,
lib/browser/nokia.rb,
lib/browser/opera.rb,
lib/browser/otter.rb,
lib/browser/rails.rb,
lib/browser/weibo.rb,
lib/browser/alipay.rb,
lib/browser/chrome.rb,
lib/browser/device.rb,
lib/browser/safari.rb,
lib/browser/yandex.rb,
lib/browser/aliases.rb,
lib/browser/browser.rb,
lib/browser/firefox.rb,
lib/browser/maxthon.rb,
lib/browser/meta/id.rb,
lib/browser/meta/ie.rb,
lib/browser/sputnik.rb,
lib/browser/testing.rb,
lib/browser/unknown.rb,
lib/browser/version.rb,
lib/browser/electron.rb,
lib/browser/facebook.rb,
lib/browser/meta/ios.rb,
lib/browser/platform.rb,
lib/browser/snapchat.rb,
lib/browser/device/tv.rb,
lib/browser/instagram.rb,
lib/browser/meta/base.rb,
lib/browser/blackberry.rb,
lib/browser/device/psp.rb,
lib/browser/device/wii.rb,
lib/browser/meta/proxy.rb,
lib/browser/middleware.rb,
lib/browser/phantom_js.rb,
lib/browser/uc_browser.rb,
lib/browser/device/base.rb,
lib/browser/device/ipad.rb,
lib/browser/device/wiiu.rb,
lib/browser/meta/device.rb,
lib/browser/meta/mobile.rb,
lib/browser/meta/safari.rb,
lib/browser/meta/tablet.rb,
lib/browser/meta/webkit.rb,
lib/browser/duck_duck_go.rb,
lib/browser/miui_browser.rb,
lib/browser/platform/ios.rb,
lib/browser/platform/mac.rb,
lib/browser/device/iphone.rb,
lib/browser/device/kindle.rb,
lib/browser/device/psvita.rb,
lib/browser/device/switch.rb,
lib/browser/meta/platform.rb,
lib/browser/platform/base.rb,
lib/browser/detect_version.rb,
lib/browser/device/android.rb,
lib/browser/device/samsung.rb,
lib/browser/device/surface.rb,
lib/browser/device/unknown.rb,
lib/browser/huawei_browser.rb,
lib/browser/platform/linux.rb,
lib/browser/sougou_browser.rb,
lib/browser/accept_language.rb,
lib/browser/device/xbox_360.rb,
lib/browser/device/xbox_one.rb,
lib/browser/micro_messenger.rb,
lib/browser/platform/kai_os.rb,
lib/browser/samsung_browser.rb,
lib/browser/platform/android.rb,
lib/browser/platform/unknown.rb,
lib/browser/platform/windows.rb,
lib/browser/action_controller.rb,
lib/browser/device/ipod_touch.rb,
lib/browser/google_search_app.rb,
lib/browser/internet_explorer.rb,
lib/browser/device/kindle_fire.rb,
lib/browser/middleware/context.rb,
lib/browser/platform/adobe_air.rb,
lib/browser/platform/chrome_os.rb,
lib/browser/bot/keyword_matcher.rb,
lib/browser/device/playstation3.rb,
lib/browser/device/playstation4.rb,
lib/browser/platform/blackberry.rb,
lib/browser/platform/firefox_os.rb,
lib/browser/meta/generic_browser.rb,
lib/browser/bot/known_bots_matcher.rb,
lib/browser/platform/windows_phone.rb,
lib/browser/platform/windows_mobile.rb,
lib/browser/device/blackberry_playbook.rb,
lib/browser/bot/empty_user_agent_matcher.rb,
lib/browser/middleware/context/additions.rb,
lib/browser/middleware/context/url_methods.rb
Defined Under Namespace
Modules: ActionController, Aliases, DetectVersion, Meta
Classes: AcceptLanguage, Alipay, Base, BlackBerry, Bot, Chrome, Device, DuckDuckGo, Edge, Electron, Facebook, Firefox, GoogleSearchApp, HuaweiBrowser, Instagram, InternetExplorer, Maxthon, MicroMessenger, Middleware, MiuiBrowser, Nokia, Opera, Otter, PhantomJS, Platform, QQ, Railtie, Safari, SamsungBrowser, Snapchat, SougouBrowser, Sputnik, UCBrowser, Unknown, Weibo, Yandex
Constant Summary
collapse
- EMPTY_STRING =
""
- Error =
Class.new(StandardError)
- VERSION =
"5.3.1"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.accept_language_size_limit ⇒ Object
Returns the value of attribute accept_language_size_limit.
61
62
63
|
# File 'lib/browser/browser.rb', line 61
def accept_language_size_limit
@accept_language_size_limit
end
|
.user_agent_size_limit ⇒ Object
Returns the value of attribute user_agent_size_limit.
61
62
63
|
# File 'lib/browser/browser.rb', line 61
def user_agent_size_limit
@user_agent_size_limit
end
|
Class Method Details
.[](key) ⇒ Object
24
25
26
|
# File 'lib/browser/testing.rb', line 24
def self.[](key)
user_agents.fetch(key)
end
|
.bot_user_agents ⇒ Object
14
15
16
|
# File 'lib/browser/testing.rb', line 14
def self.bot_user_agents
@bot_user_agents ||= YAML.load_file(Browser.root.join("test/ua_bots.yml"))
end
|
.browser_user_agents ⇒ Object
10
11
12
|
# File 'lib/browser/testing.rb', line 10
def self.browser_user_agents
@browser_user_agents ||= YAML.load_file(Browser.root.join("test/ua.yml"))
end
|
.matchers ⇒ Object
Hold the list of browser matchers. Order is important.
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/browser/browser.rb', line 69
def self.matchers
@matchers ||= [
Nokia,
UCBrowser,
PhantomJS,
BlackBerry,
Opera,
Edge,
InternetExplorer,
Firefox,
Otter,
Facebook, Instagram, Snapchat, Weibo, MicroMessenger, QQ, Alipay, Electron, Yandex, Sputnik, DuckDuckGo, SamsungBrowser, HuaweiBrowser, MiuiBrowser, Maxthon, SougouBrowser, GoogleSearchApp, Chrome,
Safari,
Unknown
]
end
|
.new(user_agent, **kwargs) ⇒ Object
103
104
105
106
107
|
# File 'lib/browser/browser.rb', line 103
def self.new(user_agent, **kwargs)
matchers
.map {|klass| klass.new(user_agent || EMPTY_STRING, **kwargs) }
.find(&:match?)
end
|
.root ⇒ Object
56
57
58
|
# File 'lib/browser/browser.rb', line 56
def self.root
@root ||= Pathname.new(File.expand_path("../..", __dir__))
end
|
.search_engine_user_agents ⇒ Object
18
19
20
21
22
|
# File 'lib/browser/testing.rb', line 18
def self.search_engine_user_agents
@search_engine_user_agents ||= begin
YAML.load_file(Browser.root.join("test/ua_search_engines.yml"))
end
end
|
.user_agents ⇒ Object
4
5
6
7
8
|
# File 'lib/browser/testing.rb', line 4
def self.user_agents
@user_agents ||= browser_user_agents
.merge(bot_user_agents)
.merge(search_engine_user_agents)
end
|