jpmobile 7.0.2 → 7.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1353f6341c914dfadbe29cdf617506304701dafdbdc826e21a7339b8963d7934
4
- data.tar.gz: 6007f9958265cae1eb8e73fdf50fb308b6d5ce086452d6986025244d52e525bb
3
+ metadata.gz: b00599e53c71e6bf45f9d8b953b4e7256d3a0f32f1e7f905006467e4a2dd8095
4
+ data.tar.gz: 935af37ae804e50db7cccf3fa979abddde111ba5f9e9fe61fea57a1420a567d8
5
5
  SHA512:
6
- metadata.gz: b5623190d12407d9f5f6bd8348faf7fa2f81b206dc773d13898acc2a1da354fac16916564883c56692246fc4ebdcd8f40dc7ddd9f39e1d9974bb22abe5bf5d33
7
- data.tar.gz: e873923cfcfcfdd0a80211a1197269117f920c905a886ed22cb0fbcadeeb8d6a3065d7dafde6839a053aff7107fff08e4d913f80c7a4fc948314a670f20588ee
6
+ metadata.gz: 4f418fba357ce7cd534817f4a398b0308d9baa720196ff6eecdb459806f5c998a1408db386ce9917bf74e62857406dd91f8f6757319b35d95f571a763b2f5ad1
7
+ data.tar.gz: 8067721a16ed607f3074326ebf340be90e6991bdc186a4e9d8f251a8b857b67789d235489d6bf75511f3b7b66923c8a6f1f62ba84df95f2e041143d3b307aa80
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jpmobile (7.0.1)
4
+ jpmobile (7.0.3)
5
5
  mail (~> 2.7.0)
6
6
  rexml
7
7
  scanf
data/README.md CHANGED
@@ -294,6 +294,28 @@ def index
294
294
  end
295
295
  ```
296
296
 
297
+ ### アクション定義の省略
298
+
299
+ Railsでは、アクション名に対応するテンプレートが存在する場合、アクション用のメソッド定義を省略できる。
300
+
301
+ しかし、端末向けテンプレートしか存在しないアクションの場合、jpmobileではメソッド定義を省略することを許していない。
302
+
303
+ ```ruby
304
+ class MyController < ApplicationController
305
+ # app/views/my/index_smart_phone.html.erb がある場合でも、次のメソッド定義は必須。
306
+ def index
307
+ end
308
+ end
309
+ ```
310
+
311
+ 次のように設定を加えると、これを省略できるようになる。
312
+
313
+ ```ruby
314
+ class MyController < ApplicationController
315
+ include Jpmobile::MethodLessActionSupport
316
+ end
317
+ ```
318
+
297
319
  ### 位置情報の取得用リンクの生成
298
320
 
299
321
  以下のようなコードで、端末に位置情報を要求するリンクを出力する。
@@ -0,0 +1,11 @@
1
+ module Jpmobile
2
+ module MethodLessActionSupport
3
+ def template_exists?(*args, **kwargs, &block)
4
+ super(
5
+ *args,
6
+ **kwargs.reverse_merge(mobile: request.mobile&.variants || []),
7
+ &block
8
+ )
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,7 @@ ActiveSupport.on_load(:action_controller) do
2
2
  require 'jpmobile/docomo_guid'
3
3
  require 'jpmobile/filter'
4
4
  require 'jpmobile/helpers'
5
+ require 'jpmobile/method_less_action_support'
5
6
  require 'jpmobile/trans_sid'
6
7
  require 'jpmobile/hook_test_request'
7
8
  ActionDispatch::Request.prepend Jpmobile::Encoding
@@ -1,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = '7.0.2'.freeze
2
+ VERSION = '7.0.3'.freeze
3
3
  end
@@ -0,0 +1,3 @@
1
+ class MethodLessActionSupportController < ApplicationController
2
+ include Jpmobile::MethodLessActionSupport
3
+ end
@@ -102,5 +102,7 @@ RailsRoot::Application.routes.draw do
102
102
  get "#{c}/#{a}", to: "#{c}##{a}"
103
103
  end
104
104
  end
105
+
106
+ get 'method_less_action_support', to: 'method_less_action_support#index'
105
107
  end
106
108
  # rubocop:enable Performance/CollectionLiteralInLoop
@@ -0,0 +1,28 @@
1
+ require 'rails_helper'
2
+
3
+ describe 'Method-less mobile template only action', type: :request do
4
+ subject do
5
+ get '/method_less_action_support', headers: headers
6
+ end
7
+
8
+ let(:headers) do
9
+ {}
10
+ end
11
+
12
+ context 'when accessed with mobile User-Agent' do
13
+ before do
14
+ headers['User-Agent'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'
15
+ end
16
+
17
+ it 'successfully renders mobile template' do
18
+ subject
19
+ expect(response).to have_http_status(200)
20
+ end
21
+ end
22
+
23
+ context 'when accessed with non-mobile User-Agent' do
24
+ it 'raises AbstractController::ActionNotFound' do
25
+ expect { subject }.to raise_error(AbstractController::ActionNotFound)
26
+ end
27
+ end
28
+ 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: 7.0.2
4
+ version: 7.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shin-ichiro OGAWA
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-06 00:00:00.000000000 Z
12
+ date: 2022-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mail
@@ -223,6 +223,7 @@ files:
223
223
  - lib/jpmobile/lookup_context.rb
224
224
  - lib/jpmobile/mail.rb
225
225
  - lib/jpmobile/mailer.rb
226
+ - lib/jpmobile/method_less_action_support.rb
226
227
  - lib/jpmobile/mobile/abstract_mobile.rb
227
228
  - lib/jpmobile/mobile/android.rb
228
229
  - lib/jpmobile/mobile/android_tablet.rb
@@ -324,6 +325,7 @@ files:
324
325
  - test/rails/overrides/app/controllers/hankaku_filter_controller.rb
325
326
  - test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb
326
327
  - test/rails/overrides/app/controllers/links_controller.rb
328
+ - test/rails/overrides/app/controllers/method_less_action_support_controller.rb
327
329
  - test/rails/overrides/app/controllers/mobile_spec_controller.rb
328
330
  - test/rails/overrides/app/controllers/template_path_controller.rb
329
331
  - test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb
@@ -359,6 +361,7 @@ files:
359
361
  - test/rails/overrides/app/views/links/show_all.html.erb
360
362
  - test/rails/overrides/app/views/links/softbank_location.html.erb
361
363
  - test/rails/overrides/app/views/links/willcom_location.html.erb
364
+ - test/rails/overrides/app/views/method_less_action_support/index_smart_phone.html.erb
362
365
  - test/rails/overrides/app/views/mobile_mailer/default_to_mail.text.erb
363
366
  - test/rails/overrides/app/views/mobile_mailer/multi_message.html.erb
364
367
  - test/rails/overrides/app/views/mobile_mailer/multi_message.text.erb
@@ -436,6 +439,7 @@ files:
436
439
  - test/rails/overrides/spec/requests/docomo_spec.rb
437
440
  - test/rails/overrides/spec/requests/emobile_spec.rb
438
441
  - test/rails/overrides/spec/requests/filter_spec.rb
442
+ - test/rails/overrides/spec/requests/method_less_action_support_spec.rb
439
443
  - test/rails/overrides/spec/requests/pc_spec.rb
440
444
  - test/rails/overrides/spec/requests/softbank_emulator_spec.rb
441
445
  - test/rails/overrides/spec/requests/template_path_spec.rb
@@ -549,6 +553,7 @@ test_files:
549
553
  - test/rails/overrides/app/controllers/hankaku_filter_controller.rb
550
554
  - test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb
551
555
  - test/rails/overrides/app/controllers/links_controller.rb
556
+ - test/rails/overrides/app/controllers/method_less_action_support_controller.rb
552
557
  - test/rails/overrides/app/controllers/mobile_spec_controller.rb
553
558
  - test/rails/overrides/app/controllers/template_path_controller.rb
554
559
  - test/rails/overrides/app/controllers/trans_sid_always_and_session_off_controller.rb
@@ -584,6 +589,7 @@ test_files:
584
589
  - test/rails/overrides/app/views/links/show_all.html.erb
585
590
  - test/rails/overrides/app/views/links/softbank_location.html.erb
586
591
  - test/rails/overrides/app/views/links/willcom_location.html.erb
592
+ - test/rails/overrides/app/views/method_less_action_support/index_smart_phone.html.erb
587
593
  - test/rails/overrides/app/views/mobile_mailer/default_to_mail.text.erb
588
594
  - test/rails/overrides/app/views/mobile_mailer/multi_message.html.erb
589
595
  - test/rails/overrides/app/views/mobile_mailer/multi_message.text.erb
@@ -661,6 +667,7 @@ test_files:
661
667
  - test/rails/overrides/spec/requests/docomo_spec.rb
662
668
  - test/rails/overrides/spec/requests/emobile_spec.rb
663
669
  - test/rails/overrides/spec/requests/filter_spec.rb
670
+ - test/rails/overrides/spec/requests/method_less_action_support_spec.rb
664
671
  - test/rails/overrides/spec/requests/pc_spec.rb
665
672
  - test/rails/overrides/spec/requests/softbank_emulator_spec.rb
666
673
  - test/rails/overrides/spec/requests/template_path_spec.rb