bizside 2.1.12 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 505728253077850f79dd349f00a51357e9b0969a94aefe4d9e516d300a3b650e
4
- data.tar.gz: 6f0cd5d78b501f3b7302eff8017f2fde987966cba56f3722840baa91fc34a7aa
3
+ metadata.gz: 85705b907c50726c6c80d22088f91c3413009119db847be089eab32ec73f8659
4
+ data.tar.gz: 1518ed67cb6cccc547823db1dcbe57f921aa7445906b9d07932916a148f09439
5
5
  SHA512:
6
- metadata.gz: f46f57a50e3bab26842bb224635033c5c5dab4044d609852ffe082fcc9aee7c0aba76eb2c928fd1bb227bef5c55fe314ec0a1020640cd6c455c31ba8bc00171a
7
- data.tar.gz: 6adc13affa302d5397f78c9083dd581e02fd945b5b928ec191b3602fb7b619dd236bae56fca85776af3b828a806c06a87a55d9c938d59cbfd2a827ef242c15c1
6
+ metadata.gz: '08592ac5b1048768a881c2be96820a7323121bf4656df65a69445bcaf875a673602e6c568baf895d6606790aa2102ada3c377bea6490bce88b4eedae56087839'
7
+ data.tar.gz: bce8b135b2ea68a35ea898a79242b2e9961d967af851f0ec785c1e09a086e48bef5d9befd3cb907a3529058128d5c043516a6757c4d8c8641689741b9a8be024
@@ -0,0 +1,50 @@
1
+ require 'action_view'
2
+
3
+ class ActionView::TemplateRenderer
4
+
5
+ def render(context, options)
6
+ @details = extract_details(options)
7
+ template = get_template_by_user_agent(context, options)
8
+
9
+ prepend_formats(template.format)
10
+
11
+ render_template(context, template, options[:layout], options[:locals] || {})
12
+ end
13
+
14
+ private
15
+
16
+ def get_user_agent(context)
17
+ if context.respond_to?(:user_agent)
18
+ if context.respond_to?(:controller)
19
+ if context.controller.respond_to?(:session)
20
+ context.user_agent
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def get_template_by_user_agent(context, options)
27
+ ret = nil
28
+ option_for_template = options[:template]
29
+
30
+ ua = get_user_agent(context)
31
+ if ua
32
+ ua.priorities.each do |priority|
33
+ begin
34
+ options[:template] = option_for_template + '.' + priority
35
+ ret = determine_template(options)
36
+ break
37
+ rescue ActionView::MissingTemplate
38
+ end
39
+ end
40
+ end
41
+
42
+ unless ret
43
+ options[:template] = option_for_template
44
+ ret = determine_template(options)
45
+ end
46
+
47
+ Rails.logger.debug "UserAgent: #{ua ? ua.name : 'unknown'} => #{ret.identifier}"
48
+ ret
49
+ end
50
+ end
@@ -5,6 +5,12 @@ when 5
5
5
  else
6
6
  load File.expand_path(File.join('action_view', 'action_view_4.rb'), __dir__)
7
7
  end
8
+ when 6
9
+ if Bizside.config.user_agent.use_variant?
10
+ load File.expand_path(File.join('action_view', 'use_variant.rb'), __dir__)
11
+ else
12
+ load File.expand_path(File.join('action_view', 'action_view_6.rb'), __dir__)
13
+ end
8
14
  else
9
15
  raise "Rails#{Rails::VERSION::MAJOR} はサポートしていません。"
10
16
  end
@@ -5,11 +5,7 @@ module Bizside
5
5
 
6
6
  included do
7
7
  case Rails::VERSION::MAJOR
8
- when 3
9
- before_filter :detect_user_agent
10
- when 4
11
- before_action :detect_user_agent
12
- when 5
8
+ when 5, 6
13
9
  before_action :detect_user_agent
14
10
  else
15
11
  raise "Rails-#{Rails::VERSION::MAJOR} は未対応です。"
@@ -1,3 +1,3 @@
1
1
  module Bizside
2
- VERSION = '2.1.12'
2
+ VERSION = '2.2.1'
3
3
  end
@@ -16,7 +16,7 @@ class IpAddressValidator < ActiveModel::EachValidator
16
16
  raise unless IPAddress::valid_ipv4?(value)
17
17
  end
18
18
  rescue
19
- record.errors[attribute] << (options[:message] || "はIPアドレスとして正しくありません。")
19
+ record.errors.add(attribute, options[:message] || "はIPアドレスとして正しくありません。")
20
20
  end
21
21
  end
22
22
  end
@@ -14,7 +14,7 @@ class TelValidator < ActiveModel::EachValidator
14
14
  return if value.nil? or value.empty?
15
15
 
16
16
  unless validate_tel(record, value)
17
- record.errors[attribute] << I18n.t('errors.messages.invalid')
17
+ record.errors.add(attribute, I18n.t('errors.messages.invalid'))
18
18
  end
19
19
  end
20
20
 
@@ -13,17 +13,17 @@ class UrlValidator < ActiveModel::EachValidator
13
13
  begin
14
14
  URI.parse(value)
15
15
  rescue URI::InvalidURIError
16
- record.errors[attribute] << (options[:message] || "はURLとして正しくありません。")
16
+ record.errors.add(attribute, options[:message] || "はURLとして正しくありません。")
17
17
  return
18
18
  end
19
19
 
20
20
  if @with_schema
21
21
  unless value.start_with?('http://') or value.start_with?('https://')
22
- record.errors[attribute] << (options[:message] || "は http:// または https:// から始めてください。")
22
+ record.errors.add(attribute, options[:message] || "は http:// または https:// から始めてください。")
23
23
  end
24
24
  else
25
25
  if value.start_with?('http://') or value.start_with?('https://')
26
- record.errors[attribute] << (options[:message] || "は http:// または https:// を含めないでください。")
26
+ record.errors.add(attribute, options[:message] || "は http:// または https:// を含めないでください。")
27
27
  end
28
28
  end
29
29
  end
@@ -12,8 +12,7 @@ class ZipValidator < ActiveModel::EachValidator
12
12
  return if (zip1.nil? or zip1.empty?) and (zip2.nil? or zip2.empty?)
13
13
 
14
14
  unless validate_zip(zip1, zip2)
15
- record.errors[attribute] << I18n.t('errors.messages.zip')
16
- return
15
+ record.errors.add(attribute, I18n.t('errors.messages.zip'))
17
16
  end
18
17
  end
19
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bizside
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.12
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bizside-developers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-17 00:00:00.000000000 Z
11
+ date: 2022-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 5.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 6.0.0
22
+ version: 7.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 5.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.0.0
32
+ version: 7.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: aws-sdk-s3
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -301,7 +301,7 @@ dependencies:
301
301
  version: 5.0.0
302
302
  - - "<"
303
303
  - !ruby/object:Gem::Version
304
- version: 6.0.0
304
+ version: 7.0.0
305
305
  type: :development
306
306
  prerelease: false
307
307
  version_requirements: !ruby/object:Gem::Requirement
@@ -311,7 +311,7 @@ dependencies:
311
311
  version: 5.0.0
312
312
  - - "<"
313
313
  - !ruby/object:Gem::Version
314
- version: 6.0.0
314
+ version: 7.0.0
315
315
  - !ruby/object:Gem::Dependency
316
316
  name: resque
317
317
  requirement: !ruby/object:Gem::Requirement
@@ -444,6 +444,7 @@ files:
444
444
  - lib/bizside/user_agent.rb
445
445
  - lib/bizside/user_agent/action_view.rb
446
446
  - lib/bizside/user_agent/action_view/action_view_4.rb
447
+ - lib/bizside/user_agent/action_view/action_view_6.rb
447
448
  - lib/bizside/user_agent/action_view/use_variant.rb
448
449
  - lib/bizside/user_agent/controller_helper.rb
449
450
  - lib/bizside/validations.rb