jpmobile 0.0.8 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -3
- data/{spec/spec.opts → .rspec} +1 -2
- data/README.rdoc +122 -128
- data/Rakefile +23 -101
- data/VERSION.yml +4 -3
- data/jpmobile.gemspec +130 -182
- data/lib/jpmobile.rb +37 -24
- data/lib/jpmobile/docomo_guid.rb +2 -1
- data/lib/jpmobile/email.rb +3 -4
- data/lib/jpmobile/emoticon.rb +2 -6
- data/lib/jpmobile/encoding.rb +29 -0
- data/lib/jpmobile/filter.rb +42 -134
- data/lib/jpmobile/helpers.rb +5 -18
- data/lib/jpmobile/hook_action_controller.rb +24 -16
- data/lib/jpmobile/hook_action_view.rb +28 -89
- data/lib/jpmobile/mobile/abstract_mobile.rb +21 -4
- data/lib/jpmobile/mobile/android.rb +10 -0
- data/lib/jpmobile/mobile/au.rb +28 -3
- data/lib/jpmobile/mobile/ddipocket.rb +12 -0
- data/lib/jpmobile/mobile/display.rb +29 -26
- data/lib/jpmobile/mobile/docomo.rb +38 -12
- data/lib/jpmobile/mobile/iphone.rb +26 -0
- data/lib/jpmobile/mobile/smart_phone.rb +21 -0
- data/lib/jpmobile/mobile/softbank.rb +16 -41
- data/lib/jpmobile/mobile/vodafone.rb +17 -0
- data/lib/jpmobile/mobile/willcom.rb +1 -10
- data/lib/jpmobile/mobile/windows_phone.rb +10 -0
- data/lib/jpmobile/position.rb +4 -3
- data/lib/jpmobile/rack.rb +43 -0
- data/lib/jpmobile/rack/filter.rb +51 -0
- data/lib/jpmobile/rack/mobile_carrier.rb +33 -0
- data/lib/jpmobile/rack/params_filter.rb +47 -0
- data/lib/jpmobile/rails.rb +22 -0
- data/lib/jpmobile/request_with_mobile.rb +8 -12
- data/lib/jpmobile/trans_sid.rb +44 -26
- data/lib/jpmobile/util.rb +68 -0
- data/{tasks → lib/tasks}/jpmobile_tasks.rake +32 -13
- data/spec/rack/jpmobile/android_spec.rb +20 -0
- data/spec/rack/jpmobile/au_spec.rb +206 -0
- data/spec/rack/jpmobile/docomo_spec.rb +237 -0
- data/spec/rack/jpmobile/emoticon_spec.rb +215 -0
- data/spec/rack/jpmobile/filter_spec.rb +181 -0
- data/spec/rack/jpmobile/iphone_spec.rb +32 -0
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +39 -0
- data/spec/rack/jpmobile/params_filter_spec.rb +193 -0
- data/spec/rack/jpmobile/softbank_spec.rb +123 -0
- data/spec/rack/jpmobile/willcom_spec.rb +67 -0
- data/spec/rack/jpmobile/windows_phone.rb +20 -0
- data/spec/rack_helper.rb +86 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/unit/detect_by_email_spec.rb +21 -27
- data/spec/unit/is_carrier_spec.rb +56 -84
- data/spec/unit/spec_helper.rb +1 -2
- data/spec/unit/util_spec.rb +2 -2
- data/spec/unit/valid_ip_spec.rb +43 -52
- data/test/legacy/autoload_test.rb +1 -3
- data/test/legacy/emoticon_test.rb +5 -6
- data/test/legacy/helper.rb +0 -71
- data/test/rails/overrides/.rspec +5 -0
- data/test/rails/overrides/Gemfile +32 -0
- data/test/rails/overrides/app/controllers/docomo_guid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +5 -0
- data/test/rails/overrides/app/controllers/docomo_guid_docomo_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/filter_controller.rb +0 -34
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +19 -0
- data/test/rails/overrides/app/controllers/hankaku_filter_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/links_controller.rb +28 -0
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb +4 -0
- data/test/rails/overrides/app/controllers/trans_sid_always_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -0
- data/test/rails/overrides/app/controllers/trans_sid_mobile_controller.rb +3 -0
- data/test/rails/overrides/app/controllers/trans_sid_none_controller.rb +3 -0
- data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
- data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
- data/test/rails/overrides/app/views/links/link.html.erb +1 -0
- data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
- data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
- data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
- data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
- data/test/rails/overrides/autotest/discover.rb +2 -0
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +1 -0
- data/test/rails/overrides/config/routes.rb +58 -0
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +16 -0
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +2 -2
- data/test/rails/overrides/spec/{controllers → requests}/docomo_guid_spec.rb +37 -14
- data/test/rails/overrides/spec/{controllers → requests}/docomo_spec.rb +11 -8
- data/test/rails/overrides/spec/{controllers → requests}/emobile_spec.rb +24 -8
- data/test/rails/overrides/spec/requests/filter_spec.rb +171 -0
- data/test/rails/overrides/spec/requests/helpers_spec.rb +187 -0
- data/test/rails/overrides/spec/requests/pc_spec.rb +22 -0
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +21 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +234 -0
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +142 -0
- data/test/rails/overrides/spec/spec_helper.rb +17 -48
- data/test/sinatra/guestbook.rb +40 -0
- data/test/sinatra/test/filter_test.rb +39 -0
- metadata +185 -312
- data/lib/jpmobile/hook_request.rb +0 -5
- data/lib/jpmobile/rack/auth.rb +0 -55
- data/lib/jpmobile/rack/combined_logger.rb +0 -54
- data/lib/jpmobile/rack/request.rb +0 -7
- data/lib/jpmobile/rack/trans_sid.rb +0 -14
- data/lib/jpmobile/version.rb +0 -9
- data/spec/unit/detect_by_ua_spec.rb +0 -40
- data/test/legacy/au_test.rb +0 -173
- data/test/legacy/docomo_test.rb +0 -187
- data/test/legacy/emoticon_functional_test.rb +0 -195
- data/test/legacy/filter_test.rb +0 -34
- data/test/legacy/helpers_test.rb +0 -217
- data/test/legacy/softbank_test.rb +0 -183
- data/test/legacy/willcom_test.rb +0 -56
- data/test/rails/2.3.2/spec/controllers/trans_sid_spec.rb +0 -99
- data/test/rails/overrides/app/controllers/docomo_guid_controller.rb +0 -13
- data/test/rails/overrides/app/controllers/trans_sid_controller.rb +0 -28
- data/test/rails/overrides/lib/tasks/rspec.rake +0 -165
- data/test/rails/overrides/spec/controllers/filter_spec.rb +0 -159
- data/test/rails/overrides/spec/controllers/pc_spec.rb +0 -13
- data/test/rails/overrides/spec/controllers/softbank_emulator_spec.rb +0 -42
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +0 -117
- data/test/rails/overrides/spec/controllers/trans_sid_spec.rb +0 -117
- data/test/rails/overrides/spec/rspec.rake +0 -165
- data/test/rails/overrides/spec/spec.opts +0 -4
data/lib/jpmobile/rack/auth.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Jpmobile
|
2
|
-
module Rack
|
3
|
-
# in your_app.ru
|
4
|
-
#
|
5
|
-
# check ip
|
6
|
-
# require 'jpmobile/rack'
|
7
|
-
# use Jpmobile::Rack::Auth::Docomo
|
8
|
-
|
9
|
-
# (but allow localhost), {
|
10
|
-
# :ident => %w( xxxxxx ),
|
11
|
-
# :check_ip => true,
|
12
|
-
# :allow_ip => %w( 127.0.0.1 )
|
13
|
-
# } # you can use block
|
14
|
-
|
15
|
-
# req is Jpmobile::Rack::Request's subclass instance.
|
16
|
-
# require 'jpmobile/rack'
|
17
|
-
# use Jpmobile::Rack::Auth {|req|
|
18
|
-
# Your::Model::AuSubno.count(:subno => req.ident) != 0
|
19
|
-
# }
|
20
|
-
class Auth
|
21
|
-
FORBIDDEN = [403, {'Content-Type' => 'text/plain' }, 'Forbidden' ]
|
22
|
-
|
23
|
-
def initialize(app, hash=nil, &block)
|
24
|
-
@app = app
|
25
|
-
if hash
|
26
|
-
@allow_ip = hash[:allow_ip]
|
27
|
-
end
|
28
|
-
@cond = block
|
29
|
-
end
|
30
|
-
|
31
|
-
def career
|
32
|
-
end
|
33
|
-
|
34
|
-
def call(env)
|
35
|
-
request = Request.new(env)
|
36
|
-
|
37
|
-
if request.mobile? and request.valid_ip?
|
38
|
-
@app.call(env)
|
39
|
-
else
|
40
|
-
FORBIDDEN
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
::Jpmobile::Mobile.constants.each do |career|
|
45
|
-
klass = Class.new(self)
|
46
|
-
klass.class_eval do
|
47
|
-
define_method :career do
|
48
|
-
::Jpmobile::Mobile.const_get(career)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
const_set(career, klass)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module Jpmobile
|
2
|
-
module Rack
|
3
|
-
# Rack::CommonLogger show too few infomation to debugging mobile web application.
|
4
|
-
# So you can Rack::Jpmobile::CombinedLogger as alternate.
|
5
|
-
# SYNOPSIS
|
6
|
-
# in your_app.up
|
7
|
-
# require 'jpmobile/rack'
|
8
|
-
# class Rack::CommonLogger
|
9
|
-
# include Jpmobile::Rack::CombinedLogger
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# use Rack::CommonLogger, STDERR # you need not write this when you use rackup on development.
|
13
|
-
#
|
14
|
-
module CombinedLogger
|
15
|
-
|
16
|
-
# XXX: It's evil way for replacing Rack::CommonLogger#each.
|
17
|
-
def self.included klass
|
18
|
-
klass.class_eval do
|
19
|
-
alias orig_each each
|
20
|
-
remove_method :each
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def each
|
25
|
-
length = 0
|
26
|
-
@body.each { |part|
|
27
|
-
length += part.size
|
28
|
-
yield part
|
29
|
-
}
|
30
|
-
|
31
|
-
@now = Time.now
|
32
|
-
|
33
|
-
# Combined Log Format: http://httpd.apache.org/docs/1.3/logs.html#combined
|
34
|
-
# 127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"
|
35
|
-
# "%h %l %u [%t] \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
|
36
|
-
@logger << %{%s - %s [%s] "%s %s%s %s" %d %s %s "%s" %0.4f\n} %
|
37
|
-
[
|
38
|
-
@env['HTTP_X_FORWARDED_FOR'] || @env["REMOTE_ADDR"] || "-",
|
39
|
-
@env["REMOTE_USER"] || @env["HTTP_X_DCMGUID"] || @env["HTTP_X_UP_SUBNO"] || @env["HTTP_X_JPHONE_UID"] || @env["HTTP_X_EM_UID"] || "-",
|
40
|
-
@now.strftime("%d/%b/%Y %H:%M:%S"),
|
41
|
-
@env["REQUEST_METHOD"],
|
42
|
-
@env["PATH_INFO"],
|
43
|
-
@env["QUERY_STRING"].empty? ? "" : "?"+@env["QUERY_STRING"],
|
44
|
-
@env["HTTP_VERSION"],
|
45
|
-
@status.to_s[0..3],
|
46
|
-
(length.zero? ? "-" : length.to_s),
|
47
|
-
@env["HTTP_REFERER"] ? %{"#{@env['Referer']}"} : '-',
|
48
|
-
@env["HTTP_USER_AGENT"],
|
49
|
-
@now - @time
|
50
|
-
]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
data/lib/jpmobile/version.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
-
|
3
|
-
describe 'Jpmobile::RequestWithMobile' do
|
4
|
-
Spec::Fixture::Base.new self, :carrier => :user_agent do
|
5
|
-
def request_class
|
6
|
-
Class.new do
|
7
|
-
include Jpmobile::RequestWithMobile
|
8
|
-
|
9
|
-
def initialize user_agent
|
10
|
-
@user_agent = user_agent
|
11
|
-
end
|
12
|
-
|
13
|
-
def user_agent
|
14
|
-
@user_agent
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
it '#mobile should return :carrier when take :user_agent as UserAgent' do |carrier, user_agent|
|
20
|
-
request_class.new(user_agent).mobile.class.should == carrier
|
21
|
-
end
|
22
|
-
|
23
|
-
set_fixtures([
|
24
|
-
[ Jpmobile::Mobile::Docomo => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)' ],
|
25
|
-
[ Jpmobile::Mobile::Docomo => 'DoCoMo/1.0/SO506iC/c20/TB/W20H10' ],
|
26
|
-
[ Jpmobile::Mobile::Docomo => 'DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)' ],
|
27
|
-
[ Jpmobile::Mobile::Au => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0' ],
|
28
|
-
[ Jpmobile::Mobile::Au => 'UP.Browser/3.04-KCTA UP.Link/3.4.5.9' ],
|
29
|
-
[ Jpmobile::Mobile::Softbank => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1' ],
|
30
|
-
[ Jpmobile::Mobile::Softbank => 'Semulator' ],
|
31
|
-
[ Jpmobile::Mobile::Vodafone => 'Vodafone/1.0/V903SH/SHJ001/SN000000000000000 Browser/UP.Browser/7.0.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0' ],
|
32
|
-
[ Jpmobile::Mobile::Jphone => 'J-PHONE/4.3/V603SH/SNXXXX0000000 SH/0007aa Profile/MIDP-1.0 Configuration/CLDC-1.0 Ext-Profile/JSCL-1.3.2' ],
|
33
|
-
[ Jpmobile::Mobile::Jphone => 'J-EMULATOR' ],
|
34
|
-
[ Jpmobile::Mobile::Willcom => 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0' ],
|
35
|
-
[ Jpmobile::Mobile::Ddipocket => 'Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0'],
|
36
|
-
[ Jpmobile::Mobile::Emobile => 'emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4' ],
|
37
|
-
[ NilClass => 'Googlebot' ],
|
38
|
-
])
|
39
|
-
end.run
|
40
|
-
end
|
data/test/legacy/au_test.rb
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__)+'/helper'
|
2
|
-
|
3
|
-
class AuTest < Test::Unit::TestCase
|
4
|
-
# au, 端末種別の識別
|
5
|
-
def test_au_ca32
|
6
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
7
|
-
"HTTP_X_UP_SUBNO"=>"00000000000000_mj.ezweb.ne.jp")
|
8
|
-
reqs.each do |req|
|
9
|
-
assert_equal(true, req.mobile?)
|
10
|
-
assert_instance_of(Jpmobile::Mobile::Au, req.mobile)
|
11
|
-
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.subno)
|
12
|
-
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident)
|
13
|
-
assert_equal("00000000000000_mj.ezweb.ne.jp", req.mobile.ident_subscriber)
|
14
|
-
assert_equal(nil, req.mobile.position)
|
15
|
-
assert(req.mobile.supports_cookie?)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# TuKa, 端末種別の識別
|
20
|
-
def test_tuka_tk22
|
21
|
-
reqs = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
|
22
|
-
reqs.each do |req|
|
23
|
-
assert_equal(true, req.mobile?)
|
24
|
-
assert_instance_of(Jpmobile::Mobile::Au, req.mobile)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# au, gps, degree, wgs84
|
29
|
-
def test_au_gps_degree
|
30
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
31
|
-
{"QUERY_STRING"=>"ver=1&datum=0&unit=1&lat=%2b43.07772&lon=%2b141.34114&alt=64&time=20061016192415&smaj=69&smin=18&vert=21&majaa=115&fm=1"})
|
32
|
-
reqs.each do |req|
|
33
|
-
assert_equal(43.07772, req.mobile.position.lat)
|
34
|
-
assert_equal(141.34114, req.mobile.position.lon)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# au, gps, dms, wgs84
|
39
|
-
# これが一番端末を選ばないようだ
|
40
|
-
# http://hiyuzawa.jpn.org/blog/2006/09/gps1_augps_1.html
|
41
|
-
def test_au_gps_dms
|
42
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
43
|
-
{"QUERY_STRING"=>"ver=1&datum=0&unit=0&lat=%2b43.05.08.95&lon=%2b141.20.25.99&alt=155&time=20060521010328&smaj=76&smin=62&vert=65&majaa=49&fm=1"})
|
44
|
-
reqs.each do |req|
|
45
|
-
assert_in_delta(43.08581944, req.mobile.position.lat, 1e-7)
|
46
|
-
assert_in_delta(141.3405528, req.mobile.position.lon, 1e-7)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# au, gps, degree, tokyo
|
51
|
-
def test_au_gps_degree_tokyo
|
52
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
53
|
-
{"QUERY_STRING"=>"ver=1&datum=1&unit=1&lat=%2b43.07475&lon=%2b141.34259&alt=8&time=20061017182825&smaj=113&smin=76&vert=72&majaa=108&fm=1"})
|
54
|
-
reqs.each do |req|
|
55
|
-
assert_in_delta(43.07719289, req.mobile.position.lat, 1e-4)
|
56
|
-
assert_in_delta(141.3389013, req.mobile.position.lon, 1e-4)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# au, gps, dms, tokyo
|
61
|
-
def test_au_gps_dms_tokyo
|
62
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
63
|
-
{"QUERY_STRING"=>"ver=1&datum=1&unit=0&lat=%2b43.04.28.26&lon=%2b141.20.33.15&alt=-5&time=20061017183807&smaj=52&smin=36&vert=31&majaa=101&fm=1"})
|
64
|
-
reqs.each do |req|
|
65
|
-
assert_in_delta(43.07695833, req.mobile.position.lat, 1e-4)
|
66
|
-
assert_in_delta(141.3388528, req.mobile.position.lon, 1e-4)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# au, antenna, dms (au簡易位置情報)
|
71
|
-
def test_au_antenna
|
72
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
73
|
-
{"QUERY_STRING"=>"datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75"})
|
74
|
-
reqs.each do |req|
|
75
|
-
assert_in_delta(43.08194444, req.mobile.position.lat, 1e-7)
|
76
|
-
assert_in_delta(141.3474306, req.mobile.position.lon, 1e-7)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
81
|
-
def test_au_valid_ip_address
|
82
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
83
|
-
{"REMOTE_ADDR"=>"210.230.128.225"})
|
84
|
-
reqs.each do |req|
|
85
|
-
assert_equal(req.mobile.valid_ip?, true)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
90
|
-
def test_au_invalid_ip_address
|
91
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
92
|
-
{"REMOTE_ADDR"=>"127.0.0.1"})
|
93
|
-
reqs.each do |req|
|
94
|
-
assert_equal(req.mobile.valid_ip?, false)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# 端末の画面サイズを正しく取得できるか。
|
99
|
-
def test_au_w41ca_display
|
100
|
-
reqs = request_with_ua("KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0",
|
101
|
-
"HTTP_X_UP_DEVCAP_SCREENDEPTH"=>"16,RGB565",
|
102
|
-
"HTTP_X_UP_DEVCAP_SCREENPIXELS"=>"240,346",
|
103
|
-
"HTTP_X_UP_DEVCAP_ISCOLOR"=>"1"
|
104
|
-
)
|
105
|
-
|
106
|
-
reqs.each do |req|
|
107
|
-
assert_equal(240, req.mobile.display.width)
|
108
|
-
assert_equal(346, req.mobile.display.height)
|
109
|
-
assert_equal(true, req.mobile.display.color?)
|
110
|
-
assert_equal(65536, req.mobile.display.colors)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# 端末の画面情報が渡ってない場合に正しく動作するか。
|
115
|
-
def test_au_w41ca_display_information_omitted
|
116
|
-
reqs = request_with_ua("KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0")
|
117
|
-
reqs.each do |req|
|
118
|
-
assert_equal(nil, req.mobile.display.width)
|
119
|
-
assert_equal(nil, req.mobile.display.height)
|
120
|
-
assert_equal(nil, req.mobile.display.browser_width)
|
121
|
-
assert_equal(nil, req.mobile.display.browser_height)
|
122
|
-
assert_equal(nil, req.mobile.display.physical_width)
|
123
|
-
assert_equal(nil, req.mobile.display.physical_height)
|
124
|
-
assert_equal(nil, req.mobile.display.color?)
|
125
|
-
assert_equal(nil, req.mobile.display.colors)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# for GeoKit::Mappable
|
130
|
-
def test_au_gps_degree_geokit
|
131
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
|
132
|
-
{"QUERY_STRING"=>"ver=1&datum=0&unit=1&lat=%2b43.07772&lon=%2b141.34114&alt=64&time=20061016192415&smaj=69&smin=18&vert=21&majaa=115&fm=1"})
|
133
|
-
reqs.each do |req|
|
134
|
-
assert_equal(43.07772, req.mobile.position.lat)
|
135
|
-
assert_equal(141.34114, req.mobile.position.lng)
|
136
|
-
assert_equal("43.07772,141.34114", req.mobile.position.ll)
|
137
|
-
assert_equal(req.mobile.position, req.mobile.position)
|
138
|
-
if req.mobile.position.respond_to?(:distance_to) # GeoKitがインストールされている場合
|
139
|
-
assert_equal(0, req.mobile.position.distance_to(req.mobile.position))
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
# 位置情報取得機能の有無, W31CA
|
145
|
-
def test_au_location_capability_w31ca
|
146
|
-
reqs = request_with_ua("KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0")
|
147
|
-
reqs.each do |req|
|
148
|
-
assert_equal("CA32", req.mobile.device_id)
|
149
|
-
assert_equal(true, req.mobile.supports_location?)
|
150
|
-
assert_equal(true, req.mobile.supports_gps?)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# 位置情報取得機能の有無, A1402S
|
155
|
-
def test_au_location_capability_a1402s
|
156
|
-
reqs = request_with_ua("KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0")
|
157
|
-
reqs.each do |req|
|
158
|
-
assert_equal("SN26", req.mobile.device_id)
|
159
|
-
assert_equal(true, req.mobile.supports_location?)
|
160
|
-
assert_equal(false, req.mobile.supports_gps?)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# 位置情報取得機能の有無, TK22
|
165
|
-
def test_au_location_capability_tk22
|
166
|
-
reqs = request_with_ua("UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
|
167
|
-
reqs.each do |req|
|
168
|
-
assert_equal("KCTA", req.mobile.device_id)
|
169
|
-
assert_equal(false, req.mobile.supports_location?)
|
170
|
-
assert_equal(false, req.mobile.supports_gps?)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
data/test/legacy/docomo_test.rb
DELETED
@@ -1,187 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require File.dirname(__FILE__)+'/helper'
|
3
|
-
|
4
|
-
class DocomoTest < Test::Unit::TestCase
|
5
|
-
# DoCoMo, 端末種別の識別
|
6
|
-
def test_docomo_sh902i
|
7
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
8
|
-
reqs.each do |req|
|
9
|
-
assert_equal(true, req.mobile?)
|
10
|
-
assert_instance_of(Jpmobile::Mobile::Docomo, req.mobile)
|
11
|
-
assert_equal(nil, req.mobile.position)
|
12
|
-
assert_equal(nil, req.mobile.areacode)
|
13
|
-
assert_equal(nil, req.mobile.serial_number)
|
14
|
-
assert_equal(nil, req.mobile.icc)
|
15
|
-
assert_equal(nil, req.mobile.ident)
|
16
|
-
assert_equal(nil, req.mobile.ident_device)
|
17
|
-
assert_equal(nil, req.mobile.ident_subscriber)
|
18
|
-
assert(!req.mobile.supports_cookie?)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
# DoCoMo, 端末種別の識別
|
23
|
-
def test_docomo_so506i
|
24
|
-
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10")
|
25
|
-
reqs.each do |req|
|
26
|
-
assert_equal(true, req.mobile?)
|
27
|
-
assert_instance_of(Jpmobile::Mobile::Docomo, req.mobile)
|
28
|
-
assert_equal(nil, req.mobile.position)
|
29
|
-
assert_equal(nil, req.mobile.areacode)
|
30
|
-
assert_equal(nil, req.mobile.serial_number)
|
31
|
-
assert_equal(nil, req.mobile.icc)
|
32
|
-
assert_equal(nil, req.mobile.ident)
|
33
|
-
assert_equal(nil, req.mobile.ident_device)
|
34
|
-
assert_equal(nil, req.mobile.ident_subscriber)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# DoCoMo, iarea
|
39
|
-
def test_docomo_iarea
|
40
|
-
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10",
|
41
|
-
{"QUERY_STRING"=>"AREACODE=00100&ACTN=OK"})
|
42
|
-
reqs.each do |req|
|
43
|
-
assert_equal("00100", req.mobile.areacode)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# DoCoMo, iarea
|
48
|
-
def test_docomo_iarea_with_posinfo
|
49
|
-
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10",
|
50
|
-
{"QUERY_STRING"=>"LAT=%2B35.00.35.600&LON=%2B135.41.35.600&GEO=wgs84&POSINFO=2&AREACODE=00100&ACTN=OK"})
|
51
|
-
reqs.each do |req|
|
52
|
-
assert_equal("00100", req.mobile.areacode)
|
53
|
-
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
54
|
-
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# DoCoMo, gps
|
59
|
-
# http://www.nttdocomo.co.jp/service/imode/make/content/html/outline/gps.html
|
60
|
-
def test_docomo_gps_sa702i
|
61
|
-
reqs = request_with_ua("DoCoMo/2.0 SA702i(c100;TB;W30H15)",
|
62
|
-
{"QUERY_STRING"=>"lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=wgs84&x-acc=3"})
|
63
|
-
reqs.each do |req|
|
64
|
-
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
65
|
-
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# DoCoMo, 903i, GPS
|
70
|
-
# "WGS84"が大文字。altで高度が取得できているようだ。どちらも仕様書には記述がない。
|
71
|
-
# http://www.nttdocomo.co.jp/service/imode/make/content/html/outline/gps.html
|
72
|
-
def test_docomo_gps_sh903i
|
73
|
-
reqs = request_with_ua("DoCoMo/2.0 SH903i(c100;TB;W24H16)",
|
74
|
-
{"QUERY_STRING"=>
|
75
|
-
"lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=WGS84&alt=%2B64.000&x-acc=1"})
|
76
|
-
reqs.each do |req|
|
77
|
-
assert_in_delta(35.00988889, req.mobile.position.lat, 1e-7)
|
78
|
-
assert_in_delta(135.6932222, req.mobile.position.lon, 1e-7)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# DoCoMo, utn, mova
|
83
|
-
def test_docomo_utn_mova
|
84
|
-
reqs = request_with_ua("DoCoMo/1.0/SO505iS/c20/TC/W30H16/serXXXXX000000")
|
85
|
-
reqs.each do |req|
|
86
|
-
assert_equal("XXXXX000000", req.mobile.serial_number)
|
87
|
-
assert_equal("XXXXX000000", req.mobile.ident)
|
88
|
-
assert_equal(nil, req.mobile.icc)
|
89
|
-
assert_equal("XXXXX000000", req.mobile.ident_device)
|
90
|
-
assert_equal(nil, req.mobile.ident_subscriber)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# DoCoMo, utn, foma
|
95
|
-
def test_docomo_utn_foma
|
96
|
-
reqs = request_with_ua("DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)")
|
97
|
-
reqs.each do |req|
|
98
|
-
assert_equal("999999999999999", req.mobile.serial_number)
|
99
|
-
assert_equal("0000000000000000000f", req.mobile.icc)
|
100
|
-
assert_equal("0000000000000000000f", req.mobile.ident)
|
101
|
-
assert_equal("999999999999999", req.mobile.ident_device)
|
102
|
-
assert_equal("0000000000000000000f", req.mobile.ident_subscriber)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# 正しいIPアドレス空間からのアクセスを判断できるか。
|
107
|
-
def test_docomo_valid_ip_address
|
108
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)",
|
109
|
-
{"REMOTE_ADDR"=>"210.153.84.1"})
|
110
|
-
reqs.each do |req|
|
111
|
-
assert_equal(true, req.mobile.valid_ip?)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
# 正しくないIPアドレス空間からのアクセスを判断できるか。
|
116
|
-
def test_docomo_invalid_ip_address
|
117
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)",
|
118
|
-
{"REMOTE_ADDR"=>"127.0.0.1"})
|
119
|
-
reqs.each do |req|
|
120
|
-
assert_equal(false, req.mobile.valid_ip?)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
# 端末の画面サイズを正しく取得できるか。
|
125
|
-
def test_docomo_so506ic_display
|
126
|
-
reqs = request_with_ua("DoCoMo/1.0/SO506iC/c20/TB/W20H10")
|
127
|
-
reqs.each do |req|
|
128
|
-
assert_equal(240, req.mobile.display.browser_width)
|
129
|
-
assert_equal(256, req.mobile.display.browser_height)
|
130
|
-
assert_equal(240, req.mobile.display.width)
|
131
|
-
assert_equal(256, req.mobile.display.height)
|
132
|
-
assert_equal(true, req.mobile.display.color?)
|
133
|
-
assert_equal(262144, req.mobile.display.colors)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# 端末の画面サイズを正しく取得できるか。
|
138
|
-
def test_docomo_sh902i_display
|
139
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
140
|
-
reqs.each do |req|
|
141
|
-
assert_equal(240, req.mobile.display.browser_width)
|
142
|
-
assert_equal(240, req.mobile.display.browser_height)
|
143
|
-
assert_equal(240, req.mobile.display.width)
|
144
|
-
assert_equal(240, req.mobile.display.height)
|
145
|
-
assert_equal(true, req.mobile.display.color?)
|
146
|
-
assert_equal(262144, req.mobile.display.colors)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
# i-modeブラウザバージョン判定
|
151
|
-
def test_docomo_imode_browser_version
|
152
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
153
|
-
reqs << request_with_ua("DoCoMo/1.0/F505iGPS/c20/TB/W20H10")
|
154
|
-
reqs.flatten.each do |req|
|
155
|
-
assert_equal('1.0', req.mobile.imode_browser_version)
|
156
|
-
end
|
157
|
-
|
158
|
-
reqs = request_with_ua("DoCoMo/2.0 P09A3(c500;TB;W20H12)")
|
159
|
-
reqs << request_with_ua("DoCoMo/2.0 P07A3(c500;TB;W24H15)")
|
160
|
-
reqs.flatten.each do |req|
|
161
|
-
assert_equal('2.0', req.mobile.imode_browser_version)
|
162
|
-
end
|
163
|
-
|
164
|
-
reqs = request_with_ua("DoCoMo/2.0 L01B(c500;TB;W40H10)")
|
165
|
-
reqs.flatten.each do |req|
|
166
|
-
assert_equal('2.0LE', req.mobile.imode_browser_version)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
# cookie support
|
171
|
-
def test_docomo_imode_browser_version
|
172
|
-
# i-modeブラウザ1.0 == false
|
173
|
-
reqs = request_with_ua("DoCoMo/2.0 SH902i(c100;TB;W24H12)")
|
174
|
-
reqs << request_with_ua("DoCoMo/1.0/F505iGPS/c20/TB/W20H10")
|
175
|
-
reqs.flatten.each do |req|
|
176
|
-
assert(!req.mobile.supports_cookie?)
|
177
|
-
end
|
178
|
-
|
179
|
-
# i-modeブラウザ2.0 & 2.0LE == true
|
180
|
-
reqs = request_with_ua("DoCoMo/2.0 P09A3(c500;TB;W20H12)")
|
181
|
-
reqs << request_with_ua("DoCoMo/2.0 P07A3(c500;TB;W24H15)")
|
182
|
-
reqs << request_with_ua("DoCoMo/2.0 L01B(c500;TB;W40H10)")
|
183
|
-
reqs.flatten.each do |req|
|
184
|
-
assert(req.mobile.supports_cookie?)
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|