jpmobile 1.0.0.pre.4 → 1.0.0.pre.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/.rspec +4 -0
  2. data/Gemfile +3 -3
  3. data/VERSION.yml +2 -2
  4. data/jpmobile.gemspec +335 -0
  5. data/lib/jpmobile.rb +0 -1
  6. data/lib/jpmobile/email.rb +47 -21
  7. data/lib/jpmobile/mail.rb +33 -26
  8. data/lib/jpmobile/mailer.rb +2 -0
  9. data/lib/jpmobile/util.rb +3 -3
  10. data/spec/unit/email-fixtures/au-attached.eml +1551 -0
  11. data/spec/unit/email-fixtures/au-decomail.eml +44 -0
  12. data/spec/unit/email-fixtures/au-emoji.eml +19 -0
  13. data/spec/unit/email-fixtures/au-emoji2.eml +45 -0
  14. data/spec/unit/email-fixtures/au-emoji5.eml +24 -0
  15. data/spec/unit/email-fixtures/docomo-emoji.eml +19 -0
  16. data/spec/unit/email-fixtures/docomo-gmail-sjis.eml +45 -0
  17. data/spec/unit/email-fixtures/docomo-jis.eml +20 -0
  18. data/spec/unit/email-fixtures/pc-mail-multi.eml +77 -0
  19. data/spec/unit/email-fixtures/pc-mail-single.eml +29 -0
  20. data/spec/unit/email-fixtures/softbank-blank.eml +20 -0
  21. data/spec/unit/email-fixtures/softbank-emoji-utf8.eml +19 -0
  22. data/spec/unit/email-fixtures/softbank-emoji.eml +19 -0
  23. data/spec/unit/email-fixtures/softbank-gmail-sjis.eml +45 -0
  24. data/spec/unit/email-fixtures/softbank-gmail-utf8.eml +45 -0
  25. data/spec/unit/{detect_by_email_spec.rb → email_spec.rb} +25 -2
  26. data/spec/unit/emoticon_spec.rb +1 -1
  27. data/spec/unit/encoding_spec.rb +1 -1
  28. data/spec/unit/is_carrier_spec.rb +1 -1
  29. data/spec/unit/mail_spec.rb +1 -1
  30. data/spec/unit/receive_mail_spec.rb +26 -1
  31. data/spec/unit/util_spec.rb +1 -1
  32. data/spec/unit/valid_ip_spec.rb +1 -1
  33. data/test/rails/.gitignore +1 -0
  34. data/test/rails/overrides/.rspec +5 -0
  35. data/test/rails/overrides/Gemfile +33 -0
  36. data/test/rails/overrides/app/views/filter/index.html.erb +0 -0
  37. data/test/rails/overrides/app/views/hankaku_filter/index.html.erb +0 -0
  38. data/test/rails/overrides/app/views/hankaku_input_filter/index.html.erb +0 -0
  39. data/test/rails/overrides/app/views/hankaku_input_filter/index_xhtml.html.erb +1 -0
  40. data/test/rails/overrides/app/views/layouts/xhtml.html.erb +12 -0
  41. data/test/rails/overrides/app/views/links/au_gps.html.erb +1 -0
  42. data/test/rails/overrides/app/views/links/au_location.html.erb +1 -0
  43. data/test/rails/overrides/app/views/links/docomo_foma_gps.html.erb +1 -0
  44. data/test/rails/overrides/app/views/links/docomo_openiarea.html.erb +1 -0
  45. data/test/rails/overrides/app/views/links/docomo_utn.html.erb +1 -0
  46. data/test/rails/overrides/app/views/links/link.html.erb +1 -0
  47. data/test/rails/overrides/app/views/links/show_all.html.erb +1 -0
  48. data/test/rails/overrides/app/views/links/softbank_location.html.erb +1 -0
  49. data/test/rails/overrides/app/views/links/willcom_location.html.erb +1 -0
  50. data/test/rails/overrides/app/views/mobile_mailer/multi_message.html.erb +11 -0
  51. data/test/rails/overrides/app/views/mobile_mailer/multi_message.text.erb +2 -0
  52. data/test/rails/overrides/app/views/mobile_mailer/view_selection.html.erb +3 -0
  53. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile.html.erb +3 -0
  54. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_au.html.erb +3 -0
  55. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_docomo.html.erb +3 -0
  56. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_emobile.html.erb +3 -0
  57. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_softbank.html.erb +3 -0
  58. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_vodafone.html.erb +3 -0
  59. data/test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_willcom.html.erb +3 -0
  60. data/test/rails/overrides/app/views/normal_mailer/msg.text.erb +3 -0
  61. data/test/rails/overrides/app/views/template_path/_partial.html.erb +1 -0
  62. data/test/rails/overrides/app/views/template_path/_partial_mobile.html.erb +1 -0
  63. data/test/rails/overrides/app/views/template_path/_partial_mobile_docomo.html.erb +1 -0
  64. data/test/rails/overrides/app/views/template_path/_partial_smart_phone.html.erb +1 -0
  65. data/test/rails/overrides/app/views/template_path/_partial_smart_phone_iphone.html.erb +1 -0
  66. data/test/rails/overrides/app/views/template_path/index.html.erb +1 -0
  67. data/test/rails/overrides/app/views/template_path/index_mobile.html.erb +1 -0
  68. data/test/rails/overrides/app/views/template_path/index_mobile_docomo.html.erb +1 -0
  69. data/test/rails/overrides/app/views/template_path/index_smart_phone.html.erb +1 -0
  70. data/test/rails/overrides/app/views/template_path/index_smart_phone_iphone.html.erb +1 -0
  71. data/test/rails/overrides/app/views/template_path/partial.html.erb +2 -0
  72. data/test/rails/overrides/app/views/template_path/show_mobile.html.erb +1 -0
  73. data/test/rails/overrides/app/views/template_path/show_mobile_docomo.html.erb +1 -0
  74. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-attached.eml +1551 -0
  75. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml +44 -0
  76. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji.eml +19 -0
  77. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji2.eml +45 -0
  78. data/test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji5.eml +24 -0
  79. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-emoji.eml +19 -0
  80. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-gmail-sjis.eml +45 -0
  81. data/test/rails/overrides/spec/fixtures/mobile_mailer/docomo-jis.eml +20 -0
  82. data/test/rails/overrides/spec/fixtures/mobile_mailer/no-from.eml +78 -0
  83. data/test/rails/overrides/spec/fixtures/mobile_mailer/non-jp.eml +45 -0
  84. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-blank.eml +20 -0
  85. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji-utf8.eml +19 -0
  86. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-emoji.eml +19 -0
  87. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-sjis.eml +45 -0
  88. data/test/rails/overrides/spec/fixtures/mobile_mailer/softbank-gmail-utf8.eml +45 -0
  89. data/test/rails/overrides/spec/helpers/helpers_spec.rb +1 -2
  90. data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +37 -1
  91. data/test/rails/overrides/spec/models/normal_mailer_spec.rb +1 -1
  92. data/test/rails/overrides/spec/rcov.opts +2 -0
  93. data/test/rails/overrides/spec/requests/docomo_guid_spec.rb +1 -2
  94. data/test/rails/overrides/spec/requests/docomo_spec.rb +1 -2
  95. data/test/rails/overrides/spec/requests/emobile_spec.rb +1 -2
  96. data/test/rails/overrides/spec/requests/filter_spec.rb +1 -1
  97. data/test/rails/overrides/spec/requests/helpers_spec.rb +1 -1
  98. data/test/rails/overrides/spec/requests/pc_spec.rb +1 -2
  99. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +1 -2
  100. data/test/rails/overrides/spec/requests/template_path_spec.rb +1 -2
  101. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +1 -2
  102. data/test/rails/overrides/spec/spec_helper.rb +1 -1
  103. metadata +229 -386
  104. data/test/rails/rails_root/app/controllers/application_controller.rb +0 -6
  105. data/test/rails/rails_root/app/controllers/docomo_guid_always_controller.rb +0 -3
  106. data/test/rails/rails_root/app/controllers/docomo_guid_base_controller.rb +0 -5
  107. data/test/rails/rails_root/app/controllers/docomo_guid_docomo_controller.rb +0 -3
  108. data/test/rails/rails_root/app/controllers/filter_controller.rb +0 -3
  109. data/test/rails/rails_root/app/controllers/filter_controller_base.rb +0 -25
  110. data/test/rails/rails_root/app/controllers/hankaku_filter_controller.rb +0 -3
  111. data/test/rails/rails_root/app/controllers/hankaku_input_filter_controller.rb +0 -7
  112. data/test/rails/rails_root/app/controllers/links_controller.rb +0 -28
  113. data/test/rails/rails_root/app/controllers/mobile_spec_controller.rb +0 -5
  114. data/test/rails/rails_root/app/controllers/template_path_controller.rb +0 -17
  115. data/test/rails/rails_root/app/controllers/trans_sid_always_and_session_off_controller.rb +0 -4
  116. data/test/rails/rails_root/app/controllers/trans_sid_always_controller.rb +0 -3
  117. data/test/rails/rails_root/app/controllers/trans_sid_base_controller.rb +0 -40
  118. data/test/rails/rails_root/app/controllers/trans_sid_metal_controller.rb +0 -15
  119. data/test/rails/rails_root/app/controllers/trans_sid_mobile_controller.rb +0 -3
  120. data/test/rails/rails_root/app/controllers/trans_sid_none_controller.rb +0 -3
  121. data/test/rails/rails_root/app/helpers/application_helper.rb +0 -2
  122. data/test/rails/rails_root/app/models/mobile_mailer.rb +0 -19
  123. data/test/rails/rails_root/app/models/normal_mailer.rb +0 -9
  124. data/test/rails/rails_root/app/models/user.rb +0 -2
  125. data/test/rails/rails_root/autotest/discover.rb +0 -2
  126. data/test/rails/rails_root/config/application.rb +0 -42
  127. data/test/rails/rails_root/config/boot.rb +0 -6
  128. data/test/rails/rails_root/config/environment.rb +0 -5
  129. data/test/rails/rails_root/config/environments/development.rb +0 -26
  130. data/test/rails/rails_root/config/environments/production.rb +0 -49
  131. data/test/rails/rails_root/config/environments/test.rb +0 -35
  132. data/test/rails/rails_root/config/initializers/backtrace_silencers.rb +0 -7
  133. data/test/rails/rails_root/config/initializers/inflections.rb +0 -10
  134. data/test/rails/rails_root/config/initializers/jpmobile_generator.rb +0 -2
  135. data/test/rails/rails_root/config/initializers/mime_types.rb +0 -5
  136. data/test/rails/rails_root/config/initializers/secret_token.rb +0 -7
  137. data/test/rails/rails_root/config/initializers/session_store.rb +0 -2
  138. data/test/rails/rails_root/config/routes.rb +0 -7
  139. data/test/rails/rails_root/db/migrate/001_add_sessions_table.rb +0 -16
  140. data/test/rails/rails_root/db/migrate/20100824062306_create_users.rb +0 -13
  141. data/test/rails/rails_root/db/schema.rb +0 -31
  142. data/test/rails/rails_root/db/seeds.rb +0 -7
  143. data/test/rails/rails_root/spec/helpers/helpers_spec.rb +0 -15
  144. data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +0 -737
  145. data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +0 -34
  146. data/test/rails/rails_root/spec/requests/docomo_guid_spec.rb +0 -102
  147. data/test/rails/rails_root/spec/requests/docomo_spec.rb +0 -33
  148. data/test/rails/rails_root/spec/requests/emobile_spec.rb +0 -53
  149. data/test/rails/rails_root/spec/requests/filter_spec.rb +0 -221
  150. data/test/rails/rails_root/spec/requests/helpers_spec.rb +0 -187
  151. data/test/rails/rails_root/spec/requests/pc_spec.rb +0 -22
  152. data/test/rails/rails_root/spec/requests/softbank_emulator_spec.rb +0 -21
  153. data/test/rails/rails_root/spec/requests/template_path_spec.rb +0 -240
  154. data/test/rails/rails_root/spec/requests/trans_sid_spec.rb +0 -207
  155. data/test/rails/rails_root/spec/spec_helper.rb +0 -38
  156. data/test/rails/rails_root/test/performance/browsing_test.rb +0 -9
  157. data/test/rails/rails_root/test/test_helper.rb +0 -13
  158. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
  159. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
  160. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
  161. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
  162. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
  163. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
  164. data/test/rails/rails_root/vendor/plugins/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
  165. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
  166. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
  167. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
  168. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/spec_helper.rb +0 -2
  169. data/test/rails/rails_root/vendor/plugins/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
  170. data/test/rails/rails_root/vendor/plugins/jpmobile/init.rb +0 -3
  171. data/test/rails/rails_root/vendor/plugins/jpmobile/install.rb +0 -1
  172. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +0 -59
  173. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/datum_conv.rb +0 -72
  174. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/docomo_guid.rb +0 -43
  175. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/email.rb +0 -33
  176. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +0 -205
  177. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/au.rb +0 -1931
  178. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/conversion_table.rb +0 -3909
  179. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/docomo.rb +0 -255
  180. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/softbank.rb +0 -965
  181. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon/z_combine.rb +0 -36
  182. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/encoding.rb +0 -29
  183. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/filter.rb +0 -113
  184. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/helpers.rb +0 -174
  185. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +0 -18
  186. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_dispatch.rb +0 -2
  187. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +0 -33
  188. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/lookup_context.rb +0 -2
  189. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +0 -330
  190. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +0 -41
  191. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +0 -168
  192. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/android.rb +0 -10
  193. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +0 -128
  194. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/ddipocket.rb +0 -12
  195. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +0 -149
  196. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/emobile.rb +0 -16
  197. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/iphone.rb +0 -26
  198. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/smart_phone.rb +0 -21
  199. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +0 -91
  200. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/vodafone.rb +0 -17
  201. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/willcom.rb +0 -28
  202. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/windows_phone.rb +0 -10
  203. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +0 -40
  204. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/position.rb +0 -68
  205. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack.rb +0 -49
  206. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/filter.rb +0 -50
  207. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/mobile_carrier.rb +0 -33
  208. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +0 -47
  209. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +0 -50
  210. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/request_with_mobile.rb +0 -45
  211. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +0 -38
  212. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/trans_sid.rb +0 -133
  213. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +0 -370
  214. data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/conversion-table.rb +0 -2588
  215. data/test/rails/rails_root/vendor/plugins/jpmobile/tmp/utf8_to_image.rb +0 -1407
  216. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/emoji/genregexp.rb +0 -47
  217. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_au_emoticon_table.rb +0 -34
  218. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_docomo_emoticon_table.rb +0 -33
  219. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_emoticon_conversion_table.rb +0 -107
  220. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/generate_softbank_emoticon_table.rb +0 -31
  221. data/test/rails/rails_root/vendor/plugins/jpmobile/tools/list_gps_unsupported_au.rb +0 -23
  222. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses.rb +0 -18
  223. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/abstract_ip_addresses.rb +0 -23
  224. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/au.rb +0 -40
  225. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/docomo.rb +0 -22
  226. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/emobile.rb +0 -15
  227. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/softbank.rb +0 -20
  228. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-ipaddresses/lib/jpmobile/mobile/ip_addresses/willcom.rb +0 -158
  229. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile-terminfo.rb +0 -9
  230. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo.rb +0 -62
  231. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/lib/jpmobile/mobile/terminfo/docomo.rb +0 -739
  232. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/spec_helper.rb +0 -2
  233. data/test/rails/rails_root/vendor/plugins/jpmobile/vendor/jpmobile-terminfo/spec/terminfo_spec.rb +0 -54
@@ -1,41 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'jpmobile/mail'
3
- require 'jpmobile/lookup_context'
4
-
5
- module Jpmobile
6
- module Mailer
7
- class Base < ActionMailer::Base
8
- self._view_paths = self._view_paths.dup
9
- self.view_paths.unshift(Jpmobile::Resolver.new(File.join(::Rails.root, "app/views")))
10
-
11
- def mail(headers={}, &block)
12
- tos = headers[:to].split(/,/)
13
-
14
- @mobile = if tos.size == 1
15
- # for mobile
16
- (Jpmobile::Email.detect(tos.first) || Jpmobile::Mobile::AbstractMobile).new(nil, nil)
17
- else
18
- # for multi to addresses
19
- Jpmobile::Mobile::AbstractMobile.new(nil, nil)
20
- end
21
- self.lookup_context.mobile = @mobile.variants
22
-
23
- m = super(headers, &block)
24
-
25
- m.mobile = @mobile
26
- m.charset = @mobile.mail_charset
27
-
28
- m
29
- end
30
-
31
- class << self
32
- protected
33
- def set_payload_for_mail(payload, mail) #:nodoc:
34
- super
35
-
36
- payload[:mail] = Jpmobile::Util.ascii_8bit(mail.encoded).gsub(/\r\n/, "\n")
37
- end
38
- end
39
- end
40
- end
41
- end
@@ -1,168 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'ipaddr'
3
-
4
- module Jpmobile::Mobile
5
- # 携帯電話の抽象クラス。
6
- class AbstractMobile
7
- # メールのデフォルトのcharset
8
- MAIL_CHARSET = "ISO-2022-JP"
9
-
10
- def initialize(env, request)
11
- @env = env
12
- @request = request
13
- end
14
-
15
- # 対応するuser-agentの正規表現
16
- USER_AGENT_REGEXP = nil
17
- # 対応するメールアドレスの正規表現
18
- MAIL_ADDRESS_REGEXP = nil
19
-
20
- # 緯度経度があれば Position のインスタンスを返す。
21
- def position; return nil; end
22
-
23
- # 契約者又は端末を識別する文字列があれば返す。
24
- def ident; ident_subscriber || ident_device; end
25
- # 契約者を識別する文字列があれば返す。
26
- def ident_subscriber; nil; end
27
- # 端末を識別する文字列があれば返す。
28
- def ident_device; nil; end
29
-
30
- # 当該キャリアのIPアドレス帯域からのアクセスであれば +true+ を返す。
31
- # そうでなければ +false+ を返す。
32
- # IP空間が定義されていない場合は +nil+ を返す。
33
- def self.valid_ip? remote_addr
34
- @ip_list ||= ip_address_class
35
- return false unless @ip_list
36
-
37
- @ip_list.valid_ip?(remote_addr)
38
- end
39
-
40
- def valid_ip?
41
- @__valid_ip ||= self.class.valid_ip? @request.ip
42
- end
43
-
44
- # 画面情報を +Display+ クラスのインスタンスで返す。
45
- def display
46
- @__displlay ||= Jpmobile::Mobile::Terminfo.new(self, @env)
47
- rescue LoadError
48
- puts "display method require jpmobile-terminfo plugin."
49
- end
50
-
51
- # クッキーをサポートしているか。
52
- def supports_cookie?
53
- return false
54
- end
55
-
56
- # smartphone かどうか
57
- def smart_phone?
58
- false
59
- end
60
-
61
- # エンコーディング変換用
62
- def to_internal(str)
63
- str
64
- end
65
- def to_external(str, content_type, charset)
66
- [str, charset]
67
- end
68
- def default_charset
69
- "UTF-8"
70
- end
71
-
72
- # for view selector
73
- def variants
74
- return @_variants if @_variants
75
-
76
- @_variants = self.class.ancestors.select {|c| c.to_s =~ /^Jpmobile/}.map do |klass|
77
- klass = klass.to_s.
78
- gsub(/Jpmobile::/, '').
79
- gsub(/AbstractMobile::/, '').
80
- gsub(/Mobile::SmartPhone/, 'smart_phone').
81
- gsub(/::/, '_').
82
- gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
83
- gsub(/([a-z\d])([A-Z])/, '\1_\2').
84
- downcase
85
- klass =~ /abstract/ ? "mobile" : klass
86
- end
87
-
88
- if @_variants.include?("smart_phone")
89
- @_variants = @_variants.reject{|v| v == "mobile"}.map{|v| v.gsub(/mobile/, "smart_phone")}
90
- end
91
-
92
- @_variants
93
- end
94
-
95
- # メール送信用
96
- def to_mail_subject(str)
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")
100
- end
101
- def to_mail_body(str)
102
- to_mail_encoding(str)
103
- end
104
- def mail_charset(charset = nil)
105
- (charset.nil? or charset == "") ? self.class::MAIL_CHARSET : charset
106
- end
107
- def to_mail_encoding(str)
108
- str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
109
- str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_PC_EMAIL, false)
110
- Jpmobile::Util.encode(str, mail_charset)
111
- end
112
- def utf8_to_mail_encode(str)
113
- case mail_charset
114
- when /ISO-2022-JP/i
115
- Jpmobile::Util.utf8_to_jis(str)
116
- when /Shift_JIS/i
117
- Jpmobile::Util.utf8_to_sjis(str)
118
- else
119
- str
120
- end
121
- end
122
- def to_mail_internal(str, charset)
123
- str
124
- end
125
- def to_mail_subject_encoded?(str)
126
- str.match(/\=\?#{mail_charset}\?B.+\?\=/i)
127
- end
128
- def to_mail_body_encoded?(str)
129
- Jpmobile::Util.jis?(str)
130
- end
131
- def decode_transfer_encoding(body, charset)
132
- body = Jpmobile::Util.set_encoding(body, charset)
133
- body = to_mail_internal(body, nil)
134
- Jpmobile::Util.force_encode(body, charset, Jpmobile::Util::UTF8)
135
- end
136
-
137
- # リクエストがこのクラスに属するか調べる
138
- # メソッド名に関して非常に不安
139
- def self.check_carrier(env)
140
- self::USER_AGENT_REGEXP && env['HTTP_USER_AGENT'] =~ self::USER_AGENT_REGEXP
141
- end
142
-
143
- #XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです
144
- Jpmobile::Mobile.carriers.each do |carrier|
145
- carrier_class = Jpmobile::Mobile.const_get(carrier)
146
- next if carrier_class == self
147
-
148
- define_method "#{carrier.downcase}?" do
149
- self.is_a?(carrier_class)
150
- end
151
- end
152
-
153
- private
154
- # リクエストのパラメータ。
155
- def params
156
- if @request.respond_to? :parameters
157
- @request.parameters
158
- else
159
- @request.params
160
- end
161
- end
162
-
163
- #
164
- def self.ip_address_class
165
- eval("::Jpmobile::Mobile::IpAddresses::#{self.to_s.split(/::/).last}").new rescue nil
166
- end
167
- end
168
- end
@@ -1,10 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # =Android
3
-
4
- module Jpmobile::Mobile
5
- # ==Android
6
- class Android < SmartPhone
7
- # 対応するUser-Agentの正規表現
8
- USER_AGENT_REGEXP = /Android/
9
- end
10
- end
@@ -1,128 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # =au携帯電話
3
-
4
- module Jpmobile::Mobile
5
- # ==au携帯電話
6
- # CDMA 1X, CDMA 1X WINを含む。
7
- class Au < AbstractMobile
8
- # 対応するUser-Agentの正規表現
9
- # User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
10
- USER_AGENT_REGEXP = /^(?:KDDI|UP.Browser\/.+?)-(.+?) /
11
- # 対応するメールアドレスの正規表現
12
- MAIL_ADDRESS_REGEXP = /.+@ezweb\.ne\.jp/
13
- # 簡易位置情報取得に対応していないデバイスID
14
- # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
15
- LOCATION_UNSUPPORTED_DEVICE_ID = ["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"]
16
- # GPS取得に対応していないデバイスID
17
- GPS_UNSUPPORTED_DEVICE_ID = ["PT21", "KC26", "SN28", "SN26", "KC23", "SA28", "TS25", "SA25", "SA24", "SN23", "ST14", "KC15", "SN22", "KC14", "ST13", "SN17", "SY15", "CA14", "HI14", "TS14", "KC13", "SN15", "SN16", "SY14", "ST12", "TS13", "CA13", "MA13", "HI13", "SN13", "SY13", "SN12", "SN14", "ST11", "DN11", "SY12", "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"]
18
-
19
- # EZ番号(サブスクライバID)があれば返す。無ければ +nil+ を返す。
20
- def subno
21
- @request.env["HTTP_X_UP_SUBNO"]
22
- end
23
- alias :ident_subscriber :subno
24
-
25
- # 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
26
- def position
27
- return @__posotion if defined? @__posotion
28
- return @__posotion = nil if ( params["lat"].nil? || params['lat'] == '' || params["lon"].nil? || params["lon"] == '' )
29
- l = Jpmobile::Position.new
30
- l.options = params.reject {|x,v| !["ver", "datum", "unit", "lat", "lon", "alt", "time", "smaj", "smin", "vert", "majaa", "fm"].include?(x) }
31
- case params["unit"]
32
- when "1"
33
- l.lat = params["lat"].to_f
34
- l.lon = params["lon"].to_f
35
- when "0", "dms"
36
- raise "Invalid dms form" unless params["lat"] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
37
- l.lat = Jpmobile::Position.dms2deg($1,$2,$3)
38
- raise "Invalid dms form" unless params["lon"] =~ /^([+-]?\d+)\.(\d+)\.(\d+\.\d+)$/
39
- l.lon = Jpmobile::Position.dms2deg($1,$2,$3)
40
- else
41
- return @__posotion = nil
42
- end
43
- if params["datum"] == "1"
44
- # ただし、params["datum"]=="tokyo"のとき(簡易位置情報)のときは、
45
- # 実際にはWGS84系のデータが渡ってくる
46
- # http://www.au.kddi.com/ezfactory/tec/spec/eznavi.html
47
- l.tokyo2wgs84!
48
- end
49
- return @__posotion = l
50
- end
51
-
52
- # デバイスIDを返す
53
- def device_id
54
- if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP
55
- return $1
56
- else
57
- nil
58
- end
59
- end
60
-
61
- # 簡易位置情報取得に対応している場合は +true+ を返す。
62
- def supports_location?
63
- ! LOCATION_UNSUPPORTED_DEVICE_ID.include?(device_id)
64
- end
65
-
66
- # GPS位置情報取得に対応している場合は +true+ を返す。
67
- def supports_gps?
68
- ! GPS_UNSUPPORTED_DEVICE_ID.include?(device_id)
69
- end
70
-
71
- # cookieに対応しているか?
72
- def supports_cookie?
73
- protocol = @request.respond_to?(:scheme) ? @request.scheme : @request.protocol rescue "none"
74
- if protocol =~ /\Ahttps/
75
- false
76
- else
77
- true
78
- end
79
- end
80
-
81
- # 文字コード変換
82
- def to_internal(str)
83
- # 絵文字を数値参照に変換
84
- str = Jpmobile::Emoticon.external_to_unicodecr_au(Jpmobile::Util.sjis(str))
85
- # 文字コードを UTF-8 に変換
86
- str = Jpmobile::Util.sjis_to_utf8(str)
87
- # 数値参照を UTF-8 に変換
88
- Jpmobile::Emoticon::unicodecr_to_utf8(str)
89
- end
90
- def to_external(str, content_type, charset)
91
- # UTF-8を数値参照に
92
- str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
93
- # 文字コードを Shift_JIS に変換
94
- if [nil, "text/html", "application/xhtml+xml"].include?(content_type)
95
- str = Jpmobile::Util.utf8_to_sjis(str)
96
- charset = default_charset unless str.empty?
97
- end
98
- # 数値参照を絵文字コードに変換
99
- str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_AU, true)
100
-
101
- [str, charset]
102
- end
103
- def default_charset
104
- "Shift_JIS"
105
- end
106
-
107
- # メール送信用
108
- def to_mail_body(str)
109
- to_mail_encoding(str)
110
- end
111
-
112
- def to_mail_internal(str, charset)
113
- if Jpmobile::Util.jis?(str) or Jpmobile::Util.ascii_8bit?(str) or charset == mail_charset
114
- # 絵文字を数値参照に変換
115
- str = Jpmobile::Emoticon.external_to_unicodecr_au_mail(Jpmobile::Util.jis(str))
116
- str = Jpmobile::Util.jis_to_utf8(Jpmobile::Util.jis(str))
117
- end
118
- str
119
- end
120
-
121
- private
122
- def to_mail_encoding(str)
123
- str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
124
- str = Jpmobile::Util.utf8_to_jis(str)
125
- Jpmobile::Util.jis(Jpmobile::Emoticon.unicodecr_to_au_email(str))
126
- end
127
- end
128
- end
@@ -1,12 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # =DDI-POCKET
3
- module Jpmobile::Mobile
4
- # ==DDI-POCKET
5
- # スーパクラスはWillcom。
6
- class Ddipocket < Willcom
7
- # 対応するUser-Agentの正規表現
8
- USER_AGENT_REGEXP = /^Mozilla\/3.0\(DDIPOCKET/
9
-
10
- MAIL_ADDRESS_REGEXP = nil # DdipocketはEmail判定だとWillcomと判定させたい
11
- end
12
- end
@@ -1,149 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # =DoCoMo携帯電話
3
-
4
- module Jpmobile::Mobile
5
- # ==DoCoMo携帯電話
6
- class Docomo < AbstractMobile
7
- # 対応するUser-Agentの正規表現
8
- USER_AGENT_REGEXP = /^DoCoMo/
9
- # 対応するメールアドレスの正規表現
10
- MAIL_ADDRESS_REGEXP = /.+@docomo\.ne\.jp/
11
- # メールのデフォルトのcharset
12
- MAIL_CHARSET = "Shift_JIS"
13
-
14
- # オープンiエリアがあればエリアコードを +String+ で返す。無ければ +nil+ を返す。
15
- def areacode
16
- if params["ACTN"] == "OK"
17
- return params["AREACODE"]
18
- else
19
- return nil
20
- end
21
- end
22
-
23
- # 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
24
- def position
25
- return @__position if defined? @__position
26
- lat = params["lat"] || params["LAT"]
27
- lon = params["lon"] || params["LON"]
28
- geo = params["geo"] || params["GEO"]
29
- return @__position = nil if ( lat.nil? || lat == '' || lon.nil? || lon == '' )
30
- raise "Unsuppoted datum" if geo.downcase != "wgs84"
31
- pos = Jpmobile::Position.new
32
- raise "Unsuppoted" unless lat =~ /^([+-]\d+)\.(\d+)\.(\d+\.\d+)/
33
- pos.lat = Jpmobile::Position.dms2deg($1,$2,$3)
34
- raise "Unsuppoted" unless lon =~ /^([+-]\d+)\.(\d+)\.(\d+\.\d+)/
35
- pos.lon = Jpmobile::Position.dms2deg($1,$2,$3)
36
- return @__position = pos
37
- end
38
-
39
- # 端末製造番号があれば返す。無ければ +nil+ を返す。
40
- def serial_number
41
- case @env["HTTP_USER_AGENT"]
42
- when /ser([0-9a-zA-Z]{11})$/ # mova
43
- return $1
44
- when /ser([0-9a-zA-Z]{15});/ # FOMA
45
- return $1
46
- else
47
- return nil
48
- end
49
- end
50
- alias :ident_device :serial_number
51
-
52
- # FOMAカード製造番号があれば返す。無ければ +nil+ を返す。
53
- def icc
54
- @env['HTTP_USER_AGENT'] =~ /icc([0-9a-zA-Z]{20})\)/
55
- return $1
56
- end
57
-
58
- # iモードIDを返す。
59
- def guid
60
- @env['HTTP_X_DCMGUID']
61
- end
62
-
63
- # iモードID, FOMAカード製造番号の順で調べ、あるものを返す。なければ +nil+ を返す。
64
- def ident_subscriber
65
- guid || icc
66
- end
67
-
68
- # cookieに対応しているか?
69
- def supports_cookie?
70
- imode_browser_version != '1.0'
71
- end
72
-
73
- # 文字コード変換
74
- def to_internal(str)
75
- # 絵文字を数値参照に変換
76
- str = Jpmobile::Emoticon.external_to_unicodecr_docomo(Jpmobile::Util.sjis(str))
77
- # 文字コードを UTF-8 に変換
78
- str = Jpmobile::Util.sjis_to_utf8(str)
79
- # 数値参照を UTF-8 に変換
80
- Jpmobile::Emoticon.unicodecr_to_utf8(str)
81
- end
82
- def to_external(str, content_type, charset)
83
- # UTF-8を数値参照に
84
- str = Jpmobile::Emoticon.utf8_to_unicodecr(str)
85
- # 文字コードを Shift_JIS に変換
86
- if [nil, "text/html", "application/xhtml+xml"].include?(content_type)
87
- str = Jpmobile::Util.utf8_to_sjis(str)
88
- charset = default_charset unless str.empty?
89
- end
90
- # 数値参照を絵文字コードに変換
91
- str = Jpmobile::Emoticon.unicodecr_to_external(str, Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)
92
-
93
- [str, charset]
94
- end
95
- def default_charset
96
- "Shift_JIS"
97
- end
98
-
99
- # メール送信用
100
- def to_mail_body(str)
101
- to_external(str, nil, nil).first
102
- end
103
- def to_mail_encoding(str)
104
- to_external(str, nil, nil).first
105
- end
106
- def to_mail_internal(str, charset)
107
- if Jpmobile::Util.shift_jis?(str) or Jpmobile::Util.ascii_8bit?(str) or charset == mail_charset
108
- # 絵文字を数値参照に変換
109
- str = Jpmobile::Emoticon.external_to_unicodecr_docomo(Jpmobile::Util.sjis(str))
110
- end
111
-
112
- str
113
- end
114
- def to_mail_body_encoded?(str)
115
- Jpmobile::Util.shift_jis?(str)
116
- end
117
-
118
- # i-mode ブラウザのバージョンを返す。
119
- # http://labs.unoh.net/2009/07/i_20.html
120
- def imode_browser_version
121
- ver = '1.0'
122
- case @request.env['HTTP_USER_AGENT']
123
- when %r{^DoCoMo/1.0/}
124
- # 必ずv1.0
125
- when %r{^DoCoMo/2.0 }
126
- @request.env['HTTP_USER_AGENT'] =~ / (\w+)\(c(\d+);/
127
- model = $1
128
- cache_size = $2.to_i
129
-
130
- ver = cache_size >= 500 ? (%w(P03B P05B L01B).member?(model) ? '2.0LE' : '2.0') : '1.0'
131
- else
132
- # DoCoMo/3.0以降等は、とりあえず非v1.0扱い
133
- ver = '2.0'
134
- end
135
-
136
- ver
137
- end
138
-
139
- # モデル名を返す。
140
- def model_name
141
- if @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/2.0 (.+)\(/
142
- return $1
143
- elsif @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/1.0\/(.+?)\//
144
- return $1
145
- end
146
- return nil
147
- end
148
- end
149
- end