uinit-type 0.1.6 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2fa003157324858ef9690e02461f5a12891514570425c7356d1c6eef2027f2
4
- data.tar.gz: b0e075b89b209a0c0aefbad71973d91da29fc8aba4adaecb6ed3f87e9051b1c8
3
+ metadata.gz: 43e2919517f943631ea31b1ccc01b0acc54c42ce9cb64947057f53678034959b
4
+ data.tar.gz: 2c3be6b8dbb8ccd9bd1b2b1fb7577b399dfc1a07418b165ec8e8aeb4f753e206
5
5
  SHA512:
6
- metadata.gz: d437e365ed02140daa4da4b1d7524bfc4e560df4bf12eb3151bd7ddeb17d6d728d77af3d569c5f9cc82c0af52cd9e4b434b5e19216cad7ce7ad34b6cc0b16fcf
7
- data.tar.gz: 91735badafaecd283b095cfa61c965655be2afc337bd3c0c4092a9195f365d520e9776e1af7b6a16b99eb54c430cd51aa63aa1bc433c0d73fb37031a00ecf01a
6
+ metadata.gz: d70e7d7c505f2a9c059a68b8a7868c64f2420e04259132a455afdbccc38e5a511aebae7477202b1bd9147aed7f544fb8377383ac1fca9cc2fcb394e24f21cea9
7
+ data.tar.gz: 52ff03846eb8635cd24b71530cf60598622262be10eb6fdedff71212a40bc97d49459169923d66e6462784eaeb870b0c5d542e3a3c89af15e8684195fb49f5d7
@@ -27,8 +27,12 @@ module Uinit
27
27
  raise error
28
28
  end
29
29
 
30
+ def name
31
+ self.class.name.split('::').last
32
+ end
33
+
30
34
  def inspect
31
- "$#{self.class.name.split('::').last}"
35
+ "$#{name}"
32
36
  end
33
37
 
34
38
  def to_s
@@ -38,6 +38,8 @@ module Uinit
38
38
  end
39
39
 
40
40
  def check!(value, depth)
41
+ super
42
+
41
43
  type_error!('Float must be finite (not Infinity or NaN)', depth) if finite && !value.finite?
42
44
  type_error!("Float too small (minimum #{min})", depth) if min && value < min
43
45
  type_error!("Float too large (maximum #{max})", depth) if max && value > max
@@ -56,12 +58,19 @@ module Uinit
56
58
  end
57
59
  # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
58
60
 
61
+ def options
62
+ { min:, max:, positive:, negative:, zero:, precision:, finite: }.compact
63
+ end
64
+
65
+ def inspect
66
+ "$#{name}[#{options.inspect}]"
67
+ end
68
+
59
69
  private
60
70
 
61
71
  def valid_precision?(value)
62
72
  return true if precision.nil?
63
73
 
64
- # Compter les décimales
65
74
  decimal_places = value.to_s.split('.').last&.length || 0
66
75
  decimal_places <= precision
67
76
  end
@@ -32,6 +32,8 @@ module Uinit
32
32
  end
33
33
 
34
34
  def check!(value, depth)
35
+ super
36
+
35
37
  type_error!("Integer too small (minimum #{min})", depth) if min && value < min
36
38
  type_error!("Integer too large (maximum #{max})", depth) if max && value > max
37
39
  type_error!('Integer cannot be positive', depth) if positive == false && value.positive?
@@ -44,6 +46,14 @@ module Uinit
44
46
  value
45
47
  end
46
48
  # rubocop:enable Metrics/PerceivedComplexity
49
+
50
+ def options
51
+ { min:, max:, positive:, negative:, zero: }.compact
52
+ end
53
+
54
+ def inspect
55
+ "$#{name}[#{options.inspect}]"
56
+ end
47
57
  end
48
58
  end
49
59
  end
@@ -27,6 +27,8 @@ module Uinit
27
27
  end
28
28
 
29
29
  def check!(value, depth)
30
+ super
31
+
30
32
  if !empty && (value.empty? || value.match?(/^\s+$/))
31
33
  type_error!('String cannot be empty or contain only whitespace', depth)
32
34
  end
@@ -44,6 +46,14 @@ module Uinit
44
46
  value
45
47
  end
46
48
  # rubocop:enable Metrics/PerceivedComplexity
49
+
50
+ def options
51
+ { empty:, min_length:, max_length:, format: }.compact
52
+ end
53
+
54
+ def inspect
55
+ "$#{name}[#{options.inspect}]"
56
+ end
47
57
  end
48
58
  end
49
59
  end
@@ -26,7 +26,7 @@ module Uinit
26
26
  end
27
27
 
28
28
  def check!(value, depth)
29
- return value if is?(value)
29
+ return value if value.is_a?(class_module)
30
30
 
31
31
  type_error!("#{value.inspect} must be an instance of #{class_module}", depth)
32
32
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Uinit
4
4
  module Type
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.8'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uinit-type
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kimoja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-26 00:00:00.000000000 Z
11
+ date: 2025-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk