jpmobile 1.0.0.pre.6 → 1.0.0.pre.7
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/VERSION.yml +1 -1
- data/lib/jpmobile.rb +9 -8
- data/lib/jpmobile/hook_test_request.rb +3 -0
- data/lib/jpmobile/mobile/abstract_mobile.rb +12 -0
- data/lib/jpmobile/rack/mobile_carrier.rb +1 -13
- data/lib/jpmobile/rails.rb +1 -0
- data/lib/jpmobile/request_with_mobile.rb +6 -0
- data/lib/jpmobile/resolver.rb +2 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +2 -1
- data/test/rails/overrides/app/views/layouts/application_mobile.html.erb +12 -0
- data/test/rails/overrides/app/views/mobile_spec/index.html.erb +1 -0
- data/test/rails/overrides/app/views/mobile_spec/index_mobile.html.erb +1 -0
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +28 -0
- metadata +7 -2
data/VERSION.yml
CHANGED
data/lib/jpmobile.rb
CHANGED
@@ -3,14 +3,15 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
|
|
3
3
|
$:.include?(File.expand_path(File.dirname(__FILE__)))
|
4
4
|
|
5
5
|
module Jpmobile
|
6
|
-
autoload :Email,
|
7
|
-
autoload :Emoticon,
|
8
|
-
autoload :Position,
|
9
|
-
autoload :RequestWithMobile,
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
6
|
+
autoload :Email, 'jpmobile/email'
|
7
|
+
autoload :Emoticon, 'jpmobile/emoticon'
|
8
|
+
autoload :Position, 'jpmobile/position'
|
9
|
+
autoload :RequestWithMobile, 'jpmobile/request_with_mobile'
|
10
|
+
autoload :RequestWithMobileTesting, 'jpmobile/request_with_mobile'
|
11
|
+
autoload :Util, 'jpmobile/util'
|
12
|
+
autoload :Encoding, 'jpmobile/encoding'
|
13
|
+
autoload :Version, 'jpmobile/version'
|
14
|
+
autoload :DatumConv, 'jpmobile/datum_conv'
|
14
15
|
|
15
16
|
# autoload mobile classes
|
16
17
|
module Mobile
|
@@ -151,6 +151,18 @@ module Jpmobile::Mobile
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
+
def self.carrier(env)
|
155
|
+
::Jpmobile::Mobile.carriers.each do |const|
|
156
|
+
c = ::Jpmobile::Mobile.const_get(const)
|
157
|
+
if c.check_carrier(env)
|
158
|
+
res = ::Rack::Request.new(env)
|
159
|
+
return c.new(env, res)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
nil
|
164
|
+
end
|
165
|
+
|
154
166
|
private
|
155
167
|
# リクエストのパラメータ。
|
156
168
|
def params
|
@@ -8,22 +8,10 @@ module Jpmobile
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
env['rack.jpmobile'] = carrier(env)
|
11
|
+
env['rack.jpmobile'] = Jpmobile::Mobile::AbstractMobile.carrier(env)
|
12
12
|
|
13
13
|
@app.call(env)
|
14
14
|
end
|
15
|
-
|
16
|
-
def carrier(env)
|
17
|
-
::Jpmobile::Mobile.carriers.each do |const|
|
18
|
-
c = ::Jpmobile::Mobile.const_get(const)
|
19
|
-
if c.check_carrier(env)
|
20
|
-
res = ::Rack::Request.new(env)
|
21
|
-
return c.new(env, res)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
nil
|
26
|
-
end
|
27
15
|
end
|
28
16
|
end
|
29
17
|
end
|
data/lib/jpmobile/rails.rb
CHANGED
@@ -6,6 +6,7 @@ ActiveSupport.on_load(:action_controller) do
|
|
6
6
|
require 'jpmobile/hook_action_controller'
|
7
7
|
require 'jpmobile/hook_action_view'
|
8
8
|
require 'jpmobile/trans_sid'
|
9
|
+
require 'jpmobile/hook_test_request'
|
9
10
|
end
|
10
11
|
ActiveSupport.on_load(:action_dispatch) do
|
11
12
|
require 'jpmobile/hook_action_dispatch'
|
data/lib/jpmobile/resolver.rb
CHANGED
@@ -29,9 +29,10 @@ module Jpmobile
|
|
29
29
|
handler, format = extract_handler_and_format(p, formats)
|
30
30
|
|
31
31
|
contents = File.open(p, "rb") {|io| io.read }
|
32
|
+
variant = p.match(/.+#{path}(.+)\.#{format}.*$/) ? $1 : ''
|
32
33
|
|
33
34
|
ActionView::Template.new(contents, File.expand_path(p), handler,
|
34
|
-
:virtual_path => path, :format => format)
|
35
|
+
:virtual_path => path + variant, :format => format)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
PC page
|
@@ -0,0 +1 @@
|
|
1
|
+
mobile page
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '/../spec_helper'))
|
3
|
+
|
4
|
+
describe MobileSpecController do
|
5
|
+
describe "GET 'index'" do
|
6
|
+
context 'PC access' do
|
7
|
+
it "should be successful" do
|
8
|
+
request.user_agent = 'Mozilla'
|
9
|
+
get 'index'
|
10
|
+
|
11
|
+
response.should be_success
|
12
|
+
response.should render_template('index')
|
13
|
+
request.mobile?.should be_false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'mobile access' do
|
18
|
+
it "should be successful" do
|
19
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
20
|
+
get 'index'
|
21
|
+
response.should be_success
|
22
|
+
response.should render_template('index_mobile')
|
23
|
+
request.mobile?.should be_true
|
24
|
+
request.mobile.should be_a(Jpmobile::Mobile::Docomo)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jpmobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.0.0.pre.
|
5
|
+
version: 1.0.0.pre.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yoji Shidara
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-28 00:00:00 +09:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- lib/jpmobile/hook_action_controller.rb
|
239
239
|
- lib/jpmobile/hook_action_dispatch.rb
|
240
240
|
- lib/jpmobile/hook_action_view.rb
|
241
|
+
- lib/jpmobile/hook_test_request.rb
|
241
242
|
- lib/jpmobile/lookup_context.rb
|
242
243
|
- lib/jpmobile/mail.rb
|
243
244
|
- lib/jpmobile/mailer.rb
|
@@ -329,6 +330,7 @@ files:
|
|
329
330
|
- test/rails/overrides/app/views/hankaku_filter/index.html.erb
|
330
331
|
- test/rails/overrides/app/views/hankaku_input_filter/index.html.erb
|
331
332
|
- test/rails/overrides/app/views/hankaku_input_filter/index_xhtml.html.erb
|
333
|
+
- test/rails/overrides/app/views/layouts/application_mobile.html.erb
|
332
334
|
- test/rails/overrides/app/views/layouts/xhtml.html.erb
|
333
335
|
- test/rails/overrides/app/views/links/au_gps.html.erb
|
334
336
|
- test/rails/overrides/app/views/links/au_location.html.erb
|
@@ -349,6 +351,8 @@ files:
|
|
349
351
|
- test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_softbank.html.erb
|
350
352
|
- test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_vodafone.html.erb
|
351
353
|
- test/rails/overrides/app/views/mobile_mailer/view_selection_mobile_willcom.html.erb
|
354
|
+
- test/rails/overrides/app/views/mobile_spec/index.html.erb
|
355
|
+
- test/rails/overrides/app/views/mobile_spec/index_mobile.html.erb
|
352
356
|
- test/rails/overrides/app/views/normal_mailer/msg.text.erb
|
353
357
|
- test/rails/overrides/app/views/template_path/_partial.html.erb
|
354
358
|
- test/rails/overrides/app/views/template_path/_partial_mobile.html.erb
|
@@ -368,6 +372,7 @@ files:
|
|
368
372
|
- test/rails/overrides/config/routes.rb
|
369
373
|
- test/rails/overrides/db/migrate/001_add_sessions_table.rb
|
370
374
|
- test/rails/overrides/db/migrate/20100824062306_create_users.rb
|
375
|
+
- test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb
|
371
376
|
- test/rails/overrides/spec/fixtures/mobile_mailer/au-attached.eml
|
372
377
|
- test/rails/overrides/spec/fixtures/mobile_mailer/au-decomail.eml
|
373
378
|
- test/rails/overrides/spec/fixtures/mobile_mailer/au-emoji.eml
|