jpmobile 1.0.0.pre.3 → 1.0.0.pre.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -3
- data/VERSION.yml +1 -1
- data/lib/jpmobile/mobile/abstract_mobile.rb +3 -1
- data/lib/jpmobile/util.rb +27 -0
- data/spec/unit/mail_spec.rb +24 -16
- data/spec/unit/util_spec.rb +25 -0
- data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +3 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +27 -0
- metadata +5 -5
data/Gemfile
CHANGED
@@ -2,9 +2,9 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
group :development, :test do
|
4
4
|
gem 'jeweler'
|
5
|
-
gem 'rails', '>= 3.0.
|
6
|
-
gem 'rspec', '>= 2.
|
7
|
-
gem 'rspec-rails', '>= 2.
|
5
|
+
gem 'rails', '>= 3.0.7'
|
6
|
+
gem 'rspec', '>= 2.5.0'
|
7
|
+
gem 'rspec-rails', '>= 2.5.0'
|
8
8
|
gem 'webrat'
|
9
9
|
gem 'geokit'
|
10
10
|
gem 'sqlite3-ruby'
|
data/VERSION.yml
CHANGED
@@ -94,7 +94,9 @@ module Jpmobile::Mobile
|
|
94
94
|
|
95
95
|
# メール送信用
|
96
96
|
def to_mail_subject(str)
|
97
|
-
|
97
|
+
Jpmobile::Util.fold_text(Jpmobile::Emoticon.unicodecr_to_utf8(str)).
|
98
|
+
map{|text| "=?#{mail_charset}?B?" + [to_mail_encoding(text)].pack('m').strip + "?=" }.
|
99
|
+
join("\n\s")
|
98
100
|
end
|
99
101
|
def to_mail_body(str)
|
100
102
|
to_mail_encoding(str)
|
data/lib/jpmobile/util.rb
CHANGED
@@ -339,5 +339,32 @@ module Jpmobile
|
|
339
339
|
def jis?(str)
|
340
340
|
detect_encoding(str) == JIS
|
341
341
|
end
|
342
|
+
|
343
|
+
def fold_text(str, size = 15)
|
344
|
+
folded_texts = []
|
345
|
+
|
346
|
+
while texts = split_text(str, size) and texts.first.size != 0
|
347
|
+
folded_texts << texts.first
|
348
|
+
str = texts.last
|
349
|
+
end
|
350
|
+
|
351
|
+
folded_texts
|
352
|
+
end
|
353
|
+
|
354
|
+
def split_text(str, size = 15)
|
355
|
+
return nil if str.nil? or str == ''
|
356
|
+
|
357
|
+
if Object.const_defined?(:Encoding)
|
358
|
+
[str[0..(size-1)], str[size..-1]]
|
359
|
+
else
|
360
|
+
str = str.split(//u)
|
361
|
+
text = str[0..(size-1)]
|
362
|
+
text = text.join if text
|
363
|
+
remain = str[size..-1]
|
364
|
+
remain = remain.join if remain
|
365
|
+
[text, remain]
|
366
|
+
end
|
367
|
+
|
368
|
+
end
|
342
369
|
end
|
343
370
|
end
|
data/spec/unit/mail_spec.rb
CHANGED
@@ -131,10 +131,12 @@ describe "Jpmobile::Mail" do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should contain encoded subject" do
|
134
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
135
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
136
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
137
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
134
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?lb6O0I3Ml3CJnpXlgtaCzIKokFyNnoLdkL2CyYKg?="))
|
135
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?guiCqoLGgqSCsoK0gqKC3IK3gsaMvoKigr2CooLG?="))
|
136
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?grGC64K+gqqCu4Kkgs2KyJJQgsmCzZWojpaCzYle?="))
|
137
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?gs6CyIKigrGCxoLwkFOCtYLEgqiCooLEguCC54Ki?="))
|
138
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?gr2CooLGi+qMvoLwkuaCt4LpjMyCyZW+jtCCzYjb?="))
|
139
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?jp2CtYLEgqKC6YLMgsWCtw==?="))
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
@@ -146,10 +148,12 @@ describe "Jpmobile::Mail" do
|
|
146
148
|
end
|
147
149
|
|
148
150
|
it "should contain encoded subject" do
|
149
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
150
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
151
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
152
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
151
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCSkA8UjpOTVExfkpnJFgkTiQqPz05fiRfQD8kSyQiGyhC?=")))
|
152
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJGokLCRIJCYkNCQ2JCQkXiQ5JEg4QCQkJD8kJCRIGyhC?=")))
|
153
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJDMkbSRAJCwkPSQmJE80SkMxJEskT0oqO3YkTzE/GyhC?=")))
|
154
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJFAkSiQkJDMkSCRyPzQkNyRGJCokJCRGJGIkaSQkGyhC?=")))
|
155
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJD8kJCRINmw4QCRyRGgkOSRrOE4kS0pAPFIkTzBdGyhC?=")))
|
156
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCO30kNyRGJCQkayROJEckORsoQg==?=")))
|
153
157
|
end
|
154
158
|
end
|
155
159
|
|
@@ -161,10 +165,12 @@ describe "Jpmobile::Mail" do
|
|
161
165
|
end
|
162
166
|
|
163
167
|
it "should contain encoded subject" do
|
164
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
165
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
166
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
167
|
-
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?
|
168
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?lb6O0I3Ml3CJnpXlgtaCzIKokFyNnoLdkL2CyYKg?="))
|
169
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?guiCqoLGgqSCsoK0gqKC3IK3gsaMvoKigr2CooLG?="))
|
170
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?grGC64K+gqqCu4Kkgs2KyJJQgsmCzZWojpaCzYle?="))
|
171
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?gs6CyIKigrGCxoLwkFOCtYLEgqiCooLEguCC54Ki?="))
|
172
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?gr2CooLGi+qMvoLwkuaCt4LpjMyCyZW+jtCCzYjb?="))
|
173
|
+
@mail.to_s.should match(sjis_regexp("=?Shift_JIS?B?jp2CtYLEgqKC6YLMgsWCtw==?="))
|
168
174
|
end
|
169
175
|
end
|
170
176
|
|
@@ -177,10 +183,12 @@ describe "Jpmobile::Mail" do
|
|
177
183
|
|
178
184
|
context "to_s" do
|
179
185
|
it "should contain encoded subject" do
|
180
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
181
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
182
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
183
|
-
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?
|
186
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCSkA8UjpOTVExfkpnJFgkTiQqPz05fiRfQD8kSyQiGyhC?=")))
|
187
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJGokLCRIJCYkNCQ2JCQkXiQ5JEg4QCQkJD8kJCRIGyhC?=")))
|
188
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJDMkbSRAJCwkPSQmJE80SkMxJEskT0oqO3YkTzE/GyhC?=")))
|
189
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJFAkSiQkJDMkSCRyPzQkNyRGJCokJCRGJGIkaSQkGyhC?=")))
|
190
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCJD8kJCRINmw4QCRyRGgkOSRrOE4kS0pAPFIkTzBdGyhC?=")))
|
191
|
+
ascii_8bit(@mail.to_s).should match(Regexp.compile(Regexp.escape("=?ISO-2022-JP?B?GyRCO30kNyRGJCQkayROJEckORsoQg==?=")))
|
184
192
|
end
|
185
193
|
end
|
186
194
|
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -58,4 +58,29 @@ describe Jpmobile::Util, ".deep_apply" do
|
|
58
58
|
jis_string_regexp.match(ascii_8bit(utf8_to_jis("abcしからずんばこじをえずdef"))).should_not be_nil
|
59
59
|
jis_to_utf8(jis("\x1b\x24\x42#{$1}\x1b\x28\x42")).should == "しからずんばこじをえず"
|
60
60
|
end
|
61
|
+
|
62
|
+
it "fold_textでUTF-8の日本語文字列が指定文字数で折り返された配列で返ること" do
|
63
|
+
fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15).should == [
|
64
|
+
'長い日本語の題名で折り返される',
|
65
|
+
'かようにするには事前に分割して',
|
66
|
+
'いないとダメなことがわかりまし',
|
67
|
+
'たよ'
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "fold_textでUTF-8の短い文字列は折り返されないこと" do
|
72
|
+
fold_text('短い', 15).should == ['短い']
|
73
|
+
end
|
74
|
+
|
75
|
+
it "split_textでUTF-8の日本語文字列が指定文字数で2つに分割されること" do
|
76
|
+
split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15).should == [
|
77
|
+
'長い日本語の題名で折り返される',
|
78
|
+
'かようにするには事前に分割していないとダメなことがわかりましたよ'
|
79
|
+
]
|
80
|
+
end
|
81
|
+
|
82
|
+
it "split_textでnilかblankの場合はnilが返ること" do
|
83
|
+
split_text('', 15).should be_nil
|
84
|
+
split_text(nil, 15).should be_nil
|
85
|
+
end
|
61
86
|
end
|
@@ -4,4 +4,4 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
# Make sure the secret is at least 30 characters and all random,
|
6
6
|
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
-
RailsRoot::Application.config.secret_token = '
|
7
|
+
RailsRoot::Application.config.secret_token = '6773d9dbfee1e199c5f7f1cb8c7fff442792f70e3051397a9535b04258bafb009a0a566b0fe0d10a67d64aefaf7396b675ea386893c634411df09272f1f978d4'
|
@@ -94,7 +94,9 @@ module Jpmobile::Mobile
|
|
94
94
|
|
95
95
|
# メール送信用
|
96
96
|
def to_mail_subject(str)
|
97
|
-
|
97
|
+
Jpmobile::Util.fold_text(Jpmobile::Emoticon.unicodecr_to_utf8(str)).
|
98
|
+
map{|text| "=?#{mail_charset}?B?" + [to_mail_encoding(text)].pack('m').strip + "?=" }.
|
99
|
+
join("\n\s")
|
98
100
|
end
|
99
101
|
def to_mail_body(str)
|
100
102
|
to_mail_encoding(str)
|
@@ -339,5 +339,32 @@ module Jpmobile
|
|
339
339
|
def jis?(str)
|
340
340
|
detect_encoding(str) == JIS
|
341
341
|
end
|
342
|
+
|
343
|
+
def fold_text(str, size = 15)
|
344
|
+
folded_texts = []
|
345
|
+
|
346
|
+
while texts = split_text(str, size) and texts.first.size != 0
|
347
|
+
folded_texts << texts.first
|
348
|
+
str = texts.last
|
349
|
+
end
|
350
|
+
|
351
|
+
folded_texts
|
352
|
+
end
|
353
|
+
|
354
|
+
def split_text(str, size = 15)
|
355
|
+
return nil if str.nil? or str == ''
|
356
|
+
|
357
|
+
if Object.const_defined?(:Encoding)
|
358
|
+
[str[0..(size-1)], str[size..-1]]
|
359
|
+
else
|
360
|
+
str = str.split(//u)
|
361
|
+
text = str[0..(size-1)]
|
362
|
+
text = text.join if text
|
363
|
+
remain = str[size..-1]
|
364
|
+
remain = remain.join if remain
|
365
|
+
[text, remain]
|
366
|
+
end
|
367
|
+
|
368
|
+
end
|
342
369
|
end
|
343
370
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jpmobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.0.0.pre.
|
5
|
+
version: 1.0.0.pre.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yoji Shidara
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-04-
|
14
|
+
date: 2011-04-19 00:00:00 +09:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 3.0.
|
35
|
+
version: 3.0.7
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: *id002
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.
|
46
|
+
version: 2.5.0
|
47
47
|
type: :development
|
48
48
|
prerelease: false
|
49
49
|
version_requirements: *id003
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 2.
|
57
|
+
version: 2.5.0
|
58
58
|
type: :development
|
59
59
|
prerelease: false
|
60
60
|
version_requirements: *id004
|