jpmobile 2.0.5 → 2.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/VERSION.yml +2 -2
- data/jpmobile.gemspec +1 -1
- data/lib/jpmobile/mail.rb +13 -2
- data/lib/jpmobile/mobile/abstract_mobile.rb +1 -1
- data/lib/jpmobile/resolver.rb +24 -22
- data/lib/tasks/jpmobile_tasks.rake +1 -0
- data/test/rails/overrides/Gemfile +2 -1
- data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +4 -0
- data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +24 -0
- metadata +49 -38
data/Gemfile
CHANGED
data/VERSION.yml
CHANGED
data/jpmobile.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jpmobile}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.6"
|
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"]
|
data/lib/jpmobile/mail.rb
CHANGED
@@ -67,7 +67,16 @@ module Mail
|
|
67
67
|
self.body.charset = @charset
|
68
68
|
self.body.mobile = @mobile
|
69
69
|
self.header['Content-Transfer-Encoding'] = @mobile.content_transfer_encoding(self.header)
|
70
|
-
|
70
|
+
if @mobile.decorated?
|
71
|
+
unless self.content_type.match(/image\//)
|
72
|
+
self.header['Content-ID'] = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
unless self.header['Content-Type'].sub_type == 'mixed'
|
76
|
+
self.header['Date'] = nil
|
77
|
+
self.header['Mime-Version'] = nil
|
78
|
+
end
|
79
|
+
end
|
71
80
|
|
72
81
|
buffer = header.encoded
|
73
82
|
buffer << "\r\n"
|
@@ -173,7 +182,9 @@ module Mail
|
|
173
182
|
attached_files = []
|
174
183
|
attachments.each do |p|
|
175
184
|
if p.content_type.match(/^image\//) and p.content_disposition.match(/^inline/)
|
176
|
-
p.header['Content-
|
185
|
+
if p.header['Content-Type'].parameters['filename']
|
186
|
+
p.header['Content-Type'].parameters['name'] = p.header['Content-Type'].parameters['filename'].to_s
|
187
|
+
end
|
177
188
|
inline_images << p
|
178
189
|
elsif p.content_disposition
|
179
190
|
attached_files << p
|
data/lib/jpmobile/resolver.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
module Jpmobile
|
2
2
|
class Resolver < ActionView::FileSystemResolver
|
3
|
-
|
4
|
-
|
5
|
-
query(path, EXTENSIONS.map { |ext| details[ext] }, details[:formats], details[:mobile])
|
6
|
-
end
|
3
|
+
EXTENSIONS = [:locale, :formats, :handlers, :mobile]
|
4
|
+
DEFAULT_PATTERN = ":prefix/:action{_:mobile,}{.:locale,}{.:formats,}{.:handlers,}"
|
7
5
|
|
8
|
-
def
|
9
|
-
path
|
10
|
-
path
|
11
|
-
path
|
12
|
-
path
|
6
|
+
def initialize(path, pattern=nil)
|
7
|
+
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
|
8
|
+
super(path, pattern || DEFAULT_PATTERN)
|
9
|
+
@path = File.expand_path(path)
|
13
10
|
end
|
14
11
|
|
15
|
-
|
16
|
-
query = File.join(@path, path)
|
17
|
-
query << '{' << mobile.map {|v| "_#{v}"}.join(',') << ',}' if mobile and mobile.respond_to?(:map)
|
18
|
-
exts.each do |ext|
|
19
|
-
query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}'
|
20
|
-
end
|
12
|
+
private
|
21
13
|
|
22
|
-
|
23
|
-
query
|
14
|
+
def query(path, details, formats)
|
15
|
+
query = build_query(path, details)
|
16
|
+
templates = []
|
17
|
+
sanitizer = Hash.new { |h,k| h[k] = Dir["#{File.dirname(k)}/*"] }
|
18
|
+
|
19
|
+
Dir[query].each do |p|
|
20
|
+
next if File.directory?(p) || !sanitizer[p].include?(p)
|
24
21
|
|
25
|
-
Dir[query].reject { |p| File.directory?(p) }.map do |p|
|
26
22
|
handler, format = extract_handler_and_format(p, formats)
|
23
|
+
contents = File.open(p, "rb") { |io| io.read }
|
27
24
|
|
28
|
-
|
29
|
-
|
25
|
+
if format
|
26
|
+
variant = p.match(/.+#{path}(.+)\.#{format.to_sym.to_s}.*$/) ? $1 : ''
|
27
|
+
else
|
28
|
+
variant = ''
|
29
|
+
end
|
30
30
|
|
31
|
-
ActionView::Template.new(contents, File.expand_path(p), handler,
|
32
|
-
:virtual_path => path + variant, :format => format)
|
31
|
+
templates << ActionView::Template.new(contents, File.expand_path(p), handler,
|
32
|
+
:virtual_path => path.name + variant, :format => format, :updated_at => mtime(p))
|
33
33
|
end
|
34
|
+
|
35
|
+
templates
|
34
36
|
end
|
35
37
|
end
|
36
38
|
end
|
@@ -25,4 +25,28 @@ describe MobileSpecController do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe "GET 'file_render'" do
|
30
|
+
context 'PC access' do
|
31
|
+
it "should be successful" do
|
32
|
+
request.user_agent = 'Mozilla'
|
33
|
+
get 'file_render'
|
34
|
+
|
35
|
+
response.should be_success
|
36
|
+
response.should render_template('422')
|
37
|
+
request.mobile?.should be_false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'mobile access' do
|
42
|
+
it "should be successful" do
|
43
|
+
request.user_agent = "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
|
44
|
+
get 'file_render'
|
45
|
+
response.should be_success
|
46
|
+
response.should render_template('422')
|
47
|
+
request.mobile?.should be_true
|
48
|
+
request.mobile.should be_a(Jpmobile::Mobile::Docomo)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
28
52
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jpmobile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-01-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mail
|
17
|
+
requirement: &21551080 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.3.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *21551080
|
15
26
|
- !ruby/object:Gem::Dependency
|
16
27
|
name: jeweler
|
17
|
-
requirement: &
|
28
|
+
requirement: &21548260 !ruby/object:Gem::Requirement
|
18
29
|
none: false
|
19
30
|
requirements:
|
20
31
|
- - ! '>='
|
@@ -22,21 +33,21 @@ dependencies:
|
|
22
33
|
version: '0'
|
23
34
|
type: :development
|
24
35
|
prerelease: false
|
25
|
-
version_requirements: *
|
36
|
+
version_requirements: *21548260
|
26
37
|
- !ruby/object:Gem::Dependency
|
27
38
|
name: rails
|
28
|
-
requirement: &
|
39
|
+
requirement: &21546540 !ruby/object:Gem::Requirement
|
29
40
|
none: false
|
30
41
|
requirements:
|
31
|
-
- -
|
42
|
+
- - ~>
|
32
43
|
- !ruby/object:Gem::Version
|
33
44
|
version: 3.1.0
|
34
45
|
type: :development
|
35
46
|
prerelease: false
|
36
|
-
version_requirements: *
|
47
|
+
version_requirements: *21546540
|
37
48
|
- !ruby/object:Gem::Dependency
|
38
49
|
name: rspec
|
39
|
-
requirement: &
|
50
|
+
requirement: &21560960 !ruby/object:Gem::Requirement
|
40
51
|
none: false
|
41
52
|
requirements:
|
42
53
|
- - ! '>='
|
@@ -44,10 +55,10 @@ dependencies:
|
|
44
55
|
version: '0'
|
45
56
|
type: :development
|
46
57
|
prerelease: false
|
47
|
-
version_requirements: *
|
58
|
+
version_requirements: *21560960
|
48
59
|
- !ruby/object:Gem::Dependency
|
49
60
|
name: rspec-rails
|
50
|
-
requirement: &
|
61
|
+
requirement: &21559180 !ruby/object:Gem::Requirement
|
51
62
|
none: false
|
52
63
|
requirements:
|
53
64
|
- - ! '>='
|
@@ -55,10 +66,10 @@ dependencies:
|
|
55
66
|
version: '0'
|
56
67
|
type: :development
|
57
68
|
prerelease: false
|
58
|
-
version_requirements: *
|
69
|
+
version_requirements: *21559180
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: webrat
|
61
|
-
requirement: &
|
72
|
+
requirement: &21557180 !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
74
|
requirements:
|
64
75
|
- - ! '>='
|
@@ -66,10 +77,10 @@ dependencies:
|
|
66
77
|
version: '0'
|
67
78
|
type: :development
|
68
79
|
prerelease: false
|
69
|
-
version_requirements: *
|
80
|
+
version_requirements: *21557180
|
70
81
|
- !ruby/object:Gem::Dependency
|
71
82
|
name: geokit
|
72
|
-
requirement: &
|
83
|
+
requirement: &21556340 !ruby/object:Gem::Requirement
|
73
84
|
none: false
|
74
85
|
requirements:
|
75
86
|
- - ! '>='
|
@@ -77,10 +88,10 @@ dependencies:
|
|
77
88
|
version: '0'
|
78
89
|
type: :development
|
79
90
|
prerelease: false
|
80
|
-
version_requirements: *
|
91
|
+
version_requirements: *21556340
|
81
92
|
- !ruby/object:Gem::Dependency
|
82
93
|
name: sqlite3-ruby
|
83
|
-
requirement: &
|
94
|
+
requirement: &21554780 !ruby/object:Gem::Requirement
|
84
95
|
none: false
|
85
96
|
requirements:
|
86
97
|
- - ! '>='
|
@@ -88,10 +99,10 @@ dependencies:
|
|
88
99
|
version: '0'
|
89
100
|
type: :development
|
90
101
|
prerelease: false
|
91
|
-
version_requirements: *
|
102
|
+
version_requirements: *21554780
|
92
103
|
- !ruby/object:Gem::Dependency
|
93
104
|
name: hpricot
|
94
|
-
requirement: &
|
105
|
+
requirement: &21569000 !ruby/object:Gem::Requirement
|
95
106
|
none: false
|
96
107
|
requirements:
|
97
108
|
- - ! '>='
|
@@ -99,10 +110,10 @@ dependencies:
|
|
99
110
|
version: '0'
|
100
111
|
type: :development
|
101
112
|
prerelease: false
|
102
|
-
version_requirements: *
|
113
|
+
version_requirements: *21569000
|
103
114
|
- !ruby/object:Gem::Dependency
|
104
115
|
name: rails
|
105
|
-
requirement: &
|
116
|
+
requirement: &21566580 !ruby/object:Gem::Requirement
|
106
117
|
none: false
|
107
118
|
requirements:
|
108
119
|
- - ! '>='
|
@@ -110,10 +121,10 @@ dependencies:
|
|
110
121
|
version: 3.1.0
|
111
122
|
type: :development
|
112
123
|
prerelease: false
|
113
|
-
version_requirements: *
|
124
|
+
version_requirements: *21566580
|
114
125
|
- !ruby/object:Gem::Dependency
|
115
126
|
name: jeweler
|
116
|
-
requirement: &
|
127
|
+
requirement: &21565660 !ruby/object:Gem::Requirement
|
117
128
|
none: false
|
118
129
|
requirements:
|
119
130
|
- - ! '>='
|
@@ -121,10 +132,10 @@ dependencies:
|
|
121
132
|
version: 1.5.1
|
122
133
|
type: :development
|
123
134
|
prerelease: false
|
124
|
-
version_requirements: *
|
135
|
+
version_requirements: *21565660
|
125
136
|
- !ruby/object:Gem::Dependency
|
126
137
|
name: rspec
|
127
|
-
requirement: &
|
138
|
+
requirement: &21564960 !ruby/object:Gem::Requirement
|
128
139
|
none: false
|
129
140
|
requirements:
|
130
141
|
- - ! '>='
|
@@ -132,10 +143,10 @@ dependencies:
|
|
132
143
|
version: 2.6.0
|
133
144
|
type: :development
|
134
145
|
prerelease: false
|
135
|
-
version_requirements: *
|
146
|
+
version_requirements: *21564960
|
136
147
|
- !ruby/object:Gem::Dependency
|
137
148
|
name: rspec-rails
|
138
|
-
requirement: &
|
149
|
+
requirement: &21564200 !ruby/object:Gem::Requirement
|
139
150
|
none: false
|
140
151
|
requirements:
|
141
152
|
- - ! '>='
|
@@ -143,10 +154,10 @@ dependencies:
|
|
143
154
|
version: 2.6.0
|
144
155
|
type: :development
|
145
156
|
prerelease: false
|
146
|
-
version_requirements: *
|
157
|
+
version_requirements: *21564200
|
147
158
|
- !ruby/object:Gem::Dependency
|
148
159
|
name: webrat
|
149
|
-
requirement: &
|
160
|
+
requirement: &21563460 !ruby/object:Gem::Requirement
|
150
161
|
none: false
|
151
162
|
requirements:
|
152
163
|
- - ! '>='
|
@@ -154,10 +165,10 @@ dependencies:
|
|
154
165
|
version: 0.7.2
|
155
166
|
type: :development
|
156
167
|
prerelease: false
|
157
|
-
version_requirements: *
|
168
|
+
version_requirements: *21563460
|
158
169
|
- !ruby/object:Gem::Dependency
|
159
170
|
name: geokit
|
160
|
-
requirement: &
|
171
|
+
requirement: &21562720 !ruby/object:Gem::Requirement
|
161
172
|
none: false
|
162
173
|
requirements:
|
163
174
|
- - ! '>='
|
@@ -165,10 +176,10 @@ dependencies:
|
|
165
176
|
version: 1.5.0
|
166
177
|
type: :development
|
167
178
|
prerelease: false
|
168
|
-
version_requirements: *
|
179
|
+
version_requirements: *21562720
|
169
180
|
- !ruby/object:Gem::Dependency
|
170
181
|
name: sqlite3-ruby
|
171
|
-
requirement: &
|
182
|
+
requirement: &21578260 !ruby/object:Gem::Requirement
|
172
183
|
none: false
|
173
184
|
requirements:
|
174
185
|
- - ! '>='
|
@@ -176,10 +187,10 @@ dependencies:
|
|
176
187
|
version: 1.3.2
|
177
188
|
type: :development
|
178
189
|
prerelease: false
|
179
|
-
version_requirements: *
|
190
|
+
version_requirements: *21578260
|
180
191
|
- !ruby/object:Gem::Dependency
|
181
192
|
name: hpricot
|
182
|
-
requirement: &
|
193
|
+
requirement: &21577620 !ruby/object:Gem::Requirement
|
183
194
|
none: false
|
184
195
|
requirements:
|
185
196
|
- - ! '>='
|
@@ -187,10 +198,10 @@ dependencies:
|
|
187
198
|
version: 0.8.3
|
188
199
|
type: :development
|
189
200
|
prerelease: false
|
190
|
-
version_requirements: *
|
201
|
+
version_requirements: *21577620
|
191
202
|
- !ruby/object:Gem::Dependency
|
192
203
|
name: git
|
193
|
-
requirement: &
|
204
|
+
requirement: &21576920 !ruby/object:Gem::Requirement
|
194
205
|
none: false
|
195
206
|
requirements:
|
196
207
|
- - ! '>='
|
@@ -198,7 +209,7 @@ dependencies:
|
|
198
209
|
version: 1.2.5
|
199
210
|
type: :development
|
200
211
|
prerelease: false
|
201
|
-
version_requirements: *
|
212
|
+
version_requirements: *21576920
|
202
213
|
description: A Rails plugin for Japanese mobile-phones
|
203
214
|
email: dara@shidara.net
|
204
215
|
executables: []
|
@@ -441,7 +452,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
441
452
|
version: '0'
|
442
453
|
requirements: []
|
443
454
|
rubyforge_project:
|
444
|
-
rubygems_version: 1.8.
|
455
|
+
rubygems_version: 1.8.15
|
445
456
|
signing_key:
|
446
457
|
specification_version: 3
|
447
458
|
summary: A Rails plugin for Japanese mobile-phones
|