Sha256: 268edadce74dfd47b90817b21584a3710adb12d4d1da3c107ff05a9c684945e8

Contents?: true

Size: 644 Bytes

Versions: 14

Compression:

Stored size: 644 Bytes

Contents

require "rack/request"

module Galakei
  module Request
    def docomo?
      /DoCoMo/i =~ user_agent
    end

    def au?
      # doesn't detect some 2G phones, but as they will be discontinued soon, doesn't really matter
      /KDDI/ =~ user_agent
    end

    def softbank?
      /^(SoftBank|Vodafone)/ =~ user_agent
    end

    def cookies?
      !imode_browser_1_0?
    end

    def imode_browser_1_0?
      if /docomo(.*\((.*;)?c(\d+)\;)?/i =~ user_agent
        $3.to_i < 500
      else
        false
      end
    end

    def galakei?
      docomo? || au? || softbank?
    end
  end
end

Rack::Request.send :include, Galakei::Request

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
galakei-0.4.1 lib/galakei/request.rb
galakei-0.4.0 lib/galakei/request.rb
galakei-0.3.8 lib/galakei/request.rb
galakei-0.3.7 lib/galakei/request.rb
galakei-0.3.6 lib/galakei/request.rb
galakei-0.3.5 lib/galakei/request.rb
galakei-0.3.4 lib/galakei/request.rb
galakei-0.3.3 lib/galakei/request.rb
galakei-0.3.2 lib/galakei/request.rb
galakei-0.3.1 lib/galakei/request.rb
galakei-0.3.0 lib/galakei/request.rb
galakei-0.2.0 lib/galakei/request.rb
galakei-0.1.0 lib/galakei/request.rb
galakei-0.0.1 lib/galakei/request.rb