bizside 2.0.5 → 2.0.8
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 +4 -4
- data/lib/bizside/job_utils.rb +35 -0
- data/lib/bizside/resque.rb +14 -0
- data/lib/bizside/task_helper.rb +2 -2
- data/lib/bizside/uploader/content_type_validator.rb +1 -1
- data/lib/bizside/user_agent/action_view/action_view_4.rb +1 -1
- data/lib/bizside/version.rb +1 -1
- data/validations/tel_validator.rb +28 -28
- data/validations/zip_validator.rb +35 -35
- metadata +21 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9689c1f6e742e9512e144312cdd80ab20e968b75780eee36b4211996f00f26a1
|
4
|
+
data.tar.gz: 6642f8337d4a1db6f55505278374888e87a198b882b3c0386ddddf1b5886bf8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ae3c04ced97b0d14a52d5db5f03bb52a30cb1cd1d7fa743ce569b7af957949f42b4fa89ad8274e7eb09a026a6aa9a27af817c02e6d89b8ca909a4c84cfe75e6
|
7
|
+
data.tar.gz: 41c281d34b047bbece294070e4bd64ee5868a797cb7ac1422ce5565e99bbe9d2fea34a78b3dcdfd0f4342cae83a6f626419b0b502dc1949a0570177a7e407bfd
|
data/lib/bizside/job_utils.rb
CHANGED
@@ -47,6 +47,41 @@ module Bizside
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
def self.enqueue_at_with_queue(queue, time, klass, *args)
|
51
|
+
if Bizside.rails_env&.test?
|
52
|
+
if klass.respond_to?(:before_enqueue)
|
53
|
+
return unless klass.before_enqueue(*args)
|
54
|
+
end
|
55
|
+
|
56
|
+
Bizside.logger.info "テスト時には遅延ジョブの登録を行わず、即時実行します。"
|
57
|
+
klass.perform(*args)
|
58
|
+
return
|
59
|
+
end
|
60
|
+
|
61
|
+
if block_given?
|
62
|
+
yield
|
63
|
+
else
|
64
|
+
Bizside.logger.info "遅延ジョブ #{klass} を #{queue} に登録します。"
|
65
|
+
end
|
66
|
+
|
67
|
+
::Resque.enqueue_at_with_queue(queue, time, klass, *args)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.enqueue_at_with_queue_silently(queue, time, klass, *args)
|
71
|
+
enqueue_at_with_queue(queue, time, klass, *args) do
|
72
|
+
# 何も出力しない
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.remove_delayed_in_queue(klass, queue, *args)
|
77
|
+
if Bizside.rails_env&.test?
|
78
|
+
Rails.logger.info "テスト時には遅延ジョブのキャンセルを行いません。"
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
::Resque.remove_delayed_in_queue(klass, queue, *args)
|
83
|
+
end
|
84
|
+
|
50
85
|
def self.set_job_at(time, klass, *args)
|
51
86
|
if Bizside.rails_env&.test?
|
52
87
|
if klass.respond_to?(:before_enqueue)
|
data/lib/bizside/resque.rb
CHANGED
@@ -121,6 +121,7 @@ module Resque
|
|
121
121
|
info = {
|
122
122
|
time: Time.now.strftime('%Y-%m-%dT%H:%M:%S.%3N%z'),
|
123
123
|
add_on_name: Bizside.config.add_on_name,
|
124
|
+
server_address: hostname,
|
124
125
|
class: payload['class'],
|
125
126
|
args: payload['args'].to_s,
|
126
127
|
queue: queue,
|
@@ -132,6 +133,19 @@ module Resque
|
|
132
133
|
info
|
133
134
|
end
|
134
135
|
|
136
|
+
# ホスト名を取得。
|
137
|
+
#
|
138
|
+
# 下記理由から hostname(1) を使用:
|
139
|
+
#
|
140
|
+
# * job 実行環境では環境変数 HOSTNAME がセットされていないケースがある
|
141
|
+
# (例: 通常の god 起動の場合。他方、container 起動の場合は
|
142
|
+
# HOSTNAME がセットされている模様)。
|
143
|
+
# * hostname(1) は Linux Standard Base 共通コマンドのため必ず存在する。
|
144
|
+
# @see https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Common/LSB-Common/rcommands.html
|
145
|
+
def hostname
|
146
|
+
@hostname ||= (`hostname`.chomp rescue '(unknown)')
|
147
|
+
end
|
148
|
+
|
135
149
|
end
|
136
150
|
end
|
137
151
|
end
|
data/lib/bizside/task_helper.rb
CHANGED
@@ -176,7 +176,7 @@ end
|
|
176
176
|
|
177
177
|
def self.ask_env(env_key, options = {})
|
178
178
|
cache_file = 'tmp/cache/env'
|
179
|
-
cache = File.
|
179
|
+
cache = File.exist?(cache_file) ? YAML.load_file(cache_file) : {}
|
180
180
|
|
181
181
|
if options.fetch(:cache, false)
|
182
182
|
options = options.merge(default: cache.fetch(env_key, options[:default]))
|
@@ -190,7 +190,7 @@ def self.ask_env(env_key, options = {})
|
|
190
190
|
cache[env_key] = ENV[env_key]
|
191
191
|
File.write(cache_file, YAML.dump(cache))
|
192
192
|
else
|
193
|
-
if File.
|
193
|
+
if File.exist?(cache_file) and cache[env_key]
|
194
194
|
cache.delete(env_key)
|
195
195
|
File.write(cache_file, YAML.dump(cache))
|
196
196
|
end
|
@@ -10,7 +10,7 @@ module Bizside
|
|
10
10
|
require 'carrierwave-magic'
|
11
11
|
include CarrierWave::Magic
|
12
12
|
process :set_magic_content_type => true
|
13
|
-
rescue
|
13
|
+
rescue
|
14
14
|
raise '[Bizside.gem ERROR] you need to add carrierwave-magic.gem.'
|
15
15
|
end
|
16
16
|
before :cache, :validate_content_type!
|
data/lib/bizside/version.rb
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# 電話番号のバリデーション
|
2
|
-
# ActiveModel::EachValidatorを継承してRailsに統合する
|
3
|
-
class TelValidator < ActiveModel::EachValidator
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
super(options)
|
7
|
-
end
|
8
|
-
|
9
|
-
# レコード保存時に呼び出されるバリデーションメソッド
|
10
|
-
# record ・・・ 保存対象のレコード
|
11
|
-
# attribute ・・・ チェック対象の属性(DBのカラム)
|
12
|
-
# value ・・・ 入力された値
|
13
|
-
def validate_each(record, attribute, value)
|
14
|
-
return if value.nil? or value.empty?
|
15
|
-
|
16
|
-
unless validate_tel(record, value)
|
17
|
-
record.errors[attribute] << I18n.t('errors.messages.invalid')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
# 電話番号として妥当かどうかのチェック
|
24
|
-
def validate_tel(record, value)
|
25
|
-
# 全角・半角とわず数字とハイフンの構成であれば良しとしている
|
26
|
-
value.match(/^[0-9|0-9]+[-|-]?[0-9|0-9]+[-|-]?[0-9|0-9]+$/)
|
27
|
-
end
|
28
|
-
end
|
1
|
+
# 電話番号のバリデーション
|
2
|
+
# ActiveModel::EachValidatorを継承してRailsに統合する
|
3
|
+
class TelValidator < ActiveModel::EachValidator
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
# レコード保存時に呼び出されるバリデーションメソッド
|
10
|
+
# record ・・・ 保存対象のレコード
|
11
|
+
# attribute ・・・ チェック対象の属性(DBのカラム)
|
12
|
+
# value ・・・ 入力された値
|
13
|
+
def validate_each(record, attribute, value)
|
14
|
+
return if value.nil? or value.empty?
|
15
|
+
|
16
|
+
unless validate_tel(record, value)
|
17
|
+
record.errors[attribute] << I18n.t('errors.messages.invalid')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
# 電話番号として妥当かどうかのチェック
|
24
|
+
def validate_tel(record, value)
|
25
|
+
# 全角・半角とわず数字とハイフンの構成であれば良しとしている
|
26
|
+
value.match(/^[0-9|0-9]+[-|-]?[0-9|0-9]+[-|-]?[0-9|0-9]+$/)
|
27
|
+
end
|
28
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
class ZipValidator < ActiveModel::EachValidator
|
2
|
-
|
3
|
-
def initialize(options = {})
|
4
|
-
super(options)
|
5
|
-
@other = options[:other]
|
6
|
-
end
|
7
|
-
|
8
|
-
def validate_each(record, attribute, value)
|
9
|
-
zip1 = value
|
10
|
-
zip2 = get_other_value(record)
|
11
|
-
|
12
|
-
return if (zip1.nil? or zip1.empty?) and (zip2.nil? or zip2.empty?)
|
13
|
-
|
14
|
-
unless validate_zip(zip1, zip2)
|
15
|
-
record.errors[attribute] << I18n.t('errors.messages.zip')
|
16
|
-
return
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def validate_zip(zip1, zip2)
|
23
|
-
return false unless zip1
|
24
|
-
return false unless zip1.match(/^[0-9|0-9]{3}$/)
|
25
|
-
|
26
|
-
return false unless zip2
|
27
|
-
return false unless zip2.match(/^[0-9|0-9]{4}$/)
|
28
|
-
|
29
|
-
true
|
30
|
-
end
|
31
|
-
|
32
|
-
def get_other_value(record)
|
33
|
-
record.__send__(@other)
|
34
|
-
end
|
35
|
-
end
|
1
|
+
class ZipValidator < ActiveModel::EachValidator
|
2
|
+
|
3
|
+
def initialize(options = {})
|
4
|
+
super(options)
|
5
|
+
@other = options[:other]
|
6
|
+
end
|
7
|
+
|
8
|
+
def validate_each(record, attribute, value)
|
9
|
+
zip1 = value
|
10
|
+
zip2 = get_other_value(record)
|
11
|
+
|
12
|
+
return if (zip1.nil? or zip1.empty?) and (zip2.nil? or zip2.empty?)
|
13
|
+
|
14
|
+
unless validate_zip(zip1, zip2)
|
15
|
+
record.errors[attribute] << I18n.t('errors.messages.zip')
|
16
|
+
return
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def validate_zip(zip1, zip2)
|
23
|
+
return false unless zip1
|
24
|
+
return false unless zip1.match(/^[0-9|0-9]{3}$/)
|
25
|
+
|
26
|
+
return false unless zip2
|
27
|
+
return false unless zip2.match(/^[0-9|0-9]{4}$/)
|
28
|
+
|
29
|
+
true
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_other_value(record)
|
33
|
+
record.__send__(@other)
|
34
|
+
end
|
35
|
+
end
|
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.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bizside-developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -160,16 +160,22 @@ dependencies:
|
|
160
160
|
name: rake
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
|
-
- - "
|
163
|
+
- - ">="
|
164
164
|
- !ruby/object:Gem::Version
|
165
165
|
version: '12.3'
|
166
|
+
- - "<"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '14.0'
|
166
169
|
type: :runtime
|
167
170
|
prerelease: false
|
168
171
|
version_requirements: !ruby/object:Gem::Requirement
|
169
172
|
requirements:
|
170
|
-
- - "
|
173
|
+
- - ">="
|
171
174
|
- !ruby/object:Gem::Version
|
172
175
|
version: '12.3'
|
176
|
+
- - "<"
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '14.0'
|
173
179
|
- !ruby/object:Gem::Dependency
|
174
180
|
name: RedCloth
|
175
181
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +199,7 @@ dependencies:
|
|
193
199
|
version: '3.0'
|
194
200
|
- - "<"
|
195
201
|
- !ruby/object:Gem::Version
|
196
|
-
version: '3.
|
202
|
+
version: '3.36'
|
197
203
|
type: :development
|
198
204
|
prerelease: false
|
199
205
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -203,27 +209,21 @@ dependencies:
|
|
203
209
|
version: '3.0'
|
204
210
|
- - "<"
|
205
211
|
- !ruby/object:Gem::Version
|
206
|
-
version: '3.
|
212
|
+
version: '3.36'
|
207
213
|
- !ruby/object:Gem::Dependency
|
208
214
|
name: cucumber
|
209
215
|
requirement: !ruby/object:Gem::Requirement
|
210
216
|
requirements:
|
211
|
-
- - "
|
212
|
-
- !ruby/object:Gem::Version
|
213
|
-
version: '2.4'
|
214
|
-
- - "<"
|
217
|
+
- - "~>"
|
215
218
|
- !ruby/object:Gem::Version
|
216
|
-
version: '
|
219
|
+
version: '7.1'
|
217
220
|
type: :development
|
218
221
|
prerelease: false
|
219
222
|
version_requirements: !ruby/object:Gem::Requirement
|
220
223
|
requirements:
|
221
|
-
- - "
|
222
|
-
- !ruby/object:Gem::Version
|
223
|
-
version: '2.4'
|
224
|
-
- - "<"
|
224
|
+
- - "~>"
|
225
225
|
- !ruby/object:Gem::Version
|
226
|
-
version: '
|
226
|
+
version: '7.1'
|
227
227
|
- !ruby/object:Gem::Dependency
|
228
228
|
name: cucumber-rails
|
229
229
|
requirement: !ruby/object:Gem::Requirement
|
@@ -350,22 +350,22 @@ dependencies:
|
|
350
350
|
name: sqlite3
|
351
351
|
requirement: !ruby/object:Gem::Requirement
|
352
352
|
requirements:
|
353
|
-
- - "
|
353
|
+
- - ">="
|
354
354
|
- !ruby/object:Gem::Version
|
355
355
|
version: '1.3'
|
356
356
|
- - "<"
|
357
357
|
- !ruby/object:Gem::Version
|
358
|
-
version: 1.
|
358
|
+
version: 1.5.0
|
359
359
|
type: :development
|
360
360
|
prerelease: false
|
361
361
|
version_requirements: !ruby/object:Gem::Requirement
|
362
362
|
requirements:
|
363
|
-
- - "
|
363
|
+
- - ">="
|
364
364
|
- !ruby/object:Gem::Version
|
365
365
|
version: '1.3'
|
366
366
|
- - "<"
|
367
367
|
- !ruby/object:Gem::Version
|
368
|
-
version: 1.
|
368
|
+
version: 1.5.0
|
369
369
|
description: Bizside is an utilities to assist building web application.
|
370
370
|
email:
|
371
371
|
- bizside-developers@lab.acs-jp.com
|
@@ -479,8 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
479
479
|
- !ruby/object:Gem::Version
|
480
480
|
version: '0'
|
481
481
|
requirements: []
|
482
|
-
|
483
|
-
rubygems_version: 2.7.6.2
|
482
|
+
rubygems_version: 3.3.10
|
484
483
|
signing_key:
|
485
484
|
specification_version: 4
|
486
485
|
summary: Bizside is an utilities for web application.
|