dynamicschema 1.0.0.beta03 → 1.0.0.beta04
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/dynamicschema.gemspec +1 -1
- data/lib/dynamic_schema/builder.rb +1 -1
- data/lib/dynamic_schema/builder_methods/validation.rb +2 -2
- data/lib/dynamic_schema/receiver.rb +2 -2
- data/lib/dynamic_schema/resolver.rb +27 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bbda4319f58741ceca992dec756544aeaa8f9b293afa0bee507ba94636405f4
|
4
|
+
data.tar.gz: 67283d904c6d84994d724d2e5a934332f78661bfa1173b0e0a6b4026a1b0a788
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fa81eb8ff0e153e2d9900eea14f26dbdc71ce90bb1b4595c9091330da1d8f6c7fdcd0fa2e8273a64346c08f5baca9a4d2519db7e67b35ea20da6d49a1adde16
|
7
|
+
data.tar.gz: 3d86d903925519d2813c379d528ada3a678e80cdf3c24287697c19ab0b3fb9ad9062f21c36bc219f5dceef384fb19bcc1208117416e964906e5cee5b4d9ae7db
|
data/README.md
CHANGED
@@ -194,7 +194,7 @@ schema = DynamicSchema.define do
|
|
194
194
|
chat_options do
|
195
195
|
model String, default: 'claude-3'
|
196
196
|
max_tokens Integer, default: 1024
|
197
|
-
temperature
|
197
|
+
temperature Float, default: 0.5, in: 0..1
|
198
198
|
stream [ TrueClass, FalseClass ]
|
199
199
|
end
|
200
200
|
end
|
data/dynamicschema.gemspec
CHANGED
@@ -61,7 +61,7 @@ module DynamicSchema
|
|
61
61
|
if criteria[ :type ] == Object
|
62
62
|
traverse_and_validate_values(
|
63
63
|
values[ name ],
|
64
|
-
schema: criteria[ :schema ] ||= criteria[ :resolver ].
|
64
|
+
schema: criteria[ :schema ] ||= criteria[ :resolver ]._schema,
|
65
65
|
path: "#{ ( path || '' ) + ( path ? '/' : '' ) + key.to_s }",
|
66
66
|
&block
|
67
67
|
)
|
@@ -80,7 +80,7 @@ module DynamicSchema
|
|
80
80
|
groups.each do | group |
|
81
81
|
traverse_and_validate_values(
|
82
82
|
group,
|
83
|
-
schema: criteria[ :schema ] ||= criteria[ :resolver ].
|
83
|
+
schema: criteria[ :schema ] ||= criteria[ :resolver ]._schema,
|
84
84
|
path: "#{ ( path || '' ) + ( path ? '/' : '' ) + key.to_s }",
|
85
85
|
&block
|
86
86
|
)
|
@@ -197,7 +197,7 @@ module DynamicSchema
|
|
197
197
|
Receiver.new(
|
198
198
|
attributes,
|
199
199
|
converters: @converters,
|
200
|
-
schema: criteria[ :schema ] ||= criteria[ :resolver ].
|
200
|
+
schema: criteria[ :schema ] ||= criteria[ :resolver ]._schema
|
201
201
|
)
|
202
202
|
end
|
203
203
|
value.instance_eval( &block ) if block
|
@@ -213,7 +213,7 @@ module DynamicSchema
|
|
213
213
|
receiver = Receiver.new(
|
214
214
|
a,
|
215
215
|
converters: @converters,
|
216
|
-
schema: criteria[ :schema ] ||= criteria[ :resolver ].
|
216
|
+
schema: criteria[ :schema ] ||= criteria[ :resolver ]._schema
|
217
217
|
)
|
218
218
|
receiver.instance_eval( &block ) if block
|
219
219
|
receiver
|
@@ -22,7 +22,8 @@ module DynamicSchema
|
|
22
22
|
self
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def _schema
|
26
|
+
|
26
27
|
if !@resolved && @block
|
27
28
|
@resolved_blocks << @block unless @resolved_blocks.include?( @block )
|
28
29
|
self.instance_eval( &@block )
|
@@ -31,6 +32,29 @@ module DynamicSchema
|
|
31
32
|
@schema
|
32
33
|
end
|
33
34
|
|
35
|
+
def _value( name, options )
|
36
|
+
name = name.to_sym
|
37
|
+
::Kernel.raise ::NameError, "The name '#{name}' is reserved and cannot be used for parameters." \
|
38
|
+
if ::DynamicSchema::Receiver.instance_methods.include?( name )
|
39
|
+
|
40
|
+
_validate_in!( name, options[ :type ], options[ :in ] ) if options[ :in ]
|
41
|
+
|
42
|
+
@schema[ name ] = options
|
43
|
+
self
|
44
|
+
end
|
45
|
+
|
46
|
+
def _object( name, options = {}, &block )
|
47
|
+
name = name.to_sym
|
48
|
+
::Kernel.raise ::NameError, "The name '#{name}' is reserved and cannot be used for parameters." \
|
49
|
+
if ::DynamicSchema::Receiver.instance_methods.include?( name )
|
50
|
+
|
51
|
+
@schema[ name ] = options.merge( {
|
52
|
+
type: ::Object,
|
53
|
+
resolver: Resolver.new( resolved_blocks: @resolved_blocks ).resolve( &block )
|
54
|
+
} )
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
34
58
|
def method_missing( method, *args, &block )
|
35
59
|
first = args.first
|
36
60
|
options = nil
|
@@ -58,9 +82,9 @@ module DynamicSchema
|
|
58
82
|
|
59
83
|
type = options[ :type ]
|
60
84
|
if type == ::Object || type.nil? && block
|
61
|
-
|
85
|
+
_object( method, options, &block )
|
62
86
|
else
|
63
|
-
|
87
|
+
_value( method, options )
|
64
88
|
end
|
65
89
|
|
66
90
|
end
|
@@ -92,27 +116,6 @@ module DynamicSchema
|
|
92
116
|
|
93
117
|
private
|
94
118
|
|
95
|
-
def _append_value( name, options )
|
96
|
-
::Kernel.raise ::NameError, "The name '#{name}' is reserved and cannot be used for parameters." \
|
97
|
-
if ::DynamicSchema::Receiver.instance_methods.include?( name )
|
98
|
-
|
99
|
-
_validate_in!( name, options[ :type ], options[ :in ] ) if options[ :in ]
|
100
|
-
|
101
|
-
@schema[ name ] = options
|
102
|
-
self
|
103
|
-
end
|
104
|
-
|
105
|
-
def _append_object( name, options = {}, &block )
|
106
|
-
::Kernel.raise ::NameError, "The name '#{name}' is reserved and cannot be used for parameters." \
|
107
|
-
if ::DynamicSchema::Receiver.instance_methods.include?( name )
|
108
|
-
|
109
|
-
@schema[ name ] = options.merge( {
|
110
|
-
type: ::Object,
|
111
|
-
resolver: Resolver.new( resolved_blocks: @resolved_blocks ).resolve( &block )
|
112
|
-
} )
|
113
|
-
self
|
114
|
-
end
|
115
|
-
|
116
119
|
def _validate_in!( name, type, in_option )
|
117
120
|
::Kernel.raise ::TypeError,
|
118
121
|
"The parameter '#{name}' includes the :in option but it does not respond to 'include?'." \
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamicschema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta04
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristoph Cichocki-Romanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|