low_type 1.1.7 → 1.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: a6cfbec60ebbfe9ff5d9a3dd68a00c201b1b8cc8aea52f08f290c3b34131fb89
4
- data.tar.gz: 4e745a28edb5c3da913b4fde7e1346ba62352469a27a1b259225ca6df62350fa
3
+ metadata.gz: 295c067ff64ba1d3ddb26243c1676a7bbe7d3a41fb65c4c51e868462a44e4f1b
4
+ data.tar.gz: 2cff7d3f4f7f1dd8f6df9ab48e34737f562929cb802f798cf497a377034eee16
5
5
  SHA512:
6
- metadata.gz: ee8a741df349ef64d5d133a553339aef6c2ecf8d2238adedc7890c41e3e4b6a2bb71556fc5eac488fdb9d8a875cdee8a251bd78d268fe05ac36ecc71d0d5c31b
7
- data.tar.gz: 3397ec0c358d4643b3c2ea3cf1a12243ba667ba4ea536c6aaac59eb7b067d5fdfea2850a0d121765f6fbbe3b2da49dc08123320d8e100c53ec2ee3865c0d678a
6
+ metadata.gz: 1f697cb2610e1acb2bc89a41ec35cd1f78a381fea7f3fed90c1984166d4ae514cffb8adf4ba6ef4916cd32897b85ba22e4ee84d26e4b187cb21657d7dedc6553
7
+ data.tar.gz: 54725a86fa96ac6bbf286d6c28d8a1af06090b64f1d75e5fe4ee21e398078d592aae71dd39b6c9d6170584f9ca4bd86175c827bf6d9ea1aaa0240540035080f7
@@ -51,7 +51,7 @@ module Low
51
51
  if type.is_a?(Array)
52
52
  "[#{type.map { |subtype| valid_subtype(subtype:) }.join(', ')}]"
53
53
  else
54
- type.inspect.to_s.delete_prefix('Low::')
54
+ type.inspect.to_s.delete_prefix('Low::Types::')
55
55
  end
56
56
  end
57
57
 
@@ -85,7 +85,7 @@ module Low
85
85
  types << 'nil' if subtype.default_value.nil?
86
86
  types.join(' | ')
87
87
  else
88
- subtype.to_s.delete_prefix('Low::')
88
+ subtype.to_s.delete_prefix('Low::Types::')
89
89
  end
90
90
  end
91
91
 
@@ -9,13 +9,16 @@ require_relative '../proxies/param_proxy'
9
9
  require_relative '../proxies/return_proxy'
10
10
  require_relative '../queries/file_parser'
11
11
  require_relative '../syntax/syntax'
12
+ require_relative '../types/complex_types'
13
+ require_relative '../types/status'
12
14
 
13
15
  module Low
14
16
  class ProxyFactory
15
17
  using ::LowType::Syntax
16
18
 
17
19
  class << self
18
- include Expressions
20
+ include Low::Expressions
21
+ include Low::Types
19
22
 
20
23
  def file_proxy(node:, path:, scope:)
21
24
  start_line = node.respond_to?(:start_line) ? node.start_line : nil
data/lib/low_type.rb CHANGED
@@ -26,6 +26,7 @@ module LowType
26
26
  parser = Low::FileParser.new(klass:, file_path:)
27
27
 
28
28
  klass.extend Low::TypeAccessors
29
+ klass.include Low::Types
29
30
  klass.include Low::Expressions
30
31
  klass.prepend Low::Redefiner.redefine(method_nodes: parser.instance_methods, class_proxy: parser.class_proxy, file_path:)
31
32
  klass.singleton_class.prepend Low::Redefiner.redefine(method_nodes: parser.class_methods, class_proxy: parser.class_proxy, file_path:)
@@ -19,7 +19,7 @@ module Low
19
19
  end
20
20
 
21
21
  def complex_type?(expression:)
22
- Low::COMPLEX_TYPES.include?(expression) || typed_array?(expression:) || typed_hash?(expression:)
22
+ Low::Types::COMPLEX_TYPES.include?(expression) || typed_array?(expression:) || typed_hash?(expression:)
23
23
  end
24
24
 
25
25
  private
@@ -4,13 +4,15 @@ require_relative '../factories/type_factory'
4
4
  require_relative 'status'
5
5
 
6
6
  module Low
7
- COMPLEX_TYPES = [
8
- Boolean = TypeFactory.complex_type(Object),
9
- Headers = TypeFactory.complex_type(Hash),
10
- HTML = TypeFactory.complex_type(String),
11
- JSON = TypeFactory.complex_type(String),
12
- Status,
13
- Tuple = TypeFactory.complex_type(Array),
14
- XML = TypeFactory.complex_type(String)
15
- ].freeze
7
+ module Types
8
+ COMPLEX_TYPES = [
9
+ Boolean = TypeFactory.complex_type(Object),
10
+ Headers = TypeFactory.complex_type(Hash),
11
+ HTML = TypeFactory.complex_type(String),
12
+ JSON = TypeFactory.complex_type(String),
13
+ Status,
14
+ Tuple = TypeFactory.complex_type(Array),
15
+ XML = TypeFactory.complex_type(String)
16
+ ].freeze
17
+ end
16
18
  end
data/lib/types/status.rb CHANGED
@@ -4,48 +4,50 @@ require_relative 'complex_type'
4
4
  require_relative 'error_types'
5
5
 
6
6
  module Low
7
- # Status is an Integer for type checking, but an instance of StatusCode for advanced functionality.
8
- class Status < Integer
9
- extend ComplexType
10
-
11
- class StatusCode
12
- attr_reader :status_code
13
-
14
- STATUS_CODES = [
15
- # Info.
16
- 100, 101, 102, 103,
17
- # Success.
18
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
19
- # Redirect.
20
- 300, 301, 302, 303, 304, 305, 306, 307, 308,
21
- # Client Error.
22
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
23
- 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
24
- # Server Error.
25
- 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511
26
- ].freeze
27
-
28
- def initialize(status_code)
29
- raise AllowedTypeError unless STATUS_CODES.include?(status_code)
30
-
31
- @status_code = status_code
7
+ module Types
8
+ # Status is an Integer for type checking, but an instance of StatusCode for advanced functionality.
9
+ class Status < Integer
10
+ extend ComplexType
11
+
12
+ class StatusCode
13
+ attr_reader :status_code
14
+
15
+ STATUS_CODES = [
16
+ # Info.
17
+ 100, 101, 102, 103,
18
+ # Success.
19
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
20
+ # Redirect.
21
+ 300, 301, 302, 303, 304, 305, 306, 307, 308,
22
+ # Client Error.
23
+ 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414,
24
+ 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
25
+ # Server Error.
26
+ 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511
27
+ ].freeze
28
+
29
+ def initialize(status_code)
30
+ raise AllowedTypeError unless STATUS_CODES.include?(status_code)
31
+
32
+ @status_code = status_code
33
+ end
34
+
35
+ def ==(other)
36
+ other.class == self.class && other.status_code == @status_code
37
+ end
38
+
39
+ def eql?(other)
40
+ self == other
41
+ end
42
+
43
+ def hash
44
+ [self.class, @status_code].hash
45
+ end
32
46
  end
33
47
 
34
- def ==(other)
35
- other.class == self.class && other.status_code == @status_code
48
+ def self.[](status_code)
49
+ @status_code = StatusCode.new(status_code)
36
50
  end
37
-
38
- def eql?(other)
39
- self == other
40
- end
41
-
42
- def hash
43
- [self.class, @status_code].hash
44
- end
45
- end
46
-
47
- def self.[](status_code)
48
- @status_code = StatusCode.new(status_code)
49
51
  end
50
52
  end
51
53
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Low
4
- TYPE_VERSION = '1.1.7'
4
+ module Type
5
+ VERSION = '1.1.8'
6
+ end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: low_type
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 1.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi