finitio 0.12.1 → 0.12.2
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 +8 -0
- data/Gemfile.lock +1 -1
- data/lib/finitio/json_schema/ad_type.rb +4 -3
- data/lib/finitio/json_schema/union_type.rb +3 -1
- data/lib/finitio/support/heading.rb +4 -0
- data/lib/finitio/type/hash_based_type.rb +4 -0
- data/lib/finitio/type/multi_tuple_type.rb +4 -0
- data/lib/finitio/type/tuple_type.rb +4 -0
- data/lib/finitio/version.rb +1 -1
- data/spec/json_schema/test_ad_type.rb +2 -2
- data/spec/json_schema/test_union_type.rb +12 -0
- data/spec/type/tuple_type/test_allbut.rb +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba23fcd08948c1ba59360fcedd3deb9eab5b7f92c49ad8849256da1964574c6
|
4
|
+
data.tar.gz: eaea92410902208a2c003fe34f3935604d4c464f4917e4bf06f7129fbfc24364
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890a227df66eef86898513ba4269863f603c3289c65bd65ff68b1cd6372b5d60b6ae726b46fc9d4c5c898dab78dbc50e124b84733bf6df176c5b4401803741a0
|
7
|
+
data.tar.gz: db438df7b731247174b40954c050893fba97d7db522e8b423bf5fb62a0075e44d6d3cb96ea5e58144416801e7ccabb8471e23ffdd1071d29ee790f9c5db1047f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 0.12.2 - 2025/03/22
|
2
|
+
|
3
|
+
* Add Heading#allbut and (Multi)TupleType#allbut, to remove some attributes.
|
4
|
+
|
5
|
+
This actually starts the support for an algebra on types...
|
6
|
+
|
7
|
+
* Don't generate anyOf with duplicate types in JsonSchema geneation.
|
8
|
+
|
1
9
|
## 0.12.1 - 2025/03/20
|
2
10
|
|
3
11
|
* Allow Hash as bulttin type recognized by JsonSchema generation.
|
data/Gemfile.lock
CHANGED
@@ -2,9 +2,10 @@ module Finitio
|
|
2
2
|
class AdType
|
3
3
|
|
4
4
|
def to_json_schema(*args, &bl)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
subtypes = contracts
|
6
|
+
.map{|c| c.infotype.to_json_schema(*args, &bl) }
|
7
|
+
.uniq
|
8
|
+
subtypes.size == 1 ? subtypes.first : { anyOf: subtypes }
|
8
9
|
end
|
9
10
|
|
10
11
|
end # class AdType
|
@@ -14,8 +14,10 @@ module Finitio
|
|
14
14
|
return { type: 'boolean'} if self == BOOLEAN_TYPE
|
15
15
|
return cs.first.to_json_schema(*args, &bl) if cs.size == 1
|
16
16
|
|
17
|
+
subtypes = cs.map{|c| c.to_json_schema(*args, &bl) }.uniq
|
18
|
+
return subtypes.first if subtypes.size == 1
|
17
19
|
{
|
18
|
-
anyOf:
|
20
|
+
anyOf: subtypes
|
19
21
|
}
|
20
22
|
end
|
21
23
|
|
@@ -114,6 +114,10 @@ module Finitio
|
|
114
114
|
Heading.new(attributes.values.map{|a| a.unconstrained }, options)
|
115
115
|
end
|
116
116
|
|
117
|
+
def allbut(attrs)
|
118
|
+
Heading.new(attributes.values.reject{|a| attrs.include?(a.name) }.to_a, @options)
|
119
|
+
end
|
120
|
+
|
117
121
|
private
|
118
122
|
|
119
123
|
def normalize_attributes(attrs)
|
data/lib/finitio/version.rb
CHANGED
@@ -3,10 +3,10 @@ module Finitio
|
|
3
3
|
describe "AdType" do
|
4
4
|
|
5
5
|
let(:type) {
|
6
|
-
type = AdType.new(Color, [rgb_contract, hex_contract])
|
6
|
+
type = AdType.new(Color, [rgb_contract, hex_contract, hex_contract])
|
7
7
|
}
|
8
8
|
|
9
|
-
it 'works as expected' do
|
9
|
+
it 'works as expected and removes duplicates' do
|
10
10
|
expect(type.to_json_schema).to eql({
|
11
11
|
anyOf: [
|
12
12
|
{ type: "integer" },
|
@@ -46,6 +46,18 @@ module Finitio
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
context 'when used with two yielding the same final type' do
|
50
|
+
let(:union_type) {
|
51
|
+
UnionType.new([string_type, string_type])
|
52
|
+
}
|
53
|
+
|
54
|
+
it 'works as expected' do
|
55
|
+
expect(union_type.to_json_schema).to eql({
|
56
|
+
:type => "string"
|
57
|
+
})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
49
61
|
context 'when used with a |Nil' do
|
50
62
|
let(:union_type) {
|
51
63
|
UnionType.new([string_type, int_type, nil_type])
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
module Finitio
|
3
|
+
describe TupleType, "allbut" do
|
4
|
+
|
5
|
+
let(:h1){ Heading.new([Attribute.new(:r, intType), Attribute.new(:b, intType)]) }
|
6
|
+
let(:h2){ Heading.new([Attribute.new(:b, intType)]) }
|
7
|
+
|
8
|
+
let(:t1) { TupleType.new(h1) }
|
9
|
+
let(:t2) { TupleType.new(h2) }
|
10
|
+
|
11
|
+
it 'removes unwanted atributes' do
|
12
|
+
expect(t1.allbut([:r])).to eql(t2)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finitio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Lambeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: citrus
|
@@ -446,6 +446,7 @@ files:
|
|
446
446
|
- spec/type/sub_type/test_name.rb
|
447
447
|
- spec/type/test_suppremum.rb
|
448
448
|
- spec/type/test_unconstrained.rb
|
449
|
+
- spec/type/tuple_type/test_allbut.rb
|
449
450
|
- spec/type/tuple_type/test_default_name.rb
|
450
451
|
- spec/type/tuple_type/test_dress.rb
|
451
452
|
- spec/type/tuple_type/test_equality.rb
|
@@ -661,6 +662,7 @@ test_files:
|
|
661
662
|
- spec/type/sub_type/test_name.rb
|
662
663
|
- spec/type/test_suppremum.rb
|
663
664
|
- spec/type/test_unconstrained.rb
|
665
|
+
- spec/type/tuple_type/test_allbut.rb
|
664
666
|
- spec/type/tuple_type/test_default_name.rb
|
665
667
|
- spec/type/tuple_type/test_dress.rb
|
666
668
|
- spec/type/tuple_type/test_equality.rb
|