finitio 0.12.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92c67dd32e89dd6c4597b4a8456572bb1a5b3de07bdf58e88bcb9dc3f0874462
4
- data.tar.gz: 4ecd7898e477113040613415f9bc2cc8f23bc3605d0f71a3ccaefbbe1eaf31ff
3
+ metadata.gz: dba23fcd08948c1ba59360fcedd3deb9eab5b7f92c49ad8849256da1964574c6
4
+ data.tar.gz: eaea92410902208a2c003fe34f3935604d4c464f4917e4bf06f7129fbfc24364
5
5
  SHA512:
6
- metadata.gz: eb3042b639a82d469bb760807e6c94e1f70c39a3249420d30e339d5f004048e8abe6026de3b3b834e3703f88b3dd10a6d2937abdba5a183444af13609cc150b5
7
- data.tar.gz: f44c30f37848ad1e0b8344487cc0f0353ad694ce31c535ff6dd4ae02e903bebc92d11b29ac78ae0aa7d21f7bce6ba3fbd7ecdceb2cb6d14aa4bd3f9d6fb5164a
6
+ metadata.gz: 890a227df66eef86898513ba4269863f603c3289c65bd65ff68b1cd6372b5d60b6ae726b46fc9d4c5c898dab78dbc50e124b84733bf6df176c5b4401803741a0
7
+ data.tar.gz: db438df7b731247174b40954c050893fba97d7db522e8b423bf5fb62a0075e44d6d3cb96ea5e58144416801e7ccabb8471e23ffdd1071d29ee790f9c5db1047f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
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
+
9
+ ## 0.12.1 - 2025/03/20
10
+
11
+ * Allow Hash as bulttin type recognized by JsonSchema generation.
12
+ * Remove Ruby 2.6 from supported versions. Requirement is Ruby 2.7.
13
+
1
14
  ## 0.12.0 - 2023/05/23
2
15
 
3
16
  * Remove support for ruby < 2.6
data/Gemfile.lock CHANGED
@@ -1,21 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- finitio (0.12.0)
4
+ finitio (0.12.2)
5
5
  citrus (>= 3.0, < 4.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4.3)
10
+ activesupport (7.0.8.7)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  awesome_print (1.9.2)
16
- builder (3.2.4)
16
+ bigdecimal (3.1.9)
17
+ builder (3.3.0)
17
18
  citrus (3.0.2)
18
- concurrent-ruby (1.2.2)
19
+ concurrent-ruby (1.3.5)
19
20
  coveralls (0.8.23)
20
21
  json (>= 1.8, < 3)
21
22
  simplecov (~> 0.16.1)
@@ -54,13 +55,13 @@ GEM
54
55
  cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
55
56
  cucumber-messages (~> 12.2, >= 12.2.0)
56
57
  diff-lcs (1.3)
57
- docile (1.4.0)
58
- ffi (1.15.5)
59
- i18n (1.13.0)
58
+ docile (1.4.1)
59
+ ffi (1.17.1-x86_64-linux-gnu)
60
+ i18n (1.14.7)
60
61
  concurrent-ruby (~> 1.0)
61
- json (2.6.3)
62
+ json (2.10.2)
62
63
  middleware (0.1.0)
63
- minitest (5.18.0)
64
+ minitest (5.25.5)
64
65
  multi_json (1.15.0)
65
66
  multi_test (0.1.2)
66
67
  path (2.1.0)
@@ -69,33 +70,34 @@ GEM
69
70
  middleware
70
71
  thor
71
72
  thread_safe
72
- rake (13.0.6)
73
- rspec (3.12.0)
74
- rspec-core (~> 3.12.0)
75
- rspec-expectations (~> 3.12.0)
76
- rspec-mocks (~> 3.12.0)
77
- rspec-core (3.12.2)
78
- rspec-support (~> 3.12.0)
79
- rspec-expectations (3.12.3)
73
+ rake (13.2.1)
74
+ rspec (3.13.0)
75
+ rspec-core (~> 3.13.0)
76
+ rspec-expectations (~> 3.13.0)
77
+ rspec-mocks (~> 3.13.0)
78
+ rspec-core (3.13.3)
79
+ rspec-support (~> 3.13.0)
80
+ rspec-expectations (3.13.3)
80
81
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.12.0)
82
- rspec-mocks (3.12.5)
82
+ rspec-support (~> 3.13.0)
83
+ rspec-mocks (3.13.2)
83
84
  diff-lcs (>= 1.2.0, < 2.0)
84
- rspec-support (~> 3.12.0)
85
- rspec-support (3.12.0)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-support (3.13.2)
86
87
  simplecov (0.16.1)
87
88
  docile (~> 1.1)
88
89
  json (>= 1.8, < 3)
89
90
  simplecov-html (~> 0.10.0)
90
91
  simplecov-html (0.10.2)
91
92
  sync (0.5.0)
92
- sys-uname (1.2.3)
93
+ sys-uname (1.3.1)
93
94
  ffi (~> 1.1)
94
- term-ansicolor (1.7.1)
95
+ term-ansicolor (1.11.2)
95
96
  tins (~> 1.0)
96
- thor (1.2.2)
97
+ thor (1.3.2)
97
98
  thread_safe (0.3.6)
98
- tins (1.32.1)
99
+ tins (1.38.0)
100
+ bigdecimal
99
101
  sync
100
102
  tzinfo (2.0.6)
101
103
  concurrent-ruby (~> 1.0)
@@ -104,6 +106,7 @@ PLATFORMS
104
106
  x86_64-linux
105
107
 
106
108
  DEPENDENCIES
109
+ activesupport (~> 7.0.8)
107
110
  awesome_print (~> 1.8)
108
111
  coveralls (~> 0.8)
109
112
  cucumber (~> 4.1)
@@ -114,4 +117,4 @@ DEPENDENCIES
114
117
  rspec (~> 3.0)
115
118
 
116
119
  BUNDLED WITH
117
- 2.3.26
120
+ 2.4.19
data/finitio.gemspec CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency("rake", "~> 13.0")
26
26
  s.add_development_dependency("rspec", "~> 3.0")
27
27
  s.add_development_dependency("cucumber", "~> 4.1")
28
+ s.add_development_dependency('activesupport', '~> 7.0.8')
28
29
  s.add_development_dependency("path", ">= 2.1", "< 3.0")
29
30
  s.add_development_dependency("awesome_print", "~> 1.8")
30
31
  s.add_development_dependency("coveralls", "~> 0.8")
@@ -2,9 +2,10 @@ module Finitio
2
2
  class AdType
3
3
 
4
4
  def to_json_schema(*args, &bl)
5
- {
6
- anyOf: contracts.map{|c| c.infotype.to_json_schema(*args, &bl) }
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
@@ -9,6 +9,7 @@ module Finitio
9
9
  Numeric => "number",
10
10
  TrueClass => "boolean",
11
11
  FalseClass => "boolean",
12
+ Hash => "object",
12
13
  Object => "object"
13
14
  }
14
15
 
@@ -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: cs.map{|c| c.to_json_schema(*args, &bl) }
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)
@@ -61,6 +61,10 @@ module Finitio
61
61
  uped
62
62
  end
63
63
 
64
+ def allbut(attrs)
65
+ factor(heading.allbut(attrs))
66
+ end
67
+
64
68
  protected
65
69
 
66
70
  def looks_a_tuple?(value)
@@ -29,5 +29,9 @@ module Finitio
29
29
  super(other, TupleType, MultiTupleType)
30
30
  end
31
31
 
32
+ def factor(heading)
33
+ MultiTupleType.new(heading)
34
+ end
35
+
32
36
  end # class MultiTupleType
33
37
  end # module Finitio
@@ -48,5 +48,9 @@ module Finitio
48
48
  super(other, TupleType, MultiTupleType)
49
49
  end
50
50
 
51
+ def factor(heading)
52
+ TupleType.new(heading)
53
+ end
54
+
51
55
  end # class TupleType
52
56
  end # module Finitio
@@ -3,7 +3,7 @@ module Finitio
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 12
6
- TINY = 0
6
+ TINY = 2
7
7
 
8
8
  def self.to_s
9
9
  [ MAJOR, MINOR, TINY ].join('.')
@@ -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.0
4
+ version: 0.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2025-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: citrus
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '4.1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: activesupport
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 7.0.8
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 7.0.8
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: path
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -432,6 +446,7 @@ files:
432
446
  - spec/type/sub_type/test_name.rb
433
447
  - spec/type/test_suppremum.rb
434
448
  - spec/type/test_unconstrained.rb
449
+ - spec/type/tuple_type/test_allbut.rb
435
450
  - spec/type/tuple_type/test_default_name.rb
436
451
  - spec/type/tuple_type/test_dress.rb
437
452
  - spec/type/tuple_type/test_equality.rb
@@ -471,7 +486,7 @@ files:
471
486
  homepage: https://github.com/blambeau/finitio
472
487
  licenses: []
473
488
  metadata: {}
474
- post_install_message:
489
+ post_install_message:
475
490
  rdoc_options: []
476
491
  require_paths:
477
492
  - lib
@@ -486,8 +501,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
486
501
  - !ruby/object:Gem::Version
487
502
  version: '0'
488
503
  requirements: []
489
- rubygems_version: 3.3.26
490
- signing_key:
504
+ rubygems_version: 3.4.19
505
+ signing_key:
491
506
  specification_version: 4
492
507
  summary: Finitio - in Ruby
493
508
  test_files:
@@ -647,6 +662,7 @@ test_files:
647
662
  - spec/type/sub_type/test_name.rb
648
663
  - spec/type/test_suppremum.rb
649
664
  - spec/type/test_unconstrained.rb
665
+ - spec/type/tuple_type/test_allbut.rb
650
666
  - spec/type/tuple_type/test_default_name.rb
651
667
  - spec/type/tuple_type/test_dress.rb
652
668
  - spec/type/tuple_type/test_equality.rb