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,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, "willcom" do
3
+ describe Jpmobile::MobileCarrier, 'willcom' do
5
4
  include Rack::Test::Methods
6
5
 
7
- context "端末種別で" do
8
- it "WX310K が判別できること" do
6
+ context '端末種別で' do
7
+ it 'WX310K が判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0")
10
+ 'HTTP_USER_AGENT' => 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0'
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::Willcom)
@@ -17,10 +17,11 @@ describe Jpmobile::MobileCarrier, "willcom" do
17
17
  expect(env['rack.jpmobile'].supports_cookie?).to be_truthy
18
18
  end
19
19
 
20
- it "AH-H3001V が判別できること" do
20
+ it 'AH-H3001V が判別できること' do
21
21
  res = Rack::MockRequest.env_for(
22
22
  'http://jpmobile-rails.org/',
23
- 'HTTP_USER_AGENT' => "Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0")
23
+ 'HTTP_USER_AGENT' => 'Mozilla/3.0(DDIPOCKET;KYOCERA/AH-K3001V/1.8.2.71.000000/0.1/C100) Opera 7.0'
24
+ )
24
25
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
25
26
 
26
27
  expect(env['rack.jpmobile'].class).to eq(Jpmobile::Mobile::Ddipocket)
@@ -30,12 +31,13 @@ describe Jpmobile::MobileCarrier, "willcom" do
30
31
  end
31
32
  end
32
33
 
33
- context "GPS で" do
34
- it "緯度経度を取得できること" do
34
+ context 'GPS で' do
35
+ it '緯度経度を取得できること' do
35
36
  res = Rack::MockRequest.env_for(
36
37
  'http://jpmobile-rails.org/',
37
- 'HTTP_USER_AGENT' => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
38
- "QUERY_STRING" => "pos=N43.04.34.049E141.21.03.279")
38
+ 'HTTP_USER_AGENT' => 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0',
39
+ 'QUERY_STRING' => 'pos=N43.04.34.049E141.21.03.279'
40
+ )
39
41
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
40
42
 
41
43
  expect(env['rack.jpmobile'].position.lat).to be_within(1e-4).of(43.078568)
@@ -43,22 +45,24 @@ describe Jpmobile::MobileCarrier, "willcom" do
43
45
  end
44
46
  end
45
47
 
46
- context "IPアドレス制限で" do
47
- it "正しいIPアドレス空間からのアクセスを判断できること" do
48
+ context 'IPアドレス制限で' do
49
+ it '正しいIPアドレス空間からのアクセスを判断できること' do
48
50
  res = Rack::MockRequest.env_for(
49
51
  'http://jpmobile-rails.org/',
50
- 'HTTP_USER_AGENT' => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
51
- "REMOTE_ADDR" => "61.198.142.1")
52
+ 'HTTP_USER_AGENT' => 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0',
53
+ 'REMOTE_ADDR' => '61.198.142.1'
54
+ )
52
55
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
53
56
 
54
57
  expect(env['rack.jpmobile'].valid_ip?).to be_truthy
55
58
  end
56
59
 
57
- it "正しくないIPアドレス空間からのアクセスを判断できること" do
60
+ it '正しくないIPアドレス空間からのアクセスを判断できること' do
58
61
  res = Rack::MockRequest.env_for(
59
62
  'http://jpmobile-rails.org/',
60
- 'HTTP_USER_AGENT' => "Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0",
61
- "REMOTE_ADDR" => "127.0.0.1")
63
+ 'HTTP_USER_AGENT' => 'Mozilla/3.0(WILLCOM;KYOCERA/WX310K/2;1.2.2.16.000000/0.1/C100) Opera 7.0',
64
+ 'REMOTE_ADDR' => '127.0.0.1'
65
+ )
62
66
  env = Jpmobile::MobileCarrier.new(UnitApplication.new).call(res)[1]
63
67
 
64
68
  expect(env['rack.jpmobile'].valid_ip?).to be_falsey
@@ -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 "WindowsPhone を判別できること" do
6
+ context '端末種別で' do
7
+ it 'WindowsPhone を判別できること' do
9
8
  res = Rack::MockRequest.env_for(
10
9
  'http://jpmobile-rails.org/',
11
- 'HTTP_USER_AGENT' => 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)')
10
+ 'HTTP_USER_AGENT' => 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'
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::WindowsPhone)
@@ -6,25 +6,25 @@ require 'jpmobile'
6
6
  require 'nkf'
7
7
 
8
8
  begin
9
- require File.dirname(__FILE__)+'/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
9
+ require File.dirname(__FILE__) + '/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
10
10
  rescue LoadError
11
- puts "IP Address test requires jpmobile-ipaddresses module"
11
+ puts 'IP Address test requires jpmobile-ipaddresses module'
12
12
  end
13
13
  begin
14
- require File.dirname(__FILE__)+'/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
14
+ require File.dirname(__FILE__) + '/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
15
15
  rescue LoadError
16
- puts "Terminal display information test requires jpmobile-terminfo module"
16
+ puts 'Terminal display information test requires jpmobile-terminfo module'
17
17
  end
18
18
 
19
19
  RSpec.configure do |config|
20
- config.filter_run :focus => true
20
+ config.filter_run focus: true
21
21
  config.run_all_when_everything_filtered = true
22
22
  config.color = true
23
23
  end
24
24
 
25
25
  class UnitApplication
26
26
  def initialize(body = nil)
27
- @body = Jpmobile::Util.utf8(body || "Body")
27
+ @body = Jpmobile::Util.utf8(body || 'Body')
28
28
  end
29
29
 
30
30
  def call(env)
@@ -60,13 +60,14 @@ module Jpmobile::RackHelper
60
60
  def user_agent(str)
61
61
  @request.user_agent = str
62
62
  end
63
+
63
64
  def init(c)
64
65
  @controller = c.new
65
66
  @controller.logger = Logger.new(nil)
66
67
  @request = ActionController::TestRequest.new
67
68
  @response = ActionController::TestResponse.new
68
- @request.host = "www.example.jp"
69
- @request.session.session_id = "mysessionid"
69
+ @request.host = 'www.example.jp'
70
+ @request.session.session_id = 'mysessionid'
70
71
  end
71
72
  include Jpmobile::Util
72
73
 
@@ -1,21 +1,20 @@
1
- # -*- coding: utf-8 -*-
2
1
  unless RSpec.const_defined?(:Rails)
3
2
  dir = File.dirname(__FILE__)
4
3
 
5
4
  # jpmobileの読み込み
6
5
  require 'rubygems'
7
6
  require 'initializer'
8
- require dir+'/../lib/jpmobile'
7
+ require dir + '/../lib/jpmobile'
9
8
  begin
10
- require dir+'/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
9
+ require dir + '/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
11
10
  rescue LoadError
12
- puts "IP Address test requires jpmobile-ipaddresses module"
11
+ puts 'IP Address test requires jpmobile-ipaddresses module'
13
12
  end
14
13
 
15
14
  begin
16
- require dir+'/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
15
+ require dir + '/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
17
16
  rescue LoadError
18
- puts "Terminal display information test requires jpmobile-terminfo module"
17
+ puts 'Terminal display information test requires jpmobile-terminfo module'
19
18
  end
20
19
 
21
20
  require 'rspec/rails'
@@ -1,26 +1,25 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
3
2
  require 'mail'
4
3
  require 'jpmobile/mail'
5
4
 
6
- describe "decorated mails" do
5
+ describe 'decorated mails' do
7
6
  include Jpmobile::Util
8
7
 
9
8
  before(:each) do
10
9
  @mail = Mail.new
11
- @mail.subject = "万葉"
10
+ @mail.subject = '万葉'
12
11
  @mail.text_part = Mail::Part.new do
13
12
  body 'ほげ'
14
13
  end
15
- @mail.from = "ちはやふる <info@jpmobile-rails.org>"
16
- @mail.to = "むすめふさほせ <info+to@jpmobile-rails.org>"
14
+ @mail.from = 'ちはやふる <info@jpmobile-rails.org>'
15
+ @mail.to = 'むすめふさほせ <info+to@jpmobile-rails.org>'
17
16
 
18
- @photo = open(File.join(File.expand_path(File.dirname(__FILE__)), "email-fixtures/photo.jpg")).read
17
+ @photo = open(File.join(File.expand_path(File.dirname(__FILE__)), 'email-fixtures/photo.jpg')).read
19
18
  @mail.attachments.inline['photo.jpg'] = @photo
20
19
  @inline_url = @mail.attachments['photo.jpg'].url
21
20
  end
22
21
 
23
- describe "docomo" do
22
+ describe 'docomo' do
24
23
  before(:each) do
25
24
  inline_url = @inline_url
26
25
  @mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
@@ -38,7 +37,7 @@ describe "decorated mails" do
38
37
  end
39
38
  end
40
39
 
41
- describe "au" do
40
+ describe 'au' do
42
41
  before(:each) do
43
42
  inline_url = @inline_url
44
43
  @mobile = Jpmobile::Mobile::Au.new(nil, nil)
@@ -56,7 +55,7 @@ describe "decorated mails" do
56
55
  end
57
56
  end
58
57
 
59
- describe "softbank" do
58
+ describe 'softbank' do
60
59
  before(:each) do
61
60
  inline_url = @inline_url
62
61
  @mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
@@ -2,23 +2,23 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  describe 'Jpmobile::Email' do
4
4
  [
5
- ['example@example.ne.jp' , nil ],
6
- ['test@docomo.ne.jp' , Jpmobile::Mobile::Docomo ],
7
- ['test@docomo.ne.jp.jp' , nil ],
8
- ['a(--)l@ezweb.ne.jp' , Jpmobile::Mobile::Au ],
9
- ['a(--)l@ezweb.ne.jp.jp' , nil ],
10
- ['dadaea@pdx.ne.jp' , Jpmobile::Mobile::Willcom ],
11
- ['dadaea@pdx.ne.jp.jp' , nil ],
12
- ['xxxe@dj.pdx.ne.jp' , Jpmobile::Mobile::Willcom ],
13
- ['xxxe@dj.pdx.ne.jp.jp' , nil ],
14
- ['xxxe@willcom.com' , Jpmobile::Mobile::Willcom ],
15
- ['xxxe@willcom.com.jp' , nil ],
16
- ['oeeikx@softbank.ne.jp' , Jpmobile::Mobile::Softbank ],
17
- ['oeeikx@softbank.ne.jp.jp' , nil ],
18
- ['eaae@disney.ne.jp' , Jpmobile::Mobile::Softbank ],
19
- ['eaae@disney.ne.jp.jp' , nil ],
20
- ['iiiaa@r.vodafone.ne.jp' , Jpmobile::Mobile::Vodafone ],
21
- ['iiiaa@r.vodafone.ne.jp.jp' , nil ],
5
+ ['example@example.ne.jp', nil],
6
+ ['test@docomo.ne.jp', Jpmobile::Mobile::Docomo],
7
+ ['test@docomo.ne.jp.jp', nil],
8
+ ['a(--)l@ezweb.ne.jp', Jpmobile::Mobile::Au],
9
+ ['a(--)l@ezweb.ne.jp.jp', nil],
10
+ ['dadaea@pdx.ne.jp', Jpmobile::Mobile::Willcom],
11
+ ['dadaea@pdx.ne.jp.jp', nil],
12
+ ['xxxe@dj.pdx.ne.jp', Jpmobile::Mobile::Willcom],
13
+ ['xxxe@dj.pdx.ne.jp.jp', nil],
14
+ ['xxxe@willcom.com', Jpmobile::Mobile::Willcom],
15
+ ['xxxe@willcom.com.jp', nil],
16
+ ['oeeikx@softbank.ne.jp', Jpmobile::Mobile::Softbank],
17
+ ['oeeikx@softbank.ne.jp.jp', nil],
18
+ ['eaae@disney.ne.jp', Jpmobile::Mobile::Softbank],
19
+ ['eaae@disney.ne.jp.jp', nil],
20
+ ['iiiaa@r.vodafone.ne.jp', Jpmobile::Mobile::Vodafone],
21
+ ['iiiaa@r.vodafone.ne.jp.jp', nil],
22
22
  ].each do |email_addr, carrier|
23
23
  it "#detect should return #{carrier} when take #{email_addr} as EmailAddr" do
24
24
  Jpmobile::Email.japanese_mail_address_regexp = nil
@@ -27,26 +27,26 @@ describe 'Jpmobile::Email' do
27
27
  end
28
28
 
29
29
  [
30
- ['From: Jpmobile Rails <example@example.ne.jp>' , nil ],
31
- ['From: Jpmobile Rails <test@docomo.ne.jp>' , Jpmobile::Mobile::Docomo ],
32
- ['From: test@docomo.ne.jp' , Jpmobile::Mobile::Docomo ],
33
- ['From: Jpmobile Rails <test@docomo.ne.jp.jp>' , nil ],
34
- ['From: Jpmobile Rails <a(--)l@ezweb.ne.jp>' , Jpmobile::Mobile::Au ],
35
- ['From: a(--)l@ezweb.ne.jp' , Jpmobile::Mobile::Au ],
36
- ['From: Jpmobile Rails <a(--)l@ezweb.ne.jp.jp>' , nil ],
37
- ['From: Jpmobile Rails <dadaea@pdx.ne.jp>' , Jpmobile::Mobile::Willcom ],
38
- ['From: Jpmobile Rails <dadaea@pdx.ne.jp.jp>' , nil ],
39
- ['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp>' , Jpmobile::Mobile::Willcom ],
40
- ['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp.jp>' , nil ],
41
- ['From: Jpmobile Rails <xxxe@willcom.com>' , Jpmobile::Mobile::Willcom ],
42
- ['From: Jpmobile Rails <xxxe@willcom.com.jp>' , nil ],
43
- ['From: Jpmobile Rails <oeeikx@softbank.ne.jp>' , Jpmobile::Mobile::Softbank ],
44
- ['From: oeeikx@softbank.ne.jp' , Jpmobile::Mobile::Softbank ],
45
- ['From: Jpmobile Rails <oeeikx@softbank.ne.jp.jp>' , nil ],
46
- ['From: Jpmobile Rails <eaae@disney.ne.jp>' , Jpmobile::Mobile::Softbank ],
47
- ['From: Jpmobile Rails <eaae@disney.ne.jp.jp>' , nil ],
48
- ['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp>' , Jpmobile::Mobile::Vodafone ],
49
- ['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp.jp>' , nil ],
30
+ ['From: Jpmobile Rails <example@example.ne.jp>', nil],
31
+ ['From: Jpmobile Rails <test@docomo.ne.jp>', Jpmobile::Mobile::Docomo],
32
+ ['From: test@docomo.ne.jp', Jpmobile::Mobile::Docomo],
33
+ ['From: Jpmobile Rails <test@docomo.ne.jp.jp>', nil],
34
+ ['From: Jpmobile Rails <a(--)l@ezweb.ne.jp>', Jpmobile::Mobile::Au],
35
+ ['From: a(--)l@ezweb.ne.jp', Jpmobile::Mobile::Au],
36
+ ['From: Jpmobile Rails <a(--)l@ezweb.ne.jp.jp>', nil],
37
+ ['From: Jpmobile Rails <dadaea@pdx.ne.jp>', Jpmobile::Mobile::Willcom],
38
+ ['From: Jpmobile Rails <dadaea@pdx.ne.jp.jp>', nil],
39
+ ['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp>', Jpmobile::Mobile::Willcom],
40
+ ['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp.jp>', nil],
41
+ ['From: Jpmobile Rails <xxxe@willcom.com>', Jpmobile::Mobile::Willcom],
42
+ ['From: Jpmobile Rails <xxxe@willcom.com.jp>', nil],
43
+ ['From: Jpmobile Rails <oeeikx@softbank.ne.jp>', Jpmobile::Mobile::Softbank],
44
+ ['From: oeeikx@softbank.ne.jp', Jpmobile::Mobile::Softbank],
45
+ ['From: Jpmobile Rails <oeeikx@softbank.ne.jp.jp>', nil],
46
+ ['From: Jpmobile Rails <eaae@disney.ne.jp>', Jpmobile::Mobile::Softbank],
47
+ ['From: Jpmobile Rails <eaae@disney.ne.jp.jp>', nil],
48
+ ['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp>', Jpmobile::Mobile::Vodafone],
49
+ ['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp.jp>', nil],
50
50
  ].each do |line, carrier|
51
51
  it "#detect_from_mail_header should return #{carrier} when take mail header #{line}}" do
52
52
  Jpmobile::Email.japanese_mail_address_regexp = nil
@@ -54,32 +54,32 @@ describe 'Jpmobile::Email' do
54
54
  end
55
55
  end
56
56
 
57
- describe "japanese_mail_address_regexp" do
57
+ describe 'japanese_mail_address_regexp' do
58
58
  before do
59
59
  Jpmobile::Email.japanese_mail_address_regexp = Regexp.new(/\.jp(?:[^a-zA-Z\.\-]|$)/)
60
60
  end
61
61
 
62
- it "#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when the header contains .jp address" do
62
+ it '#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when the header contains .jp address' do
63
63
  expect(Jpmobile::Email.detect_from_mail_header('From: Hoge Fuga <fuga@hoge.jp>')).to eq(Jpmobile::Mobile::AbstractMobile)
64
64
  expect(Jpmobile::Email.detect_from_mail_header('From: fuga@hoge.jp')).to eq(Jpmobile::Mobile::AbstractMobile)
65
65
  end
66
66
 
67
- it "#detect_from_mail_header should return nil when the header does not contain .jp address" do
67
+ it '#detect_from_mail_header should return nil when the header does not contain .jp address' do
68
68
  expect(Jpmobile::Email.detect_from_mail_header('From: Hoge Fuga <fuga@example.com>')).to eq(nil)
69
69
  expect(Jpmobile::Email.detect_from_mail_header('From: fuga@example.com')).to eq(nil)
70
70
  end
71
71
  end
72
72
 
73
- describe "convertable?" do
74
- it "return true when text/plain; charset=iso-2022-jp" do
73
+ describe 'convertable?' do
74
+ it 'return true when text/plain; charset=iso-2022-jp' do
75
75
  expect(Jpmobile::Email.convertable?('text/plain; charset=iso-2022-jp')).to be_truthy
76
76
  end
77
77
 
78
- it "return true when text/html; charset=shift_jis" do
78
+ it 'return true when text/html; charset=shift_jis' do
79
79
  expect(Jpmobile::Email.convertable?('text/html; charset=shift_jis')).to be_truthy
80
80
  end
81
81
 
82
- it "return nil when image/jpeg; name=\"20098calendar01.jpg\"" do
82
+ it 'return nil when image/jpeg; name="20098calendar01.jpg"' do
83
83
  expect(Jpmobile::Email.convertable?('image/jpeg; name="20098calendar01.jpg"')).to be_nil
84
84
  end
85
85
  end
@@ -1,153 +1,152 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
3
2
 
4
3
  describe Jpmobile::Emoticon do
5
4
  include Jpmobile::Util
6
5
 
7
- describe "unicodecr_to_external" do
8
- context "should convert unicodecr to docomo encoding" do
9
- it "when no options" do
10
- expect(Jpmobile::Emoticon::unicodecr_to_external("&#xe63e;")).to eq(sjis("\xf8\x9f"))
6
+ describe 'unicodecr_to_external' do
7
+ context 'should convert unicodecr to docomo encoding' do
8
+ it 'when no options' do
9
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe63e;')).to eq(sjis("\xf8\x9f"))
11
10
  end
12
11
 
13
- it "in multiple convertion" do
14
- expect(Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)).to eq(sjis("\xf8\x9f\xf8\xa0"))
12
+ it 'in multiple convertion' do
13
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xE48E;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)).to eq(sjis("\xf8\x9f\xf8\xa0"))
15
14
  end
16
15
  end
17
16
 
18
- context "should convert unicodecr to au encoding" do
19
- it "when no options" do
20
- expect(Jpmobile::Emoticon::unicodecr_to_external("&#xe481;")).to eq(sjis("\xf6\x59"))
17
+ context 'should convert unicodecr to au encoding' do
18
+ it 'when no options' do
19
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe481;')).to eq(sjis("\xf6\x59"))
21
20
  end
22
21
  end
23
22
 
24
- context "should convert unicodecr to softbank encoding" do
25
- it "when no opptions" do
26
- expect(Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")).to eq([0xe001].pack('U'))
23
+ context 'should convert unicodecr to softbank encoding' do
24
+ it 'when no opptions' do
25
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xf001;')).to eq([0xe001].pack('U'))
27
26
  end
28
27
 
29
- it "in multiple convertion" do
30
- expect(Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)).to eq([0xe04a, 0xe049].pack('U*'))
28
+ it 'in multiple convertion' do
29
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xE48E;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)).to eq([0xe04a, 0xe049].pack('U*'))
31
30
  end
32
31
  end
33
32
 
34
33
  it 'should convert docomo unicodecr to Unicode 6.0 emoticon' do
35
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xe63e;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x2600].pack('U'))
34
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe63e;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x2600].pack('U'))
36
35
  end
37
36
 
38
37
  it 'should convert au unicodecr to Unicode 6.0 emoticon' do
39
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xe48e;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x26C5].pack('U'))
38
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe48e;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x26C5].pack('U'))
40
39
  end
41
40
 
42
41
  it 'should convert Softbank unicodecr to Unicode 6.0 emoticon' do
43
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xf001;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x1F466].pack('U'))
42
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xf001;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq([0x1F466].pack('U'))
44
43
  end
45
44
 
46
45
  it 'should not convert 〓' do
47
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#x3013;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq('〓')
46
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#x3013;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_UNICODE_EMOTICON, false)).to eq('〓')
48
47
  end
49
48
 
50
49
  it 'should convert docomo unicodecr to Google emoticon' do
51
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xe63e;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE000].pack('U'))
50
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe63e;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE000].pack('U'))
52
51
  end
53
52
 
54
53
  it 'should convert au unicodecr to Google emoticon' do
55
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xe48e;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE00F].pack('U'))
54
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xe48e;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE00F].pack('U'))
56
55
  end
57
56
 
58
57
  it 'should convert Softbank unicodecr to Google emoticon' do
59
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#xf001;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE19B].pack('U'))
58
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#xf001;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq([0xFE19B].pack('U'))
60
59
  end
61
60
 
62
61
  it 'should not convert 〓' do
63
- expect(Jpmobile::Emoticon.unicodecr_to_external("&#x3013;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq('〓')
62
+ expect(Jpmobile::Emoticon.unicodecr_to_external('&#x3013;', Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq('〓')
64
63
  end
65
64
  end
66
65
 
67
- describe "unicodecr_to_utf8" do
68
- it "should convert unicodecr to internal utf8 encoding" do
66
+ describe 'unicodecr_to_utf8' do
67
+ it 'should convert unicodecr to internal utf8 encoding' do
69
68
  # docomo codepoint
70
- expect(Jpmobile::Emoticon::unicodecr_to_utf8("&#xe63e;")).to eq(utf8("\356\230\276"))
69
+ expect(Jpmobile::Emoticon.unicodecr_to_utf8('&#xe63e;')).to eq(utf8("\356\230\276"))
71
70
  # au codepoint
72
- expect(Jpmobile::Emoticon::unicodecr_to_utf8("&#xe481;")).to eq(utf8("\356\222\201"))
71
+ expect(Jpmobile::Emoticon.unicodecr_to_utf8('&#xe481;')).to eq(utf8("\356\222\201"))
73
72
  # softbank codepoint
74
- expect(Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")).to eq(utf8("\xef\x80\x81"))
73
+ expect(Jpmobile::Emoticon.unicodecr_to_utf8('&#xf001;')).to eq(utf8("\xef\x80\x81"))
75
74
  end
76
75
  end
77
76
 
78
- describe "utf8_to_unicodecr" do
79
- it "should convert utf8 encoding to unicodecr" do
77
+ describe 'utf8_to_unicodecr' do
78
+ it 'should convert utf8 encoding to unicodecr' do
80
79
  # docomo codepoint
81
- expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276"))).to eq("&#xe63e;")
80
+ expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\356\230\276"))).to eq('&#xe63e;')
82
81
  # au codepoint
83
- expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201"))).to eq("&#xe481;")
82
+ expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\356\222\201"))).to eq('&#xe481;')
84
83
  # softbank codepoint
85
- expect(Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))).to eq("&#xf001;")
84
+ expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\xef\x80\x81"))).to eq('&#xf001;')
86
85
  end
87
86
  end
88
87
 
89
- describe "external_to_unicodecr" do
90
- it "should convert docomo encoding to unicodecr" do
91
- expect(Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f"))).to eq("&#xe63e;")
88
+ describe 'external_to_unicodecr' do
89
+ it 'should convert docomo encoding to unicodecr' do
90
+ expect(Jpmobile::Emoticon.external_to_unicodecr_docomo(sjis("\xf8\x9f"))).to eq('&#xe63e;')
92
91
  end
93
92
 
94
- it "should convert au encoding to unicodecr" do
95
- expect(Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59"))).to eq("&#xe481;")
93
+ it 'should convert au encoding to unicodecr' do
94
+ expect(Jpmobile::Emoticon.external_to_unicodecr_au(sjis("\xf6\x59"))).to eq('&#xe481;')
96
95
  end
97
96
 
98
- it "should convert softbank encoding to unicodecr" do
99
- expect(Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))).to eq("&#xf001;")
97
+ it 'should convert softbank encoding to unicodecr' do
98
+ expect(Jpmobile::Emoticon.external_to_unicodecr_softbank([0xe001].pack('U'))).to eq('&#xf001;')
100
99
  end
101
100
 
102
- it "should not convert docomo encoding of koukai-sjis emoticons to unicodecr" do
103
- expect(Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a"))).to eq(sjis("\x8c\xf6\x8a\x4a"))
101
+ it 'should not convert docomo encoding of koukai-sjis emoticons to unicodecr' do
102
+ expect(Jpmobile::Emoticon.external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a"))).to eq(sjis("\x8c\xf6\x8a\x4a"))
104
103
  end
105
104
 
106
105
  context 'at iPhone emoticon' do
107
106
  it 'should convert iPhone Unicode emoticon to SoftBank emoticon' do
108
- expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\230\200")).to eq("&#xf04a;")
107
+ expect(Jpmobile::Emoticon.external_to_unicodecr_unicode60("\342\230\200")).to eq('&#xf04a;')
109
108
  end
110
109
 
111
110
  it 'should convert iPhone Unicode emoticon to multi SoftBank emoticons' do
112
- expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60("\342\233\205")).to eq("&#xF04A;,&#xF049;")
111
+ expect(Jpmobile::Emoticon.external_to_unicodecr_unicode60("\342\233\205")).to eq('&#xF04A;,&#xF049;')
113
112
  end
114
113
 
115
114
  it 'should not convert 〓' do
116
- expect(Jpmobile::Emoticon::external_to_unicodecr_unicode60('〓')).to eq("")
115
+ expect(Jpmobile::Emoticon.external_to_unicodecr_unicode60('〓')).to eq('')
117
116
  end
118
117
  end
119
118
 
120
119
  context 'at Android emoticon' do
121
120
  it 'should convert Android Google Unicode emoticon to Docomo emoticon' do
122
- expect(Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\200")).to eq("&#xe63e;")
121
+ expect(Jpmobile::Emoticon.external_to_unicodecr_google("\363\276\200\200")).to eq('&#xe63e;')
123
122
  end
124
123
 
125
124
  it 'should convert Android Google Unicode emoticon to multi Docomo emoticon' do
126
- expect(Jpmobile::Emoticon::external_to_unicodecr_google("\363\276\200\217")).to eq("&#xE63E;&#xE63F;")
125
+ expect(Jpmobile::Emoticon.external_to_unicodecr_google("\363\276\200\217")).to eq('&#xE63E;&#xE63F;')
127
126
  end
128
127
 
129
128
  it 'should not convert 〓' do
130
- expect(Jpmobile::Emoticon::external_to_unicodecr_google('〓')).to eq("")
129
+ expect(Jpmobile::Emoticon.external_to_unicodecr_google('〓')).to eq('')
131
130
  end
132
131
  end
133
132
  end
134
133
 
135
- context "for email" do
136
- describe "au" do
137
- it "should not convert 助助 that does not contain emoticons" do
138
- expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("助助"))).not_to match(/e484/i)
134
+ context 'for email' do
135
+ describe 'au' do
136
+ it 'should not convert 助助 that does not contain emoticons' do
137
+ expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis('助助'))).not_to match(/e484/i)
139
138
  end
140
139
 
141
- it "should not convert exterior of 2byte Kanji-code" do
142
- expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("abcd=uしから=uずんば=u"))).not_to match(/e484/i)
140
+ it 'should not convert exterior of 2byte Kanji-code' do
141
+ expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis('abcd=uしから=uずんば=u'))).not_to match(/e484/i)
143
142
  end
144
143
 
145
- it "should not convert ascii string to unicodecr" do
146
- expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("-------=_NextPart_15793_72254_63179"))).not_to match(/e5c2/i)
144
+ it 'should not convert ascii string to unicodecr' do
145
+ expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis('-------=_NextPart_15793_72254_63179'))).not_to match(/e5c2/i)
147
146
  end
148
147
 
149
- it "should not include extra JIS escape sequence between Kanji-code and emoticon" do
150
- expect(Jpmobile::Emoticon.unicodecr_to_au_email(utf8_to_jis("&#xe481;掲示板"))).to eq(Jpmobile::Util.ascii_8bit("\x1b\x24\x42\x75\x3a\x37\x47\x3C\x28\x48\x44\x1b\x28\x42"))
148
+ it 'should not include extra JIS escape sequence between Kanji-code and emoticon' do
149
+ expect(Jpmobile::Emoticon.unicodecr_to_au_email(utf8_to_jis('&#xe481;掲示板'))).to eq(Jpmobile::Util.ascii_8bit("\x1b\x24\x42\x75\x3a\x37\x47\x3C\x28\x48\x44\x1b\x28\x42"))
151
150
  end
152
151
  end
153
152
  end