ruby_llm-schema 0.1.0 → 0.1.5
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/README.md +10 -2
- data/lib/ruby_llm/schema/version.rb +1 -1
- data/lib/ruby_llm/schema.rb +54 -9
- data/lib/tasks/release.rake +7 -2
- metadata +2 -3
- data/.rspec_status +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af385c490955340f248b031be93c2f3667b8bb3163b705469d0cfce7d18e428f
|
4
|
+
data.tar.gz: 3636b4f7d55eabf5399396f8a708d26d611f2afb6bd9677bb6a1a189b9fe03ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9db25536a6c7f3cb32a6cba0e91d88665833f25e6ea51f630be4ea18aa8d50ab7809e13e31d3dce4f0cd757be36754dca6fd3063832a6dd9a91129c07903087d
|
7
|
+
data.tar.gz: 486daf28cc008eda346b7c4c1b33f5723fac2f50947ae8197fba8fa6a23d9f50921a36533c37f60942cde6b5f030260045a779066546581d67b209fd76867818
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A Ruby DSL for creating JSON schemas with a clean, Rails-inspired API. Perfect f
|
|
7
7
|
```ruby
|
8
8
|
class PersonSchema < RubyLLM::Schema
|
9
9
|
string :name, description: "Person's full name"
|
10
|
-
number :age, description: "Age in years"
|
10
|
+
number :age, description: "Age in years", minimum: 0, maximum: 120
|
11
11
|
boolean :active, required: false
|
12
12
|
|
13
13
|
object :address do
|
@@ -20,7 +20,7 @@ class PersonSchema < RubyLLM::Schema
|
|
20
20
|
|
21
21
|
array :contacts do
|
22
22
|
object do
|
23
|
-
string :email
|
23
|
+
string :email, format: "email"
|
24
24
|
string :phone, required: false
|
25
25
|
end
|
26
26
|
end
|
@@ -130,7 +130,14 @@ puts person_schema.to_json
|
|
130
130
|
string :name # Required string
|
131
131
|
string :title, required: false # Optional string
|
132
132
|
string :status, enum: ["on", "off"] # String with enum values
|
133
|
+
string :email, format: "email" # String with format validation
|
134
|
+
string :code, min_length: 3, max_length: 10 # String with length constraints
|
135
|
+
string :pattern_field, pattern: "\\d+" # String with regex pattern
|
136
|
+
|
133
137
|
number :count # Required number
|
138
|
+
number :price, minimum: 0, maximum: 100 # Number with range constraints
|
139
|
+
number :amount, multiple_of: 0.01 # Number with precision constraints
|
140
|
+
|
134
141
|
integer :id # Required integer
|
135
142
|
boolean :active # Required boolean
|
136
143
|
null :placeholder # Null type
|
@@ -141,6 +148,7 @@ null :placeholder # Null type
|
|
141
148
|
```ruby
|
142
149
|
array :tags, of: :string # Array of strings
|
143
150
|
array :scores, of: :number # Array of numbers
|
151
|
+
array :items, min_items: 1, max_items: 10 # Array with size constraints
|
144
152
|
|
145
153
|
array :items do # Array of objects
|
146
154
|
object do
|
data/lib/ruby_llm/schema.rb
CHANGED
@@ -34,12 +34,28 @@ module RubyLLM
|
|
34
34
|
@strict = value
|
35
35
|
end
|
36
36
|
|
37
|
-
def string(name = nil, enum: nil, description: nil, required: true)
|
38
|
-
|
37
|
+
def string(name = nil, enum: nil, description: nil, required: true, min_length: nil, max_length: nil, pattern: nil, format: nil)
|
38
|
+
options = {
|
39
|
+
enum: enum,
|
40
|
+
description: description,
|
41
|
+
minLength: min_length,
|
42
|
+
maxLength: max_length,
|
43
|
+
pattern: pattern,
|
44
|
+
format: format
|
45
|
+
}.compact
|
46
|
+
|
47
|
+
add_property(name, build_property_schema(:string, **options), required: required)
|
39
48
|
end
|
40
49
|
|
41
|
-
def number(name = nil, description: nil, required: true)
|
42
|
-
|
50
|
+
def number(name = nil, description: nil, required: true, minimum: nil, maximum: nil, multiple_of: nil)
|
51
|
+
options = {
|
52
|
+
description: description,
|
53
|
+
minimum: minimum,
|
54
|
+
maximum: maximum,
|
55
|
+
multipleOf: multiple_of
|
56
|
+
}.compact
|
57
|
+
|
58
|
+
add_property(name, build_property_schema(:number, **options), required: required)
|
43
59
|
end
|
44
60
|
|
45
61
|
def integer(name = nil, description: nil, required: true)
|
@@ -58,13 +74,15 @@ module RubyLLM
|
|
58
74
|
add_property(name, build_property_schema(:object, description: description, &block), required: required)
|
59
75
|
end
|
60
76
|
|
61
|
-
def array(name, of: nil, description: nil, required: true, &block)
|
77
|
+
def array(name, of: nil, description: nil, required: true, min_items: nil, max_items: nil, &block)
|
62
78
|
items = determine_array_items(of, &block)
|
63
79
|
|
64
80
|
add_property(name, {
|
65
81
|
type: "array",
|
66
82
|
description: description,
|
67
|
-
items: items
|
83
|
+
items: items,
|
84
|
+
minItems: min_items,
|
85
|
+
maxItems: max_items
|
68
86
|
}.compact, required: required)
|
69
87
|
end
|
70
88
|
|
@@ -77,6 +95,13 @@ module RubyLLM
|
|
77
95
|
}.compact, required: required)
|
78
96
|
end
|
79
97
|
|
98
|
+
def optional(name, description: nil, &block)
|
99
|
+
any_of(name, description: description) do
|
100
|
+
instance_eval(&block)
|
101
|
+
null
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
80
105
|
def define(name, &)
|
81
106
|
sub_schema = Class.new(Schema)
|
82
107
|
sub_schema.class_eval(&)
|
@@ -107,11 +132,31 @@ module RubyLLM
|
|
107
132
|
def build_property_schema(type, **options, &)
|
108
133
|
case type
|
109
134
|
when :string
|
110
|
-
{
|
135
|
+
{
|
136
|
+
type: "string",
|
137
|
+
enum: options[:enum],
|
138
|
+
description: options[:description],
|
139
|
+
minLength: options[:minLength],
|
140
|
+
maxLength: options[:maxLength],
|
141
|
+
pattern: options[:pattern],
|
142
|
+
format: options[:format]
|
143
|
+
}.compact
|
111
144
|
when :number
|
112
|
-
{
|
145
|
+
{
|
146
|
+
type: "number",
|
147
|
+
description: options[:description],
|
148
|
+
minimum: options[:minimum],
|
149
|
+
maximum: options[:maximum],
|
150
|
+
multipleOf: options[:multipleOf]
|
151
|
+
}.compact
|
113
152
|
when :integer
|
114
|
-
{
|
153
|
+
{
|
154
|
+
type: "integer",
|
155
|
+
description: options[:description],
|
156
|
+
minimum: options[:minimum],
|
157
|
+
maximum: options[:maximum],
|
158
|
+
multipleOf: options[:multipleOf]
|
159
|
+
}.compact
|
115
160
|
when :boolean
|
116
161
|
{type: "boolean", description: options[:description]}.compact
|
117
162
|
when :null
|
data/lib/tasks/release.rake
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
namespace :release do
|
2
2
|
desc "Release a new version of the gem"
|
3
3
|
task :version do
|
4
|
-
|
5
|
-
version
|
4
|
+
# Load the current version from version.rb
|
5
|
+
require_relative '../../lib/ruby_llm/schema/version'
|
6
|
+
version = RubyLlm::Schema::VERSION
|
7
|
+
|
8
|
+
puts "Releasing version #{version}..."
|
9
|
+
|
6
10
|
system "git tag v#{version}"
|
11
|
+
system "git push origin main"
|
7
12
|
system "git push origin v#{version}"
|
8
13
|
|
9
14
|
system "gem build ruby_llm-schema.gemspec"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_llm-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Friis
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-08-08 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rspec
|
@@ -44,7 +44,6 @@ extensions: []
|
|
44
44
|
extra_rdoc_files: []
|
45
45
|
files:
|
46
46
|
- ".rspec"
|
47
|
-
- ".rspec_status"
|
48
47
|
- LICENSE.txt
|
49
48
|
- README.md
|
50
49
|
- Rakefile
|
data/.rspec_status
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
--------------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:1:1] | passed | 0.0002 seconds |
|
4
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:1:2] | passed | 0.00004 seconds |
|
5
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:2:1] | passed | 0.00003 seconds |
|
6
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:2:2] | passed | 0.00027 seconds |
|
7
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:3:1] | passed | 0.00004 seconds |
|
8
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:3:2] | passed | 0.00003 seconds |
|
9
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
|
10
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
|
11
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:2:1] | passed | 0.00044 seconds |
|
12
|
-
./spec/ruby_llm/schema_class_inheritance_spec.rb[1:3:1] | passed | 0.00058 seconds |
|
13
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:1:1] | passed | 0.00004 seconds |
|
14
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:1:2] | passed | 0.00003 seconds |
|
15
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:2:1] | passed | 0.00004 seconds |
|
16
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:2:2] | passed | 0.00003 seconds |
|
17
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:3:1] | passed | 0.00003 seconds |
|
18
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:3:2] | passed | 0.00003 seconds |
|
19
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
|
20
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
|
21
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:2:1] | passed | 0.00005 seconds |
|
22
|
-
./spec/ruby_llm/schema_factory_spec.rb[1:3:1] | passed | 0.00004 seconds |
|
23
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:1:1] | passed | 0.00004 seconds |
|
24
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:1:2] | passed | 0.00003 seconds |
|
25
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:2:1] | passed | 0.00003 seconds |
|
26
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:2:2] | passed | 0.00003 seconds |
|
27
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:3:1] | passed | 0.00003 seconds |
|
28
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:3:2] | passed | 0.00003 seconds |
|
29
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
|
30
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:1:4:2] | passed | 0.00003 seconds |
|
31
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:2:1] | passed | 0.00005 seconds |
|
32
|
-
./spec/ruby_llm/schema_helpers_spec.rb[1:3:1] | passed | 0.00003 seconds |
|
33
|
-
./spec/ruby_llm/schema_spec.rb[1:1:1] | passed | 0.00018 seconds |
|
34
|
-
./spec/ruby_llm/schema_spec.rb[1:1:2] | passed | 0.00004 seconds |
|
35
|
-
./spec/ruby_llm/schema_spec.rb[1:1:3] | passed | 0.00003 seconds |
|
36
|
-
./spec/ruby_llm/schema_spec.rb[1:1:4] | passed | 0.00002 seconds |
|
37
|
-
./spec/ruby_llm/schema_spec.rb[1:1:5] | passed | 0.00002 seconds |
|
38
|
-
./spec/ruby_llm/schema_spec.rb[1:1:6] | passed | 0.0006 seconds |
|
39
|
-
./spec/ruby_llm/schema_spec.rb[1:2:1] | passed | 0.00004 seconds |
|
40
|
-
./spec/ruby_llm/schema_spec.rb[1:2:2] | passed | 0.00007 seconds |
|
41
|
-
./spec/ruby_llm/schema_spec.rb[1:2:3] | passed | 0.00004 seconds |
|
42
|
-
./spec/ruby_llm/schema_spec.rb[1:3:1] | passed | 0.00005 seconds |
|
43
|
-
./spec/ruby_llm/schema_spec.rb[1:3:2] | passed | 0.00004 seconds |
|
44
|
-
./spec/ruby_llm/schema_spec.rb[1:3:3] | passed | 0.00004 seconds |
|
45
|
-
./spec/ruby_llm/schema_spec.rb[1:4:1] | passed | 0.00006 seconds |
|
46
|
-
./spec/ruby_llm/schema_spec.rb[1:5:1] | passed | 0.00003 seconds |
|
47
|
-
./spec/ruby_llm/schema_spec.rb[1:5:2] | passed | 0.00057 seconds |
|
48
|
-
./spec/ruby_llm/schema_spec.rb[1:5:3] | passed | 0.00023 seconds |
|
49
|
-
./spec/ruby_llm/schema_spec.rb[1:6:1] | passed | 0.00038 seconds |
|
50
|
-
./spec/ruby_llm/schema_spec.rb[1:6:2] | passed | 0.00003 seconds |
|
51
|
-
./spec/ruby_llm/schema_spec.rb[1:7:1:1] | passed | 0.00021 seconds |
|
52
|
-
./spec/ruby_llm/schema_spec.rb[1:7:1:2] | passed | 0.00006 seconds |
|
53
|
-
./spec/ruby_llm/schema_spec.rb[1:7:2:1] | passed | 0.00005 seconds |
|
54
|
-
./spec/ruby_llm/schema_spec.rb[1:8:1] | passed | 0.00044 seconds |
|
55
|
-
./spec/ruby_llm/schema_spec.rb[1:8:2] | passed | 0.00008 seconds |
|