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 +4 -4
- data/lib/expressions/type_expression.rb +2 -2
- data/lib/factories/proxy_factory.rb +4 -1
- data/lib/low_type.rb +1 -0
- data/lib/queries/type_query.rb +1 -1
- data/lib/types/complex_types.rb +11 -9
- data/lib/types/status.rb +41 -39
- data/lib/version.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 295c067ff64ba1d3ddb26243c1676a7bbe7d3a41fb65c4c51e868462a44e4f1b
|
|
4
|
+
data.tar.gz: 2cff7d3f4f7f1dd8f6df9ab48e34737f562929cb802f798cf497a377034eee16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:)
|
data/lib/queries/type_query.rb
CHANGED
|
@@ -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
|
data/lib/types/complex_types.rb
CHANGED
|
@@ -4,13 +4,15 @@ require_relative '../factories/type_factory'
|
|
|
4
4
|
require_relative 'status'
|
|
5
5
|
|
|
6
6
|
module Low
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
35
|
-
|
|
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