bizside 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/images/jquery-treeTable/images/toggle-collapse-dark.png +0 -0
- data/app/assets/images/jquery-treeTable/images/toggle-collapse-light.png +0 -0
- data/app/assets/images/jquery-treeTable/images/toggle-expand-dark.png +0 -0
- data/app/assets/images/jquery-treeTable/images/toggle-expand-light.png +0 -0
- data/app/assets/javascripts/bizside.js +1 -0
- data/app/assets/javascripts/jquery-treeTable/jquery.treeTable.js +400 -0
- data/app/assets/stylesheets/bizside.css +3 -0
- data/app/assets/stylesheets/jquery-treeTable/jquery.treeTable.css.erb +55 -0
- data/lib/bizside/acl/access_control_utils.rb +36 -0
- data/lib/bizside/acl/available_helper.rb +65 -0
- data/lib/bizside/acl/controller_helper.rb +15 -0
- data/lib/bizside/acl.rb +6 -0
- data/lib/bizside/active_record_logger.rb +3 -0
- data/lib/bizside/audit/job_logger.rb +14 -0
- data/lib/bizside/audit/logger.rb +35 -0
- data/lib/bizside/audit_log.rb +158 -0
- data/lib/bizside/cache/entry.rb +112 -0
- data/lib/bizside/cache/file_store.rb +167 -0
- data/lib/bizside/cache/store.rb +237 -0
- data/lib/bizside/cache_util.rb +47 -0
- data/lib/bizside/cache_utils.rb +10 -0
- data/lib/bizside/carrierwave.rb +48 -0
- data/lib/bizside/config.rb +63 -0
- data/lib/bizside/configurations/mail.rb +37 -0
- data/lib/bizside/configurations/prefix.rb +25 -0
- data/lib/bizside/configurations/storage.rb +28 -0
- data/lib/bizside/coverage/launch.rb +25 -0
- data/lib/bizside/coverage/rcov_formatter.rb +13 -0
- data/lib/bizside/cron_validator.rb +62 -0
- data/lib/bizside/cucumber.rb +1 -0
- data/lib/bizside/engine.rb +4 -0
- data/lib/bizside/file_converter.rb +56 -0
- data/lib/bizside/file_uploader.rb +71 -0
- data/lib/bizside/gengou.rb +46 -0
- data/lib/bizside/gengou.yml +5 -0
- data/lib/bizside/hanaita_conf.rb +88 -0
- data/lib/bizside/implicit_ftps.rb +29 -0
- data/lib/bizside/itamae_conf.rb +186 -0
- data/lib/bizside/job_utils.rb +285 -0
- data/lib/bizside/log_analyzer.rb +122 -0
- data/lib/bizside/mailer.rb +56 -0
- data/lib/bizside/query_builder.rb +78 -0
- data/lib/bizside/railtie.rb +80 -0
- data/lib/bizside/record_has_warnings.rb +4 -0
- data/lib/bizside/resque.rb +141 -0
- data/lib/bizside/rsync.rb +40 -0
- data/lib/bizside/safe_pty.rb +17 -0
- data/lib/bizside/shib_utils.rb +18 -0
- data/lib/bizside/show_exceptions.rb +18 -0
- data/lib/bizside/sql_utils.rb +45 -0
- data/lib/bizside/string_io.rb +39 -0
- data/lib/bizside/string_utils.rb +157 -0
- data/lib/bizside/task_helper.rb +263 -0
- data/lib/bizside/tasks.rb +6 -0
- data/lib/bizside/test_help.rb +17 -0
- data/lib/bizside/uploader/content_type_validator.rb +39 -0
- data/lib/bizside/uploader/default_extensions.yml +15 -0
- data/lib/bizside/uploader/exif.rb +43 -0
- data/lib/bizside/uploader/extension_whitelist.rb +26 -0
- data/lib/bizside/uploader/filename_validator.rb +31 -0
- data/lib/bizside/user_agent/action_view/action_view_4.rb +56 -0
- data/lib/bizside/user_agent/action_view/use_variant.rb +4 -0
- data/lib/bizside/user_agent/action_view.rb +10 -0
- data/lib/bizside/user_agent/controller_helper.rb +51 -0
- data/lib/bizside/user_agent.rb +108 -0
- data/lib/bizside/validations.rb +8 -0
- data/lib/bizside/version.rb +3 -0
- data/lib/bizside/view_helper.rb +10 -0
- data/lib/bizside/warning.rb +24 -0
- data/lib/bizside/yes.rb +16 -0
- data/lib/bizside.rb +96 -0
- data/lib/cron_validator.rb +3 -0
- data/lib/gengou.rb +3 -0
- data/lib/job_utils.rb +3 -0
- data/lib/query_builder.rb +3 -0
- data/lib/record_has_warnings.rb +3 -0
- data/lib/sql_utils.rb +3 -0
- data/lib/string_utils.rb +3 -0
- data/lib/user_agent.rb +3 -0
- data/lib/yes.rb +3 -0
- data/rails/locales/ja.yml +12 -0
- data/validations/collection_presence_validator.rb +15 -0
- data/validations/email_validator.rb +1 -0
- data/validations/ip_address_validator.rb +22 -0
- data/validations/tel_validator.rb +28 -0
- data/validations/url_validator.rb +30 -0
- data/validations/zip_validator.rb +35 -0
- metadata +467 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bizside/record_has_warnings'
|
2
|
+
|
3
|
+
module Bizside
|
4
|
+
module Warning
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
attr_accessor :warnings_confirmed
|
9
|
+
end
|
10
|
+
|
11
|
+
def warnings
|
12
|
+
@warnings ||= []
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_warnings
|
16
|
+
raise Bizside::RecordHasWarnings.new if warnings.present?
|
17
|
+
end
|
18
|
+
|
19
|
+
def warnings_confirmed?
|
20
|
+
self.warnings_confirmed == '1' or self.warnings_confirmed == true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/bizside/yes.rb
ADDED
data/lib/bizside.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'yaml'
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext'
|
5
|
+
|
6
|
+
require 'bizside/version'
|
7
|
+
require 'bizside/config'
|
8
|
+
require 'bizside/gengou'
|
9
|
+
require 'bizside/job_utils'
|
10
|
+
require 'bizside/query_builder'
|
11
|
+
require 'bizside/sql_utils'
|
12
|
+
require 'bizside/string_utils'
|
13
|
+
require 'bizside/user_agent'
|
14
|
+
require 'bizside/yes'
|
15
|
+
|
16
|
+
module Bizside
|
17
|
+
|
18
|
+
# Railsがロードできる場合はRails.envを返し、ロードできない場合はnilを返します。
|
19
|
+
def self.rails_env
|
20
|
+
defined?(Rails) && Rails.env
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.env
|
24
|
+
rails_env || ENV['RAILS_ENV'] || 'development'
|
25
|
+
end
|
26
|
+
|
27
|
+
@@_version_info = nil
|
28
|
+
def self.version_info
|
29
|
+
if @@_version_info.nil?
|
30
|
+
release_tag_file = "/var/#{Bizside.config.add_on_name}/shared/RELEASE_TAG"
|
31
|
+
if File.exist?(release_tag_file)
|
32
|
+
@@_version_info = File.read(release_tag_file).strip
|
33
|
+
else
|
34
|
+
if Dir.exist?('.git')
|
35
|
+
info = `git describe`.strip.split('-')
|
36
|
+
@@_version_info = info[0] ? "#{info[0]}-#{info[1]}" : '0.0.0-0'
|
37
|
+
@@_version_info << "-p#{info[2]}" if info[2].to_i > 0
|
38
|
+
else
|
39
|
+
@@_version_info = '0.0.0-0'
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
@@_version_info
|
45
|
+
end
|
46
|
+
|
47
|
+
@@_config = nil
|
48
|
+
def self.config
|
49
|
+
if @@_config
|
50
|
+
return @@_config unless Bizside.env == 'development'
|
51
|
+
end
|
52
|
+
|
53
|
+
configfile = ENV['CONFIG_FILE'] || File.join('config', 'bizside.yml')
|
54
|
+
if File.exist?(configfile)
|
55
|
+
@@_config = Bizside::Config.new(YAML.load_file(configfile)[Bizside.env])
|
56
|
+
else
|
57
|
+
raise "設定ファイルの #{configfile} は必須です。"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.logger
|
62
|
+
if defined?(Rails) && Rails.logger
|
63
|
+
Rails.logger
|
64
|
+
else
|
65
|
+
@logger ||= ::Logger.new($stdout)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
require 'bizside/shib_utils'
|
71
|
+
|
72
|
+
require 'bizside/acl' if Bizside.config.acl.enabled?
|
73
|
+
require 'bizside/warning' if Bizside.config.warning_validation.enabled?
|
74
|
+
require 'bizside/user_agent' if Bizside.config.user_agent.enabled?
|
75
|
+
require 'bizside/file_converter' if Bizside.config.jod_converter.enabled?
|
76
|
+
|
77
|
+
require 'bizside/audit_log'
|
78
|
+
require 'bizside/show_exceptions'
|
79
|
+
|
80
|
+
if defined?(Rails)
|
81
|
+
require 'bizside/cache_utils'
|
82
|
+
require 'bizside/engine' unless Bizside.config.use_best_practices?
|
83
|
+
require 'bizside/railtie'
|
84
|
+
end
|
85
|
+
|
86
|
+
unless Bizside.config.within_bizside_namespace?
|
87
|
+
%w[
|
88
|
+
CronValidator Gengou JobUtils QueryBuilder
|
89
|
+
SqlUtils RecordHasWarnings StringUtils UserAgent Yes
|
90
|
+
].each do |class_name|
|
91
|
+
bizside_class_name = "::Bizside::#{class_name}"
|
92
|
+
next unless self.class.const_defined?(bizside_class_name)
|
93
|
+
|
94
|
+
self.class.const_set class_name, self.class.const_get(bizside_class_name)
|
95
|
+
end
|
96
|
+
end
|
data/lib/gengou.rb
ADDED
data/lib/job_utils.rb
ADDED
data/lib/sql_utils.rb
ADDED
data/lib/string_utils.rb
ADDED
data/lib/user_agent.rb
ADDED
data/lib/yes.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
ja:
|
2
|
+
bizside:
|
3
|
+
messages:
|
4
|
+
logout_not_available: 全てのブラウザを閉じるまでログアウトは完了しません。\n席を離れる際には全ブラウザを閉じてください。
|
5
|
+
|
6
|
+
errors:
|
7
|
+
messages:
|
8
|
+
content_type_whitelist_error: にContent-Typeが%{content_type}のファイルをアップロードすることはできません。
|
9
|
+
extension_white_list_error: に拡張子が %{extension} のファイルをアップロードすることはできません。
|
10
|
+
extension_whitelist_error: に拡張子が %{extension} のファイルをアップロードすることはできません。
|
11
|
+
filename_error: '%{filename} に使用できない文字が含まれています。'
|
12
|
+
mini_magick_processing_error: 画像ファイルの編集に失敗しました。%{e}"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CollectionPresenceValidator < ActiveModel::EachValidator
|
2
|
+
|
3
|
+
def validate_each(record, attribute, value)
|
4
|
+
value.each do |v|
|
5
|
+
if v.respond_to?(:deleted?)
|
6
|
+
next if v.deleted?
|
7
|
+
end
|
8
|
+
|
9
|
+
return if v.present?
|
10
|
+
end
|
11
|
+
|
12
|
+
record.errors.add(attribute, :empty)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'email_validator/strict'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ipaddress'
|
2
|
+
|
3
|
+
class IpAddressValidator < ActiveModel::EachValidator
|
4
|
+
|
5
|
+
def initialize(options = {})
|
6
|
+
super(options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def validate_each(record, attribute, value)
|
10
|
+
return if (value.nil? or value.empty?)
|
11
|
+
|
12
|
+
begin
|
13
|
+
if options[:cidr]
|
14
|
+
IPAddress::IPv4.new(value)
|
15
|
+
else
|
16
|
+
raise unless IPAddress::valid_ipv4?(value)
|
17
|
+
end
|
18
|
+
rescue
|
19
|
+
record.errors[attribute] << (options[:message] || "はIPアドレスとして正しくありません。")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +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
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class UrlValidator < ActiveModel::EachValidator
|
2
|
+
|
3
|
+
def initialize(options = {})
|
4
|
+
super(options)
|
5
|
+
if options.key?(:with_schema)
|
6
|
+
@with_schema = options[:with_schema]
|
7
|
+
else
|
8
|
+
@with_schema = true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def validate_each(record, attribute, value)
|
13
|
+
begin
|
14
|
+
URI.parse(value)
|
15
|
+
rescue URI::InvalidURIError
|
16
|
+
record.errors[attribute] << (options[:message] || "はURLとして正しくありません。")
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
if @with_schema
|
21
|
+
unless value.start_with?('http://') or value.start_with?('https://')
|
22
|
+
record.errors[attribute] << (options[:message] || "は http:// または https:// から始めてください。")
|
23
|
+
end
|
24
|
+
else
|
25
|
+
if value.start_with?('http://') or value.start_with?('https://')
|
26
|
+
record.errors[attribute] << (options[:message] || "は http:// または https:// を含めないでください。")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +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
|