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.
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 0
4
4
  :patch: 0
5
- :build: pre.6
5
+ :build: pre.7
@@ -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, 'jpmobile/email'
7
- autoload :Emoticon, 'jpmobile/emoticon'
8
- autoload :Position, 'jpmobile/position'
9
- autoload :RequestWithMobile, 'jpmobile/request_with_mobile'
10
- autoload :Util, 'jpmobile/util'
11
- autoload :Encoding, 'jpmobile/encoding'
12
- autoload :Version, 'jpmobile/version'
13
- autoload :DatumConv, 'jpmobile/datum_conv'
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
@@ -0,0 +1,3 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'action_controller/test_case'
3
+ ActionController::TestRequest.send :include, Jpmobile::RequestWithMobileTesting
@@ -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
@@ -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'
@@ -42,4 +42,10 @@ module Jpmobile
42
42
  env['rack.jpmobile']
43
43
  end
44
44
  end
45
+
46
+ module RequestWithMobileTesting
47
+ def mobile
48
+ Jpmobile::Mobile::AbstractMobile.carrier(env)
49
+ end
50
+ end
45
51
  end
@@ -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
@@ -1,5 +1,6 @@
1
1
  class MobileSpecController < ApplicationController
2
+ include Jpmobile::ViewSelector
3
+
2
4
  def index
3
- render :text=>"Hello, world."
4
5
  end
5
6
  end
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RailsRoot</title>
5
+ <%= csrf_meta_tag %>
6
+ </head>
7
+ <body>
8
+
9
+ <%= yield %>
10
+
11
+ </body>
12
+ </html>
@@ -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.6
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-27 00:00:00 +09:00
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