whiny_validation 1.0 → 1.1
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 +5 -5
- data/lib/whiny_validation/version.rb +1 -1
- data/lib/whiny_validation.rb +15 -5
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29b7d8158ea77148918fbe3190467de13a42fc6f8f6f982beac6918a3ff38521
|
4
|
+
data.tar.gz: c5547fa0749947d4a4f9d66ed1f3d5fffd444cf3fd58daca8d7d1e3dae451946
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d78905e6eeaf4b159dd248bf4a1497193d6dbd40961598b27f5b7ad97ef798146b37bf5202475566d8cfee43c1c3ef9f9b6130e308217f75fc46b2bee44d58e
|
7
|
+
data.tar.gz: 6dbac61f0b98fadcc58f00afb5290167a05087251aaf4d8871b88cf94ca18d396b5c094e332cd946ad3b4c1a20e442379e351883eb0e5ca27ad88bd4fb9833d5
|
data/lib/whiny_validation.rb
CHANGED
@@ -18,9 +18,17 @@ module WhinyValidation
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
21
|
+
def color_mode_options
|
22
|
+
if ActiveSupport.gem_version < Gem::Version.new("7.1.0")
|
23
|
+
true
|
24
|
+
else
|
25
|
+
{ bold: true }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
def validation_failed(event)
|
22
30
|
send(WhinyValidation.configuration.log_level) do
|
23
|
-
name = color("Validation failed", YELLOW,
|
31
|
+
name = color("Validation failed", YELLOW, color_mode_options)
|
24
32
|
object = event.payload[:object]
|
25
33
|
error_messages = color(event.payload[:error_messages].map{|message|" => #{message}"}.join("\n"), YELLOW)
|
26
34
|
|
@@ -32,8 +40,10 @@ module WhinyValidation
|
|
32
40
|
WhinyValidation::LogSubscriber.attach_to :whiny_validation
|
33
41
|
end
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
43
|
+
if defined?(ActiveRecord)
|
44
|
+
# ActiveRecord is dependent on ActiveSupport so we are good
|
45
|
+
# with calling ActiveSupport
|
46
|
+
ActiveSupport.on_load(:active_record) do
|
47
|
+
ActiveRecord::Base.send(:include, WhinyValidation)
|
38
48
|
end
|
39
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whiny_validation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Morearty
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -117,7 +117,7 @@ files:
|
|
117
117
|
homepage: https://github.com/BMorearty/whiny_validation
|
118
118
|
licenses: []
|
119
119
|
metadata: {}
|
120
|
-
post_install_message:
|
120
|
+
post_install_message:
|
121
121
|
rdoc_options: []
|
122
122
|
require_paths:
|
123
123
|
- lib
|
@@ -132,9 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
|
-
|
136
|
-
|
137
|
-
signing_key:
|
135
|
+
rubygems_version: 3.3.7
|
136
|
+
signing_key:
|
138
137
|
specification_version: 4
|
139
138
|
summary: Write ActiveRecord/ActiveModel validation error messages to the log
|
140
139
|
test_files:
|