jpmobile 0.1.0.pre → 0.1.0.pre.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/jpmobile.gemspec +2 -2
- data/lib/jpmobile/rails.rb +3 -2
- data/lib/jpmobile/trans_sid.rb +7 -16
- data/lib/tasks/jpmobile_tasks.rake +0 -7
- data/test/rails/overrides/Gemfile +1 -1
- data/test/rails/overrides/spec/requests/trans_sid_spec.rb +26 -19
- metadata +3 -2
data/VERSION.yml
CHANGED
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.0.pre"
|
8
|
+
s.version = "0.1.0.pre.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Yoji Shidara", "Shin-ichiro OGAWA"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-29}
|
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 = [
|
data/lib/jpmobile/rails.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
ActiveSupport.on_load(:action_controller) do
|
2
|
-
# -*- coding: utf-8 -*-
|
3
3
|
require 'jpmobile/docomo_guid'
|
4
4
|
require 'jpmobile/filter'
|
5
5
|
require 'jpmobile/helpers'
|
6
6
|
require 'jpmobile/hook_action_controller'
|
7
7
|
require 'jpmobile/hook_action_view'
|
8
8
|
require 'jpmobile/trans_sid'
|
9
|
+
end
|
9
10
|
|
11
|
+
ActiveSupport.on_load(:before_configuration) do
|
10
12
|
# MobileCarrierのみデフォルトで有効
|
11
13
|
::Rails.application.middleware.insert_before('ActionDispatch::ParamsParser', Jpmobile::Rack::MobileCarrier)
|
12
|
-
|
13
14
|
module Rails
|
14
15
|
class Application
|
15
16
|
class Configuration
|
data/lib/jpmobile/trans_sid.rb
CHANGED
@@ -6,14 +6,15 @@ module ParamsOverCookie
|
|
6
6
|
def self.included(base)
|
7
7
|
base.class_eval do
|
8
8
|
# cookie よりも params を先に見るパッチ
|
9
|
-
def
|
9
|
+
def extract_session_id_with_jpmobile(env)
|
10
10
|
request = Rack::Request.new(env)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
if request.params[@key] and !@cookie_only
|
12
|
+
sid = request.params[@key] unless @cookie_only
|
13
|
+
end
|
14
|
+
sid ||= request.cookies[@key]
|
15
|
+
sid
|
15
16
|
end
|
16
|
-
alias_method_chain :
|
17
|
+
alias_method_chain :extract_session_id, :jpmobile
|
17
18
|
end
|
18
19
|
end
|
19
20
|
end
|
@@ -59,21 +60,11 @@ module ActionController
|
|
59
60
|
class Base #:nodoc:
|
60
61
|
class_inheritable_accessor :trans_sid_mode
|
61
62
|
|
62
|
-
def transit_sid_mode(*args)
|
63
|
-
STDERR.puts "Method transit_sid is now deprecated. Use trans_sid instead."
|
64
|
-
trans_sid_mode(*args)
|
65
|
-
end
|
66
|
-
|
67
63
|
class << self
|
68
64
|
def trans_sid(mode = :mobile)
|
69
65
|
include Jpmobile::TransSid
|
70
66
|
self.trans_sid_mode = mode
|
71
67
|
end
|
72
|
-
|
73
|
-
def transit_sid(*args)
|
74
|
-
STDERR.puts "Method transit_sid is now deprecated. Use trans_sid instead."
|
75
|
-
trans_sid(*args)
|
76
|
-
end
|
77
68
|
end
|
78
69
|
|
79
70
|
private
|
@@ -62,13 +62,6 @@ namespace :test do
|
|
62
62
|
FileUtils.cp_r(file, rails_root)
|
63
63
|
end
|
64
64
|
|
65
|
-
# for 2.3.2
|
66
|
-
if rails_version == "2.3.2"
|
67
|
-
FileList["test/rails/2.3.2/*"].each do |file|
|
68
|
-
FileUtils.cp_r(file, rails_root)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
65
|
# for cookie_only option
|
73
66
|
config_path = File.join(rails_root, 'config', 'initializers', 'session_store.rb')
|
74
67
|
File.open(config_path, 'w') do |file|
|
@@ -17,7 +17,7 @@ shared_examples_for "trans_sid が起動しないとき" do
|
|
17
17
|
it "で form の自動書き換えが行われない" do
|
18
18
|
res = get_with_session(@controller, "form", @user_agent)
|
19
19
|
|
20
|
-
res.response.body.should =~ /<form action=\"\/.+?\/form\"/
|
20
|
+
res.response.body.should =~ /<form accept-charset="#{@charset}" action=\"\/.+?\/form\"/
|
21
21
|
end
|
22
22
|
it "で redirect の自動書き換えが行われない" do
|
23
23
|
res = get_with_session(@controller, "redirect", @user_agent)
|
@@ -35,7 +35,7 @@ shared_examples_for "trans_sid が起動するとき" do
|
|
35
35
|
it "で form の自動書き換えが行われる" do
|
36
36
|
res = get_with_session(@controller, "form", @user_agent)
|
37
37
|
|
38
|
-
res.response.body.should =~ /<form action=\"\/.+?\/form\?_session_id=[a-zA-Z0-9]{32}\"/
|
38
|
+
res.response.body.should =~ /<form accept-charset="#{@charset}" action=\"\/.+?\/form\?_session_id=[a-zA-Z0-9]{32}\"/
|
39
39
|
end
|
40
40
|
it "で redirect の自動書き換えが行われる" do
|
41
41
|
res = get_with_session(@controller, "redirect", @user_agent)
|
@@ -48,6 +48,7 @@ describe TransSidBaseController, "という trans_sid が有効になってい
|
|
48
48
|
before(:each) do
|
49
49
|
@controller = "trans_sid_base"
|
50
50
|
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
|
51
|
+
@charset = "UTF-8"
|
51
52
|
end
|
52
53
|
|
53
54
|
it "の trans_sid_mode は nil" do
|
@@ -62,6 +63,7 @@ describe TransSidNoneController, "という trans_sid :none が指定されて
|
|
62
63
|
before(:each) do
|
63
64
|
@controller = "trans_sid_none"
|
64
65
|
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
|
66
|
+
@charset = "UTF-8"
|
65
67
|
end
|
66
68
|
|
67
69
|
it "の trans_sid_mode は :none" do
|
@@ -76,6 +78,7 @@ describe TransSidAlwaysController, "という trans_sid :always が指定され
|
|
76
78
|
before(:each) do
|
77
79
|
@controller = "trans_sid_always"
|
78
80
|
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
|
81
|
+
@charset = "UTF-8"
|
79
82
|
end
|
80
83
|
|
81
84
|
it "の trans_sid_mode は :always" do
|
@@ -90,6 +93,7 @@ describe TransSidMobileController, "という trans_sid :mobile が指定され
|
|
90
93
|
before(:each) do
|
91
94
|
@controller = "trans_sid_mobile"
|
92
95
|
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
|
96
|
+
@charset = "UTF-8"
|
93
97
|
end
|
94
98
|
|
95
99
|
it "の trans_sid_mode は :mobile" do
|
@@ -99,44 +103,47 @@ describe TransSidMobileController, "という trans_sid :mobile が指定され
|
|
99
103
|
end
|
100
104
|
end
|
101
105
|
|
102
|
-
def describe_mobile_with_ua(user_agent, &block)
|
106
|
+
def describe_mobile_with_ua(user_agent, charset, &block)
|
103
107
|
describe("trans_sid :mobile が指定されているコントローラに #{user_agent} からアクセスしたとき") do
|
104
108
|
before(:each) do
|
105
109
|
@controller = "trans_sid_mobile"
|
106
110
|
@user_agent = user_agent
|
111
|
+
@charset = charset
|
107
112
|
end
|
108
113
|
|
109
114
|
instance_eval(&block)
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
118
|
+
describe TransSidAlwaysAndSessionOffController, "という trans_sid :always が指定されていて session がロードされていないとき" do
|
119
|
+
before(:each) do
|
120
|
+
@controller = "trans_sid_always_and_session_off"
|
121
|
+
@user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)"
|
122
|
+
@charset = "UTF-8"
|
123
|
+
end
|
119
124
|
|
120
|
-
|
121
|
-
|
125
|
+
it "の trans_sid_mode は :always" do
|
126
|
+
res = get_with_session(@controller, "link", @user_agent)
|
122
127
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
128
|
+
res.controller.trans_sid_mode.should == :always
|
129
|
+
end
|
130
|
+
it_should_behave_like "trans_sid が起動しないとき"
|
131
|
+
end
|
127
132
|
|
128
|
-
|
133
|
+
# NOTE: 3.0.0RC では accept-charset は UTF-8 で埋め込まれるので保留
|
134
|
+
describe_mobile_with_ua "DoCoMo/2.0 SH902i(c100;TB;W24H12)", "UTF-8" do
|
129
135
|
it_should_behave_like "trans_sid が起動するとき"
|
130
136
|
end
|
131
137
|
|
132
|
-
|
138
|
+
# NOTE: 3.0.0RC では accept-charset は UTF-8 で埋め込まれるので保留
|
139
|
+
describe_mobile_with_ua "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0", "UTF-8" do
|
133
140
|
it_should_behave_like "trans_sid が起動しないとき"
|
134
141
|
end
|
135
142
|
|
136
|
-
describe_mobile_with_ua "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1" do
|
143
|
+
describe_mobile_with_ua "SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1", "UTF-8" do
|
137
144
|
it_should_behave_like "trans_sid が起動しないとき"
|
138
145
|
end
|
139
146
|
|
140
|
-
describe_mobile_with_ua "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0" do
|
147
|
+
describe_mobile_with_ua "Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0", "UTF-8" do
|
141
148
|
it_should_behave_like "trans_sid が起動しないとき"
|
142
149
|
end
|
metadata
CHANGED
@@ -7,7 +7,8 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- pre
|
10
|
-
|
10
|
+
- 2
|
11
|
+
version: 0.1.0.pre.2
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Yoji Shidara
|
@@ -16,7 +17,7 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2010-07-
|
20
|
+
date: 2010-07-29 00:00:00 +09:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|