Sha256: 9640d993605b8563bd719195b6cbb1091631d86cb5ea8c0a4e776eeac8460a65

Contents?: true

Size: 961 Bytes

Versions: 10

Compression:

Stored size: 961 Bytes

Contents

require "rack/request"

module Galakei
  module Request
    def docomo?
      /^DoCoMo/ =~ 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 imode_browser_1_0?
      if /docomo(.*\((.*;)?c(\d+)\;)?/i =~ user_agent
        $3.to_i < 500
      else
        false
      end
    end

    def au_browser_6?
      /KDDI.* UP\.Browser\/6\./ =~ user_agent && /UP\.Browser\/6\.2_7/ !~ user_agent
    end

    def different_cookie_in_ssl?
      au? || softbank?
    end

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

    def galakei_uid
      if docomo?
        env["HTTP_X_DCMGUID"]
      elsif au?
        env["HTTP_X_UP_SUBNO"]
      elsif softbank?
        env["HTTP_X_JPHONE_UID"]
      end
    end
  end
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
galakei-0.12.0 lib/galakei/request.rb
galakei-0.11.3 lib/galakei/request.rb
galakei-0.11.2 lib/galakei/request.rb
galakei-0.11.1 lib/galakei/request.rb
galakei-0.11.0 lib/galakei/request.rb
galakei-0.10.1 lib/galakei/request.rb
galakei-0.10.0 lib/galakei/request.rb
galakei-0.9.1 lib/galakei/request.rb
galakei-0.9.0 lib/galakei/request.rb
galakei-0.8.1 lib/galakei/request.rb