27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/agent_orange/browser.rb', line 27
def parse(user_agent)
AgentOrange.debug "BROWSER PARSING", 2
groups = parse_user_agent_string_into_groups(user_agent)
groups.each_with_index do |content,i|
if content[:name] =~ /(#{BROWSERS.collect{|cat,regex| regex}.join(')|(')})/i
self.populate(content)
break
elsif content[:comment] =~ /(#{BROWSERS.collect{|cat,regex| regex}.join(')|(')})/i
chosen_content = { :name => nil, :version => nil }
additional_groups = (content[:comment])
additional_groups.each do |additional_content|
if additional_content[:name] =~ /(#{BROWSERS.collect{|cat,regex| regex}.join(')|(')})/i
chosen_content = additional_content
BROWSERS.each do |cat, regex|
chosen_content[:name] = BROWSER_TITLES[cat] if additional_content[:name] =~ /(#{regex})/i
end
end
end
populate(chosen_content)
end
end
analysis
end
|