Module: Woothee::Misc

Extended by:
Util
Defined in:
lib/woothee/misc.rb

Class Method Summary collapse

Methods included from Util

update_category, update_map, update_os, update_os_version, update_version

Class Method Details

.challenge_desktoptools(ua, result) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/woothee/misc.rb', line 9

def self.challenge_desktoptools(ua, result)
  data = case
         when ua.index('AppleSyndication/') then Woothee::DataSet.get('SafariRSSReader')
         when ua.index('compatible; Google Desktop/') then Woothee::DataSet.get('GoogleDesktop')
         when ua.index('Windows-RSS-Platform') then Woothee::DataSet.get('WindowsRSSReader')
         else nil
         end
  return false unless data

  update_map(result, data)
  true
end

.challenge_http_library(ua, result) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/woothee/misc.rb', line 33

def self.challenge_http_library(ua, result)
  data,version = case
                 when ua =~ /^(?:Apache-HttpClient\/|Jakarta Commons-HttpClient\/|Java\/)/o || ua =~ /[- ]HttpClient(\/|$)/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'Java']
                 when ua.index('Java(TM) 2 Runtime Environment,')
                   [Woothee::DataSet.get('HTTPLibrary'), 'Java']
                 when ua =~ /^Wget/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'wget']
                 when ua =~ /^(?:libwww-perl|WWW-Mechanize|LWP::Simple|LWP |lwp-trivial)/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'perl']
                 when ua =~ /^(?:Ruby|feedzirra|Typhoeus)/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'ruby']
                 when ua =~ /^(Python-urllib\/|Twisted )/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'python']
                 when ua =~ /^(?:PHP|WordPress|CakePHP|PukiWiki|PECL::HTTP)(?:\/| |$)/o || ua =~ /(?:PEAR |)HTTP_Request(?: class|2)/o
                   [Woothee::DataSet.get('HTTPLibrary'), 'php']
                 when ua.index('curl/') == 0
                   [Woothee::DataSet.get('HTTPLibrary'), 'curl']
                 else [nil,nil]
                 end
  return false unless data

  update_map(result, data)
  update_version(result, version)
  true
end

.challenge_maybe_rss_reader(ua, result) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/woothee/misc.rb', line 60

def self.challenge_maybe_rss_reader(ua, result)
  data = if ua =~ /rss(?:reader|bar|[-_ \/;()]|[ +]*\/)/oi || ua =~ /headline-reader/oi
           Woothee::DataSet.get('VariousRSSReader')
         elsif ua.index('cococ/')
           Woothee::DataSet.get('VariousRSSReader')
         else
           nil
         end
  return false unless data

  update_map(result, data)
  true
end

.challenge_smartphone_patterns(ua, result) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/woothee/misc.rb', line 22

def self.challenge_smartphone_patterns(ua, result)
  if ua.index('CFNetwork/')
    data = Woothee::DataSet.get('iOS')
    update_category(result, data[Woothee::KEY_CATEGORY])
    update_os(result, data[Woothee::KEY_NAME])
    return true
  end

  false
end