cmdx 1.5.0 → 1.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de49105a37f479ac8172f6329536b45a976adbb4e09c43b9351e329dbf662760
4
- data.tar.gz: 7b100f2619d36ae0ac287c108bbab114168d87528beb1751951ac1282dbc37d3
3
+ metadata.gz: bd6e2321faffcce3015989a0e58df96c87be1dbdc4755cc7b783546bc5ecbc4f
4
+ data.tar.gz: cc5f262ac3f329a308e8a0c25a0f200830830d09c3560c913f8a80ff5997aab8
5
5
  SHA512:
6
- metadata.gz: becbfc6dcc4657b16697559c91bac79a2416610655f2831cef74745d30720ac6e0f64991b442229384c8c98259f3b9dc0df706b60c988c01462a8a02eb8ee097
7
- data.tar.gz: e0dc0122625d710048768d0a31b39a1081ef800206e331f7e842b483c4639108177dbe83a6e1b47cbd08328ddfc5899e5d5b682ce65ec90287035b8e17a7d8f3
6
+ metadata.gz: 71e5f8a864f91b10ca26985bfbd7502fcc751e70117562bee62f606f340468bd517e329a05de5f80d495ff7bb0aaf0195564ceaa95267b9bfdba6d3c424c0698
7
+ data.tar.gz: 2d560416d0838761e481952a5d759e05db859fef027e74a5c6c5bb65e49756ab041a35f7725d88ba40746b93f2726bee65e317b7c89d5e56291dd9767c99603f
@@ -58,4 +58,3 @@ business logic within service/command objects.
58
58
  - Keep comments up-to-date with code changes
59
59
  - Keep documentation consistent
60
60
  - Update CHANGELOG.md with any changes
61
-
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [TODO]
8
8
 
9
+ ## [1.5.1] - 2025-08-21
10
+
11
+ ### Changes
12
+ - Prefix I18n with `::` to play nice with `CMDx::I18n`
13
+ - Safe navigate length and numeric validators
14
+ - Update railtie file path points to correct directory
15
+
9
16
  ## [1.5.0] - 2025-08-21
10
17
 
11
18
  ### Changes
data/lib/cmdx/locale.rb CHANGED
@@ -36,7 +36,7 @@ module CMDx
36
36
  # # => "Custom fallback message"
37
37
  def translate(key, **options)
38
38
  options[:default] ||= EN.dig("en", *key.to_s.split("."))
39
- return I18n.t(key, **options) if defined?(I18n)
39
+ return ::I18n.t(key, **options) if defined?(::I18n)
40
40
 
41
41
  case message = options.delete(:default)
42
42
  when NilClass then "Translation missing: #{key}"
data/lib/cmdx/railtie.rb CHANGED
@@ -23,7 +23,7 @@ module CMDx
23
23
  # # in the CMDx gem's locales directory
24
24
  initializer("cmdx.configure_locales") do |app|
25
25
  Array(app.config.i18n.available_locales).each do |locale|
26
- path = CMDx.gem_path.join("locales/#{locale}.yml")
26
+ path = CMDx.gem_path.join("lib/locales/#{locale}.yml")
27
27
  next unless File.file?(path)
28
28
 
29
29
  I18n.load_path << path
@@ -52,25 +52,27 @@ module CMDx
52
52
  # Length.call("short", not_in: 1..3)
53
53
  # # => nil (validation passes - length 5 is not in excluded range)
54
54
  def call(value, options = {})
55
+ length = value&.length
56
+
55
57
  case options
56
58
  in within:
57
- raise_within_validation_error!(within.begin, within.end, options) unless within.cover?(value.length)
59
+ raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(length)
58
60
  in not_within:
59
- raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within.cover?(value.length)
61
+ raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(length)
60
62
  in in: xin
61
- raise_within_validation_error!(xin.begin, xin.end, options) unless xin.cover?(value.length)
63
+ raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(length)
62
64
  in not_in:
63
- raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in.cover?(value.length)
65
+ raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(length)
64
66
  in min:, max:
65
- raise_within_validation_error!(min, max, options) unless value.length.between?(min, max)
67
+ raise_within_validation_error!(min, max, options) unless length&.between?(min, max)
66
68
  in min:
67
- raise_min_validation_error!(min, options) unless min <= value.length
69
+ raise_min_validation_error!(min, options) unless !length.nil? && (min <= length)
68
70
  in max:
69
- raise_max_validation_error!(max, options) unless value.length <= max
71
+ raise_max_validation_error!(max, options) unless !length.nil? && (length <= max)
70
72
  in is:
71
- raise_is_validation_error!(is, options) unless value.length == is
73
+ raise_is_validation_error!(is, options) unless !length.nil? && (length == is)
72
74
  in is_not:
73
- raise_is_not_validation_error!(is_not, options) if value.length == is_not
75
+ raise_is_not_validation_error!(is_not, options) if !length.nil? && (length == is_not)
74
76
  else
75
77
  raise ArgumentError, "unknown length validator options given"
76
78
  end
@@ -51,23 +51,23 @@ module CMDx
51
51
  def call(value, options = {})
52
52
  case options
53
53
  in within:
54
- raise_within_validation_error!(within.begin, within.end, options) unless within.cover?(value)
54
+ raise_within_validation_error!(within.begin, within.end, options) unless within&.cover?(value)
55
55
  in not_within:
56
- raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within.cover?(value)
56
+ raise_not_within_validation_error!(not_within.begin, not_within.end, options) if not_within&.cover?(value)
57
57
  in in: xin
58
- raise_within_validation_error!(xin.begin, xin.end, options) unless xin.cover?(value)
58
+ raise_within_validation_error!(xin.begin, xin.end, options) unless xin&.cover?(value)
59
59
  in not_in:
60
- raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in.cover?(value)
60
+ raise_not_within_validation_error!(not_in.begin, not_in.end, options) if not_in&.cover?(value)
61
61
  in min:, max:
62
- raise_within_validation_error!(min, max, options) unless value.between?(min, max)
62
+ raise_within_validation_error!(min, max, options) unless value&.between?(min, max)
63
63
  in min:
64
- raise_min_validation_error!(min, options) unless min <= value
64
+ raise_min_validation_error!(min, options) unless !value.nil? && (min <= value)
65
65
  in max:
66
- raise_max_validation_error!(max, options) unless value <= max
66
+ raise_max_validation_error!(max, options) unless !value.nil? && (value <= max)
67
67
  in is:
68
- raise_is_validation_error!(is, options) unless value == is
68
+ raise_is_validation_error!(is, options) unless !value.nil? && (value == is)
69
69
  in is_not:
70
- raise_is_not_validation_error!(is_not, options) if value == is_not
70
+ raise_is_not_validation_error!(is_not, options) if !value.nil? && (value == is_not)
71
71
  else
72
72
  raise ArgumentError, "unknown numeric validator options given"
73
73
  end
data/lib/cmdx/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module CMDx
4
4
 
5
- VERSION = "1.5.0"
5
+ VERSION = "1.5.1"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmdx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez