jpmobile 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -6,10 +6,12 @@
6
6
 
7
7
  * 携帯電話のキャリア判別
8
8
  * 端末位置情報の取得
9
- * GeoKit(http://geokit.rubyforge.org)との連携
9
+ * {GeoKit}[http://geokit.rubyforge.org] との連携
10
10
  * 端末製造番号、契約者番号等の取得
11
11
  * IPアドレスの検証(キャリアが公開しているIPアドレス帯域からのアクセスか判定)
12
+ * IPアドレスの検証には {jpmobile-ipaddresses}[http://github.com/jpmobile/jpmobile-ipaddresses] が必要です。
12
13
  * ディスプレイ情報(画面サイズ、ブラウザ画面サイズ、カラー・白黒、色数)の取得
14
+ * ディスプレイ情報の取得には {jpmobile-terminfo}[http://github.com/jpmobile/jpmobile-terminfo] が必要です。
13
15
  * 文字コード変換機能/絵文字のキャリア間相互変換
14
16
 
15
17
  また Rails 3.0 に以下の機能を追加する
@@ -20,9 +22,17 @@
20
22
  == インストール
21
23
  === Rails pluginとしてインストールする場合
22
24
  % rails plugin install git://github.com/jpmobile/jpmobile.git
25
+ ==== IPアドレス検証が必要な場合
26
+ % rails plugin install git://github.com/jpmobile/jpmobile-ipaddresses.git
27
+ ==== ディスプレイ情報を取得する必要がある場合
28
+ % rails plugin install git://github.com/jpmobile/jpmobile-ipaddresses.git
23
29
 
24
30
  === gemでインストールする場合
25
31
  % gem install jpmobile
32
+ ==== IPアドレス検証が必要な場合
33
+ % gem install jpmobile-ipaddresses
34
+ ==== ディスプレイ情報を取得する必要がある場合
35
+ % gem install jpmobile-terminfo
26
36
 
27
37
  == 使用例
28
38
 
@@ -97,7 +107,7 @@ Rack::Request#mobile.position に位置情報が格納されます。
97
107
  @latitude = request.mobile.position.lat
98
108
  @longuitude = request.mobile.position.lon
99
109
 
100
- ==== GeoKit(http://geokit.rubyforge.org)との連携
110
+ ==== {GeoKit}[http://geokit.rubyforge.org] との連携
101
111
 
102
112
  vandor/plugins/geokit以下にGeoKitがインストールされていると、Jpmobile::PositionにGeoKit::Mappableがincludeされる。したがって、
103
113
 
@@ -122,12 +132,13 @@ vandor/plugins/geokit以下にGeoKitがインストールされていると、Jp
122
132
  === IPの検証
123
133
  キャリアが公開しているIPアドレス帯域からのアクセスか判定する。
124
134
  request.mobile.valid_ip?
125
- ただしスマートフォンの場合は必ずfalseとなる。
135
+ ただし {jpmobile-ipaddresses}[http://github.com/jpmobile/jpmobile-ipaddresses] がインストールされていないか、スマートフォンの場合は必ずfalseとなる。
126
136
 
127
137
  === 端末の画面サイズ
128
138
  request.mobile.display で Jpmobile::Display クラスのインスタンスが返る。
129
139
  画面幅 <%= request.mobile.display.width %>
130
140
  画面高さ <%= request.mobile.display.height %>
141
+ ただし {jpmobile-terminfo}[http://github.com/jpmobile/jpmobile-terminfo] がインストールされていない場合はエラーとなるので注意が必要。
131
142
 
132
143
  === 文字コード変換機能/絵文字のキャリア間相互変換
133
144
 
data/Rakefile CHANGED
@@ -52,7 +52,8 @@ namespace :test do
52
52
  desc "Preparation of external modules"
53
53
  task :prepare do
54
54
  external_repos = [
55
- "jpmobile-ipaddresses"
55
+ "jpmobile-ipaddresses",
56
+ "jpmobile-terminfo"
56
57
  ]
57
58
  github_prefix = "git://github.com/jpmobile"
58
59
  vendor_path = Pathname.new(Dir.pwd).join("vendor")
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :minor: 1
3
- :patch: 1
4
2
  :major: 0
3
+ :minor: 1
4
+ :patch: 2
5
5
  :build:
data/jpmobile.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jpmobile}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yoji Shidara", "Shin-ichiro OGAWA"]
12
- s.date = %q{2010-09-06}
12
+ s.date = %q{2010-09-16}
13
13
  s.description = %q{A Rails plugin for Japanese mobile-phones}
14
14
  s.email = %q{dara@shidara.net}
15
15
  s.extra_rdoc_files = [
@@ -46,7 +46,6 @@ Gem::Specification.new do |s|
46
46
  "lib/jpmobile/mobile/android.rb",
47
47
  "lib/jpmobile/mobile/au.rb",
48
48
  "lib/jpmobile/mobile/ddipocket.rb",
49
- "lib/jpmobile/mobile/display.rb",
50
49
  "lib/jpmobile/mobile/docomo.rb",
51
50
  "lib/jpmobile/mobile/emobile.rb",
52
51
  "lib/jpmobile/mobile/iphone.rb",
@@ -55,7 +54,6 @@ Gem::Specification.new do |s|
55
54
  "lib/jpmobile/mobile/vodafone.rb",
56
55
  "lib/jpmobile/mobile/willcom.rb",
57
56
  "lib/jpmobile/mobile/windows_phone.rb",
58
- "lib/jpmobile/mobile/z_display_info_docomo.rb",
59
57
  "lib/jpmobile/position.rb",
60
58
  "lib/jpmobile/rack.rb",
61
59
  "lib/jpmobile/rack/filter.rb",
@@ -84,7 +82,6 @@ Gem::Specification.new do |s|
84
82
  "spec/unit/spec_helper.rb",
85
83
  "spec/unit/util_spec.rb",
86
84
  "spec/unit/valid_ip_spec.rb",
87
- "test/legacy/autoload_test.rb",
88
85
  "test/legacy/emoticon_test.rb",
89
86
  "test/legacy/helper.rb",
90
87
  "test/rails/.gitignore",
@@ -149,15 +146,12 @@ Gem::Specification.new do |s|
149
146
  "test/rails/overrides/spec/spec_helper.rb",
150
147
  "test/sinatra/guestbook.rb",
151
148
  "test/sinatra/test/filter_test.rb",
152
- "tools/disabled_update_display_info_docomo.rb",
153
149
  "tools/emoji/genregexp.rb",
154
150
  "tools/generate_au_emoticon_table.rb",
155
151
  "tools/generate_docomo_emoticon_table.rb",
156
152
  "tools/generate_emoticon_conversion_table.rb",
157
153
  "tools/generate_softbank_emoticon_table.rb",
158
- "tools/list_gps_unsupported_au.rb",
159
- "tools/update_ip_addresses_au.rb",
160
- "tools/update_ip_addresses_willcom.rb"
154
+ "tools/list_gps_unsupported_au.rb"
161
155
  ]
162
156
  s.homepage = %q{http://github.com/jpmobile/jpmobile}
163
157
  s.rdoc_options = ["--charset=UTF-8"]
@@ -183,7 +177,6 @@ Gem::Specification.new do |s|
183
177
  "spec/unit/is_carrier_spec.rb",
184
178
  "spec/spec_helper.rb",
185
179
  "spec/rack_helper.rb",
186
- "test/legacy/autoload_test.rb",
187
180
  "test/legacy/emoticon_test.rb",
188
181
  "test/legacy/helper.rb",
189
182
  "test/sinatra/guestbook.rb",
@@ -40,7 +40,9 @@ module Jpmobile::Mobile
40
40
 
41
41
  # 画面情報を +Display+ クラスのインスタンスで返す。
42
42
  def display
43
- @__displlay ||= Jpmobile::Display.new
43
+ @__displlay ||= Jpmobile::Mobile::Terminfo.new(self, @env)
44
+ rescue LoadError
45
+ puts "display method require jpmobile-terminfo plugin."
44
46
  end
45
47
 
46
48
  # クッキーをサポートしているか。
@@ -5,8 +5,6 @@ module Jpmobile::Mobile
5
5
  # ==au携帯電話
6
6
  # CDMA 1X, CDMA 1X WINを含む。
7
7
  class Au < AbstractMobile
8
- autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_au'
9
-
10
8
  # 対応するUser-Agentの正規表現
11
9
  # User-Agent文字列中に "UP.Browser" を含むVodafoneの端末があるので注意が必要
12
10
  USER_AGENT_REGEXP = /^(?:KDDI|UP.Browser\/.+?)-(.+?) /
@@ -51,24 +49,6 @@ module Jpmobile::Mobile
51
49
  return @__posotion = l
52
50
  end
53
51
 
54
- # 画面情報を +Display+ クラスのインスタンスで返す。
55
- def display
56
- return @__display if @__display
57
-
58
- p_w = p_h = col_p = cols = nil
59
- if r = @request.env['HTTP_X_UP_DEVCAP_SCREENPIXELS']
60
- p_w, p_h = r.split(/,/,2).map {|x| x.to_i}
61
- end
62
- if r = @request.env['HTTP_X_UP_DEVCAP_ISCOLOR']
63
- col_p = (r == '1')
64
- end
65
- if r = @request.env['HTTP_X_UP_DEVCAP_SCREENDEPTH']
66
- a = r.split(/,/)
67
- cols = 2 ** a[0].to_i
68
- end
69
- @__display = Jpmobile::Mobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
70
- end
71
-
72
52
  # デバイスIDを返す
73
53
  def device_id
74
54
  if @request.env['HTTP_USER_AGENT'] =~ USER_AGENT_REGEXP
@@ -4,9 +4,6 @@
4
4
  module Jpmobile::Mobile
5
5
  # ==DoCoMo携帯電話
6
6
  class Docomo < AbstractMobile
7
- autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_docomo'
8
- autoload :DISPLAY_INFO, 'jpmobile/mobile/z_display_info_docomo'
9
-
10
7
  # 対応するUser-Agentの正規表現
11
8
  USER_AGENT_REGEXP = /^DoCoMo/
12
9
  # 対応するメールアドレスの正規表現
@@ -66,15 +63,6 @@ module Jpmobile::Mobile
66
63
  guid || icc
67
64
  end
68
65
 
69
- # 画面情報を +Display+ クラスのインスタンスで返す。
70
- def display
71
- @__display ||= Jpmobile::Mobile::Display.new(nil,nil,
72
- display_info[:browser_width],
73
- display_info[:browser_height],
74
- display_info[:color_p],
75
- display_info[:colors])
76
- end
77
-
78
66
  # cookieに対応しているか?
79
67
  def supports_cookie?
80
68
  imode_browser_version != '1.0'
@@ -127,7 +115,6 @@ module Jpmobile::Mobile
127
115
  ver
128
116
  end
129
117
 
130
- private
131
118
  # モデル名を返す。
132
119
  def model_name
133
120
  if @env["HTTP_USER_AGENT"] =~ /^DoCoMo\/2.0 (.+)\(/
@@ -137,10 +124,5 @@ module Jpmobile::Mobile
137
124
  end
138
125
  return nil
139
126
  end
140
-
141
- # 画面の情報を含むハッシュを返す。
142
- def display_info
143
- DISPLAY_INFO[model_name] || {}
144
- end
145
127
  end
146
128
  end
@@ -1,10 +1,9 @@
1
+ # -*- coding: utf-8 -*-
1
2
  # =EMOBILE携帯電話
2
3
 
3
4
  module Jpmobile::Mobile
4
5
  # ==EMOBILE携帯電話
5
6
  class Emobile < AbstractMobile
6
- autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_emobile'
7
-
8
7
  USER_AGENT_REGEXP = %r{^emobile/|^Mozilla/5.0 \(H11T; like Gecko; OpenBrowser\) NetFront/3.4$|^Mozilla/4.0 \(compatible; MSIE 6.0; Windows CE; IEMobile 7.7\) S11HT$}
9
8
  # 対応するメールアドレスの正規表現
10
9
  MAIL_ADDRESS_REGEXP = /^.+@emnet\.ne\.jp$/
@@ -5,8 +5,6 @@ module Jpmobile::Mobile
5
5
  # ==Softbank携帯電話
6
6
  # Vodafoneのスーパクラス。
7
7
  class Softbank < AbstractMobile
8
- autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_softbank'
9
-
10
8
  # 対応するuser-agentの正規表現
11
9
  USER_AGENT_REGEXP = /^(?:SoftBank|Semulator)/
12
10
  # 対応するメールアドレスの正規表現 ディズニーモバイル対応
@@ -40,27 +38,6 @@ module Jpmobile::Mobile
40
38
  end
41
39
  end
42
40
 
43
- # 画面情報を +Display+ クラスのインスタンスで返す。
44
- def display
45
- return @__display if @__display
46
- p_w = p_h = col_p = cols = nil
47
- if r = @request.env['HTTP_X_JPHONE_DISPLAY']
48
- p_w, p_h = r.split(/\*/,2).map {|x| x.to_i}
49
- end
50
- if r = @request.env['HTTP_X_JPHONE_COLOR']
51
- case r
52
- when /^C/
53
- col_p = true
54
- when /^G/
55
- col_p = false
56
- end
57
- if r =~ /^.(\d+)$/
58
- cols = $1.to_i
59
- end
60
- end
61
- @__display = Jpmobile::Mobile::Display.new(p_w, p_h, nil, nil, col_p, cols)
62
- end
63
-
64
41
  # cookieに対応しているか?
65
42
  def supports_cookie?
66
43
  true
@@ -4,8 +4,6 @@ module Jpmobile::Mobile
4
4
  # ==Willcom携帯電話
5
5
  # Ddipocketのスーパクラス。
6
6
  class Willcom < AbstractMobile
7
- autoload :IP_ADDRESSES, 'jpmobile/mobile/z_ip_addresses_willcom'
8
-
9
7
  # 対応するUser-Agentの正規表現
10
8
  USER_AGENT_REGEXP = /^Mozilla\/3.0\(WILLCOM/
11
9
  # 対応するメールアドレスの正規表現
@@ -22,7 +22,7 @@ module Jpmobile
22
22
  end
23
23
 
24
24
  body = response_to_body(response)
25
- body = body.sub('<input name="_snowman" type="hidden" value="&#9731;" />', ' ')
25
+ body = body.sub('<input name="utf8" type="hidden" value="&#x2713;" />', ' ')
26
26
 
27
27
  response, charset = mobile.to_external(body, type, charset)
28
28
 
@@ -68,6 +68,17 @@ namespace :test do
68
68
  puts "IP Address test requires jpmobile-ipaddresses module"
69
69
  end
70
70
 
71
+ # setup jpmobile-terminfo
72
+ begin
73
+ plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile-terminfo')
74
+ FileUtils.mkdir_p(plugin_path)
75
+ FileList["vendor/jpmobile-terminfo/*"].exclude("test").each do |file|
76
+ FileUtils.cp_r(file, plugin_path)
77
+ end
78
+ rescue LoadError
79
+ puts "Terminal display information test requires jpmobile-terminfo module"
80
+ end
81
+
71
82
  # setup tests
72
83
  FileList["test/rails/overrides/*"].each do |file|
73
84
  FileUtils.cp_r(file, rails_root)
@@ -52,7 +52,7 @@ describe Jpmobile::Rack::Filter do
52
52
  "/",
53
53
  "REQUEST_METHOD" => "GET",
54
54
  'HTTP_USER_AGENT' => 'DoCoMo/2.0 SH906i(c100;TB;W24H16)')
55
- res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new('<input name="_snowman" type="hidden" value="&#9731;" />'))).call(res)
55
+ res = Jpmobile::Rack::MobileCarrier.new(Jpmobile::Rack::Filter.new(UnitApplication.new('<input name="utf8" type="hidden" value="&#x2713;" />'))).call(res)
56
56
  res[1]['Content-Type'].should == "text/html; charset=Shift_JIS"
57
57
  response_body(res).should == " "
58
58
  end
data/spec/rack_helper.rb CHANGED
@@ -10,6 +10,11 @@ begin
10
10
  rescue LoadError
11
11
  puts "IP Address test requires jpmobile-ipaddresses module"
12
12
  end
13
+ begin
14
+ require File.dirname(__FILE__)+'/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
15
+ rescue LoadError
16
+ puts "Terminal display information test requires jpmobile-terminfo module"
17
+ end
13
18
 
14
19
  RSpec.configure do |config|
15
20
  config.include Rack::Test::Methods
data/spec/spec_helper.rb CHANGED
@@ -8,11 +8,17 @@ unless RSpec.const_defined?(:Rails)
8
8
  require 'action_mailer'
9
9
  require 'initializer'
10
10
  require dir+'/../lib/jpmobile'
11
- # begin
11
+ begin
12
12
  require dir+'/../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
13
- # rescue LoadError
14
- # puts "IP Address test requires jpmobile-ipaddresses module"
15
- # end
13
+ rescue LoadError
14
+ puts "IP Address test requires jpmobile-ipaddresses module"
15
+ end
16
+
17
+ begin
18
+ require dir+'/../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
19
+ rescue LoadError
20
+ puts "Terminal display information test requires jpmobile-terminfo module"
21
+ end
16
22
 
17
23
  # set (dummy) RAILS_ROOT
18
24
  RAILS_ROOT=dir+"/.."
@@ -5,5 +5,10 @@ require 'jpmobile'
5
5
  begin
6
6
  require File.dirname(__FILE__)+'/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
7
7
  rescue LoadError
8
- puts "[NOTICE] IP Address test requires jpmobile-ipaddresses module"
8
+ puts "IP Address test requires jpmobile-ipaddresses module"
9
+ end
10
+ begin
11
+ require File.dirname(__FILE__)+'/../../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
12
+ rescue LoadError
13
+ puts "Terminal display information test requires jpmobile-terminfo module"
9
14
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jpmobile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
11
10
  platform: ruby
12
11
  authors:
13
12
  - Yoji Shidara
@@ -16,7 +15,7 @@ autorequire:
16
15
  bindir: bin
17
16
  cert_chain: []
18
17
 
19
- date: 2010-09-06 00:00:00 +09:00
18
+ date: 2010-09-16 00:00:00 +09:00
20
19
  default_executable:
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
@@ -27,7 +26,6 @@ dependencies:
27
26
  requirements:
28
27
  - - "="
29
28
  - !ruby/object:Gem::Version
30
- hash: 62196417
31
29
  segments:
32
30
  - 2
33
31
  - 0
@@ -45,7 +43,6 @@ dependencies:
45
43
  requirements:
46
44
  - - "="
47
45
  - !ruby/object:Gem::Version
48
- hash: 62196417
49
46
  segments:
50
47
  - 2
51
48
  - 0
@@ -63,7 +60,6 @@ dependencies:
63
60
  requirements:
64
61
  - - ">="
65
62
  - !ruby/object:Gem::Version
66
- hash: 7
67
63
  segments:
68
64
  - 1
69
65
  - 4
@@ -110,7 +106,6 @@ files:
110
106
  - lib/jpmobile/mobile/android.rb
111
107
  - lib/jpmobile/mobile/au.rb
112
108
  - lib/jpmobile/mobile/ddipocket.rb
113
- - lib/jpmobile/mobile/display.rb
114
109
  - lib/jpmobile/mobile/docomo.rb
115
110
  - lib/jpmobile/mobile/emobile.rb
116
111
  - lib/jpmobile/mobile/iphone.rb
@@ -119,7 +114,6 @@ files:
119
114
  - lib/jpmobile/mobile/vodafone.rb
120
115
  - lib/jpmobile/mobile/willcom.rb
121
116
  - lib/jpmobile/mobile/windows_phone.rb
122
- - lib/jpmobile/mobile/z_display_info_docomo.rb
123
117
  - lib/jpmobile/position.rb
124
118
  - lib/jpmobile/rack.rb
125
119
  - lib/jpmobile/rack/filter.rb
@@ -148,7 +142,6 @@ files:
148
142
  - spec/unit/spec_helper.rb
149
143
  - spec/unit/util_spec.rb
150
144
  - spec/unit/valid_ip_spec.rb
151
- - test/legacy/autoload_test.rb
152
145
  - test/legacy/emoticon_test.rb
153
146
  - test/legacy/helper.rb
154
147
  - test/rails/.gitignore
@@ -213,15 +206,12 @@ files:
213
206
  - test/rails/overrides/spec/spec_helper.rb
214
207
  - test/sinatra/guestbook.rb
215
208
  - test/sinatra/test/filter_test.rb
216
- - tools/disabled_update_display_info_docomo.rb
217
209
  - tools/emoji/genregexp.rb
218
210
  - tools/generate_au_emoticon_table.rb
219
211
  - tools/generate_docomo_emoticon_table.rb
220
212
  - tools/generate_emoticon_conversion_table.rb
221
213
  - tools/generate_softbank_emoticon_table.rb
222
214
  - tools/list_gps_unsupported_au.rb
223
- - tools/update_ip_addresses_au.rb
224
- - tools/update_ip_addresses_willcom.rb
225
215
  has_rdoc: true
226
216
  homepage: http://github.com/jpmobile/jpmobile
227
217
  licenses: []
@@ -236,7 +226,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
236
226
  requirements:
237
227
  - - ">="
238
228
  - !ruby/object:Gem::Version
239
- hash: 3
240
229
  segments:
241
230
  - 0
242
231
  version: "0"
@@ -245,7 +234,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
234
  requirements:
246
235
  - - ">="
247
236
  - !ruby/object:Gem::Version
248
- hash: 3
249
237
  segments:
250
238
  - 0
251
239
  version: "0"
@@ -275,7 +263,6 @@ test_files:
275
263
  - spec/unit/is_carrier_spec.rb
276
264
  - spec/spec_helper.rb
277
265
  - spec/rack_helper.rb
278
- - test/legacy/autoload_test.rb
279
266
  - test/legacy/emoticon_test.rb
280
267
  - test/legacy/helper.rb
281
268
  - test/sinatra/guestbook.rb