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,47 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # リクエストパラメータの変換
3
- module Jpmobile
4
- module Rack
5
- class ParamsFilter
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def call(env)
11
- # 入力
12
- if @mobile = env['rack.jpmobile']
13
- # パラメータをkey, valueに分解
14
- # form_params
15
- if env['REQUEST_METHOD'] == 'POST'
16
- env['rack.input'] = StringIO.new(parse_query(env['rack.input'].read))
17
- end
18
-
19
- # query_params
20
- env['QUERY_STRING'] = parse_query(env['QUERY_STRING'])
21
- end
22
-
23
- status, env, body = @app.call(env)
24
-
25
- [status, env, body]
26
- end
27
-
28
- private
29
- def to_internal(str)
30
- ::Rack::Utils.escape(@mobile.to_internal(::Rack::Utils.unescape(str)))
31
- end
32
- def parse_query(str)
33
- return nil unless str
34
-
35
- new_array = []
36
- str.split("&").each do |param_pair|
37
- k, v = param_pair.split("=")
38
- k = to_internal(k) if k
39
- v = to_internal(v) if v
40
- new_array << "#{k}=#{v}" if k
41
- end
42
-
43
- new_array.join("&")
44
- end
45
- end
46
- end
47
- end
@@ -1,50 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- ActiveSupport.on_load(:action_controller) do
3
- require 'jpmobile/docomo_guid'
4
- require 'jpmobile/filter'
5
- require 'jpmobile/helpers'
6
- require 'jpmobile/hook_action_controller'
7
- require 'jpmobile/hook_action_view'
8
- require 'jpmobile/trans_sid'
9
- end
10
- ActiveSupport.on_load(:action_dispatch) do
11
- require 'jpmobile/hook_action_dispatch'
12
- end
13
-
14
- ActiveSupport.on_load(:before_configuration) do
15
- # MobileCarrierのみデフォルトで有効
16
- ::Rails.application.middleware.insert_before('ActionDispatch::ParamsParser', Jpmobile::Rack::MobileCarrier)
17
- module Rails
18
- class Application
19
- class Configuration
20
- def jpmobile
21
- @jpmobile ||= ::Jpmobile::Configuration.new
22
- end
23
- end
24
- end
25
- end
26
- end
27
-
28
- module Jpmobile
29
- module ViewSelector
30
- def self.included(base)
31
- base.class_eval do
32
- before_filter :register_mobile
33
-
34
- self._view_paths = self._view_paths.dup
35
- self.view_paths.unshift(Jpmobile::Resolver.new(File.join(Rails.root, "app/views")))
36
- end
37
- end
38
-
39
- def register_mobile
40
- if request.mobile
41
- # register mobile
42
- self.lookup_context.mobile = request.mobile.variants
43
- end
44
- end
45
-
46
- def disable_mobile_view!
47
- self.lookup_context.mobile = nil
48
- end
49
- end
50
- end
@@ -1,45 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # jpmobile の各機能を提供するモジュール
4
- # envメソッドが実装されている必要がある。
5
-
6
- module Jpmobile
7
- module RequestWithMobile
8
- # 環境変数 HTTP_USER_AGENT を返す。
9
- def user_agent
10
- env['HTTP_USER_AGENT']
11
- end
12
-
13
- # for reverse proxy.
14
- def remote_addr
15
- if respond_to?(:remote_ip)
16
- return __send__(:remote_ip) # for Rails
17
- elsif respond_to?(:ip)
18
- return __send__(:ip) # for Rack
19
- else
20
- return ( env["HTTP_X_FORWARDED_FOR"] ? env["HTTP_X_FORWARDED_FOR"].split(',').pop : env["REMOTE_ADDR"] )
21
- end
22
- end
23
-
24
- # 環境変数 HTTP_USER_AGENT を設定する。
25
- def user_agent=(str)
26
- self.env["HTTP_USER_AGENT"] = str
27
- end
28
-
29
- # 携帯電話からであれば +true+を、そうでなければ +false+ を返す。
30
- def mobile?
31
- mobile and not mobile.smart_phone?
32
- end
33
-
34
- # viewの切り替えをするかどうか
35
- def smart_phone?
36
- mobile and mobile.smart_phone?
37
- end
38
-
39
- # 携帯電話の機種に応じて Mobile::xxx を返す。
40
- # 携帯電話でない場合はnilを返す。
41
- def mobile
42
- env['rack.jpmobile']
43
- end
44
- end
45
- end
@@ -1,38 +0,0 @@
1
- module Jpmobile
2
- class Resolver < ActionView::FileSystemResolver
3
- # EXTENSION_ORDER = [:variants, :locale, :formats, :handlers]
4
-
5
- def find_templates(name, prefix, partial, details)
6
- path = build_path(name, prefix, partial, details)
7
- query(path, EXTENSION_ORDER.map { |ext| details[ext] }, details[:formats], details[:mobile])
8
- end
9
-
10
- def build_path(name, prefix, partial, details)
11
- path = ""
12
- path << "#{prefix}/" unless prefix.empty?
13
- path << (partial ? "_#{name}" : name)
14
- path
15
- end
16
-
17
- def query(path, exts, formats, mobile)
18
- query = File.join(@path, path)
19
- query << '{' << mobile.map {|v| "_#{v}"}.join(',') << ',}' if mobile and mobile.respond_to?(:map)
20
-
21
- exts.each do |ext|
22
- query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}'
23
- end
24
-
25
- query.gsub!(/\{\.html,/, "{.html,.text.html,")
26
- query.gsub!(/\{\.text,/, "{.text,.text.plain,")
27
-
28
- Dir[query].reject { |p| File.directory?(p) }.map do |p|
29
- handler, format = extract_handler_and_format(p, formats)
30
-
31
- contents = File.open(p, "rb") {|io| io.read }
32
-
33
- ActionView::Template.new(contents, File.expand_path(p), handler,
34
- :virtual_path => path, :format => format)
35
- end
36
- end
37
- end
38
- end
@@ -1,133 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # = セッションIDの付与
3
- require 'active_support/version'
4
-
5
- module ParamsOverCookie
6
- def self.included(base)
7
- base.class_eval do
8
- # cookie よりも params を先に見るパッチ
9
- def extract_session_id_with_jpmobile(env)
10
- request = ActionDispatch::Request.new(env.dup)
11
- if request.params[@key] and !@cookie_only
12
- sid = request.params[@key]
13
- end
14
- sid ||= request.cookies[@key]
15
- sid
16
- end
17
- alias_method_chain :extract_session_id, :jpmobile
18
- end
19
- end
20
- end
21
-
22
- module ActionDispatch
23
- module Session
24
- class AbstractStore
25
- include ParamsOverCookie
26
- end
27
- end
28
- end
29
-
30
- module ActionController
31
- module Redirecting
32
- def redirect_to_with_jpmobile(options = {}, response_status = {})
33
- if apply_trans_sid? and jpmobile_session_id
34
- case options
35
- when %r{^\w[\w+.-]*:.*}
36
- # nothing to do
37
- when String
38
- unless options.match(/#{session_key}/)
39
- url = URI.parse(options)
40
- if url.query
41
- url.query += "&#{session_key}=#{jpmobile_session_id}"
42
- else
43
- url.query = "#{session_key}=#{jpmobile_session_id}"
44
- end
45
- options = url.to_s
46
- end
47
- when :back
48
- # nothing to do
49
- when Hash
50
- unless options[session_key.to_sym]
51
- options[session_key.to_sym] = jpmobile_session_id
52
- end
53
- else
54
- # nothing to do
55
- end
56
- end
57
-
58
- redirect_to_without_jpmobile(options, response_status)
59
- end
60
-
61
- alias_method_chain :redirect_to, :jpmobile
62
- end
63
-
64
- class Metal #:nodoc:
65
- class_inheritable_accessor :trans_sid_mode
66
-
67
- class << self
68
- def trans_sid(mode = :mobile)
69
- include Jpmobile::TransSid
70
- self.trans_sid_mode = mode
71
- end
72
- end
73
-
74
- private
75
- # trans_sidを適用すべきかを返す。
76
- def apply_trans_sid?
77
- # session_id が blank の場合は適用しない
78
- return false if trans_sid_mode and jpmobile_session_id.blank?
79
-
80
- case trans_sid_mode
81
- when :always
82
- session.inspect
83
- return true
84
- when :mobile
85
- if request.mobile? and !request.mobile.supports_cookie?
86
- session.inspect
87
- return true
88
- end
89
- end
90
-
91
- return false
92
- end
93
- end
94
- end
95
-
96
- module Jpmobile::TransSid #:nodoc:
97
- def self.included(controller)
98
- controller.after_filter(:append_session_id_parameter)
99
- end
100
-
101
- protected
102
- # URLにsession_idを追加する。
103
- def default_url_options
104
- result = super || {}
105
- return result unless request # for test process
106
- return result unless apply_trans_sid?
107
- return result.merge({session_key => jpmobile_session_id})
108
- end
109
-
110
- private
111
- # session_keyを返す。
112
- def session_key
113
- unless key = Rails.application.config.session_options.merge(request.session_options || {})[:key]
114
- key = ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS[:key]
115
- end
116
- key
117
- end
118
- # session_idを返す
119
- def jpmobile_session_id
120
- request.session_options[:id] rescue session.session_id
121
- end
122
- # session_idを埋め込むためのhidden fieldを出力する。
123
- def sid_hidden_field_tag
124
- "<input type=\"hidden\" name=\"#{CGI::escapeHTML session_key}\" value=\"#{CGI::escapeHTML jpmobile_session_id}\" />"
125
- end
126
- # formにsession_idを追加する。
127
- def append_session_id_parameter
128
- return unless request # for test process
129
- return unless apply_trans_sid?
130
- return unless jpmobile_session_id
131
- response.body = response.body.gsub(%r{(</form>)}i, sid_hidden_field_tag+'\1')
132
- end
133
- end
@@ -1,370 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'tempfile'
3
- module Jpmobile
4
- module Util
5
- # SJIS = "Shift_JIS"
6
- SJIS = "Windows-31J"
7
- UTF8 = "UTF-8"
8
- JIS = "ISO-2022-JP"
9
- BINARY = "ASCII-8BIT"
10
-
11
- WAVE_DASH = [0x301c].pack("U")
12
- FULLWIDTH_TILDE = [0xff5e].pack("U")
13
-
14
- OVERLINE = [0x203e].pack("U")
15
- FULLWIDTH_MACRON = [0xffe3].pack("U")
16
-
17
- EM_DASH = [0x2014].pack("U")
18
- HORIZONTAL_BAR = [0x2015].pack("U")
19
-
20
- MINUS_SIGN = [0x2212].pack("U")
21
- FULLWIDTH_HYPHEN_MINUS = [0xFF0D].pack("U")
22
-
23
- module_function
24
- def deep_apply(obj, &proc)
25
- case obj
26
- when Hash
27
- obj.each_pair do |key, value|
28
- obj[key] = deep_apply(value, &proc)
29
- end
30
- when Array
31
- obj.collect!{|value| deep_apply(value, &proc)}
32
- when String
33
- obj = obj.to_param if obj.respond_to?(:to_param)
34
- proc.call(obj)
35
- else
36
- # NilClass, TrueClass, FalseClass, Tempfile, StringIO, etc...
37
- return obj
38
- end
39
- end
40
-
41
- def deep_convert(obj, &proc)
42
- case obj
43
- when Hash
44
- new_obj = {}
45
- obj.each_pair do |key, value|
46
- new_obj[deep_convert(key.dup, &proc)] = deep_convert(value, &proc)
47
- end
48
- new_obj
49
- when Array
50
- new_obj = obj.map do |value|
51
- deep_convert(value, &proc)
52
- end
53
- when Symbol
54
- new_obj = proc.call(obj.to_s).to_sym
55
- when String
56
- obj = obj.to_param if obj.respond_to?(:to_param)
57
- new_obj = proc.call(obj)
58
- else
59
- # NilClass, TrueClass, FalseClass, Tempfile, StringIO, etc...
60
- new_obj = obj
61
- end
62
-
63
- new_obj
64
- end
65
-
66
- def sjis(str)
67
- if str.respond_to?(:force_encoding) and !shift_jis?(str)
68
- str.force_encoding(SJIS)
69
- end
70
- str
71
- end
72
-
73
- def utf8(str)
74
- if str.respond_to?(:force_encoding) and !utf8?(str)
75
- str.force_encoding(UTF8)
76
- end
77
- str
78
- end
79
-
80
- def jis(str)
81
- if str.respond_to?(:force_encoding) and !jis?(str)
82
- str.force_encoding(JIS)
83
- end
84
- str
85
- end
86
-
87
- def ascii_8bit(str)
88
- if str.respond_to?(:force_encoding) and !ascii_8bit?(str)
89
- str.force_encoding(BINARY)
90
- end
91
- str
92
- end
93
-
94
- def utf8_to_sjis(utf8_str)
95
- # 波ダッシュ対策
96
- utf8_str = wavedash_to_fullwidth_tilde(utf8_str)
97
- # オーバーライン対策(不可逆的)
98
- utf8_str = overline_to_fullwidth_macron(utf8_str)
99
- # ダッシュ対策(不可逆的)
100
- utf8_str = emdash_to_horizontal_bar(utf8_str)
101
- # マイナス対策(不可逆的)
102
- utf8_str = minus_sign_to_fullwidth_pyphen_minus(utf8_str)
103
-
104
- if utf8_str.respond_to?(:encode)
105
- utf8_str.encode(SJIS, :crlf_newline => true)
106
- else
107
- NKF.nkf("-m0 -x -W --oc=cp932", utf8_str).gsub(/\n/, "\r\n")
108
- end
109
- end
110
-
111
- def sjis_to_utf8(sjis_str)
112
- utf8_str = if sjis_str.respond_to?(:encode)
113
- sjis_str.encode("UTF-8", :universal_newline => true)
114
- else
115
- NKF.nkf("-m0 -x -w --ic=cp932", sjis_str).gsub(/\r\n/, "\n")
116
- end
117
-
118
- # 波ダッシュ対策
119
- fullwidth_tilde_to_wavedash(utf8_str)
120
- end
121
-
122
- def utf8_to_jis(utf8_str)
123
- if utf8_str.respond_to?(:encode)
124
- utf8_str.encode(JIS, :crlf_newline => true)
125
- else
126
- NKF.nkf("-m0 -x -Wj", utf8_str).gsub(/\n/, "\r\n")
127
- end
128
- end
129
-
130
- def jis_to_utf8(jis_str)
131
- if jis_str.respond_to?(:encode)
132
- jis_str.encode(UTF8, :universal_newline => true)
133
- else
134
- NKF.nkf("-m0 -x -Jw", jis_str).gsub(/\r\n/, "\n")
135
- end
136
- end
137
-
138
- def regexp_utf8_to_sjis(utf8_str)
139
- if Object.const_defined?(:Encoding)
140
- Regexp.compile(Regexp.escape(utf8_to_sjis(utf8_str)))
141
- else
142
- Regexp.compile(Regexp.escape(utf8_to_sjis(utf8_str),"s"),nil,'s')
143
- end
144
- end
145
-
146
- def regexp_to_sjis(sjis_str)
147
- if Object.const_defined?(:Encoding)
148
- Regexp.compile(Regexp.escape(sjis(sjis_str)))
149
- else
150
- Regexp.compile(Regexp.escape(sjis_str,"s"),nil,'s')
151
- end
152
- end
153
-
154
- def hash_to_utf8(hash)
155
- new_hash = {}
156
- hash.each do |keu, value|
157
- new_hash[utf8(key)] = utf8(value)
158
- end
159
- end
160
-
161
- def sjis_regexp(sjis)
162
- sjis_str = sjis.kind_of?(Numeric) ? [sjis].pack('n') : sjis
163
-
164
- if Object.const_defined?(:Encoding)
165
- Regexp.compile(Regexp.escape(sjis_str.force_encoding(SJIS)))
166
- else
167
- Regexp.compile(Regexp.escape(sjis_str,"s"),nil,'s')
168
- end
169
- end
170
-
171
- def jis_regexp(jis)
172
- jis_str = jis.kind_of?(Numeric) ? [jis].pack('n') : jis
173
-
174
- if Object.const_defined?(:Encoding)
175
- # Regexp.compile(Regexp.escape(jis_str.force_encoding("stateless-ISO-2022-JP-KDDI"))) # for au only
176
- Regexp.compile(Regexp.escape(jis_str.force_encoding(BINARY))) # for au only
177
- else
178
- Regexp.compile(Regexp.escape(jis_str,"j"),nil,'j')
179
- end
180
- end
181
-
182
- def jis_string_regexp
183
- Regexp.compile(Regexp.escape(ascii_8bit("\x1b\x24\x42")) + "(.+)" + Regexp.escape(ascii_8bit("\x1b\x28\x42")))
184
- end
185
-
186
- def encode(str, charset)
187
- if Object.const_defined?(:Encoding)
188
- (charset.nil? or charset == "" or str.nil? or str == "") ? str : str.encode(charset)
189
- else
190
- if str.nil?
191
- str
192
- else
193
- case charset
194
- when /iso-2022-jp/i
195
- NKF.nkf("-j", str)
196
- when /shift_jis/i
197
- NKF.nkf("-s", str)
198
- when /utf-8/i
199
- NKF.nkf("-w", str)
200
- else
201
- str
202
- end
203
- end
204
- end
205
- end
206
-
207
- def wavedash_to_fullwidth_tilde(utf8_str)
208
- utf8_str.gsub(WAVE_DASH, FULLWIDTH_TILDE)
209
- end
210
-
211
- def fullwidth_tilde_to_wavedash(utf8_str)
212
- utf8_str.gsub(FULLWIDTH_TILDE, WAVE_DASH)
213
- end
214
-
215
- def overline_to_fullwidth_macron(utf8_str)
216
- utf8_str.gsub(OVERLINE, FULLWIDTH_MACRON)
217
- end
218
-
219
- def fullwidth_macron_to_overline(utf8_str)
220
- utf8_str.gsub(FULLWIDTH_MACRON, OVERLINE)
221
- end
222
-
223
- def emdash_to_horizontal_bar(utf8_str)
224
- utf8_str.gsub(EM_DASH, HORIZONTAL_BAR)
225
- end
226
-
227
- def minus_sign_to_fullwidth_pyphen_minus(utf8_str)
228
- utf8_str.gsub(MINUS_SIGN, FULLWIDTH_HYPHEN_MINUS)
229
- end
230
-
231
- def fullwidth_pyphen_minus_to_minus_sign(utf8_str)
232
- utf8_str.gsub(FULLWIDTH_HYPHEN_MINUS, MINUS_SIGN)
233
- end
234
-
235
- def force_encode(str, from, to)
236
- s = str.dup
237
- return str if detect_encoding(str) == to
238
-
239
- if Object.const_defined?(:Encoding)
240
- to = SJIS if to =~ /shift_jis/i
241
-
242
- to_enc = ::Encoding.find(to)
243
- return str if s.encoding == to_enc
244
-
245
- if from
246
- from_enc = ::Encoding.find(from)
247
- s.force_encoding(from) unless s.encoding == from_enc
248
- end
249
-
250
- s.encode(to)
251
- else
252
- opt = []
253
- opt << case from
254
- when /iso-2022-jp/i
255
- "-Jx"
256
- when /shift_jis/i
257
- "-Sx"
258
- when /utf-8/i
259
- "-Wx"
260
- else
261
- ""
262
- end
263
- opt << case to
264
- when /iso-2022-jp/i
265
- "-j"
266
- when /shift_jis/i, /windows_31j/i
267
- "-s"
268
- when /utf-8/i
269
- "-w"
270
- else
271
- ""
272
- end
273
- NKF.nkf(opt.join(" "), str)
274
- end
275
- end
276
-
277
- def set_encoding(str, encoding)
278
- if encoding and Object.const_defined?(:Encoding)
279
- encoding = SJIS if encoding =~ /shift_jis/i
280
-
281
- str.force_encoding(encoding)
282
- end
283
-
284
- str
285
- end
286
-
287
- def extract_charset(str)
288
- case str
289
- when /iso-2022-jp/i
290
- "ISO-2022-JP"
291
- when /shift_jis/i
292
- "Shift_JIS"
293
- when /utf-8/i
294
- "UTF-8"
295
- else
296
- ""
297
- end
298
- end
299
-
300
- def detect_encoding(str)
301
- if Object.const_defined?(:Encoding)
302
- case str.encoding
303
- when ::Encoding::ISO2022_JP
304
- JIS
305
- when ::Encoding::Shift_JIS, ::Encoding::Windows_31J, ::Encoding::CP932
306
- SJIS
307
- when ::Encoding::UTF_8
308
- UTF8
309
- when ::Encoding::ASCII_8BIT
310
- BINARY
311
- else
312
- BINARY
313
- end
314
- else
315
- case NKF.guess(str)
316
- when NKF::SJIS
317
- SJIS
318
- when NKF::JIS
319
- JIS
320
- when NKF::UTF8
321
- UTF8
322
- when NKF::BINARY
323
- BINARY
324
- else
325
- BINARY
326
- end
327
- end
328
- end
329
-
330
- def ascii_8bit?(str)
331
- detect_encoding(str) == BINARY
332
- end
333
- def utf8?(str)
334
- detect_encoding(str) == UTF8
335
- end
336
- def shift_jis?(str)
337
- detect_encoding(str) == SJIS
338
- end
339
- def jis?(str)
340
- detect_encoding(str) == JIS
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
369
- end
370
- end