Sha256: 440d2123c1436cfe14acfd3838fd5e00b18a7eb5242b8fde617fc58efe8440bf

Contents?: true

Size: 1.05 KB

Versions: 41

Compression:

Stored size: 1.05 KB

Contents

# -*- coding: utf-8 -*-
#DoCoMoの時guid=onの付与
class ActionController::Base #:nodoc:
  class_inheritable_accessor :docomo_guid_mode

  class << self
    def docomo_guid(mode=:docomo)
      include Jpmobile::DocomoGuid
      self.docomo_guid_mode = mode
    end
  end
end


module Jpmobile::DocomoGuid #:nodoc:
  protected
  def default_url_options
    result = super || {}
    return result unless request # for test process
    return result unless apply_add_guid?
    return result.merge({:guid => "ON"})
  end

  #guid=ONを付与すべきか否かを返す
  def apply_add_guid?
    return true if docomo_guid_mode == :always
    return false if docomo_guid_mode == :none

    return false unless request.mobile?
    return false unless request.mobile.is_a?(Jpmobile::Mobile::Docomo)
    return false if not_apply_guid_user_agent?

    if docomo_guid_mode == :valid_ip
      return false unless request.mobile.valid_ip?
    end

    return true
  end

  def not_apply_guid_user_agent?
    request.user_agent.match(/(?:Googlebot|Y!J-SRD\/1\.0|Y!J-MBS\/1\.0)/)
  end
end

Version data entries

41 entries across 33 versions & 1 rubygems

Version Path
jpmobile-1.0.12 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.11 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.10 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.9 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.8 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.7 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.6 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.5 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.4 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.3 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.2 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.1 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.7 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.6 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.5 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.4 lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.4 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.3 test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb
jpmobile-1.0.0.pre.3 lib/jpmobile/docomo_guid.rb