jpmobile 7.0.4 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +2 -2
- data/.rubocop.yml +48 -3
- data/.ruby-version +1 -1
- data/Gemfile +1 -4
- data/Gemfile.lock +189 -160
- data/jpmobile.gemspec +2 -2
- data/lib/jpmobile/email.rb +1 -1
- data/lib/jpmobile/emoticon.rb +1 -2
- data/lib/jpmobile/fallback_view_selector.rb +1 -1
- data/lib/jpmobile/filter.rb +1 -1
- data/lib/jpmobile/helpers.rb +1 -1
- data/lib/jpmobile/hook_template_details_requested.rb +1 -1
- data/lib/jpmobile/mail.rb +23 -25
- data/lib/jpmobile/mailer.rb +5 -6
- data/lib/jpmobile/method_less_action_support.rb +3 -3
- data/lib/jpmobile/mobile/abstract_mobile.rb +8 -8
- data/lib/jpmobile/mobile/android.rb +1 -1
- data/lib/jpmobile/mobile/au.rb +2 -2
- data/lib/jpmobile/mobile/black_berry.rb +1 -1
- data/lib/jpmobile/mobile/ddipocket.rb +1 -1
- data/lib/jpmobile/mobile/docomo.rb +2 -2
- data/lib/jpmobile/mobile/emobile.rb +2 -2
- data/lib/jpmobile/mobile/ipad.rb +1 -1
- data/lib/jpmobile/mobile/iphone.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +2 -2
- data/lib/jpmobile/mobile/vodafone.rb +2 -2
- data/lib/jpmobile/mobile/willcom.rb +2 -2
- data/lib/jpmobile/mobile/windows_phone.rb +1 -1
- data/lib/jpmobile/path_set.rb +1 -1
- data/lib/jpmobile/rack/filter.rb +2 -0
- data/lib/jpmobile/resolver.rb +7 -4
- data/lib/jpmobile/session/active_record_store.rb +1 -1
- data/lib/jpmobile/session/mem_cache_store.rb +1 -1
- data/lib/jpmobile/template_details.rb +1 -1
- data/lib/jpmobile/trans_sid.rb +1 -1
- data/lib/jpmobile/version.rb +1 -1
- data/spec/rack_helper.rb +0 -1
- data/spec/unit/email_spec.rb +2 -2
- data/spec/unit/is_carrier_spec.rb +1 -1
- data/spec/unit/receive_mail_spec.rb +1 -1
- data/spec/unit/util_spec.rb +0 -1
- data/test/rails/overrides/spec/controllers/hankaku_filter_controller_spec.rb +1 -1
- data/test/rails/overrides/spec/controllers/helpers_spec.rb +1 -1
- data/test/rails/overrides/spec/rails_helper.rb +3 -1
- data/test/rails/overrides/spec/requests/method_less_action_support_spec.rb +4 -3
- data/test/rails/overrides/spec/requests/pc_spec.rb +3 -2
- data/test/rails/overrides/spec/system_helper.rb +1 -1
- data/test/sinatra/guestbook.rb +1 -1
- metadata +6 -9
- data/tools/generate_au_emoticon_table.rb +0 -34
- data/tools/generate_docomo_emoticon_table.rb +0 -33
- data/tools/generate_softbank_emoticon_table.rb +0 -31
data/lib/jpmobile/mail.rb
CHANGED
@@ -2,14 +2,6 @@ require 'mail'
|
|
2
2
|
|
3
3
|
module Mail
|
4
4
|
# encoding patch
|
5
|
-
Ruby19.class_eval do
|
6
|
-
# change encoding
|
7
|
-
def self.b_value_encode(str, encoding = nil)
|
8
|
-
str = Jpmobile::Util.encode(str, encoding.to_s)
|
9
|
-
[Ruby19.encode_base64(str), encoding]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
5
|
class Message
|
14
6
|
attr_reader :mobile
|
15
7
|
|
@@ -55,7 +47,9 @@ module Mail
|
|
55
47
|
|
56
48
|
def parse_message_with_jpmobile
|
57
49
|
_crlf_raw_source = raw_source.encode(raw_source.encoding, universal_newline: true).encode!(raw_source.encoding, crlf_newline: true)
|
58
|
-
header_part, body_part = _crlf_raw_source.lstrip.split(
|
50
|
+
header_part, body_part = _crlf_raw_source.lstrip.split(
|
51
|
+
/#{Constants::CRLF}#{Constants::CRLF}|#{Constants::CRLF}#{Constants::WSP}*#{Constants::CRLF}(?!#{Constants::WSP})/mo, 2
|
52
|
+
)
|
59
53
|
# header_part, body_part = raw_source.lstrip.split(HEADER_SEPARATOR, 2)
|
60
54
|
|
61
55
|
self.header = header_part
|
@@ -202,7 +196,7 @@ module Mail
|
|
202
196
|
end
|
203
197
|
|
204
198
|
unless self.header['Content-Type'].sub_type == 'mixed'
|
205
|
-
self.header['Content-Type'] = self.content_type.gsub(/#{self.header[
|
199
|
+
self.header['Content-Type'] = self.content_type.gsub(/#{self.header["Content-Type"].sub_type}/, 'mixed')
|
206
200
|
end
|
207
201
|
self.parts.clear
|
208
202
|
self.body = nil
|
@@ -277,9 +271,9 @@ module Mail
|
|
277
271
|
end
|
278
272
|
|
279
273
|
def parse_message_with_jpmobile
|
280
|
-
header_part, body_part = raw_source.split(/#{CRLF}#{WSP}*#{CRLF}/mo, 2)
|
274
|
+
header_part, body_part = raw_source.split(/#{Constants::CRLF}#{Constants::WSP}*#{Constants::CRLF}/mo, 2)
|
281
275
|
|
282
|
-
self.header = if header_part && header_part.match(HEADER_LINE)
|
276
|
+
self.header = if header_part && header_part.match(Constants::HEADER_LINE)
|
283
277
|
header_part
|
284
278
|
else
|
285
279
|
"Content-Type: text/plain\r\n"
|
@@ -321,7 +315,7 @@ module Mail
|
|
321
315
|
end
|
322
316
|
Jpmobile::Util.set_encoding(_raw_source, @mobile.mail_charset(@charset))
|
323
317
|
when /quoted-printable/
|
324
|
-
Jpmobile::Util.set_encoding([@mobile.to_mail_body(@raw_source)].pack('M').gsub(
|
318
|
+
Jpmobile::Util.set_encoding([@mobile.to_mail_body(@raw_source)].pack('M').gsub("\n", "\r\n"), @mobile.mail_charset(@charset))
|
325
319
|
else
|
326
320
|
@mobile.to_mail_body(Jpmobile::Util.force_encode(@raw_source, nil, Jpmobile::Util::UTF8))
|
327
321
|
end
|
@@ -429,6 +423,10 @@ module Mail
|
|
429
423
|
end
|
430
424
|
end
|
431
425
|
|
426
|
+
class NamedUnstructuredField
|
427
|
+
attr_accessor :mobile
|
428
|
+
end
|
429
|
+
|
432
430
|
class UnstructuredField
|
433
431
|
attr_accessor :mobile
|
434
432
|
end
|
@@ -440,7 +438,7 @@ module Mail
|
|
440
438
|
end
|
441
439
|
|
442
440
|
# for subject
|
443
|
-
class SubjectField <
|
441
|
+
class SubjectField < NamedUnstructuredField
|
444
442
|
def encoded_with_jpmobile
|
445
443
|
if @mobile
|
446
444
|
if @mobile.to_mail_subject_encoded?(value)
|
@@ -482,7 +480,7 @@ module Mail
|
|
482
480
|
match = str.match(/=\?(.+)?\?[Bb]\?(.*)\?=/m)
|
483
481
|
if match
|
484
482
|
charset = match[1]
|
485
|
-
str =
|
483
|
+
str = Utilities.decode_base64(match[2])
|
486
484
|
@mobile.decode_transfer_encoding(str, charset)
|
487
485
|
else
|
488
486
|
str
|
@@ -494,7 +492,7 @@ module Mail
|
|
494
492
|
attr_accessor :mobile
|
495
493
|
end
|
496
494
|
|
497
|
-
class FromField <
|
495
|
+
class FromField < CommonAddressField
|
498
496
|
def initialize_with_jpmobile(value = nil, charset = 'utf-8')
|
499
497
|
@jpmobile_raw_text = value
|
500
498
|
initialize_without_jpmobile(value, charset)
|
@@ -516,14 +514,14 @@ module Mail
|
|
516
514
|
if @mobile
|
517
515
|
self.charset = @mobile.mail_charset
|
518
516
|
|
519
|
-
_value =
|
517
|
+
_value = element.addresses.map {|_a|
|
520
518
|
if Utilities.blank?(_a.display_name) || _a.display_name.ascii_only?
|
521
519
|
_a.to_s
|
522
520
|
else
|
523
521
|
"#{@mobile.to_mail_subject(_a.display_name)} <#{_a.address}>"
|
524
522
|
end
|
525
523
|
}.join(', ')
|
526
|
-
@
|
524
|
+
@element = AddressList.new(_value)
|
527
525
|
end
|
528
526
|
|
529
527
|
encoded_without_jpmobile
|
@@ -533,7 +531,7 @@ module Mail
|
|
533
531
|
alias_method :encoded, :encoded_with_jpmobile
|
534
532
|
end
|
535
533
|
|
536
|
-
class ToField <
|
534
|
+
class ToField < CommonAddressField
|
537
535
|
def initialize_with_jpmobile(value = nil, charset = 'utf-8')
|
538
536
|
@jpmobile_raw_text = value
|
539
537
|
initialize_without_jpmobile(value, charset)
|
@@ -555,14 +553,14 @@ module Mail
|
|
555
553
|
if @mobile
|
556
554
|
self.charset = @mobile.mail_charset
|
557
555
|
|
558
|
-
_value =
|
556
|
+
_value = element.addresses.map {|_a|
|
559
557
|
if Utilities.blank?(_a.display_name) || _a.display_name.ascii_only?
|
560
558
|
_a.to_s
|
561
559
|
else
|
562
560
|
"#{@mobile.to_mail_subject(_a.display_name)} <#{_a.address}>"
|
563
561
|
end
|
564
562
|
}.join(', ')
|
565
|
-
@
|
563
|
+
@element = AddressList.new(_value)
|
566
564
|
end
|
567
565
|
|
568
566
|
encoded_without_jpmobile
|
@@ -596,7 +594,7 @@ module Mail
|
|
596
594
|
class ContentTypeElement # :nodoc:
|
597
595
|
def initialize_with_jpmobile(string)
|
598
596
|
if (m = string.match(/\A(.*?)(name|filename)=("|')(.+)("|')(.*?)\z/)) &&
|
599
|
-
m[4].each_byte.detect {|b|
|
597
|
+
m[4].each_byte.detect {|b| b == 0 || b > 127 }
|
600
598
|
name = [m[4]].pack('m').strip
|
601
599
|
string = "#{m[1]}#{m[2]}=#{m[3]}#{name}#{m[5]}#{m[6]}"
|
602
600
|
end
|
@@ -610,7 +608,7 @@ module Mail
|
|
610
608
|
class ContentDispositionElement # :nodoc:
|
611
609
|
def initialize_with_jpmobile(string)
|
612
610
|
if (m = string.match(/\A(.*?)(name|filename)=("|')(.+)("|')(.*?)\z/)) &&
|
613
|
-
m[4].each_byte.detect {|b|
|
611
|
+
m[4].each_byte.detect {|b| b == 0 || b > 127 }
|
614
612
|
name = [m[4]].pack('m').strip
|
615
613
|
string = "#{m[1]}#{m[2]}=#{m[3]}#{name}#{m[5]}#{m[6]}"
|
616
614
|
end
|
@@ -624,7 +622,7 @@ module Mail
|
|
624
622
|
class ContentLocationElement # :nodoc:
|
625
623
|
def initialize_with_jpmobile(string)
|
626
624
|
if (m = string.match(/\A(.*?)(name|filename)=("|')(.+)("|')(.*?)\z/)) &&
|
627
|
-
m[4].each_byte.detect {|b|
|
625
|
+
m[4].each_byte.detect {|b| b == 0 || b > 127 }
|
628
626
|
name = [m[4]].pack('m').strip
|
629
627
|
string = "#{m[1]}#{m[2]}=#{m[3]}#{name}#{m[5]}#{m[6]}"
|
630
628
|
end
|
@@ -647,7 +645,7 @@ module Mail
|
|
647
645
|
end
|
648
646
|
|
649
647
|
IO.popen("#{path} #{arguments} #{destinations}", 'w+') do |io|
|
650
|
-
io.puts encoded_mail.gsub(
|
648
|
+
io.puts encoded_mail.gsub("\r\r\n", "\n").to_lf
|
651
649
|
io.flush
|
652
650
|
end
|
653
651
|
end
|
data/lib/jpmobile/mailer.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'jpmobile/mail'
|
2
2
|
require 'jpmobile/lookup_context'
|
3
3
|
|
4
|
-
Jpmobile::Email.japanese_mail_address_regexp =
|
4
|
+
Jpmobile::Email.japanese_mail_address_regexp = /\.jp(?:[^a-zA-Z.-]|$)/
|
5
5
|
|
6
6
|
module Jpmobile
|
7
7
|
module Mailer
|
8
8
|
class Base < ActionMailer::Base
|
9
|
-
self.
|
10
|
-
self.view_paths.unshift(Jpmobile::Resolver.new(File.join(::Rails.root, 'app/views')))
|
9
|
+
self.prepend_view_path(Jpmobile::Resolver.new(File.join(::Rails.root, 'app/views')))
|
11
10
|
|
12
|
-
def mail(headers = {}, &
|
11
|
+
def mail(headers = {}, &)
|
13
12
|
tos = headers[:to] || self.default_params[:to]
|
14
13
|
tos = tos.split(',')
|
15
14
|
|
@@ -24,7 +23,7 @@ module Jpmobile
|
|
24
23
|
|
25
24
|
@mobile.decorated = headers.delete(:decorated)
|
26
25
|
|
27
|
-
m = super
|
26
|
+
m = super
|
28
27
|
|
29
28
|
m.mobile = @mobile
|
30
29
|
|
@@ -40,7 +39,7 @@ module Jpmobile
|
|
40
39
|
def set_payload_for_mail(payload, mail) # :nodoc:
|
41
40
|
super
|
42
41
|
|
43
|
-
payload[:mail] = Jpmobile::Util.ascii_8bit(mail.encoded).gsub(
|
42
|
+
payload[:mail] = Jpmobile::Util.ascii_8bit(mail.encoded).gsub("\r\n", "\n")
|
44
43
|
end
|
45
44
|
end
|
46
45
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Jpmobile
|
2
2
|
module MethodLessActionSupport
|
3
|
-
def template_exists?(
|
3
|
+
def template_exists?(*, **kwargs, &)
|
4
4
|
super(
|
5
|
-
|
5
|
+
*,
|
6
6
|
**kwargs.reverse_merge(mobile: request.mobile&.variants || []),
|
7
|
-
&
|
7
|
+
&
|
8
8
|
)
|
9
9
|
end
|
10
10
|
end
|
@@ -96,11 +96,11 @@ module Jpmobile::Mobile
|
|
96
96
|
|
97
97
|
@_variants = self.class.ancestors.select {|c| c.to_s =~ /^Jpmobile/ && c.to_s !~ /Emoticon/ }.map do |klass|
|
98
98
|
klass = klass.to_s.
|
99
|
-
gsub(
|
100
|
-
gsub(
|
101
|
-
gsub(
|
102
|
-
gsub(
|
103
|
-
gsub(
|
99
|
+
gsub('Jpmobile::', '').
|
100
|
+
gsub('AbstractMobile::', '').
|
101
|
+
gsub('Mobile::SmartPhone', 'smart_phone').
|
102
|
+
gsub('Mobile::Tablet', 'tablet').
|
103
|
+
gsub('::', '_').
|
104
104
|
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
105
105
|
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
106
106
|
downcase
|
@@ -108,9 +108,9 @@ module Jpmobile::Mobile
|
|
108
108
|
end
|
109
109
|
|
110
110
|
if @_variants.include?('tablet')
|
111
|
-
@_variants = @_variants.reject {|v| v == 'mobile' }.map {|v| v.gsub(
|
111
|
+
@_variants = @_variants.reject {|v| v == 'mobile' }.map {|v| v.gsub('mobile_', 'tablet_') }
|
112
112
|
elsif @_variants.include?('smart_phone')
|
113
|
-
@_variants = @_variants.reject {|v| v == 'mobile' }.map {|v| v.gsub(
|
113
|
+
@_variants = @_variants.reject {|v| v == 'mobile' }.map {|v| v.gsub('mobile_', 'smart_phone_') }
|
114
114
|
end
|
115
115
|
|
116
116
|
@_variants || []
|
@@ -253,7 +253,7 @@ module Jpmobile::Mobile
|
|
253
253
|
carrier_class = Jpmobile::Mobile.const_get(carrier)
|
254
254
|
next if carrier_class == self
|
255
255
|
|
256
|
-
define_method "#{carrier.downcase}?" do
|
256
|
+
define_method :"#{carrier.downcase}?" do
|
257
257
|
self.is_a?(carrier_class)
|
258
258
|
end
|
259
259
|
end
|
data/lib/jpmobile/mobile/au.rb
CHANGED
@@ -6,9 +6,9 @@ module Jpmobile::Mobile
|
|
6
6
|
class Au < AbstractMobile
|
7
7
|
# 対応するUser-Agentの正規表現
|
8
8
|
# User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
|
9
|
-
USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }
|
9
|
+
USER_AGENT_REGEXP = %r{^(?:KDDI|UP.Browser/.+?)-(.+?) }
|
10
10
|
# 対応するメールアドレスの正規表現
|
11
|
-
MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp
|
11
|
+
MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/
|
12
12
|
# 簡易位置情報取得に対応していないデバイスID
|
13
13
|
# http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
|
14
14
|
LOCATION_UNSUPPORTED_DEVICE_ID = %w[PT21 TS25 KCTE TST9 KCU1 SYT5 KCTD TST8 TST7 KCTC SYT4 KCTB KCTA TST6 KCT9 TST5 TST4 KCT8 SYT3 KCT7 MIT1 MAT3 KCT6 TST3 KCT5 KCT4 SYT2 MAT1 MAT2 TST2 KCT3 KCT2 KCT1 TST1 SYT1].freeze
|
@@ -4,7 +4,7 @@ module Jpmobile::Mobile
|
|
4
4
|
# スーパクラスはWillcom。
|
5
5
|
class Ddipocket < Willcom
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}
|
7
|
+
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(DDIPOCKET}
|
8
8
|
|
9
9
|
MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
|
10
10
|
end
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# ==DoCoMo携帯電話
|
5
5
|
class Docomo < AbstractMobile
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = /^DoCoMo
|
7
|
+
USER_AGENT_REGEXP = /^DoCoMo/
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp/
|
10
10
|
# メールのデフォルトのcharset
|
11
11
|
MAIL_CHARSET = 'Shift_JIS'.freeze
|
12
12
|
# テキスト部分の content-transfer-encoding
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Jpmobile::Mobile
|
4
4
|
# ==EMOBILE携帯電話
|
5
5
|
class Emobile < AbstractMobile
|
6
|
-
USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}
|
6
|
+
USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}
|
7
7
|
# 対応するメールアドレスの正規表現
|
8
|
-
MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp
|
8
|
+
MAIL_ADDRESS_REGEXP = /.+@emnet\.ne\.jp/
|
9
9
|
# EMnet対応端末から通知されるユニークなユーザIDを取得する。
|
10
10
|
def em_uid
|
11
11
|
@request.env['HTTP_X_EM_UID']
|
data/lib/jpmobile/mobile/ipad.rb
CHANGED
@@ -5,9 +5,9 @@ module Jpmobile::Mobile
|
|
5
5
|
# Vodafoneのスーパクラス。
|
6
6
|
class Softbank < AbstractMobile
|
7
7
|
# 対応するuser-agentの正規表現
|
8
|
-
USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)
|
8
|
+
USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)/
|
9
9
|
# 対応するメールアドレスの正規表現 ディズニーモバイル対応
|
10
|
-
MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)
|
10
|
+
MAIL_ADDRESS_REGEXP = /.+@(?:softbank\.ne\.jp|disney\.ne\.jp)/
|
11
11
|
# メールのデフォルトのcharset
|
12
12
|
MAIL_CHARSET = 'Shift_JIS'.freeze
|
13
13
|
# テキスト部分の content-transfer-encoding
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# スーパクラスはSoftbank。
|
5
5
|
class Vodafone < Softbank
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)
|
7
|
+
USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/
|
10
10
|
|
11
11
|
# cookieに対応しているか?
|
12
12
|
def supports_cookie?
|
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
|
|
4
4
|
# Ddipocketのスーパクラス。
|
5
5
|
class Willcom < AbstractMobile
|
6
6
|
# 対応するUser-Agentの正規表現
|
7
|
-
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}
|
7
|
+
USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}
|
8
8
|
# 対応するメールアドレスの正規表現
|
9
|
-
MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)
|
9
|
+
MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/
|
10
10
|
|
11
11
|
# 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
|
12
12
|
def position
|
data/lib/jpmobile/path_set.rb
CHANGED
data/lib/jpmobile/rack/filter.rb
CHANGED
@@ -43,11 +43,13 @@ module Jpmobile
|
|
43
43
|
if response.respond_to?(:to_str)
|
44
44
|
response.to_str
|
45
45
|
elsif response.respond_to?(:each)
|
46
|
+
# rubocop:disable Style/MapIntoArray
|
46
47
|
body = []
|
47
48
|
response.each do |part|
|
48
49
|
body << response_to_body(part)
|
49
50
|
end
|
50
51
|
body.join("\n")
|
52
|
+
# rubocop:enable Style/MapIntoArray
|
51
53
|
else
|
52
54
|
body
|
53
55
|
end
|
data/lib/jpmobile/resolver.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jpmobile
|
2
2
|
class Resolver < ::ActionView::FileSystemResolver
|
3
3
|
def initialize(path)
|
4
|
-
super
|
4
|
+
super
|
5
5
|
|
6
6
|
@path_parser = Jpmobile::Resolver::PathParser.new
|
7
7
|
end
|
@@ -14,10 +14,13 @@ module Jpmobile
|
|
14
14
|
|
15
15
|
class PathParser < ::ActionView::Resolver::PathParser
|
16
16
|
def build_path_regex
|
17
|
-
handlers = ::ActionView::Template::Handlers.extensions.map
|
18
|
-
formats = ::ActionView::Template::Types.symbols.map
|
19
|
-
|
17
|
+
handlers = Regexp.union(::ActionView::Template::Handlers.extensions.map(&:to_s))
|
18
|
+
formats = Regexp.union(::ActionView::Template::Types.symbols.map(&:to_s))
|
19
|
+
available_locales = I18n.available_locales.map(&:to_s)
|
20
|
+
regular_locales = [/[a-z]{2}(?:[-_][A-Z]{2})?/]
|
21
|
+
locales = Regexp.union(available_locales + regular_locales)
|
20
22
|
variants = '[^.]*'
|
23
|
+
|
21
24
|
mobile = Jpmobile::Mobile.all_variants.map {|x| Regexp.escape(x) }.join('|')
|
22
25
|
|
23
26
|
%r{
|
@@ -28,7 +28,7 @@ module Jpmobile
|
|
28
28
|
attr_reader :mobile, :mobile_idx
|
29
29
|
|
30
30
|
def initialize(locale:, handlers:, formats:, variants:, mobile:)
|
31
|
-
super(locale
|
31
|
+
super(locale:, handlers:, formats:, variants:)
|
32
32
|
|
33
33
|
@mobile = mobile.map(&:to_sym)
|
34
34
|
@mobile_idx = build_idx_hash(mobile)
|
data/lib/jpmobile/trans_sid.rb
CHANGED
data/lib/jpmobile/version.rb
CHANGED
data/spec/rack_helper.rb
CHANGED
data/spec/unit/email_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe 'Jpmobile::Email' do
|
|
56
56
|
|
57
57
|
describe 'japanese_mail_address_regexp' do
|
58
58
|
before do
|
59
|
-
Jpmobile::Email.japanese_mail_address_regexp =
|
59
|
+
Jpmobile::Email.japanese_mail_address_regexp = /\.jp(?:[^a-zA-Z.-]|$)/
|
60
60
|
end
|
61
61
|
|
62
62
|
it '#detect_from_mail_header should return Jpmobile::Mobile::AbstractMobile when the header contains .jp address' do
|
@@ -80,7 +80,7 @@ describe 'Jpmobile::Email' do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it 'return nil when image/jpeg; name="20098calendar01.jpg"' do
|
83
|
-
expect(Jpmobile::Email.convertable?('image/jpeg; name="20098calendar01.jpg"')).to
|
83
|
+
expect(Jpmobile::Email.convertable?('image/jpeg; name="20098calendar01.jpg"')).to be_falsy
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -59,7 +59,7 @@ describe 'Jpmobile::Mobile' do
|
|
59
59
|
[%w[Ddipocket ddipocket], true],
|
60
60
|
].each do |carrier, expected|
|
61
61
|
it "#{carrier.first}##{carrier.last}? should be return #{expected}" do
|
62
|
-
expect(Jpmobile::Mobile.const_get(carrier.first).new({}, {}).__send__("#{carrier.last}?")).to eq(expected)
|
62
|
+
expect(Jpmobile::Mobile.const_get(carrier.first).new({}, {}).__send__(:"#{carrier.last}?")).to eq(expected)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -7,7 +7,7 @@ describe 'Jpmobile::Mail#receive' do
|
|
7
7
|
|
8
8
|
before(:each) do
|
9
9
|
@to = 'info@jpmobile-rails.org'
|
10
|
-
Jpmobile::Email.japanese_mail_address_regexp =
|
10
|
+
Jpmobile::Email.japanese_mail_address_regexp = /\.jp[^a-zA-Z.-]/
|
11
11
|
end
|
12
12
|
|
13
13
|
describe 'PC mail' do
|
data/spec/unit/util_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe HankakuFilterController, type: :controller do
|
|
6
6
|
|
7
7
|
it 'should be successful' do
|
8
8
|
request.user_agent = 'DoCoMo/2.0 P05C(c500;TB;W24H16)'
|
9
|
-
get
|
9
|
+
get('index', params:)
|
10
10
|
expect(response).to be_successful
|
11
11
|
expect(request.mobile?).to be_truthy
|
12
12
|
end
|
@@ -9,7 +9,7 @@ describe LinksController, type: :controller do
|
|
9
9
|
def get_href_and_texts(str)
|
10
10
|
results = []
|
11
11
|
(Nokogiri::HTML.parse(str) / 'a').each do |link|
|
12
|
-
path, query = link['href'].split(
|
12
|
+
path, query = link['href'].split('?', 2)
|
13
13
|
params = query.nil? ? nil : Rack::Utils.parse_query(query)
|
14
14
|
results << [link.inner_html, link.attributes, path, params]
|
15
15
|
end
|
@@ -28,7 +28,9 @@ ActiveRecord::Migration.maintain_test_schema!
|
|
28
28
|
|
29
29
|
RSpec.configure do |config|
|
30
30
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
31
|
-
config.
|
31
|
+
config.fixture_paths = [
|
32
|
+
"#{Rails.root}/spec/fixtures",
|
33
|
+
]
|
32
34
|
|
33
35
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
34
36
|
# examples within a transaction, remove the following line or assign false
|
@@ -2,7 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe 'Method-less mobile template only action', type: :request do
|
4
4
|
subject do
|
5
|
-
get '/method_less_action_support', headers:
|
5
|
+
get '/method_less_action_support', headers:
|
6
6
|
end
|
7
7
|
|
8
8
|
let(:headers) do
|
@@ -21,8 +21,9 @@ describe 'Method-less mobile template only action', type: :request do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
context 'when accessed with non-mobile User-Agent' do
|
24
|
-
it '
|
25
|
-
|
24
|
+
it 'retuens 404 status' do
|
25
|
+
subject
|
26
|
+
expect(response).to have_http_status(404)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -19,8 +19,9 @@ describe 'PCからのアクセスの場合', type: :request do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
context 'routesが存在しない場合' do
|
22
|
-
it '
|
23
|
-
|
22
|
+
it '404を返す' do
|
23
|
+
get '/not_exist', params: {}, env: @headers
|
24
|
+
expect(response).to have_http_status(404)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|