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,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = "5.0.0"
2
+ VERSION = '5.0.1'.freeze
3
3
  end
@@ -19,30 +19,28 @@ begin
19
19
  end
20
20
  end
21
21
  rescue LoadError
22
- warn "RSpec is not installed. Some tasks were skipped. please install rspec"
22
+ warn 'RSpec is not installed. Some tasks were skipped. please install rspec'
23
23
  end
24
24
 
25
25
  namespace :test do
26
- desc "Generate rails app and run jpmobile tests in the app"
27
- task :rails, [:skip] do |t, args|
28
- rails_root = "test/rails/rails_root"
29
- relative_root = "../../../"
26
+ desc 'Generate rails app and run jpmobile tests in the app'
27
+ task :rails, [:skip] do |_, args|
28
+ rails_root = 'test/rails/rails_root'
30
29
 
31
- puts "Running tests in Rails"
32
- skip = args.skip == "true"
30
+ puts 'Running tests in Rails'
31
+ skip = args.skip == 'true'
33
32
 
34
33
  unless skip
35
34
  # generate rails app
36
- FileUtils.rm_rf("Gemfile.lock")
37
35
  FileUtils.rm_rf(rails_root)
38
36
  FileUtils.mkdir_p(rails_root)
39
- `rails new #{rails_root} --skip-bundle`
37
+ `rails _5.0.3_ new #{rails_root} --skip-bundle`
40
38
  end
41
39
 
42
40
  # setup jpmobile
43
41
  plugin_path = File.join(rails_root, 'vendor', 'jpmobile')
44
42
  FileUtils.mkdir_p(plugin_path)
45
- FileList["*"].exclude("test").exclude("spec").exclude('vendor').each do |file|
43
+ FileList['*'].exclude('test').exclude('spec').exclude('vendor').each do |file|
46
44
  FileUtils.cp_r(file, plugin_path)
47
45
  end
48
46
 
@@ -50,37 +48,37 @@ namespace :test do
50
48
  begin
51
49
  plugin_path = File.join(rails_root, 'vendor', 'jpmobile-ipaddresses')
52
50
  FileUtils.mkdir_p(plugin_path)
53
- FileList["vendor/jpmobile-ipaddresses/*"].exclude("test").each do |file|
51
+ FileList['vendor/jpmobile-ipaddresses/*'].exclude('test').each do |file|
54
52
  FileUtils.cp_r(file, plugin_path)
55
53
  end
56
54
  rescue LoadError
57
- puts "IP Address test requires jpmobile-ipaddresses module"
55
+ puts 'IP Address test requires jpmobile-ipaddresses module'
58
56
  end
59
57
 
60
58
  # setup jpmobile-terminfo
61
59
  begin
62
60
  plugin_path = File.join(rails_root, 'vendor', 'jpmobile-terminfo')
63
61
  FileUtils.mkdir_p(plugin_path)
64
- FileList["vendor/jpmobile-terminfo/*"].exclude("test").each do |file|
62
+ FileList['vendor/jpmobile-terminfo/*'].exclude('test').each do |file|
65
63
  FileUtils.cp_r(file, plugin_path)
66
64
  end
67
65
  rescue LoadError
68
- puts "Terminal display information test requires jpmobile-terminfo module"
66
+ puts 'Terminal display information test requires jpmobile-terminfo module'
69
67
  end
70
68
 
71
69
  # setup activerecord-session_store
72
70
  begin
73
71
  plugin_path = File.join(rails_root, 'vendor', 'activerecord-session_store')
74
72
  FileUtils.mkdir_p(plugin_path)
75
- FileList["../activerecord-session_store/*"].exclude("test").each do |file|
73
+ FileList['../activerecord-session_store/*'].exclude('test').each do |file|
76
74
  FileUtils.cp_r(file, plugin_path)
77
75
  end
78
76
  rescue LoadError
79
- puts "Terminal display information test requires jpmobile-terminfo module"
77
+ puts 'Terminal display information test requires jpmobile-terminfo module'
80
78
  end
81
79
 
82
80
  # setup tests
83
- FileList["test/rails/overrides/*"].each do |file|
81
+ FileList['test/rails/overrides/*'].each do |file|
84
82
  FileUtils.cp_r(file, rails_root)
85
83
  end
86
84
 
@@ -88,9 +86,9 @@ namespace :test do
88
86
  # for cookie_only option
89
87
  config_path = File.join(rails_root, 'config', 'initializers', 'session_store.rb')
90
88
  File.open(config_path, 'w') do |file|
91
- file.write <<-END
92
- Rails.application.config.session_store :active_record_store, :key => '_session_id'
93
- Rails.application.config.session_options = {:cookie_only => false}
89
+ file.write <<~END
90
+ Rails.application.config.session_store :active_record_store, :key => '_session_id'
91
+ Rails.application.config.session_options = {:cookie_only => false}
94
92
  END
95
93
  end
96
94
  end
@@ -99,20 +97,29 @@ END
99
97
  # add gems for jpmobile spec
100
98
  config_path = File.join(rails_root, 'Gemfile')
101
99
  File.open(config_path, 'a+') do |file|
102
- file.write <<-END
103
- instance_eval File.read(File.expand_path(__FILE__) + '.jpmobile')
100
+ file.write <<~END
101
+ instance_eval File.read(File.expand_path(__FILE__) + '.jpmobile')
104
102
  END
105
103
  end
106
104
  end
107
105
 
108
106
  # run tests in rails
109
- cd rails_root
110
- ruby "-S bundle install"
111
- ruby "-S rails db:migrate RAILS_ENV=test" unless skip
112
- ruby "-S rails spec"
113
- # ruby "-S rspec -b --color spec/features/filter_spec.rb"
107
+ Dir.chdir(rails_root) do
108
+ Bundler.with_clean_env do
109
+ original_env = ENV.to_hash
110
+
111
+ ENV.update('RBENV_VERSION' => nil)
112
+ ENV.update('RBENV_DIR' => nil)
113
+
114
+ system 'bundle install'
115
+ system 'bin/rails db:migrate RAILS_ENV=test' unless skip
116
+ system 'bin/rails spec'
117
+
118
+ ENV.replace(original_env)
119
+ end
120
+ end
114
121
  end
115
- desc "Run sinatra on jpmobile tests"
122
+ desc 'Run sinatra on jpmobile tests'
116
123
  Rake::TestTask.new(:sinatra) do |t|
117
124
  t.libs << 'lib'
118
125
  t.libs << 'test/sinatra'
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "android" do
3
+ describe Jpmobile::MobileCarrier, 'android' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "Android を判別できること" do
6
+ context '端末種別で' do
7
+ it 'Android を判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => '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')
10
+ 'HTTP_USER_AGENT' => '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'
11
+ )
12
12
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
13
13
 
14
14
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Android)
@@ -1,184 +1,198 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "au" do
3
+ describe Jpmobile::MobileCarrier, 'au' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "KDDI-CA32 で判別できること" do
6
+ context '端末種別で' do
7
+ it 'KDDI-CA32 で判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
12
- "HTTP_X_UP_SUBNO" => "00000000000000_mj.ezweb.ne.jp")
10
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
11
+ 'HTTP_X_UP_SUBNO' => '00000000000000_mj.ezweb.ne.jp'
12
+ )
13
13
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
14
14
 
15
15
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Au)
16
- expect(env['rack.jpmobile'].subno).to eq("00000000000000_mj.ezweb.ne.jp")
17
- expect(env['rack.jpmobile'].ident).to eq("00000000000000_mj.ezweb.ne.jp")
18
- expect(env['rack.jpmobile'].ident_subscriber).to eq("00000000000000_mj.ezweb.ne.jp")
16
+ expect(env['rack.jpmobile'].subno).to eq('00000000000000_mj.ezweb.ne.jp')
17
+ expect(env['rack.jpmobile'].ident).to eq('00000000000000_mj.ezweb.ne.jp')
18
+ expect(env['rack.jpmobile'].ident_subscriber).to eq('00000000000000_mj.ezweb.ne.jp')
19
19
 
20
20
  expect(env['rack.jpmobile'].position).to be_nil
21
21
  expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
22
22
  end
23
23
 
24
- it "TK22 で判別できること" do
24
+ it 'TK22 で判別できること' do
25
25
  res = Rack::MockRequest.env_for(
26
26
  'http://jpmobile-rails.org/',
27
- 'HTTP_USER_AGENT' => "UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
27
+ 'HTTP_USER_AGENT' => 'UP.Browser/3.04-KCTA UP.Link/3.4.5.9'
28
+ )
28
29
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
29
30
 
30
31
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Au)
31
32
  end
32
33
  end
33
34
 
34
- context "GPS で" do
35
- it "緯度経度を取得できること(dgree)" do
35
+ context 'GPS で' do
36
+ it '緯度経度を取得できること(dgree)' do
36
37
  res = Rack::MockRequest.env_for(
37
38
  'http://jpmobile-rails.org/',
38
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
39
- "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")
39
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
40
+ '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'
41
+ )
40
42
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
41
43
 
42
44
  expect(env['rack.jpmobile'].position.lat).to eq(43.07772)
43
45
  expect(env['rack.jpmobile'].position.lon).to eq(141.34114)
44
46
  end
45
47
 
46
- it "緯度経度を取得できること(dms)" do
48
+ it '緯度経度を取得できること(dms)' do
47
49
  res = Rack::MockRequest.env_for(
48
50
  'http://jpmobile-rails.org/',
49
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
50
- "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")
51
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
52
+ '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'
53
+ )
51
54
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
52
55
 
53
56
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(43.08581944)
54
57
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(141.3405528)
55
58
  end
56
59
 
57
- it "緯度経度を取得できること(dgree_tokyo)" do
60
+ it '緯度経度を取得できること(dgree_tokyo)' do
58
61
  res = Rack::MockRequest.env_for(
59
62
  'http://jpmobile-rails.org/',
60
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
61
- "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")
63
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
64
+ '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'
65
+ )
62
66
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
63
67
 
64
68
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-4).of(43.07719289)
65
69
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-4).of(141.3389013)
66
70
  end
67
71
 
68
- it "緯度経度を取得できること(dgree_tokyo)" do
72
+ it '緯度経度を取得できること(dgree_tokyo)' do
69
73
  res = Rack::MockRequest.env_for(
70
74
  'http://jpmobile-rails.org/',
71
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
72
- "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")
75
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
76
+ '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'
77
+ )
73
78
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
74
79
 
75
80
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-4).of(43.07719289)
76
81
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-4).of(141.3389013)
77
82
  end
78
83
 
79
- it "緯度経度を取得できること(dms_tokyo)" do
84
+ it '緯度経度を取得できること(dms_tokyo)' do
80
85
  res = Rack::MockRequest.env_for(
81
86
  'http://jpmobile-rails.org/',
82
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
83
- "QUERY_STRING" => "datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75")
87
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
88
+ 'QUERY_STRING' => 'datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75'
89
+ )
84
90
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
85
91
 
86
92
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(43.08194444)
87
93
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(141.3474306)
88
94
  end
89
95
 
90
- it "緯度経度を取得できること(antenna)" do
96
+ it '緯度経度を取得できること(antenna)' do
91
97
  res = Rack::MockRequest.env_for(
92
98
  'http://jpmobile-rails.org/',
93
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
94
- "QUERY_STRING" => "datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75")
99
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
100
+ 'QUERY_STRING' => 'datum=tokyo&unit=dms&lat=43.04.55.00&lon=141.20.50.75'
101
+ )
95
102
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
96
103
 
97
104
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(43.08194444)
98
105
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(141.3474306)
99
106
  end
100
107
 
101
- it "GeoKit がある場合に取得できること" do
108
+ it 'GeoKit がある場合に取得できること' do
102
109
  res = Rack::MockRequest.env_for(
103
110
  'http://jpmobile-rails.org/',
104
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
105
- "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")
111
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
112
+ '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'
113
+ )
106
114
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
107
115
 
108
116
  expect(env['rack.jpmobile'].position.lat).to eq(43.07772)
109
117
  expect(env['rack.jpmobile'].position.lon).to eq(141.34114)
110
- expect(env['rack.jpmobile'].position.ll).to eq("43.07772,141.34114")
118
+ expect(env['rack.jpmobile'].position.ll).to eq('43.07772,141.34114')
111
119
  if env['rack.jpmobile'].position.respond_to?(:distance_to) # GeoKit method
112
120
  expect(env['rack.jpmobile'].position.distance_to(env['rack.jpmobile'].position)).to eq(0)
113
121
  end
114
122
  end
115
123
 
116
- context "古い機種での取得可否で" do
117
- it "W31CA を判定できること" do
124
+ context '古い機種での取得可否で' do
125
+ it 'W31CA を判定できること' do
118
126
  res = Rack::MockRequest.env_for(
119
127
  'http://jpmobile-rails.org/',
120
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0")
128
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'
129
+ )
121
130
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
122
131
 
123
- expect(env['rack.jpmobile'].device_id).to eq("CA32")
132
+ expect(env['rack.jpmobile'].device_id).to eq('CA32')
124
133
  expect(env['rack.jpmobile'].supports_location?).to be_truthy
125
134
  expect(env['rack.jpmobile'].supports_gps?).to be_truthy
126
135
  end
127
136
 
128
- it "A1402S を判定できること" do
137
+ it 'A1402S を判定できること' do
129
138
  res = Rack::MockRequest.env_for(
130
139
  'http://jpmobile-rails.org/',
131
- 'HTTP_USER_AGENT' => "KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0")
140
+ 'HTTP_USER_AGENT' => 'KDDI-SN26 UP.Browser/6.2.0.6.2 (GUI) MMP/2.0'
141
+ )
132
142
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
133
143
 
134
- expect(env['rack.jpmobile'].device_id).to eq("SN26")
144
+ expect(env['rack.jpmobile'].device_id).to eq('SN26')
135
145
  expect(env['rack.jpmobile'].supports_location?).to be_truthy
136
146
  expect(env['rack.jpmobile'].supports_gps?).to be_falsey
137
147
  end
138
148
 
139
- it "TK22 を判定できること" do
149
+ it 'TK22 を判定できること' do
140
150
  res = Rack::MockRequest.env_for(
141
151
  'http://jpmobile-rails.org/',
142
- 'HTTP_USER_AGENT' => "UP.Browser/3.04-KCTA UP.Link/3.4.5.9")
152
+ 'HTTP_USER_AGENT' => 'UP.Browser/3.04-KCTA UP.Link/3.4.5.9'
153
+ )
143
154
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
144
155
 
145
- expect(env['rack.jpmobile'].device_id).to eq("KCTA")
156
+ expect(env['rack.jpmobile'].device_id).to eq('KCTA')
146
157
  expect(env['rack.jpmobile'].supports_location?).to be_falsey
147
158
  expect(env['rack.jpmobile'].supports_gps?).to be_falsey
148
159
  end
149
160
  end
150
161
  end
151
162
 
152
- context "IPアドレス制限で" do
153
- it "正しいIPアドレス空間からのアクセスを判断できること" do
163
+ context 'IPアドレス制限で' do
164
+ it '正しいIPアドレス空間からのアクセスを判断できること' do
154
165
  res = Rack::MockRequest.env_for(
155
166
  'http://jpmobile-rails.org/',
156
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
157
- "REMOTE_ADDR" => "210.230.128.225")
167
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
168
+ 'REMOTE_ADDR' => '210.230.128.225'
169
+ )
158
170
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
159
171
 
160
172
  expect(env['rack.jpmobile'].valid_ip?).to be_truthy
161
173
  end
162
174
 
163
- it "正しくないIPアドレス空間からのアクセスを判断できること" do
175
+ it '正しくないIPアドレス空間からのアクセスを判断できること' do
164
176
  res = Rack::MockRequest.env_for(
165
177
  'http://jpmobile-rails.org/',
166
- 'HTTP_USER_AGENT' => "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0",
167
- "REMOTE_ADDR" => "127.0.0.1")
178
+ 'HTTP_USER_AGENT' => 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0',
179
+ 'REMOTE_ADDR' => '127.0.0.1'
180
+ )
168
181
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
169
182
 
170
183
  expect(env['rack.jpmobile'].valid_ip?).to be_falsey
171
184
  end
172
185
  end
173
186
 
174
- context "画面情報で" do
175
- it "端末の画面サイズを正しく取得できること" do
187
+ context '画面情報で' do
188
+ it '端末の画面サイズを正しく取得できること' do
176
189
  res = Rack::MockRequest.env_for(
177
190
  'http://jpmobile-rails.org/',
178
- 'HTTP_USER_AGENT' => "KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0",
179
- "HTTP_X_UP_DEVCAP_SCREENDEPTH" => "16,RGB565",
180
- "HTTP_X_UP_DEVCAP_SCREENPIXELS" => "240,346",
181
- "HTTP_X_UP_DEVCAP_ISCOLOR" => "1")
191
+ 'HTTP_USER_AGENT' => 'KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0',
192
+ 'HTTP_X_UP_DEVCAP_SCREENDEPTH' => '16,RGB565',
193
+ 'HTTP_X_UP_DEVCAP_SCREENPIXELS' => '240,346',
194
+ 'HTTP_X_UP_DEVCAP_ISCOLOR' => '1'
195
+ )
182
196
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
183
197
 
184
198
  expect(env['rack.jpmobile'].display.width).to eq(240)
@@ -187,10 +201,11 @@ describe Jpmobile::MobileCarrier, "au" do
187
201
  expect(env['rack.jpmobile'].display.colors).to eq(65536)
188
202
  end
189
203
 
190
- it "端末の画面情報が渡ってない場合に正しく動作すること" do
204
+ it '端末の画面情報が渡ってない場合に正しく動作すること' do
191
205
  res = Rack::MockRequest.env_for(
192
206
  'http://jpmobile-rails.org/',
193
- 'HTTP_USER_AGENT' => "KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0")
207
+ 'HTTP_USER_AGENT' => 'KDDI-CA33 UP.Browser/6.2.0.10.4 (GUI) MMP/2.0'
208
+ )
194
209
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
195
210
 
196
211
  expect(env['rack.jpmobile'].display.width).to be_nil
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "Windows Phone" do
3
+ describe Jpmobile::MobileCarrier, 'Windows Phone' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "BlackBerryを判別できること" do
6
+ context '端末種別で' do
7
+ it 'BlackBerryを判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220')
10
+ 'HTTP_USER_AGENT' => 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220'
11
+ )
12
12
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
13
13
 
14
14
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::BlackBerry)
@@ -1,14 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')
3
2
 
4
- describe Jpmobile::MobileCarrier, "docomo" do
3
+ describe Jpmobile::MobileCarrier, 'docomo' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "SH902i のとき" do
6
+ context 'SH902i のとき' do
8
7
  before(:each) do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH902i(c100;TB;W24H16)')
10
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH902i(c100;TB;W24H16)'
11
+ )
12
12
  @env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
13
13
  end
14
14
 
@@ -16,7 +16,7 @@ describe Jpmobile::MobileCarrier, "docomo" do
16
16
  expect(@env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Docomo)
17
17
  end
18
18
 
19
- it "#position などが nil になること" do
19
+ it '#position などが nil になること' do
20
20
  expect(@env['rack.jpmobile'].position).to be_nil
21
21
  expect(@env['rack.jpmobile'].areacode).to be_nil
22
22
  expect(@env['rack.jpmobile'].serial_number).to be_nil
@@ -26,20 +26,21 @@ describe Jpmobile::MobileCarrier, "docomo" do
26
26
  expect(@env['rack.jpmobile'].ident_subscriber).to be_nil
27
27
  end
28
28
 
29
- it "#supports_cookie? などが false になること" do
29
+ it '#supports_cookie? などが false になること' do
30
30
  expect(@env['rack.jpmobile'].supports_cookie?).to be_falsey
31
31
  end
32
32
 
33
- it "#imode_browser_versionが1.0になること" do
33
+ it '#imode_browser_versionが1.0になること' do
34
34
  expect(@env['rack.jpmobile'].imode_browser_version).to eq('1.0')
35
35
  end
36
36
  end
37
37
 
38
- context "SO506iC のとき" do
38
+ context 'SO506iC のとき' do
39
39
  before(:each) do
40
40
  res = Rack::MockRequest.env_for(
41
41
  'http://jpmobile-rails.org/',
42
- 'HTTP_USER_AGENT' => "DoCoMo/1.0/SO506iC/c20/TB/W20H10")
42
+ 'HTTP_USER_AGENT' => 'DoCoMo/1.0/SO506iC/c20/TB/W20H10'
43
+ )
43
44
  @env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
44
45
  end
45
46
 
@@ -47,7 +48,7 @@ describe Jpmobile::MobileCarrier, "docomo" do
47
48
  expect(@env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Docomo)
48
49
  end
49
50
 
50
- it "#position などが nil になること" do
51
+ it '#position などが nil になること' do
51
52
  expect(@env['rack.jpmobile'].position).to be_nil
52
53
  expect(@env['rack.jpmobile'].areacode).to be_nil
53
54
  expect(@env['rack.jpmobile'].serial_number).to be_nil
@@ -57,97 +58,103 @@ describe Jpmobile::MobileCarrier, "docomo" do
57
58
  expect(@env['rack.jpmobile'].ident_subscriber).to be_nil
58
59
  end
59
60
 
60
- it "#supports_cookie? などが false になること" do
61
+ it '#supports_cookie? などが false になること' do
61
62
  expect(@env['rack.jpmobile'].supports_cookie?).to be_falsey
62
63
  end
63
64
 
64
- it "#imode_browser_versionが1.0になること" do
65
+ it '#imode_browser_versionが1.0になること' do
65
66
  expect(@env['rack.jpmobile'].imode_browser_version).to eq('1.0')
66
67
  end
67
68
  end
68
69
 
69
- context "P09A3で" do
70
+ context 'P09A3で' do
70
71
  before(:each) do
71
72
  res = Rack::MockRequest.env_for(
72
73
  'http://jpmobile-rails.org/',
73
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 P09A3(c500;TB;W20H12)")
74
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 P09A3(c500;TB;W20H12)'
75
+ )
74
76
  @env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
75
77
  end
76
78
 
77
- it "#supports_cookie? が true になること" do
79
+ it '#supports_cookie? が true になること' do
78
80
  expect(@env['rack.jpmobile'].supports_cookie?).to be_truthy
79
81
  end
80
82
 
81
- it "#imode_browser_versionが2.0になること" do
83
+ it '#imode_browser_versionが2.0になること' do
82
84
  expect(@env['rack.jpmobile'].imode_browser_version).to eq('2.0')
83
85
  end
84
86
  end
85
87
 
86
- context "P07A3で" do
88
+ context 'P07A3で' do
87
89
  before(:each) do
88
90
  res = Rack::MockRequest.env_for(
89
91
  'http://jpmobile-rails.org/',
90
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 P07A3(c500;TB;W24H15)")
92
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 P07A3(c500;TB;W24H15)'
93
+ )
91
94
  @env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
92
95
  end
93
96
 
94
- it "#supports_cookie? が true になること" do
97
+ it '#supports_cookie? が true になること' do
95
98
  expect(@env['rack.jpmobile'].supports_cookie?).to be_truthy
96
99
  end
97
100
 
98
- it "#imode_browser_versionが2.0になること" do
101
+ it '#imode_browser_versionが2.0になること' do
99
102
  expect(@env['rack.jpmobile'].imode_browser_version).to eq('2.0')
100
103
  end
101
104
  end
102
105
 
103
- context "L01Bで" do
106
+ context 'L01Bで' do
104
107
  before(:each) do
105
108
  res = Rack::MockRequest.env_for(
106
109
  'http://jpmobile-rails.org/',
107
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 L01B(c500;TB;W40H10)")
110
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 L01B(c500;TB;W40H10)'
111
+ )
108
112
  @env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
109
113
  end
110
114
 
111
- it "#supports_cookie? が true になること" do
115
+ it '#supports_cookie? が true になること' do
112
116
  expect(@env['rack.jpmobile'].supports_cookie?).to be_truthy
113
117
  end
114
118
 
115
- it "#imode_browser_versionが2.0になること" do
119
+ it '#imode_browser_versionが2.0になること' do
116
120
  expect(@env['rack.jpmobile'].imode_browser_version).to eq('2.0LE')
117
121
  end
118
122
  end
119
123
 
120
- context "iエリアで" do
121
- it "データが取得できること" do
124
+ context 'iエリアで' do
125
+ it 'データが取得できること' do
122
126
  res = Rack::MockRequest.env_for(
123
127
  'http://jpmobile-rails.org/',
124
- 'HTTP_USER_AGENT' => "DoCoMo/1.0/SO506iC/c20/TB/W20H10",
125
- "QUERY_STRING" => "AREACODE=00100&ACTN=OK")
128
+ 'HTTP_USER_AGENT' => 'DoCoMo/1.0/SO506iC/c20/TB/W20H10',
129
+ 'QUERY_STRING' => 'AREACODE=00100&ACTN=OK'
130
+ )
126
131
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
127
132
 
128
- expect(env['rack.jpmobile'].areacode).to eq("00100")
133
+ expect(env['rack.jpmobile'].areacode).to eq('00100')
129
134
  end
130
135
 
131
- it "位置情報も取得できること" do
136
+ it '位置情報も取得できること' do
132
137
  res = Rack::MockRequest.env_for(
133
138
  'http://jpmobile-rails.org/',
134
- 'HTTP_USER_AGENT' => "DoCoMo/1.0/SO506iC/c20/TB/W20H10",
135
- "QUERY_STRING" => "LAT=%2B35.00.35.600&LON=%2B135.41.35.600&GEO=wgs84&POSINFO=2&AREACODE=00100&ACTN=OK")
139
+ 'HTTP_USER_AGENT' => 'DoCoMo/1.0/SO506iC/c20/TB/W20H10',
140
+ 'QUERY_STRING' => 'LAT=%2B35.00.35.600&LON=%2B135.41.35.600&GEO=wgs84&POSINFO=2&AREACODE=00100&ACTN=OK'
141
+ )
136
142
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
137
143
 
138
- expect(env['rack.jpmobile'].areacode).to eq("00100")
144
+ expect(env['rack.jpmobile'].areacode).to eq('00100')
139
145
 
140
146
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(35.00988889)
141
147
  expect(env['rack.jpmobile'].position.lon).to be_within(1e-7).of(135.6932222)
142
148
  end
143
149
  end
144
150
 
145
- context "GPS で" do
146
- it "位置が取得できること" do
151
+ context 'GPS で' do
152
+ it '位置が取得できること' do
147
153
  res = Rack::MockRequest.env_for(
148
154
  'http://jpmobile-rails.org/',
149
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 SA702i(c100;TB;W30H15)",
150
- "QUERY_STRING" => "lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=wgs84&x-acc=3")
155
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SA702i(c100;TB;W30H15)',
156
+ 'QUERY_STRING' => 'lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=wgs84&x-acc=3'
157
+ )
151
158
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
152
159
 
153
160
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(35.00988889)
@@ -157,11 +164,12 @@ describe Jpmobile::MobileCarrier, "docomo" do
157
164
  # DoCoMo, 903i, GPS
158
165
  # "WGS84"が大文字。altで高度が取得できているようだ。どちらも仕様書には記述がない。
159
166
  # http://www.nttdocomo.co.jp/service/imode/make/content/html/outline/gps.html
160
- it "903iでは高度があるが、正確にデータが取得できること" do
167
+ it '903iでは高度があるが、正確にデータが取得できること' do
161
168
  res = Rack::MockRequest.env_for(
162
169
  'http://jpmobile-rails.org/',
163
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 SH903i(c100;TB;W24H16)",
164
- "QUERY_STRING" => "lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=WGS84&alt=%2B64.000&x-acc=1")
170
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH903i(c100;TB;W24H16)',
171
+ 'QUERY_STRING' => 'lat=%2B35.00.35.600&lon=%2B135.41.35.600&geo=WGS84&alt=%2B64.000&x-acc=1'
172
+ )
165
173
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
166
174
 
167
175
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-7).of(35.00988889)
@@ -169,61 +177,66 @@ describe Jpmobile::MobileCarrier, "docomo" do
169
177
  end
170
178
  end
171
179
 
172
- context "端末番号が" do
173
- it "mova で取得できること" do
180
+ context '端末番号が' do
181
+ it 'mova で取得できること' do
174
182
  res = Rack::MockRequest.env_for(
175
183
  'http://jpmobile-rails.org/',
176
- 'HTTP_USER_AGENT' => "DoCoMo/1.0/SO505iS/c20/TC/W30H16/serXXXXX000000")
184
+ 'HTTP_USER_AGENT' => 'DoCoMo/1.0/SO505iS/c20/TC/W30H16/serXXXXX000000'
185
+ )
177
186
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
178
187
 
179
- expect(env['rack.jpmobile'].serial_number).to eq("XXXXX000000")
180
- expect(env['rack.jpmobile'].ident).to eq("XXXXX000000")
188
+ expect(env['rack.jpmobile'].serial_number).to eq('XXXXX000000')
189
+ expect(env['rack.jpmobile'].ident).to eq('XXXXX000000')
181
190
  expect(env['rack.jpmobile'].icc).to be_nil
182
- expect(env['rack.jpmobile'].ident_device).to eq("XXXXX000000")
191
+ expect(env['rack.jpmobile'].ident_device).to eq('XXXXX000000')
183
192
  expect(env['rack.jpmobile'].ident_subscriber).to be_nil
184
193
  end
185
194
 
186
- it "FOMA で取得できること" do
195
+ it 'FOMA で取得できること' do
187
196
  res = Rack::MockRequest.env_for(
188
197
  'http://jpmobile-rails.org/',
189
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)")
198
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 D902i(c100;TB;W23H16;ser999999999999999;icc0000000000000000000f)'
199
+ )
190
200
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
191
201
 
192
- expect(env['rack.jpmobile'].serial_number).to eq("999999999999999")
193
- expect(env['rack.jpmobile'].icc).to eq("0000000000000000000f")
194
- expect(env['rack.jpmobile'].ident).to eq("0000000000000000000f")
195
- expect(env['rack.jpmobile'].ident_device).to eq("999999999999999")
196
- expect(env['rack.jpmobile'].ident_subscriber).to eq("0000000000000000000f")
202
+ expect(env['rack.jpmobile'].serial_number).to eq('999999999999999')
203
+ expect(env['rack.jpmobile'].icc).to eq('0000000000000000000f')
204
+ expect(env['rack.jpmobile'].ident).to eq('0000000000000000000f')
205
+ expect(env['rack.jpmobile'].ident_device).to eq('999999999999999')
206
+ expect(env['rack.jpmobile'].ident_subscriber).to eq('0000000000000000000f')
197
207
  end
198
208
  end
199
209
 
200
- context "IPアドレス制限で" do
201
- it "正しいIPアドレス空間からのアクセスを判断できること" do
210
+ context 'IPアドレス制限で' do
211
+ it '正しいIPアドレス空間からのアクセスを判断できること' do
202
212
  res = Rack::MockRequest.env_for(
203
213
  'http://jpmobile-rails.org/',
204
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 SH902i(c100;TB;W24H12)",
205
- "REMOTE_ADDR" => "210.153.84.1")
214
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)',
215
+ 'REMOTE_ADDR' => '210.153.84.1'
216
+ )
206
217
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
207
218
 
208
219
  expect(env['rack.jpmobile'].valid_ip?).to be_truthy
209
220
  end
210
221
 
211
- it "正しくないIPアドレス空間からのアクセスを判断できること" do
222
+ it '正しくないIPアドレス空間からのアクセスを判断できること' do
212
223
  res = Rack::MockRequest.env_for(
213
224
  'http://jpmobile-rails.org/',
214
- 'HTTP_USER_AGENT' => "DoCoMo/2.0 SH902i(c100;TB;W24H12)",
215
- "REMOTE_ADDR" => "127.0.0.1")
225
+ 'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH902i(c100;TB;W24H12)',
226
+ 'REMOTE_ADDR' => '127.0.0.1'
227
+ )
216
228
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
217
229
 
218
230
  expect(env['rack.jpmobile'].valid_ip?).to be_falsey
219
231
  end
220
232
  end
221
233
 
222
- context "端末サイズ" do
223
- it "SO506iCのサイズを適切に取得できること" do
234
+ context '端末サイズ' do
235
+ it 'SO506iCのサイズを適切に取得できること' do
224
236
  res = Rack::MockRequest.env_for(
225
237
  'http://jpmobile-rails.org/',
226
- 'HTTP_USER_AGENT' => "DoCoMo/1.0/SO506iC/c20/TB/W20H10")
238
+ 'HTTP_USER_AGENT' => 'DoCoMo/1.0/SO506iC/c20/TB/W20H10'
239
+ )
227
240
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
228
241
 
229
242
  expect(env['rack.jpmobile'].display.browser_width).to eq(240)
@@ -231,7 +244,7 @@ describe Jpmobile::MobileCarrier, "docomo" do
231
244
  expect(env['rack.jpmobile'].display.width).to eq(240)
232
245
  expect(env['rack.jpmobile'].display.height).to eq(256)
233
246
  expect(env['rack.jpmobile'].display.color?).to be_truthy
234
- expect(env['rack.jpmobile'].display.colors).to eq(262144)
247
+ expect(env['rack.jpmobile'].display.colors).to eq(262144)
235
248
  end
236
249
  end
237
250
  end