File: testing.rb

package info (click to toggle)
ruby-browser 5.3.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 872 kB
  • sloc: ruby: 4,752; makefile: 13
file content (27 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module Browser
  def self.user_agents
    @user_agents ||= browser_user_agents
                     .merge(bot_user_agents)
                     .merge(search_engine_user_agents)
  end

  def self.browser_user_agents
    @browser_user_agents ||= YAML.load_file(Browser.root.join("test/ua.yml"))
  end

  def self.bot_user_agents
    @bot_user_agents ||= YAML.load_file(Browser.root.join("test/ua_bots.yml"))
  end

  def self.search_engine_user_agents
    @search_engine_user_agents ||= begin
      YAML.load_file(Browser.root.join("test/ua_search_engines.yml"))
    end
  end

  def self.[](key)
    user_agents.fetch(key)
  end
end