jpmobile 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -3
  3. data/.rubocop.yml +123 -0
  4. data/CONTRIBUTING.md +16 -14
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +198 -0
  7. data/README.md +409 -0
  8. data/Rakefile +9 -9
  9. data/circle.yml +14 -0
  10. data/jpmobile.gemspec +9 -10
  11. data/lib/jpmobile.rb +6 -5
  12. data/lib/jpmobile/datum_conv.rb +35 -35
  13. data/lib/jpmobile/docomo_guid.rb +7 -8
  14. data/lib/jpmobile/email.rb +12 -12
  15. data/lib/jpmobile/emoticon.rb +85 -76
  16. data/lib/jpmobile/emoticon/au.rb +1284 -1284
  17. data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
  18. data/lib/jpmobile/emoticon/docomo.rb +252 -252
  19. data/lib/jpmobile/emoticon/google.rb +9 -9
  20. data/lib/jpmobile/emoticon/softbank.rb +471 -471
  21. data/lib/jpmobile/emoticon/unicode.rb +9 -9
  22. data/lib/jpmobile/emoticon/z_combine.rb +20 -23
  23. data/lib/jpmobile/encoding.rb +1 -1
  24. data/lib/jpmobile/fallback_view_selector.rb +2 -3
  25. data/lib/jpmobile/filter.rb +44 -47
  26. data/lib/jpmobile/helpers.rb +38 -38
  27. data/lib/jpmobile/hook_action_view.rb +7 -7
  28. data/lib/jpmobile/hook_test_request.rb +0 -1
  29. data/lib/jpmobile/lookup_context.rb +1 -2
  30. data/lib/jpmobile/mail.rb +156 -134
  31. data/lib/jpmobile/mailer.rb +4 -4
  32. data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
  33. data/lib/jpmobile/mobile/android.rb +0 -1
  34. data/lib/jpmobile/mobile/android_tablet.rb +0 -1
  35. data/lib/jpmobile/mobile/au.rb +40 -28
  36. data/lib/jpmobile/mobile/black_berry.rb +0 -1
  37. data/lib/jpmobile/mobile/ddipocket.rb +1 -2
  38. data/lib/jpmobile/mobile/docomo.rb +47 -36
  39. data/lib/jpmobile/mobile/emobile.rb +1 -2
  40. data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
  41. data/lib/jpmobile/mobile/ipad.rb +0 -1
  42. data/lib/jpmobile/mobile/iphone.rb +0 -1
  43. data/lib/jpmobile/mobile/smart_phone.rb +0 -1
  44. data/lib/jpmobile/mobile/softbank.rb +24 -20
  45. data/lib/jpmobile/mobile/tablet.rb +0 -1
  46. data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
  47. data/lib/jpmobile/mobile/vodafone.rb +0 -1
  48. data/lib/jpmobile/mobile/willcom.rb +7 -7
  49. data/lib/jpmobile/mobile/windows_phone.rb +0 -1
  50. data/lib/jpmobile/path_set.rb +1 -1
  51. data/lib/jpmobile/position.rb +30 -14
  52. data/lib/jpmobile/rack/filter.rb +4 -4
  53. data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
  54. data/lib/jpmobile/rack/params_filter.rb +7 -6
  55. data/lib/jpmobile/rails.rb +3 -4
  56. data/lib/jpmobile/request_with_mobile.rb +9 -6
  57. data/lib/jpmobile/resolver.rb +23 -17
  58. data/lib/jpmobile/session/active_record_store.rb +7 -9
  59. data/lib/jpmobile/session/mem_cache_store.rb +7 -9
  60. data/lib/jpmobile/sinatra.rb +1 -1
  61. data/lib/jpmobile/trans_sid.rb +15 -20
  62. data/lib/jpmobile/util.rb +61 -77
  63. data/lib/jpmobile/version.rb +1 -1
  64. data/lib/tasks/jpmobile_tasks.rake +35 -28
  65. data/spec/rack/jpmobile/android_spec.rb +5 -5
  66. data/spec/rack/jpmobile/au_spec.rb +74 -59
  67. data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
  68. data/spec/rack/jpmobile/docomo_spec.rb +77 -64
  69. data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
  70. data/spec/rack/jpmobile/filter_spec.rb +149 -128
  71. data/spec/rack/jpmobile/iphone_spec.rb +9 -8
  72. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
  73. data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
  74. data/spec/rack/jpmobile/softbank_spec.rb +49 -42
  75. data/spec/rack/jpmobile/willcom_spec.rb +22 -18
  76. data/spec/rack/jpmobile/windows_phone.rb +5 -5
  77. data/spec/rack_helper.rb +9 -8
  78. data/spec/spec_helper.rb +5 -6
  79. data/spec/unit/decorated_mail_spec.rb +8 -9
  80. data/spec/unit/email_spec.rb +44 -44
  81. data/spec/unit/emoticon_spec.rb +57 -58
  82. data/spec/unit/encoding_spec.rb +35 -36
  83. data/spec/unit/is_carrier_spec.rb +49 -49
  84. data/spec/unit/mail_spec.rb +153 -143
  85. data/spec/unit/mobile/iphone_spec.rb +6 -7
  86. data/spec/unit/receive_mail_spec.rb +172 -173
  87. data/spec/unit/spec_helper.rb +6 -6
  88. data/spec/unit/util_spec.rb +125 -46
  89. data/spec/unit/valid_ip_spec.rb +35 -35
  90. data/spec/unit/variants_spec.rb +18 -19
  91. data/test/rails/overrides/Gemfile +54 -0
  92. data/test/rails/overrides/Gemfile.jpmobile +1 -2
  93. data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
  94. data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
  95. data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
  96. data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
  97. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  98. data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
  99. data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
  100. data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
  101. data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
  102. data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
  103. data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
  104. data/test/rails/overrides/autotest/discover.rb +2 -2
  105. data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
  106. data/test/rails/overrides/config/routes.rb +95 -2
  107. data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
  108. data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
  109. data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
  110. data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
  111. data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
  112. data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
  113. data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
  114. data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
  115. data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
  116. data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
  117. data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
  118. data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
  119. data/test/rails/overrides/spec/rails_helper.rb +1 -1
  120. data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
  121. data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
  122. data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
  123. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
  124. data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
  125. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
  126. data/test/sinatra/test/filter_test.rb +10 -11
  127. data/tools/e4u_conv.rb +0 -1
  128. metadata +18 -14
  129. data/README +0 -0
  130. data/README.rdoc +0 -308
@@ -1,33 +1,33 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
3
  describe Jpmobile::MobileCarrier do
5
4
  include Rack::Test::Methods
6
5
 
7
6
  [
8
- [ Jpmobile::Mobile::Docomo , 'DoCoMo/2.0 SH902i(c100;TB;W24H12)' ],
9
- [ Jpmobile::Mobile::Docomo , 'DoCoMo/1.0/SO506iC/c20/TB/W20H10' ],
10
- [ Jpmobile::Mobile::Docomo , 'DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)' ],
11
- [ Jpmobile::Mobile::Au , 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0' ],
12
- [ Jpmobile::Mobile::Au , 'UP.Browser/3.04-KCTA UP.Link/3.4.5.9' ],
13
- [ Jpmobile::Mobile::Softbank , 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1' ],
14
- [ Jpmobile::Mobile::Softbank , 'Semulator' ],
15
- [ 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' ],
16
- [ Jpmobile::Mobile::Willcom , 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0' ],
17
- [ Jpmobile::Mobile::Ddipocket , 'Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0'],
18
- [ Jpmobile::Mobile::Emobile , 'emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4' ],
19
- [ Jpmobile::Mobile::Iphone , 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16' ],
20
- [ Jpmobile::Mobile::Android , 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1' ],
21
- [ Jpmobile::Mobile::WindowsPhone , 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)' ],
22
- [ Jpmobile::Mobile::BlackBerry, 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220' ],
23
- [ Jpmobile::Mobile::Ipad , 'Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5'],
24
- [ Jpmobile::Mobile::AndroidTablet, 'Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'],
25
- [ Jpmobile::Mobile::AndroidTablet, 'Mozilla/5.0 (Linux; U; Android 3.2; ja-jp; Sony Tablet S Build/THMAS11002) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13'],
7
+ [Jpmobile::Mobile::Docomo, 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'],
8
+ [Jpmobile::Mobile::Docomo, 'DoCoMo/1.0/SO506iC/c20/TB/W20H10'],
9
+ [Jpmobile::Mobile::Docomo, 'DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)'],
10
+ [Jpmobile::Mobile::Au, 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'],
11
+ [Jpmobile::Mobile::Au, 'UP.Browser/3.04-KCTA UP.Link/3.4.5.9'],
12
+ [Jpmobile::Mobile::Softbank, 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'],
13
+ [Jpmobile::Mobile::Softbank, 'Semulator'],
14
+ [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'],
15
+ [Jpmobile::Mobile::Willcom, 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0'],
16
+ [Jpmobile::Mobile::Ddipocket, 'Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0'],
17
+ [Jpmobile::Mobile::Emobile, 'emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4'],
18
+ [Jpmobile::Mobile::Iphone, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'],
19
+ [Jpmobile::Mobile::Android, 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1'],
20
+ [Jpmobile::Mobile::WindowsPhone, 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'],
21
+ [Jpmobile::Mobile::BlackBerry, 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220'],
22
+ [Jpmobile::Mobile::Ipad, 'Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5'],
23
+ [Jpmobile::Mobile::AndroidTablet, 'Mozilla/5.0 (Linux; U; Android 2.2; ja-jp; SC-01C Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'],
24
+ [Jpmobile::Mobile::AndroidTablet, 'Mozilla/5.0 (Linux; U; Android 3.2; ja-jp; Sony Tablet S Build/THMAS11002) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13'],
26
25
  ].each do |carrier, user_agent|
27
26
  it "#mobile should return #{carrier} when take #{user_agent} as UserAgent" do
28
27
  res = Rack::MockRequest.env_for(
29
28
  'http://jpmobile-rails.org/',
30
- 'HTTP_USER_AGENT' => user_agent)
29
+ 'HTTP_USER_AGENT' => user_agent
30
+ )
31
31
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
32
32
  expect(env['rack.jpmobile'].class).to eq(carrier)
33
33
  end
@@ -36,7 +36,8 @@ describe Jpmobile::MobileCarrier do
36
36
  it "Googlebot のときは rack['rack.jpmobile.carrier'] が nil になること" do
37
37
  res = Rack::MockRequest.env_for(
38
38
  'http://jpmobile-rails.org/',
39
- 'HTTP_USER_AGENT' => 'Googlebot')
39
+ 'HTTP_USER_AGENT' => 'Googlebot'
40
+ )
40
41
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
41
42
  expect(env['rack.jpmobile']).to be_nil
42
43
  end
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
3
  describe Jpmobile::ParamsFilter do
@@ -6,36 +5,37 @@ describe Jpmobile::ParamsFilter do
6
5
  include Jpmobile::RackHelper
7
6
  include Jpmobile::Util
8
7
 
9
- context "漢字コード変換" do
8
+ context '漢字コード変換' do
10
9
  before(:each) do
11
10
  @query_params = {
12
- "hoge" => "ほげ",
13
- "パラメータ" => "テストです〜■",
11
+ 'hoge' => 'ほげ',
12
+ 'パラメータ' => 'テストです〜■',
14
13
  }
15
14
  @form_params = {
16
- "bar" => "万葉集",
17
- "アジャイル" => "僕の〜♪",
15
+ 'bar' => '万葉集',
16
+ 'アジャイル' => '僕の〜♪',
18
17
  }
19
18
  end
20
19
 
21
- context "Shift_JIS 変換の " do
20
+ context 'Shift_JIS 変換の ' do
22
21
  before(:each) do
23
- @query_string = @query_params.map {|k, v|
24
- "%s=%s" % [::Rack::Utils.escape(utf8_to_sjis(k)), ::Rack::Utils.escape(utf8_to_sjis(v))]
25
- }.join("&")
26
- @form_string = @form_params.map {|k, v|
27
- "%s=%s" % [utf8_to_sjis(k), utf8_to_sjis(v)]
28
- }.join("&")
22
+ @query_string = @query_params.map { |k, v|
23
+ '%s=%s' % [::Rack::Utils.escape(utf8_to_sjis(k)), ::Rack::Utils.escape(utf8_to_sjis(v))]
24
+ }.join('&')
25
+ @form_string = @form_params.map { |k, v|
26
+ '%s=%s' % [utf8_to_sjis(k), utf8_to_sjis(v)]
27
+ }.join('&')
29
28
  end
30
29
 
31
- context "docomo のとき" do
32
- it "Shift_JIS が UTF-8 に変換されること" do
30
+ context 'docomo のとき' do
31
+ it 'Shift_JIS が UTF-8 に変換されること' do
33
32
  res = Rack::MockRequest.env_for(
34
33
  "/?#{@query_string}",
35
- "REQUEST_METHOD" => "POST",
36
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
34
+ 'REQUEST_METHOD' => 'POST',
35
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
37
36
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
38
- :input => @form_string)
37
+ :input => @form_string
38
+ )
39
39
 
40
40
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
41
41
  req = Rack::Request.new(res[1])
@@ -49,14 +49,15 @@ describe Jpmobile::ParamsFilter do
49
49
  end
50
50
  end
51
51
 
52
- context "au のとき" do
53
- it "Shift_JIS が UTF-8 に変換されること" do
52
+ context 'au のとき' do
53
+ it 'Shift_JIS が UTF-8 に変換されること' do
54
54
  res = Rack::MockRequest.env_for(
55
55
  "/?#{@query_string}",
56
- "REQUEST_METHOD" => "POST",
57
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
58
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
59
- :input => @form_string)
56
+ 'REQUEST_METHOD' => 'POST',
57
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
58
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
59
+ :input => @form_string
60
+ )
60
61
 
61
62
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
62
63
  req = Rack::Request.new(res[1])
@@ -71,24 +72,25 @@ describe Jpmobile::ParamsFilter do
71
72
  end
72
73
  end
73
74
 
74
- context "UTF-8 の" do
75
+ context 'UTF-8 の' do
75
76
  before(:each) do
76
- @query_string = @query_params.map {|k, v|
77
- "%s=%s" % [::Rack::Utils.escape(k), ::Rack::Utils.escape(v)]
78
- }.join("&")
79
- @form_string = @form_params.map {|k, v|
80
- "%s=%s" % [k, v]
81
- }.join("&")
77
+ @query_string = @query_params.map { |k, v|
78
+ '%s=%s' % [::Rack::Utils.escape(k), ::Rack::Utils.escape(v)]
79
+ }.join('&')
80
+ @form_string = @form_params.map { |k, v|
81
+ '%s=%s' % [k, v]
82
+ }.join('&')
82
83
  end
83
84
 
84
- context "softbank のとき" do
85
- it "変換されないこと" do
85
+ context 'softbank のとき' do
86
+ it '変換されないこと' do
86
87
  res = Rack::MockRequest.env_for(
87
88
  "/?#{@query_string}",
88
- "REQUEST_METHOD" => "POST",
89
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
90
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
91
- :input => @form_string)
89
+ 'REQUEST_METHOD' => 'POST',
90
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
91
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
92
+ :input => @form_string
93
+ )
92
94
 
93
95
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
94
96
  req = Rack::Request.new(res[1])
@@ -104,131 +106,137 @@ describe Jpmobile::ParamsFilter do
104
106
  end
105
107
  end
106
108
 
107
- context "絵文字変換" do
108
- context "docomo の場合" do
109
- it "Shift_JIS 絵文字がUTF-8に変換されること" do
110
- query_string = "hoge=" + ::Rack::Utils.escape(sjis("\xf8\x9f"))
111
- form_string = "foo=" + sjis("\xf8\xa1")
109
+ context '絵文字変換' do
110
+ context 'docomo の場合' do
111
+ it 'Shift_JIS 絵文字がUTF-8に変換されること' do
112
+ query_string = 'hoge=' + ::Rack::Utils.escape(sjis("\xf8\x9f"))
113
+ form_string = 'foo=' + sjis("\xf8\xa1")
112
114
 
113
115
  res = Rack::MockRequest.env_for(
114
116
  "/?#{query_string}",
115
- "REQUEST_METHOD" => "POST",
116
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
117
+ 'REQUEST_METHOD' => 'POST',
118
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
117
119
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)',
118
- :input => form_string)
120
+ :input => form_string
121
+ )
119
122
 
120
123
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
121
124
  req = Rack::Request.new(res[1])
122
125
  expect(req.params.size).to eq(2)
123
126
 
124
- expect(req.params["hoge"]).to eq("\356\230\276")
125
- expect(req.params["foo"]).to eq("\356\231\200")
127
+ expect(req.params['hoge']).to eq("\356\230\276")
128
+ expect(req.params['foo']).to eq("\356\231\200")
126
129
  end
127
130
  end
128
131
 
129
- context "au の場合" do
130
- it "Shift_JIS 絵文字がUTF-8に変換されること" do
131
- query_string = "hoge=" + ::Rack::Utils.escape(sjis("\xf6\x59"))
132
- form_string = "foo=" + sjis("\xf6\xfb")
132
+ context 'au の場合' do
133
+ it 'Shift_JIS 絵文字がUTF-8に変換されること' do
134
+ query_string = 'hoge=' + ::Rack::Utils.escape(sjis("\xf6\x59"))
135
+ form_string = 'foo=' + sjis("\xf6\xfb")
133
136
 
134
137
  res = Rack::MockRequest.env_for(
135
138
  "/?#{query_string}",
136
- "REQUEST_METHOD" => "POST",
137
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
138
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
139
- :input => form_string)
139
+ 'REQUEST_METHOD' => 'POST',
140
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
141
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
142
+ :input => form_string
143
+ )
140
144
 
141
145
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
142
146
  req = Rack::Request.new(res[1])
143
147
  expect(req.params.size).to eq(2)
144
148
 
145
- expect(req.params["hoge"]).to eq("\356\222\201")
146
- expect(req.params["foo"]).to eq("\356\224\242")
149
+ expect(req.params['hoge']).to eq("\356\222\201")
150
+ expect(req.params['foo']).to eq("\356\224\242")
147
151
  end
148
152
  end
149
153
 
150
- context "Softbank の場合" do
151
- it "UTF-8 絵文字がUTF-8に変換されること" do
152
- query_string = ascii_8bit("hoge=" + ::Rack::Utils.escape([0xe001].pack('U')))
153
- form_string = ascii_8bit("foo=" + [0xe21c].pack('U'))
154
+ context 'Softbank の場合' do
155
+ it 'UTF-8 絵文字がUTF-8に変換されること' do
156
+ query_string = ascii_8bit('hoge=' + ::Rack::Utils.escape([0xe001].pack('U')))
157
+ form_string = ascii_8bit('foo=' + [0xe21c].pack('U'))
154
158
 
155
159
  res = Rack::MockRequest.env_for(
156
160
  "/?#{query_string}",
157
- "REQUEST_METHOD" => "POST",
158
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
159
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
160
- :input => form_string)
161
+ 'REQUEST_METHOD' => 'POST',
162
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
163
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
164
+ :input => form_string
165
+ )
161
166
 
162
167
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
163
168
  req = Rack::Request.new(res[1])
164
169
  expect(req.params.size).to eq(2)
165
170
 
166
- expect(req.params["hoge"]).to eq("\xef\x80\x81")
167
- expect(req.params["foo"]).to eq("\xef\x88\x9c")
171
+ expect(req.params['hoge']).to eq("\xef\x80\x81")
172
+ expect(req.params['foo']).to eq("\xef\x88\x9c")
168
173
  end
169
174
  end
170
175
  end
171
176
 
172
- context "パラメータの変換で" do
173
- context "値として" do
174
- it "+ が入ってるものが正確に取得できること(token)" do
175
- token = "lm/3Pu6RrY+kp8hsnEWp2xygYLInZIxwsB3UWeksaHQ="
176
- form_string = ascii_8bit("foo=#{::Rack::Utils.escape(token)}")
177
+ context 'パラメータの変換で' do
178
+ context '値として' do
179
+ it '+ が入ってるものが正確に取得できること(token)' do
180
+ token = 'lm/3Pu6RrY+kp8hsnEWp2xygYLInZIxwsB3UWeksaHQ='
181
+ form_string = ascii_8bit("foo=#{::Rack::Utils.escape(token)}")
177
182
 
178
183
  res = Rack::MockRequest.env_for(
179
- "/",
180
- "REQUEST_METHOD" => "POST",
181
- "CONTENT_TYPE" => 'application/x-www-form-urlencoded',
182
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
183
- :input => form_string)
184
+ '/',
185
+ 'REQUEST_METHOD' => 'POST',
186
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
187
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
188
+ :input => form_string
189
+ )
184
190
 
185
191
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
186
192
  req = Rack::Request.new(res[1])
187
193
  expect(req.params.size).to eq(1)
188
194
 
189
- expect(req.params["foo"]).to eq(ascii_8bit(token))
195
+ expect(req.params['foo']).to eq(ascii_8bit(token))
190
196
  end
191
197
  end
192
198
  end
193
199
 
194
- context "CONTENT_TYPEに" do
195
- context "application/jsonが含まれる場合" do
196
- it "inputが変換されないこと" do
200
+ context 'CONTENT_TYPEに' do
201
+ context 'application/jsonが含まれる場合' do
202
+ it 'inputが変換されないこと' do
197
203
  form_string = '{"index":"1"}'
198
204
 
199
205
  res = Rack::MockRequest.env_for(
200
- "/",
201
- "REQUEST_METHOD" => "POST",
202
- "CONTENT_TYPE" => 'application/json',
203
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
204
- :input => form_string)
206
+ '/',
207
+ 'REQUEST_METHOD' => 'POST',
208
+ 'CONTENT_TYPE' => 'application/json',
209
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
210
+ :input => form_string
211
+ )
205
212
 
206
213
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
207
214
  req = Rack::Request.new(res[1])
208
215
  expect(req.params.size).to eq(0)
209
216
 
210
- expect(req.body.read).to eq(form_string)
217
+ expect(req.body.read).to eq(form_string)
211
218
  end
212
219
  end
213
220
  end
214
221
 
215
- context "CONTENT_TYPEに" do
216
- context "application/xmlが含まれる場合" do
217
- it "inputが変換されないこと" do
222
+ context 'CONTENT_TYPEに' do
223
+ context 'application/xmlが含まれる場合' do
224
+ it 'inputが変換されないこと' do
218
225
  form_string = '<?xml version="1.0"?><value><string>hoge</string></value>'
219
226
 
220
227
  res = Rack::MockRequest.env_for(
221
- "/",
222
- "REQUEST_METHOD" => "POST",
223
- "CONTENT_TYPE" => 'application/xml',
224
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
225
- :input => form_string)
228
+ '/',
229
+ 'REQUEST_METHOD' => 'POST',
230
+ 'CONTENT_TYPE' => 'application/xml',
231
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
232
+ :input => form_string
233
+ )
226
234
 
227
235
  res = Jpmobile::MobileCarrier.new(Jpmobile::ParamsFilter.new(UnitApplication.new)).call(res)
228
236
  req = Rack::Request.new(res[1])
229
237
  expect(req.params.size).to eq(0)
230
238
 
231
- expect(req.body.read).to eq(form_string)
239
+ expect(req.body.read).to eq(form_string)
232
240
  end
233
241
  end
234
242
  end
@@ -1,99 +1,105 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "softbank" do
3
+ describe Jpmobile::MobileCarrier, 'softbank' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "910T を判別できること" do
6
+ context '端末種別で' do
7
+ it '910T を判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1")
10
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'
11
+ )
12
12
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
13
13
 
14
- expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Softbank)
14
+ expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Softbank)
15
15
  expect(env['rack.jpmobile'].position).to be_nil
16
- expect(env['rack.jpmobile'].serial_number).to eq("000000000000000")
17
- expect(env['rack.jpmobile'].ident).to eq("000000000000000")
18
- expect(env['rack.jpmobile'].ident_device).to eq("000000000000000")
16
+ expect(env['rack.jpmobile'].serial_number).to eq('000000000000000')
17
+ expect(env['rack.jpmobile'].ident).to eq('000000000000000')
18
+ expect(env['rack.jpmobile'].ident_device).to eq('000000000000000')
19
19
  expect(env['rack.jpmobile'].ident_subscriber).to be_nil
20
20
  expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
21
21
  expect(env['rack.jpmobile'].smart_phone?).to be_falsey
22
22
  end
23
23
 
24
- it "X_JPHONE_UID 付きの 910T を判別できること" do
24
+ it 'X_JPHONE_UID 付きの 910T を判別できること' do
25
25
  res = Rack::MockRequest.env_for(
26
26
  'http://jpmobile-rails.org/',
27
- 'HTTP_USER_AGENT' => "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1",
28
- "HTTP_X_JPHONE_UID" => "aaaaaaaaaaaaaaaa")
27
+ 'HTTP_USER_AGENT' => 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1',
28
+ 'HTTP_X_JPHONE_UID' => 'aaaaaaaaaaaaaaaa'
29
+ )
29
30
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
30
31
 
31
- expect(env['rack.jpmobile'].serial_number).to eq("000000000000000")
32
- expect(env['rack.jpmobile'].x_jphone_uid).to eq("aaaaaaaaaaaaaaaa")
33
- expect(env['rack.jpmobile'].ident).to eq("aaaaaaaaaaaaaaaa")
34
- expect(env['rack.jpmobile'].ident_device).to eq("000000000000000")
35
- expect(env['rack.jpmobile'].ident_subscriber).to eq("aaaaaaaaaaaaaaaa")
32
+ expect(env['rack.jpmobile'].serial_number).to eq('000000000000000')
33
+ expect(env['rack.jpmobile'].x_jphone_uid).to eq('aaaaaaaaaaaaaaaa')
34
+ expect(env['rack.jpmobile'].ident).to eq('aaaaaaaaaaaaaaaa')
35
+ expect(env['rack.jpmobile'].ident_device).to eq('000000000000000')
36
+ expect(env['rack.jpmobile'].ident_subscriber).to eq('aaaaaaaaaaaaaaaa')
36
37
  expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
37
38
  end
38
39
 
39
- it "V903T を判別できること" do
40
+ it 'V903T を判別できること' do
40
41
  res = Rack::MockRequest.env_for(
41
42
  'http://jpmobile-rails.org/',
42
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
43
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0'
44
+ )
43
45
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
44
46
 
45
- expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Vodafone)
47
+ expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Vodafone)
46
48
  expect(env['rack.jpmobile'].position).to be_nil
47
49
  expect(env['rack.jpmobile'].ident).to be_nil
48
50
  expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
49
51
  end
50
52
  end
51
53
 
52
- context "GPS で" do
53
- it "位置情報が取得できること" do
54
+ context 'GPS で' do
55
+ it '位置情報が取得できること' do
54
56
  res = Rack::MockRequest.env_for(
55
57
  'http://jpmobile-rails.org/',
56
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
57
- "QUERY_STRING" => "pos=N43.3.18.42E141.21.1.88&geo=wgs84&x-acr=1")
58
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0',
59
+ 'QUERY_STRING' => 'pos=N43.3.18.42E141.21.1.88&geo=wgs84&x-acr=1'
60
+ )
58
61
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
59
62
 
60
63
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(43.05511667)
61
64
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(141.3505222)
62
- expect(env['rack.jpmobile'].position.options['pos']).to eq("N43.3.18.42E141.21.1.88")
63
- expect(env['rack.jpmobile'].position.options['geo']).to eq("wgs84")
64
- expect(env['rack.jpmobile'].position.options['x-acr']).to eq("1")
65
+ expect(env['rack.jpmobile'].position.options['pos']).to eq('N43.3.18.42E141.21.1.88')
66
+ expect(env['rack.jpmobile'].position.options['geo']).to eq('wgs84')
67
+ expect(env['rack.jpmobile'].position.options['x-acr']).to eq('1')
65
68
  end
66
69
  end
67
70
 
68
- context "IPアドレス制限で" do
69
- it "正しいIPアドレス空間からのアクセスを判断できること" do
71
+ context 'IPアドレス制限で' do
72
+ it '正しいIPアドレス空間からのアクセスを判断できること' do
70
73
  res = Rack::MockRequest.env_for(
71
74
  'http://jpmobile-rails.org/',
72
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
73
- "REMOTE_ADDR"=>"210.146.7.199")
75
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0',
76
+ 'REMOTE_ADDR' => '210.146.7.199'
77
+ )
74
78
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
75
79
 
76
80
  expect(env['rack.jpmobile'].valid_ip?).to be_truthy
77
81
  end
78
82
 
79
- it "正しくないIPアドレス空間からのアクセスを判断できること" do
83
+ it '正しくないIPアドレス空間からのアクセスを判断できること' do
80
84
  res = Rack::MockRequest.env_for(
81
85
  'http://jpmobile-rails.org/',
82
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
83
- "REMOTE_ADDR"=>"127.0.0.1")
86
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0',
87
+ 'REMOTE_ADDR' => '127.0.0.1'
88
+ )
84
89
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
85
90
 
86
91
  expect(env['rack.jpmobile'].valid_ip?).to be_falsey
87
92
  end
88
93
  end
89
94
 
90
- context "画面情報で" do
91
- it "端末の画面サイズを正しく取得できること" do
95
+ context '画面情報で' do
96
+ it '端末の画面サイズを正しく取得できること' do
92
97
  res = Rack::MockRequest.env_for(
93
98
  'http://jpmobile-rails.org/',
94
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
95
- "HTTP_X_JPHONE_DISPLAY"=>"240*320",
96
- "HTTP_X_JPHONE_COLOR"=>"C262144")
99
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0',
100
+ 'HTTP_X_JPHONE_DISPLAY' => '240*320',
101
+ 'HTTP_X_JPHONE_COLOR' => 'C262144'
102
+ )
97
103
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
98
104
 
99
105
  expect(env['rack.jpmobile'].display.width).to eq(240)
@@ -101,13 +107,14 @@ describe Jpmobile::MobileCarrier, "softbank" do
101
107
  expect(env['rack.jpmobile'].display.physical_width).to eq(240)
102
108
  expect(env['rack.jpmobile'].display.physical_height).to eq(320)
103
109
  expect(env['rack.jpmobile'].display.color?).to be_truthy
104
- expect(env['rack.jpmobile'].display.colors).to eq(262144)
110
+ expect(env['rack.jpmobile'].display.colors).to eq(262144)
105
111
  end
106
112
 
107
- it "端末の画面情報が渡ってない場合に正しく動作すること" do
113
+ it '端末の画面情報が渡ってない場合に正しく動作すること' do
108
114
  res = Rack::MockRequest.env_for(
109
115
  'http://jpmobile-rails.org/',
110
- 'HTTP_USER_AGENT' => "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0")
116
+ 'HTTP_USER_AGENT' => 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0'
117
+ )
111
118
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
112
119
 
113
120
  expect(env['rack.jpmobile'].display.width).to be_nil