low_type 1.3.0 → 1.3.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 +4 -4
- data/lib/definitions/evaluator.rb +3 -3
- data/lib/definitions/type_accessors.rb +11 -0
- data/lib/low_type.rb +10 -9
- data/lib/version.rb +1 -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: 4c2486123df7a2ef95af428ffed95c0cefa986c300f5b7e20edcba5926454d2c
|
|
4
|
+
data.tar.gz: b06eecc97f2d4d6a768e8dfc715bda4a7b38b4d281b5f4bb730350e56cad9663
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53654148a7e391a5f6bcdd86d1b33aea7b56e5a11d2e5be4b83c18901ae40ed72976d67c699710c3114babfd4390aef573580e750d49bfc3c0bbe076bd68f684
|
|
7
|
+
data.tar.gz: '05132820addc2ebe0ee79418b6f9c881ae881d205449a39a04bd24548b4cca8dc653fd1dbedf30207e4123632a263343e5920b5bed43d2c68f9f471c68100327'
|
|
@@ -35,7 +35,7 @@ module Low
|
|
|
35
35
|
include Types
|
|
36
36
|
using LowType::Syntax
|
|
37
37
|
|
|
38
|
-
def
|
|
38
|
+
def low_evaluate(proxy:)
|
|
39
39
|
# Not a security risk because the code comes from a trusted source; the file that included lowtype.
|
|
40
40
|
eval(proxy.value, binding, proxy.file_path, proxy.start_line) # rubocop:disable Security/Eval
|
|
41
41
|
end
|
|
@@ -59,7 +59,7 @@ module Low
|
|
|
59
59
|
begin # rubocop:disable Style/RedundantBegin
|
|
60
60
|
method_proxy.tagged_params(:value).each do |param_proxy|
|
|
61
61
|
expression = begin
|
|
62
|
-
new.
|
|
62
|
+
new.low_evaluate(proxy: param_proxy)
|
|
63
63
|
rescue NameError
|
|
64
64
|
raise unless class_binding
|
|
65
65
|
|
|
@@ -75,7 +75,7 @@ module Low
|
|
|
75
75
|
|
|
76
76
|
def evaluate_return_proxy_expression(return_proxy:)
|
|
77
77
|
begin
|
|
78
|
-
expression = new.
|
|
78
|
+
expression = new.low_evaluate(proxy: return_proxy)
|
|
79
79
|
rescue NameError
|
|
80
80
|
rp = return_proxy
|
|
81
81
|
raise NameError, "Unknown return type '#{rp.value}' for #{rp.scope} at #{rp.file_path}:#{rp.start_line}"
|
|
@@ -5,6 +5,17 @@ require_relative '../proxies/return_proxy'
|
|
|
5
5
|
require_relative '../queries/type_query'
|
|
6
6
|
|
|
7
7
|
module Low
|
|
8
|
+
# Usage:
|
|
9
|
+
#
|
|
10
|
+
# type_accessor name: String # => @name getter and @name=() setter
|
|
11
|
+
# type_accessor name: String | 'Cher'
|
|
12
|
+
#
|
|
13
|
+
# type_reader name: String
|
|
14
|
+
# type_reader name: String | 'Cher' # defaults to 'Cher' if nil
|
|
15
|
+
#
|
|
16
|
+
# type_writer name: String
|
|
17
|
+
# type_writer name: String | nil # accepts String or nil
|
|
18
|
+
#
|
|
8
19
|
module TypeAccessors
|
|
9
20
|
def type_reader(named_expressions)
|
|
10
21
|
named_expressions.each do |name, exp|
|
data/lib/low_type.rb
CHANGED
|
@@ -63,17 +63,18 @@ module LowType
|
|
|
63
63
|
tp.enable
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
+
Config = Struct.new(
|
|
67
|
+
:type_checking,
|
|
68
|
+
:error_mode,
|
|
69
|
+
:output_mode,
|
|
70
|
+
:output_size,
|
|
71
|
+
:deep_type_check,
|
|
72
|
+
:union_type_expressions
|
|
73
|
+
)
|
|
74
|
+
|
|
66
75
|
class << self
|
|
67
76
|
def config
|
|
68
|
-
config
|
|
69
|
-
:type_checking,
|
|
70
|
-
:error_mode,
|
|
71
|
-
:output_mode,
|
|
72
|
-
:output_size,
|
|
73
|
-
:deep_type_check,
|
|
74
|
-
:union_type_expressions
|
|
75
|
-
)
|
|
76
|
-
@config ||= config.new(true, :error, :type, 100, true, true)
|
|
77
|
+
@config ||= Config.new(true, :error, :type, 100, true, true)
|
|
77
78
|
end
|
|
78
79
|
|
|
79
80
|
def configure
|
data/lib/version.rb
CHANGED