jpmobile 5.0.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.rubocop.yml +123 -0
- data/CONTRIBUTING.md +16 -14
- data/Gemfile +6 -0
- data/Gemfile.lock +198 -0
- data/README.md +409 -0
- data/Rakefile +9 -9
- data/circle.yml +14 -0
- data/jpmobile.gemspec +9 -10
- data/lib/jpmobile.rb +6 -5
- data/lib/jpmobile/datum_conv.rb +35 -35
- data/lib/jpmobile/docomo_guid.rb +7 -8
- data/lib/jpmobile/email.rb +12 -12
- data/lib/jpmobile/emoticon.rb +85 -76
- data/lib/jpmobile/emoticon/au.rb +1284 -1284
- data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
- data/lib/jpmobile/emoticon/docomo.rb +252 -252
- data/lib/jpmobile/emoticon/google.rb +9 -9
- data/lib/jpmobile/emoticon/softbank.rb +471 -471
- data/lib/jpmobile/emoticon/unicode.rb +9 -9
- data/lib/jpmobile/emoticon/z_combine.rb +20 -23
- data/lib/jpmobile/encoding.rb +1 -1
- data/lib/jpmobile/fallback_view_selector.rb +2 -3
- data/lib/jpmobile/filter.rb +44 -47
- data/lib/jpmobile/helpers.rb +38 -38
- data/lib/jpmobile/hook_action_view.rb +7 -7
- data/lib/jpmobile/hook_test_request.rb +0 -1
- data/lib/jpmobile/lookup_context.rb +1 -2
- data/lib/jpmobile/mail.rb +156 -134
- data/lib/jpmobile/mailer.rb +4 -4
- data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
- data/lib/jpmobile/mobile/android.rb +0 -1
- data/lib/jpmobile/mobile/android_tablet.rb +0 -1
- data/lib/jpmobile/mobile/au.rb +40 -28
- data/lib/jpmobile/mobile/black_berry.rb +0 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -2
- data/lib/jpmobile/mobile/docomo.rb +47 -36
- data/lib/jpmobile/mobile/emobile.rb +1 -2
- data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
- data/lib/jpmobile/mobile/ipad.rb +0 -1
- data/lib/jpmobile/mobile/iphone.rb +0 -1
- data/lib/jpmobile/mobile/smart_phone.rb +0 -1
- data/lib/jpmobile/mobile/softbank.rb +24 -20
- data/lib/jpmobile/mobile/tablet.rb +0 -1
- data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
- data/lib/jpmobile/mobile/vodafone.rb +0 -1
- data/lib/jpmobile/mobile/willcom.rb +7 -7
- data/lib/jpmobile/mobile/windows_phone.rb +0 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/position.rb +30 -14
- data/lib/jpmobile/rack/filter.rb +4 -4
- data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
- data/lib/jpmobile/rack/params_filter.rb +7 -6
- data/lib/jpmobile/rails.rb +3 -4
- data/lib/jpmobile/request_with_mobile.rb +9 -6
- data/lib/jpmobile/resolver.rb +23 -17
- data/lib/jpmobile/session/active_record_store.rb +7 -9
- data/lib/jpmobile/session/mem_cache_store.rb +7 -9
- data/lib/jpmobile/sinatra.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +15 -20
- data/lib/jpmobile/util.rb +61 -77
- data/lib/jpmobile/version.rb +1 -1
- data/lib/tasks/jpmobile_tasks.rake +35 -28
- data/spec/rack/jpmobile/android_spec.rb +5 -5
- data/spec/rack/jpmobile/au_spec.rb +74 -59
- data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
- data/spec/rack/jpmobile/docomo_spec.rb +77 -64
- data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
- data/spec/rack/jpmobile/filter_spec.rb +149 -128
- data/spec/rack/jpmobile/iphone_spec.rb +9 -8
- data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
- data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
- data/spec/rack/jpmobile/softbank_spec.rb +49 -42
- data/spec/rack/jpmobile/willcom_spec.rb +22 -18
- data/spec/rack/jpmobile/windows_phone.rb +5 -5
- data/spec/rack_helper.rb +9 -8
- data/spec/spec_helper.rb +5 -6
- data/spec/unit/decorated_mail_spec.rb +8 -9
- data/spec/unit/email_spec.rb +44 -44
- data/spec/unit/emoticon_spec.rb +57 -58
- data/spec/unit/encoding_spec.rb +35 -36
- data/spec/unit/is_carrier_spec.rb +49 -49
- data/spec/unit/mail_spec.rb +153 -143
- data/spec/unit/mobile/iphone_spec.rb +6 -7
- data/spec/unit/receive_mail_spec.rb +172 -173
- data/spec/unit/spec_helper.rb +6 -6
- data/spec/unit/util_spec.rb +125 -46
- data/spec/unit/valid_ip_spec.rb +35 -35
- data/spec/unit/variants_spec.rb +18 -19
- data/test/rails/overrides/Gemfile +54 -0
- data/test/rails/overrides/Gemfile.jpmobile +1 -2
- data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
- data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
- data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
- data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
- data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
- data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
- data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
- data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
- data/test/rails/overrides/autotest/discover.rb +2 -2
- data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
- data/test/rails/overrides/config/routes.rb +95 -2
- data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
- data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
- data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
- data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
- data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
- data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
- data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
- data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
- data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
- data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
- data/test/rails/overrides/spec/rails_helper.rb +1 -1
- data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
- data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
- data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
- data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
- data/test/sinatra/test/filter_test.rb +10 -11
- data/tools/e4u_conv.rb +0 -1
- metadata +18 -14
- data/README +0 -0
- 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,
|
3
|
+
describe Jpmobile::MobileCarrier, 'willcom' do
|
5
4
|
include Rack::Test::Methods
|
6
5
|
|
7
|
-
context
|
8
|
-
it
|
6
|
+
context '端末種別で' do
|
7
|
+
it 'WX310K が判別できること' do
|
9
8
|
res = Rack::MockRequest.env_for(
|
10
9
|
'http://jpmobile-rails.org/',
|
11
|
-
'HTTP_USER_AGENT' =>
|
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
|
20
|
+
it 'AH-H3001V が判別できること' do
|
21
21
|
res = Rack::MockRequest.env_for(
|
22
22
|
'http://jpmobile-rails.org/',
|
23
|
-
'HTTP_USER_AGENT' =>
|
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
|
34
|
-
it
|
34
|
+
context 'GPS で' do
|
35
|
+
it '緯度経度を取得できること' do
|
35
36
|
res = Rack::MockRequest.env_for(
|
36
37
|
'http://jpmobile-rails.org/',
|
37
|
-
'HTTP_USER_AGENT' =>
|
38
|
-
|
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
|
47
|
-
it
|
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' =>
|
51
|
-
|
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
|
60
|
+
it '正しくないIPアドレス空間からのアクセスを判断できること' do
|
58
61
|
res = Rack::MockRequest.env_for(
|
59
62
|
'http://jpmobile-rails.org/',
|
60
|
-
'HTTP_USER_AGENT' =>
|
61
|
-
|
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,
|
3
|
+
describe Jpmobile::MobileCarrier, 'Windows Phone' do
|
5
4
|
include Rack::Test::Methods
|
6
5
|
|
7
|
-
context
|
8
|
-
it
|
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)
|
data/spec/rack_helper.rb
CHANGED
@@ -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
|
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
|
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 :
|
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 ||
|
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 =
|
69
|
-
@request.session.session_id =
|
69
|
+
@request.host = 'www.example.jp'
|
70
|
+
@request.session.session_id = 'mysessionid'
|
70
71
|
end
|
71
72
|
include Jpmobile::Util
|
72
73
|
|
data/spec/spec_helper.rb
CHANGED
@@ -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
|
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
|
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
|
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 =
|
16
|
-
@mail.to =
|
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__)),
|
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
|
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
|
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
|
58
|
+
describe 'softbank' do
|
60
59
|
before(:each) do
|
61
60
|
inline_url = @inline_url
|
62
61
|
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
data/spec/unit/email_spec.rb
CHANGED
@@ -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'
|
6
|
-
['test@docomo.ne.jp'
|
7
|
-
['test@docomo.ne.jp.jp'
|
8
|
-
['a(--)l@ezweb.ne.jp'
|
9
|
-
['a(--)l@ezweb.ne.jp.jp'
|
10
|
-
['dadaea@pdx.ne.jp'
|
11
|
-
['dadaea@pdx.ne.jp.jp'
|
12
|
-
['xxxe@dj.pdx.ne.jp'
|
13
|
-
['xxxe@dj.pdx.ne.jp.jp'
|
14
|
-
['xxxe@willcom.com'
|
15
|
-
['xxxe@willcom.com.jp'
|
16
|
-
['oeeikx@softbank.ne.jp'
|
17
|
-
['oeeikx@softbank.ne.jp.jp'
|
18
|
-
['eaae@disney.ne.jp'
|
19
|
-
['eaae@disney.ne.jp.jp'
|
20
|
-
['iiiaa@r.vodafone.ne.jp'
|
21
|
-
['iiiaa@r.vodafone.ne.jp.jp'
|
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>'
|
31
|
-
['From: Jpmobile Rails <test@docomo.ne.jp>'
|
32
|
-
['From: test@docomo.ne.jp'
|
33
|
-
['From: Jpmobile Rails <test@docomo.ne.jp.jp>'
|
34
|
-
['From: Jpmobile Rails <a(--)l@ezweb.ne.jp>'
|
35
|
-
['From: a(--)l@ezweb.ne.jp'
|
36
|
-
['From: Jpmobile Rails <a(--)l@ezweb.ne.jp.jp>'
|
37
|
-
['From: Jpmobile Rails <dadaea@pdx.ne.jp>'
|
38
|
-
['From: Jpmobile Rails <dadaea@pdx.ne.jp.jp>'
|
39
|
-
['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp>'
|
40
|
-
['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp.jp>'
|
41
|
-
['From: Jpmobile Rails <xxxe@willcom.com>'
|
42
|
-
['From: Jpmobile Rails <xxxe@willcom.com.jp>'
|
43
|
-
['From: Jpmobile Rails <oeeikx@softbank.ne.jp>'
|
44
|
-
['From: oeeikx@softbank.ne.jp'
|
45
|
-
['From: Jpmobile Rails <oeeikx@softbank.ne.jp.jp>'
|
46
|
-
['From: Jpmobile Rails <eaae@disney.ne.jp>'
|
47
|
-
['From: Jpmobile Rails <eaae@disney.ne.jp.jp>'
|
48
|
-
['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp>'
|
49
|
-
['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp.jp>'
|
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
|
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
|
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
|
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
|
74
|
-
it
|
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
|
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
|
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
|
data/spec/unit/emoticon_spec.rb
CHANGED
@@ -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
|
8
|
-
context
|
9
|
-
it
|
10
|
-
expect(Jpmobile::Emoticon
|
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('')).to eq(sjis("\xf8\x9f"))
|
11
10
|
end
|
12
11
|
|
13
|
-
it
|
14
|
-
expect(Jpmobile::Emoticon
|
12
|
+
it 'in multiple convertion' do
|
13
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)).to eq(sjis("\xf8\x9f\xf8\xa0"))
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
|
-
context
|
19
|
-
it
|
20
|
-
expect(Jpmobile::Emoticon
|
17
|
+
context 'should convert unicodecr to au encoding' do
|
18
|
+
it 'when no options' do
|
19
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('')).to eq(sjis("\xf6\x59"))
|
21
20
|
end
|
22
21
|
end
|
23
22
|
|
24
|
-
context
|
25
|
-
it
|
26
|
-
expect(Jpmobile::Emoticon
|
23
|
+
context 'should convert unicodecr to softbank encoding' do
|
24
|
+
it 'when no opptions' do
|
25
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('')).to eq([0xe001].pack('U'))
|
27
26
|
end
|
28
27
|
|
29
|
-
it
|
30
|
-
expect(Jpmobile::Emoticon
|
28
|
+
it 'in multiple convertion' do
|
29
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
34
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
38
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
42
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
46
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('〓', 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(
|
50
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
54
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
58
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('', 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(
|
62
|
+
expect(Jpmobile::Emoticon.unicodecr_to_external('〓', Jpmobile::Emoticon::CONVERSION_TABLE_TO_GOOGLE_EMOTICON, false)).to eq('〓')
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
|
-
describe
|
68
|
-
it
|
66
|
+
describe 'unicodecr_to_utf8' do
|
67
|
+
it 'should convert unicodecr to internal utf8 encoding' do
|
69
68
|
# docomo codepoint
|
70
|
-
expect(Jpmobile::Emoticon
|
69
|
+
expect(Jpmobile::Emoticon.unicodecr_to_utf8('')).to eq(utf8("\356\230\276"))
|
71
70
|
# au codepoint
|
72
|
-
expect(Jpmobile::Emoticon
|
71
|
+
expect(Jpmobile::Emoticon.unicodecr_to_utf8('')).to eq(utf8("\356\222\201"))
|
73
72
|
# softbank codepoint
|
74
|
-
expect(Jpmobile::Emoticon
|
73
|
+
expect(Jpmobile::Emoticon.unicodecr_to_utf8('')).to eq(utf8("\xef\x80\x81"))
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
|
-
describe
|
79
|
-
it
|
77
|
+
describe 'utf8_to_unicodecr' do
|
78
|
+
it 'should convert utf8 encoding to unicodecr' do
|
80
79
|
# docomo codepoint
|
81
|
-
expect(Jpmobile::Emoticon
|
80
|
+
expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\356\230\276"))).to eq('')
|
82
81
|
# au codepoint
|
83
|
-
expect(Jpmobile::Emoticon
|
82
|
+
expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\356\222\201"))).to eq('')
|
84
83
|
# softbank codepoint
|
85
|
-
expect(Jpmobile::Emoticon
|
84
|
+
expect(Jpmobile::Emoticon.utf8_to_unicodecr(utf8("\xef\x80\x81"))).to eq('')
|
86
85
|
end
|
87
86
|
end
|
88
87
|
|
89
|
-
describe
|
90
|
-
it
|
91
|
-
expect(Jpmobile::Emoticon
|
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('')
|
92
91
|
end
|
93
92
|
|
94
|
-
it
|
95
|
-
expect(Jpmobile::Emoticon
|
93
|
+
it 'should convert au encoding to unicodecr' do
|
94
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_au(sjis("\xf6\x59"))).to eq('')
|
96
95
|
end
|
97
96
|
|
98
|
-
it
|
99
|
-
expect(Jpmobile::Emoticon
|
97
|
+
it 'should convert softbank encoding to unicodecr' do
|
98
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_softbank([0xe001].pack('U'))).to eq('')
|
100
99
|
end
|
101
100
|
|
102
|
-
it
|
103
|
-
expect(Jpmobile::Emoticon
|
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
|
107
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_unicode60("\342\230\200")).to eq('')
|
109
108
|
end
|
110
109
|
|
111
110
|
it 'should convert iPhone Unicode emoticon to multi SoftBank emoticons' do
|
112
|
-
expect(Jpmobile::Emoticon
|
111
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_unicode60("\342\233\205")).to eq(',')
|
113
112
|
end
|
114
113
|
|
115
114
|
it 'should not convert 〓' do
|
116
|
-
expect(Jpmobile::Emoticon
|
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
|
121
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_google("\363\276\200\200")).to eq('')
|
123
122
|
end
|
124
123
|
|
125
124
|
it 'should convert Android Google Unicode emoticon to multi Docomo emoticon' do
|
126
|
-
expect(Jpmobile::Emoticon
|
125
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_google("\363\276\200\217")).to eq('')
|
127
126
|
end
|
128
127
|
|
129
128
|
it 'should not convert 〓' do
|
130
|
-
expect(Jpmobile::Emoticon
|
129
|
+
expect(Jpmobile::Emoticon.external_to_unicodecr_google('〓')).to eq('〓')
|
131
130
|
end
|
132
131
|
end
|
133
132
|
end
|
134
133
|
|
135
|
-
context
|
136
|
-
describe
|
137
|
-
it
|
138
|
-
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis(
|
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
|
142
|
-
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis(
|
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
|
146
|
-
expect(Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis(
|
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
|
150
|
-
expect(Jpmobile::Emoticon.unicodecr_to_au_email(utf8_to_jis(
|
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('掲示板'))).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
|