jpmobile 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README +32 -10
  2. data/Rakefile +8 -8
  3. data/doc/classes/ActionController.html +120 -0
  4. data/doc/classes/ActionController/AbstractRequest.html +118 -0
  5. data/doc/classes/ActionController/CgiRequest.html +160 -0
  6. data/doc/classes/ActionView.html +101 -0
  7. data/doc/classes/DatumConv.html +324 -0
  8. data/doc/classes/Jpmobile/Display.html +333 -0
  9. data/doc/classes/Jpmobile/Emoticon.html +467 -0
  10. data/doc/classes/Jpmobile/Filter.html +120 -0
  11. data/doc/classes/Jpmobile/Filter/ApplyOnlyForMobile.html +172 -0
  12. data/doc/classes/Jpmobile/Filter/Base.html +269 -0
  13. data/doc/classes/Jpmobile/Filter/Emoticon.html +118 -0
  14. data/doc/classes/Jpmobile/Filter/Emoticon/Inner.html +184 -0
  15. data/doc/classes/Jpmobile/Filter/Emoticon/Outer.html +207 -0
  16. data/doc/classes/Jpmobile/Filter/FilterTable.html +178 -0
  17. data/doc/classes/Jpmobile/Filter/HankakuKana.html +126 -0
  18. data/doc/classes/Jpmobile/Filter/Sjis.html +271 -0
  19. data/doc/classes/Jpmobile/Helpers.html +588 -0
  20. data/doc/classes/Jpmobile/Mobile.html +150 -0
  21. data/doc/classes/Jpmobile/Mobile/AbstractMobile.html +389 -0
  22. data/doc/classes/Jpmobile/Mobile/Au.html +420 -0
  23. data/doc/classes/Jpmobile/Mobile/Ddipocket.html +138 -0
  24. data/doc/classes/Jpmobile/Mobile/Docomo.html +411 -0
  25. data/doc/classes/Jpmobile/Mobile/Emobile.html +183 -0
  26. data/doc/classes/Jpmobile/Mobile/Jphone.html +212 -0
  27. data/doc/classes/Jpmobile/Mobile/Softbank.html +344 -0
  28. data/doc/classes/Jpmobile/Mobile/Vodafone.html +176 -0
  29. data/doc/classes/Jpmobile/Mobile/Willcom.html +211 -0
  30. data/doc/classes/Jpmobile/Position.html +384 -0
  31. data/doc/classes/Jpmobile/RequestWithMobile.html +263 -0
  32. data/doc/created.rid +1 -0
  33. data/doc/files/CHANGELOG.html +110 -0
  34. data/doc/files/README.html +455 -0
  35. data/doc/files/lib/jpmobile/datum_conv_rb.html +110 -0
  36. data/doc/files/lib/jpmobile/emoticon/au_rb.html +124 -0
  37. data/doc/files/lib/jpmobile/emoticon/conversion_table_rb.html +124 -0
  38. data/doc/files/lib/jpmobile/emoticon/docomo_rb.html +119 -0
  39. data/doc/files/lib/jpmobile/emoticon/softbank_rb.html +119 -0
  40. data/doc/files/lib/jpmobile/emoticon/z_combine_rb.html +101 -0
  41. data/doc/files/lib/jpmobile/emoticon_rb.html +101 -0
  42. data/doc/files/lib/jpmobile/filter_rb.html +115 -0
  43. data/doc/files/lib/jpmobile/helpers_rb.html +105 -0
  44. data/doc/files/lib/jpmobile/hook_abstract_request_rb.html +108 -0
  45. data/doc/files/lib/jpmobile/hook_action_controller_rb.html +101 -0
  46. data/doc/files/lib/jpmobile/hook_action_view_rb.html +110 -0
  47. data/doc/files/lib/jpmobile/mobile/abstract_mobile_rb.html +108 -0
  48. data/doc/files/lib/jpmobile/mobile/au_rb.html +112 -0
  49. data/doc/files/lib/jpmobile/mobile/display_rb.html +111 -0
  50. data/doc/files/lib/jpmobile/mobile/docomo_rb.html +105 -0
  51. data/doc/files/lib/jpmobile/mobile/emobile_rb.html +105 -0
  52. data/doc/files/lib/jpmobile/mobile/softbank_rb.html +115 -0
  53. data/doc/files/lib/jpmobile/mobile/willcom_rb.html +108 -0
  54. data/doc/files/lib/jpmobile/mobile/z_display_info_docomo_rb.html +114 -0
  55. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_au_rb.html +114 -0
  56. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_docomo_rb.html +124 -0
  57. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_emobile_rb.html +111 -0
  58. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_softbank_rb.html +124 -0
  59. data/doc/files/lib/jpmobile/mobile/z_ip_addresses_willcom_rb.html +114 -0
  60. data/doc/files/lib/jpmobile/position_rb.html +105 -0
  61. data/doc/files/lib/jpmobile/request_with_mobile_rb.html +111 -0
  62. data/doc/files/lib/jpmobile/trans_sid_rb.html +118 -0
  63. data/doc/files/lib/jpmobile/version_rb.html +101 -0
  64. data/doc/files/lib/jpmobile_rb.html +101 -0
  65. data/doc/fr_class_index.html +55 -0
  66. data/doc/fr_file_index.html +58 -0
  67. data/doc/fr_method_index.html +134 -0
  68. data/doc/index.html +24 -0
  69. data/doc/rdoc-style.css +208 -0
  70. data/lib/jpmobile.rb +32 -1
  71. data/lib/jpmobile/emoticon.rb +18 -0
  72. data/lib/jpmobile/emoticon/au.rb +643 -0
  73. data/lib/jpmobile/filter.rb +5 -1
  74. data/lib/jpmobile/helpers.rb +9 -1
  75. data/lib/jpmobile/hook_abstract_request.rb +3 -24
  76. data/lib/jpmobile/hook_action_controller.rb +2 -2
  77. data/lib/jpmobile/hook_action_view.rb +41 -8
  78. data/lib/jpmobile/mobile/abstract_mobile.rb +18 -12
  79. data/lib/jpmobile/mobile/au.rb +11 -5
  80. data/lib/jpmobile/mobile/docomo.rb +27 -11
  81. data/lib/jpmobile/mobile/emobile.rb +15 -0
  82. data/lib/jpmobile/mobile/softbank.rb +11 -7
  83. data/lib/jpmobile/mobile/willcom.rb +5 -2
  84. data/lib/jpmobile/mobile/z_display_info_docomo.rb +343 -219
  85. data/lib/jpmobile/mobile/z_ip_addresses_au.rb +4 -1
  86. data/lib/jpmobile/mobile/z_ip_addresses_docomo.rb +10 -0
  87. data/lib/jpmobile/mobile/z_ip_addresses_emobile.rb +10 -0
  88. data/lib/jpmobile/mobile/{z_ip_addresses.rb → z_ip_addresses_softbank.rb} +2 -13
  89. data/lib/jpmobile/mobile/z_ip_addresses_willcom.rb +20 -1
  90. data/lib/jpmobile/position.rb +2 -2
  91. data/lib/jpmobile/request_with_mobile.rb +44 -0
  92. data/lib/jpmobile/trans_sid.rb +52 -14
  93. data/lib/jpmobile/version.rb +1 -1
  94. data/test/au_test.rb +94 -63
  95. data/test/autoload_test.rb +49 -0
  96. data/test/docomo_test.rb +92 -59
  97. data/test/emoticon_functional_test.rb +30 -3
  98. data/test/filter_test.rb +0 -64
  99. data/test/helper.rb +8 -1
  100. data/test/helpers_test.rb +14 -13
  101. data/test/softbank_test.rb +113 -85
  102. data/test/willcom_test.rb +30 -20
  103. data/tools/generate_au_emoticon_table.rb +12 -3
  104. data/tools/update_display_info_docomo.rb +0 -0
  105. data/tools/update_ip_addresses_au.rb +1 -1
  106. data/tools/update_ip_addresses_willcom.rb +1 -1
  107. metadata +135 -54
  108. data/test/filter_functional_test.rb +0 -146
@@ -0,0 +1,263 @@
1
+ <?xml version="1.0" encoding=" UTF-8"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Jpmobile::RequestWithMobile</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Jpmobile::RequestWithMobile</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/jpmobile/request_with_mobile_rb.html">
59
+ lib/jpmobile/request_with_mobile.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+ <div id="method-list">
80
+ <h3 class="section-bar">Methods</h3>
81
+
82
+ <div class="name-list">
83
+ <a href="#M000011">mobile</a>&nbsp;&nbsp;
84
+ <a href="#M000010">mobile?</a>&nbsp;&nbsp;
85
+ <a href="#M000008">remote_addr</a>&nbsp;&nbsp;
86
+ <a href="#M000007">user_agent</a>&nbsp;&nbsp;
87
+ <a href="#M000009">user_agent=</a>&nbsp;&nbsp;
88
+ </div>
89
+ </div>
90
+
91
+ </div>
92
+
93
+
94
+ <!-- if includes -->
95
+
96
+ <div id="section">
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <!-- if method_list -->
106
+ <div id="methods">
107
+ <h3 class="section-bar">Public Instance methods</h3>
108
+
109
+ <div id="method-M000011" class="method-detail">
110
+ <a name="M000011"></a>
111
+
112
+ <div class="method-heading">
113
+ <a href="#M000011" class="method-signature">
114
+ <span class="method-name">mobile</span><span class="method-args">()</span>
115
+ </a>
116
+ </div>
117
+
118
+ <div class="method-description">
119
+ <p>
120
+ 携帯電話の機種に応じて Mobile::xxx を返す。
121
+ 携帯電話でない場合はnilを返す。
122
+ </p>
123
+ <p><a class="source-toggle" href="#"
124
+ onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
125
+ <div class="method-source-code" id="M000011-source">
126
+ <pre>
127
+ <span class="ruby-comment cmt"># File lib/jpmobile/request_with_mobile.rb, line 33</span>
128
+ 33: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mobile</span>
129
+ 34: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@__mobile</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@__mobile</span>
130
+ 35:
131
+ 36: <span class="ruby-constant">Jpmobile</span><span class="ruby-operator">::</span><span class="ruby-constant">Mobile</span>.<span class="ruby-identifier">constants</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">const</span><span class="ruby-operator">|</span>
132
+ 37: <span class="ruby-identifier">c</span> = <span class="ruby-constant">Jpmobile</span><span class="ruby-operator">::</span><span class="ruby-constant">Mobile</span>.<span class="ruby-identifier">const_get</span>(<span class="ruby-identifier">const</span>)
133
+ 38: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@__mobile</span> = <span class="ruby-identifier">c</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">c</span><span class="ruby-operator">::</span><span class="ruby-constant">USER_AGENT_REGEXP</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">user_agent</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">c</span><span class="ruby-operator">::</span><span class="ruby-constant">USER_AGENT_REGEXP</span>
134
+ 39: <span class="ruby-keyword kw">end</span>
135
+ 40: <span class="ruby-keyword kw">nil</span>
136
+ 41: <span class="ruby-keyword kw">end</span>
137
+ </pre>
138
+ </div>
139
+ </div>
140
+ </div>
141
+
142
+ <div id="method-M000010" class="method-detail">
143
+ <a name="M000010"></a>
144
+
145
+ <div class="method-heading">
146
+ <a href="#M000010" class="method-signature">
147
+ <span class="method-name">mobile?</span><span class="method-args">()</span>
148
+ </a>
149
+ </div>
150
+
151
+ <div class="method-description">
152
+ <p>
153
+ 携帯電話からであれば <tt>true</tt>を、そうでなければ
154
+ <tt>false</tt> を返す。
155
+ </p>
156
+ <p><a class="source-toggle" href="#"
157
+ onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
158
+ <div class="method-source-code" id="M000010-source">
159
+ <pre>
160
+ <span class="ruby-comment cmt"># File lib/jpmobile/request_with_mobile.rb, line 27</span>
161
+ 27: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mobile?</span>
162
+ 28: <span class="ruby-identifier">mobile</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword kw">nil</span>
163
+ 29: <span class="ruby-keyword kw">end</span>
164
+ </pre>
165
+ </div>
166
+ </div>
167
+ </div>
168
+
169
+ <div id="method-M000008" class="method-detail">
170
+ <a name="M000008"></a>
171
+
172
+ <div class="method-heading">
173
+ <a href="#M000008" class="method-signature">
174
+ <span class="method-name">remote_addr</span><span class="method-args">()</span>
175
+ </a>
176
+ </div>
177
+
178
+ <div class="method-description">
179
+ <p>
180
+ for reverse proxy.
181
+ </p>
182
+ <p><a class="source-toggle" href="#"
183
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
184
+ <div class="method-source-code" id="M000008-source">
185
+ <pre>
186
+ <span class="ruby-comment cmt"># File lib/jpmobile/request_with_mobile.rb, line 13</span>
187
+ 13: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remote_addr</span>
188
+ 14: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:remote_ip</span>
189
+ 15: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:remote_ip</span>)
190
+ 16: <span class="ruby-keyword kw">else</span>
191
+ 17: <span class="ruby-keyword kw">return</span> ( <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_X_FORWARDED_FOR&quot;</span>] <span class="ruby-operator">?</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_X_FORWARDED_FOR&quot;</span>].<span class="ruby-identifier">split</span>(<span class="ruby-value str">','</span>).<span class="ruby-identifier">pop</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;REMOTE_ADDR&quot;</span>] )
192
+ 18: <span class="ruby-keyword kw">end</span>
193
+ 19: <span class="ruby-keyword kw">end</span>
194
+ </pre>
195
+ </div>
196
+ </div>
197
+ </div>
198
+
199
+ <div id="method-M000007" class="method-detail">
200
+ <a name="M000007"></a>
201
+
202
+ <div class="method-heading">
203
+ <a href="#M000007" class="method-signature">
204
+ <span class="method-name">user_agent</span><span class="method-args">()</span>
205
+ </a>
206
+ </div>
207
+
208
+ <div class="method-description">
209
+ <p>
210
+ 環境変数 HTTP_USER_AGENT を返す。
211
+ </p>
212
+ <p><a class="source-toggle" href="#"
213
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
214
+ <div class="method-source-code" id="M000007-source">
215
+ <pre>
216
+ <span class="ruby-comment cmt"># File lib/jpmobile/request_with_mobile.rb, line 8</span>
217
+ 8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user_agent</span>
218
+ 9: <span class="ruby-identifier">env</span>[<span class="ruby-value str">'HTTP_USER_AGENT'</span>]
219
+ 10: <span class="ruby-keyword kw">end</span>
220
+ </pre>
221
+ </div>
222
+ </div>
223
+ </div>
224
+
225
+ <div id="method-M000009" class="method-detail">
226
+ <a name="M000009"></a>
227
+
228
+ <div class="method-heading">
229
+ <a href="#M000009" class="method-signature">
230
+ <span class="method-name">user_agent=</span><span class="method-args">(str)</span>
231
+ </a>
232
+ </div>
233
+
234
+ <div class="method-description">
235
+ <p>
236
+ 環境変数 HTTP_USER_AGENT を設定する。
237
+ </p>
238
+ <p><a class="source-toggle" href="#"
239
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
240
+ <div class="method-source-code" id="M000009-source">
241
+ <pre>
242
+ <span class="ruby-comment cmt"># File lib/jpmobile/request_with_mobile.rb, line 22</span>
243
+ 22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">user_agent=</span>(<span class="ruby-identifier">str</span>)
244
+ 23: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">env</span>[<span class="ruby-value str">&quot;HTTP_USER_AGENT&quot;</span>] = <span class="ruby-identifier">str</span>
245
+ 24: <span class="ruby-keyword kw">end</span>
246
+ </pre>
247
+ </div>
248
+ </div>
249
+ </div>
250
+
251
+
252
+ </div>
253
+
254
+
255
+ </div>
256
+
257
+
258
+ <div id="validator-badges">
259
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
260
+ </div>
261
+
262
+ </body>
263
+ </html>
data/doc/created.rid ADDED
@@ -0,0 +1 @@
1
+ Wed, 23 Jul 2008 19:26:26 +0900
@@ -0,0 +1,110 @@
1
+ <?xml version="1.0" encoding=" UTF-8"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: CHANGELOG</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>CHANGELOG</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>CHANGELOG
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Sun Jun 29 23:25:09 +0900 2008</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h2>0.0.1 2007-06-16</h2>
73
+ <ul>
74
+ <li>Initial release
75
+
76
+ </li>
77
+ </ul>
78
+
79
+ </div>
80
+
81
+
82
+ </div>
83
+
84
+
85
+ </div>
86
+
87
+
88
+ <!-- if includes -->
89
+
90
+ <div id="section">
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+ <!-- if method_list -->
100
+
101
+
102
+ </div>
103
+
104
+
105
+ <div id="validator-badges">
106
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
107
+ </div>
108
+
109
+ </body>
110
+ </html>
@@ -0,0 +1,455 @@
1
+ <?xml version="1.0" encoding=" UTF-8"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Jul 23 19:24:51 +0900 2008</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <h1>jpmobile: A Rails plugin for Japanese mobile-phones</h1>
73
+ <h2>jpmobileとは</h2>
74
+ <p>
75
+ 携帯電話特有の機能を Rails
76
+ で利用するためのプラグイン。 以下の機能を備える。
77
+ </p>
78
+ <ul>
79
+ <li>携帯電話のキャリア判別
80
+
81
+ </li>
82
+ <li>端末位置情報の取得
83
+
84
+ </li>
85
+ <li>端末製造番号、契約者番号等の取得
86
+
87
+ </li>
88
+ <li>IPアドレスの検証(キャリアが公開しているIPアドレス帯域からのアクセスか判定)
89
+
90
+ </li>
91
+ <li>セッションIDをフォーム/リンクに付与(Trans SID)
92
+
93
+ </li>
94
+ <li>携帯電話ビューへの自動振分け
95
+
96
+ </li>
97
+ <li>ディスプレイ情報(画面サイズ、ブラウザ画面サイズ、カラー・白黒、色数)の取得
98
+
99
+ </li>
100
+ <li>GeoKit(<a
101
+ href="http://geokit.rubyforge.org">geokit.rubyforge.org</a>)との連携
102
+
103
+ </li>
104
+ <li>文字コード変換機能/絵文字のキャリア間相互変換
105
+
106
+ </li>
107
+ </ul>
108
+ <h2>インストール</h2>
109
+ <h3>svnレポジトリからインストールする場合</h3>
110
+ <p>
111
+ リリース版:
112
+ </p>
113
+ <pre>
114
+ % ./script/plugin install http://jpmobile.rubyforge.org/svn/tags/rel-x.x.x/jpmobile
115
+ (x.x.xはバージョン)
116
+ </pre>
117
+ <p>
118
+ 開発版:
119
+ </p>
120
+ <pre>
121
+ % ./script/plugin install git://github.com/darashi/jpmobile.git
122
+ </pre>
123
+ <h3>gemでインストールする場合</h3>
124
+ <pre>
125
+ # gem install jpmobile
126
+ </pre>
127
+ <p>
128
+ としてgemをインストールした後 RAILS_ROOT/config/environment.rb
129
+ の Rails::Initializer.run do |config| 〜 end 内に
130
+ </p>
131
+ <pre>
132
+ config.gem &quot;jpmobile&quot;
133
+ </pre>
134
+ <p>
135
+ の行を追加する。
136
+ </p>
137
+ <h2>使用例</h2>
138
+ <h3>携帯電話の識別</h3>
139
+ <h4>Viewの中で一部を切替える例</h4>
140
+ <pre>
141
+ &lt;% if request.mobile? %&gt;
142
+ 携帯電話からのアクセスです。
143
+ &lt;% else %&gt;
144
+ 携帯電話からのアクセスではありません。
145
+ &lt;% end %&gt;
146
+ </pre>
147
+ <h4>別に用意した携帯電話用コントローラへリダイレクトする例</h4>
148
+ <pre>
149
+ class PcController &lt; ApplicationController
150
+ before_filter :redirect_if_mobile
151
+
152
+ def index
153
+ end
154
+
155
+ private
156
+ def redirect_if_mobile
157
+ if request.mobile?
158
+ pa = params.dup
159
+ pa[:controller] = &quot;/mobile&quot;
160
+ redirect_to pa
161
+ end
162
+ end
163
+ end
164
+
165
+ class MobileController &lt; ApplicationController
166
+ after_filter :to_sjis
167
+
168
+ def index
169
+ end
170
+
171
+ private
172
+ def to_sjis
173
+ @headers[&quot;Content-Type&quot;] = &quot;text/html; charset=Shift_JIS&quot;
174
+ response.body = response.body.tosjis
175
+ end
176
+ end
177
+ </pre>
178
+ <h3>携帯電話viewの自動振分け</h3>
179
+ <p>
180
+ DoCoMo携帯電話からアクセスすると、
181
+ </p>
182
+ <ul>
183
+ <li>index_mobile_docomo.rhtml
184
+
185
+ </li>
186
+ <li>index_mobile.rhtml
187
+
188
+ </li>
189
+ <li>index.rhtml
190
+
191
+ </li>
192
+ </ul>
193
+ <p>
194
+ の順でテンプレートを検索し、最初に見付かったテンプレートが利用される。
195
+ Auの場合は、index_mobile_au.rhtml、Softbankの場合はindex_mobile_softbank.rhtmlが最初に検索される。
196
+ </p>
197
+ <p>
198
+ BUG: 現状、上記の例では index.rhtml
199
+ が存在しない場合に振り分けが行われない(ダミーファイルを置くことで回避可能)。
200
+ </p>
201
+ <h4>キャリアの識別</h4>
202
+ <pre>
203
+ case request.mobile
204
+ when Jpmobile::Mobile::Docomo
205
+ # for DoCoMo
206
+ when Jpmobile::Mobile::Au
207
+ # for au
208
+ when Jpmobile::Mobile::Softbank
209
+ # for SoftBank
210
+ when Jpmobile::Mobile::Willcom
211
+ # for Willcom
212
+ when Jpmobile::Mobile::Emobile
213
+ # for Willcom
214
+ else
215
+ # for PC
216
+ end
217
+ </pre>
218
+ <p>
219
+ あるいは
220
+ </p>
221
+ <pre>
222
+ if request.mobile.is_a?(Jpmobile::Mobile::Docomo)
223
+ # for DoCoMo
224
+ end
225
+ </pre>
226
+ <h3>位置情報の取得</h3>
227
+ <h4>取得用リンクの生成</h4>
228
+ <p>
229
+ 以下のようなコードで、端末に位置情報を要求するリンクを出力する。
230
+ </p>
231
+ <pre>
232
+ &lt;%= get_position_link_to(:action=&gt;:gps) %&gt;
233
+ </pre>
234
+ <h4>位置情報の取得</h4>
235
+ <pre>
236
+ class MobileController &lt; ApplicationController
237
+ def gps
238
+ if request.mobile &amp;&amp; pos = request.mobile.position
239
+ @latitude = pos.lat
240
+ @longuitude = pos.lon
241
+ end
242
+ end
243
+ end
244
+ </pre>
245
+ <h3>端末情報の取得</h3>
246
+ <p>
247
+ 端末側から通知されている場合、request.ident で
248
+ 契約に固有の識別子もしくは端末の製造番号を取得できる。
249
+ 両方存在する場合は契約に固有のIDが優先される。
250
+ </p>
251
+ <ul>
252
+ <li>契約に固有のID (request.ident_subscriber)
253
+
254
+ <ul>
255
+ <li>au: EZ番号(サブスクライバ番号)
256
+
257
+ </li>
258
+ <li>DoCoMo: FOMAカード製造番号
259
+
260
+ </li>
261
+ <li>EMOBILE: EMnet対応端末から通知されるユニークなユーザID
262
+
263
+ </li>
264
+ </ul>
265
+ </li>
266
+ <li>端末製造番号 (request.ident_device)
267
+
268
+ <ul>
269
+ <li>DoCoMo: 端末製造番号(FOMA, MOVA)
270
+
271
+ </li>
272
+ <li>SoftBank: 製造番号
273
+
274
+ </li>
275
+ </ul>
276
+ </li>
277
+ </ul>
278
+ <h3>IPの検証</h3>
279
+ <p>
280
+ キャリアが公開しているIPアドレス帯域からのアクセスか判定する。
281
+ </p>
282
+ <pre>
283
+ request.mobile.valid_ip?
284
+ </pre>
285
+ <h3>セッションIDの付与(Transit SID)</h3>
286
+ <h4>Cookie非対応携帯だけに付与する</h4>
287
+ <pre>
288
+ class MyController
289
+ trans_sid
290
+ end
291
+ </pre>
292
+ <h4>PCにも付与する</h4>
293
+ <pre>
294
+ class MyController
295
+ trans_sid :always
296
+ end
297
+ </pre>
298
+ <h3>端末の画面サイズ</h3>
299
+ <p>
300
+ request.mobile.display で <a
301
+ href="../classes/Jpmobile/Display.html">Jpmobile::Display</a>
302
+ クラスのインスタンスが返る。
303
+ </p>
304
+ <pre>
305
+ 画面幅 &lt;%= request.mobile.display.width %&gt;
306
+ 画面高さ &lt;%= request.mobile.display.height %&gt;
307
+ </pre>
308
+ <h3>GeoKit(<a href="http://geokit.rubyforge.org">geokit.rubyforge.org</a>)との連携</h3>
309
+ <p>
310
+ vandor/plugins/geokit以下にGeoKitがインストールされていると、<a
311
+ href="../classes/Jpmobile/Position.html">Jpmobile::Position</a>にGeoKit::Mappableがincludeされる。したがって、
312
+ </p>
313
+ <pre>
314
+ request.mobile.position.distance_to('札幌駅')
315
+ </pre>
316
+ <p>
317
+ とすることで、端末と「札幌駅」との距離を求めることができる。詳細は
318
+ <a
319
+ href="http://geokit.rubyforge.org/api/index.html">geokit.rubyforge.org/api/index.html</a>
320
+ 参照。
321
+ </p>
322
+ <h3>文字コード変換機能/絵文字のキャリア間相互変換</h3>
323
+ <p>
324
+ JpmobileではControllerにmobile_filterを指定することで
325
+ DoCoMo、Au、SoftBankの絵文字を透過的に扱うことができる。
326
+ </p>
327
+ <pre>
328
+ class MyController
329
+ mobile_filter
330
+ end
331
+ </pre>
332
+ <p>
333
+ また、半角・全角の自動変換を用いる場合は
334
+ </p>
335
+ <pre>
336
+ class MyController
337
+ mobile_filter :hankaku=&gt;true
338
+ end
339
+ </pre>
340
+ <p>
341
+ と指定する。
342
+ </p>
343
+ <p>
344
+ Jpmobile内では、各キャリアの絵文字はUnicode私的領域上にマッピングされ、管理される。
345
+ このとき、DoCoMo、Auは公式サイト記載のマッピングが使用される。
346
+ ただしSoftBankはAuとの重複を避けるため、公式のマッピングに0x1000加算しU+F001以降に割り当てる。
347
+ テンプレート内ではUTF-8でエンコードするか、数値文字参照の&amp;xHHHH;形式で指定する。
348
+ </p>
349
+ <p>
350
+ 絵文字は送出時に内蔵の変換表に基づいて変換され、携帯電話のエンコーディングにあわせて送出される。
351
+ 携帯電話から受信した絵文字は上記マッピングに基づいてUTF-8でparamsに渡される。
352
+ </p>
353
+ <p>
354
+ mobile_filterを有効にすると以下の処理が自動で行われる。
355
+ </p>
356
+ <ul>
357
+ <li>DoCoMo、Auとの通信時にはShift_JIS、SoftBankとの通信時にはUTF-8が使用される。
358
+
359
+ </li>
360
+ <li>:hankaku=&gt;true指定時は、カタカナは半角カナに変換されて送出される。携帯電話から送られた半角カナは全角カナに変換される。
361
+
362
+ </li>
363
+ <li>絵文字はキャリアにあわせて変換されて送出される。
364
+
365
+ </li>
366
+ <li>携帯電話からの絵文字はUnicode私的領域にマップされ、UTF-8でparamsに格納される。
367
+
368
+ </li>
369
+ </ul>
370
+ <h2>テストに必要なgemパッケージ</h2>
371
+ <p>
372
+ テストを実行するためには以下のgemパッケージが必要です。
373
+ </p>
374
+ <ul>
375
+ <li>rails
376
+
377
+ </li>
378
+ <li>rack
379
+
380
+ </li>
381
+ <li>hpricot
382
+
383
+ </li>
384
+ <li>spec-fixtures
385
+
386
+ </li>
387
+ </ul>
388
+ <h2>リンク</h2>
389
+ <ul>
390
+ <li>Project Website: <a href="http://jpmobile-rails.org">jpmobile-rails.org</a>
391
+
392
+ </li>
393
+ <li>RDoc Documentation: <a
394
+ href="http://jpmobile.rubyforge.org/rdoc">jpmobile.rubyforge.org/rdoc</a>
395
+
396
+ </li>
397
+ <li>GitHub: <a
398
+ href="http://github.com/darashi/jpmobile">github.com/darashi/jpmobile</a>/
399
+
400
+ </li>
401
+ <li>RubyForge Project Page: <a
402
+ href="http://rubyforge.org/projects/jpmobile">rubyforge.org/projects/jpmobile</a>
403
+
404
+ </li>
405
+ <li>Mailing List: <a
406
+ href="http://groups.google.com/group/jpmobile">groups.google.com/group/jpmobile</a>
407
+
408
+ </li>
409
+ <li>IRC Channel jpmobile@freenode.net
410
+
411
+ </li>
412
+ </ul>
413
+ <h2>作者</h2>
414
+ <p>
415
+ Copyright 2006 (c) Yohji Shidara, under MIT License.
416
+ </p>
417
+ <p>
418
+ Yohji Shidara &lt;dara@shidara.net&gt;
419
+ </p>
420
+ <p>
421
+ <a href="http://d.hatena.ne.jp/darashi">d.hatena.ne.jp/darashi</a>
422
+ </p>
423
+
424
+ </div>
425
+
426
+
427
+ </div>
428
+
429
+
430
+ </div>
431
+
432
+
433
+ <!-- if includes -->
434
+
435
+ <div id="section">
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+ <!-- if method_list -->
445
+
446
+
447
+ </div>
448
+
449
+
450
+ <div id="validator-badges">
451
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
452
+ </div>
453
+
454
+ </body>
455
+ </html>