uinit-type 0.1.5 → 0.1.7

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: 5bd4a4dd91cfd1b86c516b8a94c0449f01e410222900c73f352a6cba5c9d701f
4
- data.tar.gz: 050b3c0341ec1abdb28bfb876487ca56a1572c2cdc8e7b2eb9455c59c88d857c
3
+ metadata.gz: f997cfcc44febfb12672561136eae00f9b87fc9931dab1e8a3e194dfe2cbb672
4
+ data.tar.gz: ea33520aa33c273c82e1e67a505ab06ab83b1639094e890847d702eedf6e93b6
5
5
  SHA512:
6
- metadata.gz: eec7569793abefa92343963566c67dddc2486bd1576973f4dcb8e2aa2ffa49699a26726cad42e00c6b9f38cd4017624705eb22cb1aa6c029a100a3a848d0e390
7
- data.tar.gz: 1f0ce366d5488199b402e5fa4d291291e5543b1847892f600a405e194cb5b405976da6ee83dec1d22f1d993cf1381a16113dcb3b4c20feb976b30ecc70b4db47
6
+ metadata.gz: 107befa7e3e4a6ff7c3ecccd22f2760f9bd9bbd8de403b714c257d818a69740ffa662cd5170c8e32332d611cca9ad96b002ae6d0389631ab35262fe0f5e429ce
7
+ data.tar.gz: 0c7d307cc9189c1de58ca221342d0d9a39924750443deae2499c7e11d8f3e93362fd4520225f470fc91bf73cfc1713b56ac3fe7bef5836ab78b4afc68388aac8
@@ -5,10 +5,7 @@ module Uinit
5
5
  module Context
6
6
  Nil = Const[nil].freeze
7
7
  Boolean = (Const[true] | Const[false]).freeze
8
- Str = String.freeze
9
8
  Sym = TypeOf[Symbol].freeze
10
- Int = Integer.freeze
11
- Float = Float.freeze
12
9
  Hsh = TypeOf[Hash].freeze
13
10
  Arr = TypeOf[Array].freeze
14
11
 
@@ -52,6 +49,20 @@ module Uinit
52
49
  TypeOf.new(type)
53
50
  end
54
51
 
52
+ def string(**)
53
+ String.new(**)
54
+ end
55
+ alias str string
56
+
57
+ def integer(**)
58
+ Integer.new(**)
59
+ end
60
+ alias int integer
61
+
62
+ def float(**)
63
+ Float.new(**)
64
+ end
65
+
55
66
  def nilable
56
67
  Nil
57
68
  end
@@ -63,20 +74,6 @@ module Uinit
63
74
  end
64
75
  alias bool boolean
65
76
 
66
- def string
67
- Str
68
- end
69
- alias str string
70
-
71
- def integer
72
- Int
73
- end
74
- alias int integer
75
-
76
- def float
77
- Float
78
- end
79
-
80
77
  def hash
81
78
  Hsh
82
79
  end
@@ -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
@@ -61,7 +63,6 @@ module Uinit
61
63
  def valid_precision?(value)
62
64
  return true if precision.nil?
63
65
 
64
- # Compter les décimales
65
66
  decimal_places = value.to_s.split('.').last&.length || 0
66
67
  decimal_places <= precision
67
68
  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?
@@ -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
@@ -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.5'
5
+ VERSION = '0.1.7'
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.5
4
+ version: 0.1.7
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