can_has_validations 1.3.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/lib/can_has_validations/locale/ja.yml +12 -0
- data/lib/can_has_validations/validators/hostname_validator.rb +6 -3
- data/lib/can_has_validations/validators/ipaddr_validator.rb +11 -15
- data/lib/can_has_validations/validators/write_once_validator.rb +3 -1
- data/lib/can_has_validations/version.rb +1 -1
- data/lib/can_has_validations.rb +3 -1
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +33 -0
- data/test/dummy/config/application.rb +15 -51
- data/test/dummy/config/boot.rb +2 -9
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +4 -4
- data/test/dummy/config/environments/development.rb +53 -22
- data/test/dummy/config/environments/production.rb +59 -39
- data/test/dummy/config/environments/test.rb +42 -19
- data/test/dummy/config/initializers/content_security_policy.rb +26 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
- data/test/dummy/config/initializers/inflections.rb +10 -9
- data/test/dummy/config/initializers/permissions_policy.rb +11 -0
- data/test/dummy/config/storage.yml +34 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +8 -0
- data/test/dummy/log/test.log +6 -0
- data/test/dummy/tmp/development_secret.txt +1 -0
- metadata +65 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9758f98d0ba52576c225f0ffe184d18fe1b5e00038117faf309a122493f495c3
|
4
|
+
data.tar.gz: 5efdd9ed78a93c3e6372bd869149b49fb4d38e3421921805981f94f1a0b42444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a054838d0d0e7fd0aa25a805faa82a7708a21e909fa3cbd8e4fef962cca68ea2a4a4e70c81b064e2d23b50d60b5d51795c22e6255596d42a95e09037ac1699f6
|
7
|
+
data.tar.gz: 805563f53b9f845d06ba6617ed565f28737b204e6d5bdc2efc88b4abf5d38a704bfe33b3ccae75909010846b8b7369fc82a133fd3780c2e07c6c591e5a0a89fc
|
data/MIT-LICENSE
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
ja:
|
2
|
+
errors:
|
3
|
+
messages:
|
4
|
+
invalid_email: は無効なメールです。
|
5
|
+
invalid_hostname: は無効なホスト名です。
|
6
|
+
invalid_ip: は無効な IP です。
|
7
|
+
ip_not_allowed: は許可された IP ではありません。
|
8
|
+
single_ip_required: は、単一の IP である必要があります。
|
9
|
+
invalid_url: は無効な URL です。
|
10
|
+
unchangeable: は変更できません。
|
11
|
+
before: は、 %{attribute2} の前でなければなりません。
|
12
|
+
after: は、 %{attribute2} の後でなければなりません。
|
@@ -24,8 +24,8 @@
|
|
24
24
|
# allows 'a.example.com', but not 'example.com'
|
25
25
|
# validates :domain, hostname: {allow_ip: true} # or 4 or 6 for ipv4 or ipv6 only
|
26
26
|
# allows '1.2.3.4' or 'a.example.com'
|
27
|
-
# validates :subdomain, hostname: {skip_tld: true
|
28
|
-
# allows 'subdomain1'
|
27
|
+
# validates :subdomain, hostname: {skip_tld: true}
|
28
|
+
# allows 'subdomain1'; implies segments: 1..100 unless otherwise specified
|
29
29
|
|
30
30
|
require 'resolv'
|
31
31
|
|
@@ -37,6 +37,7 @@ module ActiveModel::Validations
|
|
37
37
|
RESERVED_OPTIONS = %i(allow_ip allow_slash allow_underscore allow_wildcard)
|
38
38
|
|
39
39
|
def validate_each(record, attribute, value)
|
40
|
+
value = value.to_s
|
40
41
|
case options[:allow_ip]
|
41
42
|
when 4, '4'
|
42
43
|
return if value =~ Resolv::IPv4::Regex
|
@@ -46,7 +47,7 @@ module ActiveModel::Validations
|
|
46
47
|
return if value =~ Resolv::IPv4::Regex || value =~ Resolv::IPv6::Regex
|
47
48
|
end
|
48
49
|
|
49
|
-
segments = options[:segments] || (2..100)
|
50
|
+
segments = options[:segments] || (options[:skip_tld] ? 1..100 : 2..100)
|
50
51
|
segments = segments..segments if segments.is_a?(Integer)
|
51
52
|
if defined?(Addressable::IDNA)
|
52
53
|
value &&= Addressable::IDNA.to_ascii(value)
|
@@ -63,6 +64,8 @@ module ActiveModel::Validations
|
|
63
64
|
is_valid &&= label.length <= 63
|
64
65
|
if !options[:skip_tld] && idx+1==labels.size
|
65
66
|
is_valid &&= label =~ FINAL_LABEL_REGEXP
|
67
|
+
elsif options[:allow_wildcard]==:multi && idx==0
|
68
|
+
is_valid &&= %w(** *).include?(label) || label =~ LABEL_REGEXP
|
66
69
|
elsif options[:allow_wildcard] && idx==0
|
67
70
|
is_valid &&= label=='*' || label =~ LABEL_REGEXP
|
68
71
|
else
|
@@ -37,9 +37,9 @@ module ActiveModel::Validations
|
|
37
37
|
if !options[:allow_block] && (ip.ipv4? && ip.prefix!=32 or ip.ipv6? && ip.prefix!=128)
|
38
38
|
record.errors.add(attribute, :single_ip_required, **options.merge(value: value))
|
39
39
|
end
|
40
|
-
if allowed_ips && allowed_ips.none?{|blk|
|
40
|
+
if allowed_ips && allowed_ips.none?{|blk| ip_within_block? ip, blk}
|
41
41
|
record.errors.add(attribute, :ip_not_allowed, **options.merge(value: value))
|
42
|
-
elsif disallowed_ips && disallowed_ips.any?{|blk|
|
42
|
+
elsif disallowed_ips && disallowed_ips.any?{|blk| ip_within_block? ip, blk}
|
43
43
|
record.errors.add(attribute, :ip_not_allowed, **options.merge(value: value))
|
44
44
|
end
|
45
45
|
end
|
@@ -47,6 +47,13 @@ module ActiveModel::Validations
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
+
def ip_within_block?(ip, blk)
|
51
|
+
return false unless ip.family == blk.family
|
52
|
+
ip = ip.to_range
|
53
|
+
blk = blk.to_range
|
54
|
+
ip.begin >= blk.begin && ip.end <= blk.end
|
55
|
+
end
|
56
|
+
|
50
57
|
def normalize_within(val, key)
|
51
58
|
if val.nil? || val.respond_to?(:call) || val.is_a?(Symbol)
|
52
59
|
val
|
@@ -72,20 +79,9 @@ module ActiveModel::Validations
|
|
72
79
|
else
|
73
80
|
val
|
74
81
|
end
|
82
|
+
# raise "#{val.inspect} did not resolve to an Array of IPAddr" unless res.is_a?(Array) && res.all?{|r| r.is_a?(IPAddr)}
|
83
|
+
# res
|
75
84
|
end
|
76
85
|
|
77
86
|
end
|
78
87
|
end
|
79
|
-
|
80
|
-
# tests for & fixes broken IPAddr <= 1.2.2
|
81
|
-
if IPAddr.new('192.168.2.0/32').include? '192.168.2.0/24'
|
82
|
-
# warn 'IPAddr <= 1.2.2 is broken; monkey-patching'
|
83
|
-
class IPAddr
|
84
|
-
def include?(other)
|
85
|
-
range = to_range
|
86
|
-
other = coerce_other(other).to_range
|
87
|
-
range.begin <= other.begin && range.end >= other.end
|
88
|
-
end
|
89
|
-
alias === include?
|
90
|
-
end
|
91
|
-
end
|
@@ -18,7 +18,9 @@ module ActiveModel::Validations
|
|
18
18
|
|
19
19
|
def validate_each(record, attribute, _)
|
20
20
|
return unless record.persisted?
|
21
|
-
if !record.respond_to?("#{attribute}_changed?")
|
21
|
+
if ( !record.respond_to?("#{attribute}_changed?") ||
|
22
|
+
!record.respond_to?("#{attribute}_was")
|
23
|
+
) && record.respond_to?("#{attribute}_id_changed?")
|
22
24
|
attr2 = "#{attribute}_id"
|
23
25
|
else
|
24
26
|
attr2 = attribute
|
data/lib/can_has_validations.rb
CHANGED
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path("..", __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts "== Installing dependencies =="
|
17
|
+
system! "gem install bundler --conservative"
|
18
|
+
system("bundle check") || system!("bundle install")
|
19
|
+
|
20
|
+
# puts "\n== Copying sample files =="
|
21
|
+
# unless File.exist?("config/database.yml")
|
22
|
+
# FileUtils.cp "config/database.yml.sample", "config/database.yml"
|
23
|
+
# end
|
24
|
+
|
25
|
+
puts "\n== Preparing database =="
|
26
|
+
system! "bin/rails db:prepare"
|
27
|
+
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
29
|
+
system! "bin/rails log:clear tmp:clear"
|
30
|
+
|
31
|
+
puts "\n== Restarting application server =="
|
32
|
+
system! "bin/rails restart"
|
33
|
+
end
|
@@ -1,59 +1,23 @@
|
|
1
|
-
|
1
|
+
require_relative "boot"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/all"
|
4
4
|
|
5
|
-
|
5
|
+
# Require the gems listed in Gemfile, including any gems
|
6
|
+
# you've limited to :test, :development, or :production.
|
7
|
+
Bundler.require(*Rails.groups)
|
6
8
|
require "can_has_validations"
|
7
9
|
|
8
10
|
module Dummy
|
9
11
|
class Application < Rails::Application
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
#
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# config.
|
20
|
-
|
21
|
-
# Activate observers that should always be running.
|
22
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
-
|
24
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
-
|
28
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
-
# config.i18n.default_locale = :de
|
31
|
-
|
32
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
-
config.encoding = "utf-8"
|
34
|
-
|
35
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
-
config.filter_parameters += [:password]
|
37
|
-
|
38
|
-
# Enable escaping HTML in JSON.
|
39
|
-
config.active_support.escape_html_entities_in_json = true
|
40
|
-
|
41
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
42
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
43
|
-
# like if you have constraints or database-specific column types
|
44
|
-
# config.active_record.schema_format = :sql
|
45
|
-
|
46
|
-
# Enforce whitelist mode for mass assignment.
|
47
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
48
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
49
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
50
|
-
config.active_record.whitelist_attributes = true
|
51
|
-
|
52
|
-
# Enable the asset pipeline
|
53
|
-
config.assets.enabled = true
|
54
|
-
|
55
|
-
# Version of your assets, change this if you want to expire all your assets
|
56
|
-
config.assets.version = '1.0'
|
12
|
+
# Initialize configuration defaults for originally generated Rails version.
|
13
|
+
config.load_defaults 7.0
|
14
|
+
|
15
|
+
# Configuration for the application, engines, and railties goes here.
|
16
|
+
#
|
17
|
+
# These settings can be overridden in specific environments using the files
|
18
|
+
# in config/environments, which are processed later.
|
19
|
+
#
|
20
|
+
# config.time_zone = "Central Time (US & Canada)"
|
21
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
57
22
|
end
|
58
23
|
end
|
59
|
-
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,10 +1,3 @@
|
|
1
|
-
|
2
|
-
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
1
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
3
2
|
|
4
|
-
|
5
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
|
-
end
|
9
|
-
|
10
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
3
|
+
require "bundler/setup" # Set up gems listed in the Gemfile.
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# Load the
|
2
|
-
|
1
|
+
# Load the Rails application.
|
2
|
+
require_relative "application"
|
3
3
|
|
4
|
-
# Initialize the
|
5
|
-
|
4
|
+
# Initialize the Rails application.
|
5
|
+
Rails.application.initialize!
|
@@ -1,37 +1,68 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
require "active_support/core_ext/integer/time"
|
3
2
|
|
4
|
-
|
5
|
-
#
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# In the development environment your application's code is reloaded any time
|
7
|
+
# it changes. This slows down response time but is perfect for development
|
6
8
|
# since you don't have to restart the web server when you make code changes.
|
7
9
|
config.cache_classes = false
|
8
10
|
|
9
|
-
#
|
10
|
-
config.
|
11
|
+
# Do not eager load code on boot.
|
12
|
+
config.eager_load = false
|
13
|
+
|
14
|
+
# Show full error reports.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
|
17
|
+
# Enable server timing
|
18
|
+
config.server_timing = true
|
19
|
+
|
20
|
+
# Enable/disable caching. By default caching is disabled.
|
21
|
+
# Run rails dev:cache to toggle caching.
|
22
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
23
|
+
config.action_controller.perform_caching = true
|
24
|
+
config.action_controller.enable_fragment_cache_logging = true
|
25
|
+
|
26
|
+
config.cache_store = :memory_store
|
27
|
+
config.public_file_server.headers = {
|
28
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
29
|
+
}
|
30
|
+
else
|
31
|
+
config.action_controller.perform_caching = false
|
11
32
|
|
12
|
-
|
13
|
-
|
14
|
-
config.action_controller.perform_caching = false
|
33
|
+
config.cache_store = :null_store
|
34
|
+
end
|
15
35
|
|
16
|
-
#
|
36
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
37
|
+
config.active_storage.service = :local
|
38
|
+
|
39
|
+
# Don't care if the mailer can't send.
|
17
40
|
config.action_mailer.raise_delivery_errors = false
|
18
41
|
|
19
|
-
|
42
|
+
config.action_mailer.perform_caching = false
|
43
|
+
|
44
|
+
# Print deprecation notices to the Rails logger.
|
20
45
|
config.active_support.deprecation = :log
|
21
46
|
|
22
|
-
#
|
23
|
-
config.
|
47
|
+
# Raise exceptions for disallowed deprecations.
|
48
|
+
config.active_support.disallowed_deprecation = :raise
|
49
|
+
|
50
|
+
# Tell Active Support which deprecation messages to disallow.
|
51
|
+
config.active_support.disallowed_deprecation_warnings = []
|
52
|
+
|
53
|
+
# Raise an error on page load if there are pending migrations.
|
54
|
+
config.active_record.migration_error = :page_load
|
55
|
+
|
56
|
+
# Highlight code that triggered database queries in logs.
|
57
|
+
config.active_record.verbose_query_logs = true
|
24
58
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
59
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
60
|
+
# Raises error for missing translations.
|
61
|
+
# config.i18n.raise_on_missing_translations = true
|
31
62
|
|
32
|
-
#
|
33
|
-
config.
|
63
|
+
# Annotate rendered view with file names.
|
64
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
34
65
|
|
35
|
-
#
|
36
|
-
config.
|
66
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
67
|
+
# config.action_cable.disable_request_forgery_protection = true
|
37
68
|
end
|
@@ -1,67 +1,87 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
require "active_support/core_ext/integer/time"
|
3
2
|
|
4
|
-
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# Code is not reloaded between requests.
|
5
7
|
config.cache_classes = true
|
6
8
|
|
7
|
-
#
|
9
|
+
# Eager load code on boot. This eager loads most of Rails and
|
10
|
+
# your application in memory, allowing both threaded web servers
|
11
|
+
# and those relying on copy on write to perform better.
|
12
|
+
# Rake tasks automatically ignore this option for performance.
|
13
|
+
config.eager_load = true
|
14
|
+
|
15
|
+
# Full error reports are disabled and caching is turned on.
|
8
16
|
config.consider_all_requests_local = false
|
9
17
|
config.action_controller.perform_caching = true
|
10
18
|
|
11
|
-
#
|
12
|
-
config.
|
19
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
20
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
21
|
+
# config.require_master_key = true
|
13
22
|
|
14
|
-
#
|
15
|
-
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
16
26
|
|
17
|
-
#
|
18
|
-
config.
|
27
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
28
|
+
# config.asset_host = "http://assets.example.com"
|
19
29
|
|
20
|
-
#
|
21
|
-
config.
|
30
|
+
# Specifies the header that your server uses for sending files.
|
31
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
32
|
+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
22
33
|
|
23
|
-
#
|
24
|
-
|
34
|
+
# Store uploaded files on the local file system (see config/storage.yml for options).
|
35
|
+
config.active_storage.service = :local
|
25
36
|
|
26
|
-
#
|
27
|
-
# config.
|
28
|
-
# config.
|
37
|
+
# Mount Action Cable outside main process or domain.
|
38
|
+
# config.action_cable.mount_path = nil
|
39
|
+
# config.action_cable.url = "wss://example.com/cable"
|
40
|
+
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
|
29
41
|
|
30
42
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
43
|
# config.force_ssl = true
|
32
44
|
|
33
|
-
#
|
34
|
-
#
|
45
|
+
# Include generic and useful information about system operation, but avoid logging too much
|
46
|
+
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
47
|
+
config.log_level = :info
|
35
48
|
|
36
|
-
# Prepend all log lines with the following tags
|
37
|
-
|
49
|
+
# Prepend all log lines with the following tags.
|
50
|
+
config.log_tags = [ :request_id ]
|
38
51
|
|
39
|
-
# Use a different
|
40
|
-
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
|
-
|
42
|
-
# Use a different cache store in production
|
52
|
+
# Use a different cache store in production.
|
43
53
|
# config.cache_store = :mem_cache_store
|
44
54
|
|
45
|
-
#
|
46
|
-
# config.
|
55
|
+
# Use a real queuing backend for Active Job (and separate queues per environment).
|
56
|
+
# config.active_job.queue_adapter = :resque
|
57
|
+
# config.active_job.queue_name_prefix = "dummy_production"
|
47
58
|
|
48
|
-
|
49
|
-
# config.assets.precompile += %w( search.js )
|
59
|
+
config.action_mailer.perform_caching = false
|
50
60
|
|
51
|
-
#
|
61
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
62
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
52
63
|
# config.action_mailer.raise_delivery_errors = false
|
53
64
|
|
54
|
-
# Enable threaded mode
|
55
|
-
# config.threadsafe!
|
56
|
-
|
57
65
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
-
# the I18n.default_locale when a translation
|
66
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
67
|
config.i18n.fallbacks = true
|
60
68
|
|
61
|
-
#
|
62
|
-
config.active_support.
|
69
|
+
# Don't log any deprecations.
|
70
|
+
config.active_support.report_deprecations = false
|
71
|
+
|
72
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
73
|
+
config.log_formatter = ::Logger::Formatter.new
|
74
|
+
|
75
|
+
# Use a different logger for distributed setups.
|
76
|
+
# require "syslog/logger"
|
77
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
|
78
|
+
|
79
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
80
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
81
|
+
logger.formatter = config.log_formatter
|
82
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
83
|
+
end
|
63
84
|
|
64
|
-
#
|
65
|
-
|
66
|
-
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
85
|
+
# Do not dump schema after migrations.
|
86
|
+
config.active_record.dump_schema_after_migration = false
|
67
87
|
end
|
@@ -1,37 +1,60 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
require "active_support/core_ext/integer/time"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
|
8
|
+
Rails.application.configure do
|
9
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
10
|
+
|
11
|
+
# Turn false under Spring and add config.action_view.cache_template_loading = true.
|
8
12
|
config.cache_classes = true
|
9
13
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
14
|
+
# Eager loading loads your whole application. When running a single test locally,
|
15
|
+
# this probably isn't necessary. It's a good idea to do in a continuous integration
|
16
|
+
# system, or in some way before deploying your code.
|
17
|
+
config.eager_load = ENV["CI"].present?
|
13
18
|
|
14
|
-
#
|
15
|
-
config.
|
19
|
+
# Configure public file server for tests with Cache-Control for performance.
|
20
|
+
config.public_file_server.enabled = true
|
21
|
+
config.public_file_server.headers = {
|
22
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
23
|
+
}
|
16
24
|
|
17
|
-
# Show full error reports and disable caching
|
25
|
+
# Show full error reports and disable caching.
|
18
26
|
config.consider_all_requests_local = true
|
19
27
|
config.action_controller.perform_caching = false
|
28
|
+
config.cache_store = :null_store
|
20
29
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
30
|
+
# Raise exceptions instead of rendering exception templates.
|
22
31
|
config.action_dispatch.show_exceptions = false
|
23
32
|
|
24
|
-
# Disable request forgery protection in test environment
|
25
|
-
config.action_controller.allow_forgery_protection
|
33
|
+
# Disable request forgery protection in test environment.
|
34
|
+
config.action_controller.allow_forgery_protection = false
|
35
|
+
|
36
|
+
# Store uploaded files on the local file system in a temporary directory.
|
37
|
+
config.active_storage.service = :test
|
38
|
+
|
39
|
+
config.action_mailer.perform_caching = false
|
26
40
|
|
27
41
|
# Tell Action Mailer not to deliver emails to the real world.
|
28
42
|
# The :test delivery method accumulates sent emails in the
|
29
43
|
# ActionMailer::Base.deliveries array.
|
30
44
|
config.action_mailer.delivery_method = :test
|
31
45
|
|
32
|
-
#
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
34
|
-
|
35
|
-
# Print deprecation notices to the stderr
|
46
|
+
# Print deprecation notices to the stderr.
|
36
47
|
config.active_support.deprecation = :stderr
|
48
|
+
|
49
|
+
# Raise exceptions for disallowed deprecations.
|
50
|
+
config.active_support.disallowed_deprecation = :raise
|
51
|
+
|
52
|
+
# Tell Active Support which deprecation messages to disallow.
|
53
|
+
config.active_support.disallowed_deprecation_warnings = []
|
54
|
+
|
55
|
+
# Raises error for missing translations.
|
56
|
+
# config.i18n.raise_on_missing_translations = true
|
57
|
+
|
58
|
+
# Annotate rendered view with file names.
|
59
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
37
60
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Define an application-wide content security policy
|
4
|
+
# For further information see the following documentation
|
5
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
6
|
+
|
7
|
+
# Rails.application.configure do
|
8
|
+
# config.content_security_policy do |policy|
|
9
|
+
# policy.default_src :self, :https
|
10
|
+
# policy.font_src :self, :https, :data
|
11
|
+
# policy.img_src :self, :https, :data
|
12
|
+
# policy.object_src :none
|
13
|
+
# policy.script_src :self, :https
|
14
|
+
# policy.style_src :self, :https
|
15
|
+
# # Specify URI for violation reports
|
16
|
+
# # policy.report_uri "/csp-violation-report-endpoint"
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# # Generate session nonces for permitted importmap and inline scripts
|
20
|
+
# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
|
21
|
+
# config.content_security_policy_nonce_directives = %w(script-src)
|
22
|
+
#
|
23
|
+
# # Report CSP violations to a specified URI. See:
|
24
|
+
# # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
|
25
|
+
# # config.content_security_policy_report_only = true
|
26
|
+
# end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
# Add new inflection rules using the following format
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# inflect.
|
8
|
-
# inflect.
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
8
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
9
|
+
# inflect.irregular "person", "people"
|
9
10
|
# inflect.uncountable %w( fish sheep )
|
10
11
|
# end
|
11
|
-
|
12
|
+
|
12
13
|
# These inflection rules are supported but not enabled by default:
|
13
|
-
# ActiveSupport::Inflector.inflections do |inflect|
|
14
|
-
# inflect.acronym
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym "RESTful"
|
15
16
|
# end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Define an application-wide HTTP permissions policy. For further
|
2
|
+
# information see https://developers.google.com/web/updates/2018/06/feature-policy
|
3
|
+
#
|
4
|
+
# Rails.application.config.permissions_policy do |f|
|
5
|
+
# f.camera :none
|
6
|
+
# f.gyroscope :none
|
7
|
+
# f.microphone :none
|
8
|
+
# f.usb :none
|
9
|
+
# f.fullscreen :self
|
10
|
+
# f.payment :self, "https://secure.example.com"
|
11
|
+
# end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
test:
|
2
|
+
service: Disk
|
3
|
+
root: <%= Rails.root.join("tmp/storage") %>
|
4
|
+
|
5
|
+
local:
|
6
|
+
service: Disk
|
7
|
+
root: <%= Rails.root.join("storage") %>
|
8
|
+
|
9
|
+
# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)
|
10
|
+
# amazon:
|
11
|
+
# service: S3
|
12
|
+
# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
|
13
|
+
# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
|
14
|
+
# region: us-east-1
|
15
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
16
|
+
|
17
|
+
# Remember not to checkin your GCS keyfile to a repository
|
18
|
+
# google:
|
19
|
+
# service: GCS
|
20
|
+
# project: your_project
|
21
|
+
# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %>
|
22
|
+
# bucket: your_own_bucket-<%= Rails.env %>
|
23
|
+
|
24
|
+
# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
|
25
|
+
# microsoft:
|
26
|
+
# service: AzureStorage
|
27
|
+
# storage_account_name: your_account_name
|
28
|
+
# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
|
29
|
+
# container: your_container_name-<%= Rails.env %>
|
30
|
+
|
31
|
+
# mirror:
|
32
|
+
# service: Mirror
|
33
|
+
# primary: local
|
34
|
+
# mirrors: [ amazon, google, microsoft ]
|
File without changes
|
@@ -0,0 +1,8 @@
|
|
1
|
+
DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
|
2
|
+
`legacy_connection_handling` to `false` in your application.
|
3
|
+
|
4
|
+
The new connection handling does not support `connection_handlers`
|
5
|
+
getter and setter.
|
6
|
+
|
7
|
+
Read more about how to migrate at: https://guides.rubyonrails.org/active_record_multiple_databases.html#migrate-to-the-new-connection-handling
|
8
|
+
(called from require at script/rails:6)
|
data/test/dummy/log/test.log
CHANGED
@@ -0,0 +1,6 @@
|
|
1
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT sqlite_version(*)[0m
|
2
|
+
[1m[36mTRANSACTION (0.1ms)[0m [1m[36mbegin transaction[0m
|
3
|
+
---------------------------------
|
4
|
+
CanHasValidationsTest: test_truth
|
5
|
+
---------------------------------
|
6
|
+
[1m[36mTRANSACTION (0.0ms)[0m [1m[31mrollback transaction[0m
|
@@ -0,0 +1 @@
|
|
1
|
+
4b5a6e34b8d3a11481cda90f33b0c97c64277abf7578bd84874e62006d4892bace067c2bfa3fdfb6e7eaf7290d4f0dc3e32c0018d627a75b1dea7d8271fc51ea
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: can_has_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thomas morgan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,20 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '5.
|
29
|
+
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: sqlite3
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,8 +58,8 @@ dependencies:
|
|
44
58
|
- - ">="
|
45
59
|
- !ruby/object:Gem::Version
|
46
60
|
version: '0'
|
47
|
-
description: 'Assorted Rails 5.x-
|
48
|
-
Hostname, IP address, Ordering, URL, Write Once'
|
61
|
+
description: 'Assorted Rails 5.x-7.x validators: Array, Email, Existence, Grandparent,
|
62
|
+
Hash keys, Hash values, Hostname, IP address, Ordering, URL, Write Once'
|
49
63
|
email:
|
50
64
|
- tm@iprog.com
|
51
65
|
executables: []
|
@@ -58,6 +72,7 @@ files:
|
|
58
72
|
- lib/can_has_validations.rb
|
59
73
|
- lib/can_has_validations/locale/en.yml
|
60
74
|
- lib/can_has_validations/locale/es.yml
|
75
|
+
- lib/can_has_validations/locale/ja.yml
|
61
76
|
- lib/can_has_validations/validators/array_validator.rb
|
62
77
|
- lib/can_has_validations/validators/email_validator.rb
|
63
78
|
- lib/can_has_validations/validators/existence_validator.rb
|
@@ -79,28 +94,39 @@ files:
|
|
79
94
|
- test/dummy/app/controllers/application_controller.rb
|
80
95
|
- test/dummy/app/helpers/application_helper.rb
|
81
96
|
- test/dummy/app/views/layouts/application.html.erb
|
97
|
+
- test/dummy/bin/rails
|
98
|
+
- test/dummy/bin/rake
|
99
|
+
- test/dummy/bin/setup
|
82
100
|
- test/dummy/config.ru
|
83
101
|
- test/dummy/config/application.rb
|
84
102
|
- test/dummy/config/boot.rb
|
103
|
+
- test/dummy/config/cable.yml
|
85
104
|
- test/dummy/config/database.yml
|
86
105
|
- test/dummy/config/environment.rb
|
87
106
|
- test/dummy/config/environments/development.rb
|
88
107
|
- test/dummy/config/environments/production.rb
|
89
108
|
- test/dummy/config/environments/test.rb
|
90
109
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
110
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
111
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
91
112
|
- test/dummy/config/initializers/inflections.rb
|
92
113
|
- test/dummy/config/initializers/mime_types.rb
|
114
|
+
- test/dummy/config/initializers/permissions_policy.rb
|
93
115
|
- test/dummy/config/initializers/secret_token.rb
|
94
116
|
- test/dummy/config/initializers/session_store.rb
|
95
117
|
- test/dummy/config/initializers/wrap_parameters.rb
|
96
118
|
- test/dummy/config/locales/en.yml
|
97
119
|
- test/dummy/config/routes.rb
|
120
|
+
- test/dummy/config/storage.yml
|
121
|
+
- test/dummy/db/test.sqlite3
|
122
|
+
- test/dummy/log/development.log
|
98
123
|
- test/dummy/log/test.log
|
99
124
|
- test/dummy/public/404.html
|
100
125
|
- test/dummy/public/422.html
|
101
126
|
- test/dummy/public/500.html
|
102
127
|
- test/dummy/public/favicon.ico
|
103
128
|
- test/dummy/script/rails
|
129
|
+
- test/dummy/tmp/development_secret.txt
|
104
130
|
- test/test_helper.rb
|
105
131
|
homepage: https://github.com/zarqman/can_has_validations
|
106
132
|
licenses:
|
@@ -121,39 +147,50 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
147
|
- !ruby/object:Gem::Version
|
122
148
|
version: '0'
|
123
149
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
150
|
+
rubygems_version: 3.2.22
|
125
151
|
signing_key:
|
126
152
|
specification_version: 4
|
127
|
-
summary: Assorted Rails 5.x-
|
153
|
+
summary: Assorted Rails 5.x-7.x validators
|
128
154
|
test_files:
|
129
|
-
- test/
|
130
|
-
- test/dummy/
|
155
|
+
- test/can_has_validations_test.rb
|
156
|
+
- test/dummy/README.rdoc
|
157
|
+
- test/dummy/Rakefile
|
131
158
|
- test/dummy/app/assets/javascripts/application.js
|
132
159
|
- test/dummy/app/assets/stylesheets/application.css
|
160
|
+
- test/dummy/app/controllers/application_controller.rb
|
133
161
|
- test/dummy/app/helpers/application_helper.rb
|
134
|
-
- test/dummy/
|
135
|
-
- test/dummy/
|
136
|
-
- test/dummy/
|
137
|
-
- test/dummy/
|
138
|
-
- test/dummy/config/environments/test.rb
|
139
|
-
- test/dummy/config/environment.rb
|
162
|
+
- test/dummy/app/views/layouts/application.html.erb
|
163
|
+
- test/dummy/bin/rails
|
164
|
+
- test/dummy/bin/rake
|
165
|
+
- test/dummy/bin/setup
|
140
166
|
- test/dummy/config/application.rb
|
141
|
-
- test/dummy/config/database.yml
|
142
167
|
- test/dummy/config/boot.rb
|
168
|
+
- test/dummy/config/cable.yml
|
169
|
+
- test/dummy/config/database.yml
|
170
|
+
- test/dummy/config/environment.rb
|
171
|
+
- test/dummy/config/environments/development.rb
|
172
|
+
- test/dummy/config/environments/production.rb
|
173
|
+
- test/dummy/config/environments/test.rb
|
143
174
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
175
|
+
- test/dummy/config/initializers/content_security_policy.rb
|
176
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
177
|
+
- test/dummy/config/initializers/inflections.rb
|
144
178
|
- test/dummy/config/initializers/mime_types.rb
|
179
|
+
- test/dummy/config/initializers/permissions_policy.rb
|
180
|
+
- test/dummy/config/initializers/secret_token.rb
|
145
181
|
- test/dummy/config/initializers/session_store.rb
|
146
182
|
- test/dummy/config/initializers/wrap_parameters.rb
|
147
|
-
- test/dummy/config/
|
148
|
-
- test/dummy/config/
|
183
|
+
- test/dummy/config/locales/en.yml
|
184
|
+
- test/dummy/config/routes.rb
|
185
|
+
- test/dummy/config/storage.yml
|
149
186
|
- test/dummy/config.ru
|
150
|
-
- test/dummy/
|
151
|
-
- test/dummy/
|
152
|
-
- test/dummy/
|
187
|
+
- test/dummy/db/test.sqlite3
|
188
|
+
- test/dummy/log/development.log
|
189
|
+
- test/dummy/log/test.log
|
190
|
+
- test/dummy/public/404.html
|
153
191
|
- test/dummy/public/422.html
|
154
192
|
- test/dummy/public/500.html
|
155
|
-
- test/dummy/public/
|
156
|
-
- test/dummy/
|
157
|
-
- test/dummy/
|
158
|
-
- test/can_has_validations_test.rb
|
193
|
+
- test/dummy/public/favicon.ico
|
194
|
+
- test/dummy/script/rails
|
195
|
+
- test/dummy/tmp/development_secret.txt
|
159
196
|
- test/test_helper.rb
|