scheming 0.3.0 → 0.4.0
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/CHANGELOG.md +35 -10
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/lib/scheming/dsl/data_builder.rb +8 -5
- data/lib/scheming/dsl/tagging.rb +47 -0
- data/lib/scheming/dsl.rb +1 -0
- data/lib/scheming/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9200950b341609a10673661255198aacf8012bdb89b89868d66eed91aa11c395
|
4
|
+
data.tar.gz: 175243bb9bd5204b93b5f59f2e0b403163c86ed745a01a23c2e987bc2aab2813
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c83e51b6db0200f0d222250e690696061ecf581bad11e4c5916df828cfef2d6ae01da50349d7a1cdea2097b7a235fe19950c48ec0b11f628522ed734a100e48
|
7
|
+
data.tar.gz: b35ebaf5d8d1a30b1538471d153a7da1ed648037c84c89ec2132742bad94fcfee0b0d4744b0c82b3f36de924d30a39579e881a812f4d1ba6fc3bff9c46283415
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.4.0] - 2024-05-02
|
4
4
|
|
5
|
-
|
5
|
+
### Breaking Change
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
- Opting for a `tag` system to work with attributes instead
|
8
|
+
of a blanket lexical scope like `optional` to work with
|
9
|
+
attributes. The long term goal is to expand out the tagging
|
10
|
+
system so that it can support much more than we can
|
11
|
+
anticipate today.
|
12
12
|
|
13
13
|
# Example:
|
14
14
|
```ruby
|
@@ -18,12 +18,12 @@
|
|
18
18
|
attribute :taxable, :bool
|
19
19
|
attribute :price, Float
|
20
20
|
|
21
|
-
optional
|
22
|
-
|
21
|
+
tag(:optional)
|
23
22
|
attribute :desc, Nullable(String)
|
23
|
+
|
24
|
+
tag(:optional)
|
24
25
|
attribute :item_type, Enum('entertainment', 'staple')
|
25
26
|
end
|
26
|
-
```
|
27
27
|
|
28
28
|
## [0.3.0] - 2024-05-01
|
29
29
|
|
@@ -35,4 +35,29 @@
|
|
35
35
|
|
36
36
|
### Enhancement
|
37
37
|
|
38
|
+
## [0.2.0] - 2024-05-01
|
39
|
+
|
40
|
+
### Added
|
41
|
+
|
42
|
+
- Support for `optional` fields
|
43
|
+
|
44
|
+
# Example:
|
45
|
+
```ruby
|
46
|
+
LineItem = Scheming.object do
|
47
|
+
attribute :id, Integer
|
48
|
+
attribute :name, String
|
49
|
+
attribute :taxable, :bool
|
50
|
+
attribute :price, Float
|
51
|
+
|
52
|
+
optional
|
53
|
+
|
54
|
+
attribute :desc, Nullable(String)
|
55
|
+
attribute :item_type, Enum('entertainment', 'staple')
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
38
59
|
- Ensure all types produce valid JSON Schema
|
60
|
+
|
61
|
+
## [0.1.0] - 2024-04-26
|
62
|
+
|
63
|
+
- Initial release
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ class Scheming::DSL::DataBuilder
|
|
7
7
|
def initialize(builder = Scheming::Attribute::ListBuilder.new)
|
8
8
|
@builder = builder
|
9
9
|
@resolver = Scheming::DSL::TypeResolver
|
10
|
-
@
|
10
|
+
@tagging = Scheming::DSL::Tagging.new
|
11
11
|
end
|
12
12
|
|
13
13
|
# @param field_name [Symbol]
|
@@ -18,14 +18,17 @@ class Scheming::DSL::DataBuilder
|
|
18
18
|
@builder = @builder.attribute(
|
19
19
|
field_name,
|
20
20
|
type: @resolver.resolve(type_spec),
|
21
|
-
|
21
|
+
**@tagging.attribute_params
|
22
22
|
)
|
23
|
+
@tagging.reset!
|
23
24
|
nil
|
24
25
|
end
|
25
26
|
|
26
|
-
#
|
27
|
-
|
28
|
-
|
27
|
+
# @param name [Symbol]
|
28
|
+
# @param args [Hash<Symbol, Object>]
|
29
|
+
def tag(name, **args)
|
30
|
+
@tagging.tag!(name, args)
|
31
|
+
nil
|
29
32
|
end
|
30
33
|
|
31
34
|
# @return [Class]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# = Type Resolver
|
4
|
+
class Scheming::DSL::Tagging
|
5
|
+
# = Attribute Tag
|
6
|
+
#
|
7
|
+
# Simple representation of a concept
|
8
|
+
# that can be used to aid in the
|
9
|
+
# creation of an [Scheming::Attribute]
|
10
|
+
#
|
11
|
+
class Tag
|
12
|
+
# @param name [Symbo]
|
13
|
+
# @data [Hash<Symbol, Object>]
|
14
|
+
def initialize(name, data)
|
15
|
+
@name = name
|
16
|
+
@data = data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
private_constant :Tag
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
# @type [Hash<Symbol, Tag>]
|
23
|
+
@tags = {}
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [void]
|
27
|
+
def reset!
|
28
|
+
@tags.clear
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param taglist [Hash<Symbol, Object>]
|
33
|
+
# @param name [Symbol]
|
34
|
+
# @return [Tag]
|
35
|
+
def tag!(name, data)
|
36
|
+
@tags[name] = Tag.new(name, data)
|
37
|
+
end
|
38
|
+
|
39
|
+
def attribute_params
|
40
|
+
{
|
41
|
+
is_required: missing?(:optional)
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def missing?(name) = !has?(name)
|
46
|
+
def has?(name) = @tags.key?(name)
|
47
|
+
end
|
data/lib/scheming/dsl.rb
CHANGED
data/lib/scheming/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scheming
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Falk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ergonomic Data Design for the Masses
|
14
14
|
email:
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- lib/scheming/dsl.rb
|
33
33
|
- lib/scheming/dsl/data_builder.rb
|
34
34
|
- lib/scheming/dsl/object_type_def.rb
|
35
|
+
- lib/scheming/dsl/tagging.rb
|
35
36
|
- lib/scheming/dsl/type_resolver.rb
|
36
37
|
- lib/scheming/dsl/type_specs.rb
|
37
38
|
- lib/scheming/schema.rb
|