finitio 0.12.3 → 1.1.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 +53 -0
- data/Gemfile.lock +129 -82
- data/README.md +92 -6
- data/finitio.gemspec +18 -8
- data/lib/finitio/json_schema/union_type.rb +2 -2
- data/lib/finitio/stdlib/finitio/data.fio +1 -3
- data/lib/finitio/version.rb +3 -3
- data/spec/regression/test_stdlib_boolean_aliases.rb +29 -0
- data/tasks/gem.rake +3 -23
- metadata +31 -26
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31c9fbb540427b735e6d706ff1179c017fa92b27897188f4331ac5412f00417c
|
|
4
|
+
data.tar.gz: 3e117cc15ce2eb110dfcef795290c0a07617c9c1b207e743f671c629a604b64b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 809468453d4e0cc763b01df85ff46797a9d6322a6eb3f5bd2dc93191cf0a5470a5ae50623c36e0025ea11ea055defb170b56c43ff625ae87126f084fcdde08ba
|
|
7
|
+
data.tar.gz: 0cfa5e1bbda2e76a15b749362ef479506336d70ed1caea8a8fe7944f747d861d4b3e8e997c72a218fa20f608e8af469a3f50daf38bb3548cebb009a09b88bd21
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
## 1.1.0 - 2026/09/30
|
|
2
|
+
|
|
3
|
+
* Ruby 4.0 is now supported, and the test grid covers 3.2, 3.3, 3.4 and
|
|
4
|
+
4.0. The library itself needed no change; the Cucumber suite used to
|
|
5
|
+
require `ostruct`, which stopped being a default gem in 4.0, and no
|
|
6
|
+
longer does (the require was unused). Ruby 3.2 remains the minimum
|
|
7
|
+
supported version.
|
|
8
|
+
|
|
9
|
+
* Upgrade development dependencies: rake ~> 13.4 and multi_json ~> 1.21.
|
|
10
|
+
|
|
11
|
+
## 1.0.0 - 2026/08/06
|
|
12
|
+
|
|
13
|
+
This first major release does not reshape the language or the API: code
|
|
14
|
+
written against 0.12.3 keeps working, apart from the removal announced
|
|
15
|
+
below. It states that the public API is now stable, and that breaking
|
|
16
|
+
changes will be signalled by a major version bump from here on.
|
|
17
|
+
|
|
18
|
+
* BREAKING: the deprecated `Fixnum` and `Bignum` aliases are removed from
|
|
19
|
+
the `finitio/data` standard library. They had been aliases of `.Integer`
|
|
20
|
+
since 0.12.0, where their removal was announced. Use `Integer` instead.
|
|
21
|
+
|
|
22
|
+
* BREAKING: Ruby 3.2 is now the minimum supported version, and the test
|
|
23
|
+
grid covers 3.2, 3.3 and 3.4. Ruby 2.7 and 3.1 are both end-of-life.
|
|
24
|
+
|
|
25
|
+
* Fix the `FalseClass` alias of the `finitio/data` standard library, which
|
|
26
|
+
was defined as `.TrueClass`: it accepted `true` and rejected `false`.
|
|
27
|
+
The `False` alias was, and remains, correct. Schemas that worked around
|
|
28
|
+
the bug by writing `FalseClass` where they meant a true value must be
|
|
29
|
+
updated.
|
|
30
|
+
|
|
31
|
+
* Development dependencies are upgraded to their latest releases, notably
|
|
32
|
+
cucumber 11.1, activesupport 8.1 and simplecov 1.0 (through
|
|
33
|
+
`coveralls_reborn`, the unmaintained `coveralls` gem having pinned
|
|
34
|
+
simplecov to 0.16.1).
|
|
35
|
+
|
|
36
|
+
* Fix `rake test`, which was broken on Ruby 3.4: the gemspec was eval'd
|
|
37
|
+
without a filename, so `__FILE__` resolved to a bogus path when looking
|
|
38
|
+
up `Manifest.txt`.
|
|
39
|
+
|
|
40
|
+
* The dressing rule for extra attributes is now pinned by a feature: an
|
|
41
|
+
untyped `...` accepts extra attributes but constrains them in no way, so
|
|
42
|
+
they are dropped, while a typed `...: Age` guarantees their type and
|
|
43
|
+
keeps them.
|
|
44
|
+
|
|
45
|
+
* Integration tests now also run on pushes to master, not only on pull
|
|
46
|
+
requests targeting it.
|
|
47
|
+
|
|
48
|
+
* Remove `finitio.noespec`, the Noe template descriptor. It had not been
|
|
49
|
+
updated since 0.7.0 in 2019 and every value in it had gone stale, while
|
|
50
|
+
Noe itself is no longer a dependency of the project. `tasks/gem.rake`,
|
|
51
|
+
the only file still advertising itself as generated from it, is now
|
|
52
|
+
plainly hand-maintained.
|
|
53
|
+
|
|
1
54
|
## 0.12.3 - 2025/09/01
|
|
2
55
|
|
|
3
56
|
* Add Heading#project and (Multi)TupleType#project, to remove some attributes.
|
data/Gemfile.lock
CHANGED
|
@@ -1,122 +1,169 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
finitio (
|
|
4
|
+
finitio (1.1.0)
|
|
5
5
|
citrus (>= 3.0, < 4.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
8
8
|
remote: https://rubygems.org/
|
|
9
9
|
specs:
|
|
10
|
-
activesupport (
|
|
11
|
-
|
|
10
|
+
activesupport (8.1.4)
|
|
11
|
+
base64
|
|
12
|
+
bigdecimal
|
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
14
|
+
connection_pool (>= 2.2.5)
|
|
15
|
+
drb
|
|
12
16
|
i18n (>= 1.6, < 2)
|
|
17
|
+
json
|
|
18
|
+
logger (>= 1.4.2)
|
|
13
19
|
minitest (>= 5.1)
|
|
14
|
-
|
|
20
|
+
securerandom (>= 0.3)
|
|
21
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
22
|
+
uri (>= 0.13.1)
|
|
15
23
|
awesome_print (1.9.2)
|
|
16
|
-
|
|
24
|
+
base64 (0.3.0)
|
|
25
|
+
bigdecimal (4.1.3)
|
|
17
26
|
builder (3.3.0)
|
|
18
27
|
citrus (3.0.2)
|
|
19
|
-
concurrent-ruby (1.3.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
simplecov (
|
|
23
|
-
term-ansicolor (
|
|
24
|
-
thor (>=
|
|
25
|
-
tins (
|
|
26
|
-
cucumber (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
cucumber-
|
|
30
|
-
cucumber-
|
|
31
|
-
cucumber-
|
|
32
|
-
cucumber-html-formatter (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
multi_test (~>
|
|
37
|
-
sys-uname (~> 1.
|
|
38
|
-
cucumber-
|
|
39
|
-
|
|
40
|
-
cucumber-
|
|
41
|
-
cucumber-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
cucumber-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
cucumber-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ffi (1.17.
|
|
60
|
-
|
|
28
|
+
concurrent-ruby (1.3.8)
|
|
29
|
+
connection_pool (3.0.2)
|
|
30
|
+
coveralls_reborn (1.0.0)
|
|
31
|
+
simplecov (>= 1.0)
|
|
32
|
+
term-ansicolor (>= 1.11)
|
|
33
|
+
thor (>= 1.5)
|
|
34
|
+
tins (>= 1.54)
|
|
35
|
+
cucumber (11.1.1)
|
|
36
|
+
base64 (~> 0.2)
|
|
37
|
+
builder (~> 3.2)
|
|
38
|
+
cucumber-ci-environment (> 9, < 12)
|
|
39
|
+
cucumber-core (>= 16.2.0, < 17)
|
|
40
|
+
cucumber-cucumber-expressions (> 17, < 20)
|
|
41
|
+
cucumber-html-formatter (> 21, < 24)
|
|
42
|
+
diff-lcs (~> 1.5)
|
|
43
|
+
logger (~> 1.6)
|
|
44
|
+
mini_mime (~> 1.1)
|
|
45
|
+
multi_test (~> 1.1)
|
|
46
|
+
sys-uname (~> 1.5)
|
|
47
|
+
cucumber-ci-environment (11.0.0)
|
|
48
|
+
cucumber-core (16.2.0)
|
|
49
|
+
cucumber-gherkin (> 36, < 40)
|
|
50
|
+
cucumber-messages (> 31, < 33)
|
|
51
|
+
cucumber-tag-expressions (> 6, < 9)
|
|
52
|
+
cucumber-cucumber-expressions (19.0.1)
|
|
53
|
+
bigdecimal
|
|
54
|
+
cucumber-gherkin (39.1.0)
|
|
55
|
+
cucumber-messages (>= 31, < 33)
|
|
56
|
+
cucumber-html-formatter (23.1.0)
|
|
57
|
+
cucumber-messages (> 23, < 33)
|
|
58
|
+
cucumber-messages (32.3.1)
|
|
59
|
+
cucumber-tag-expressions (8.1.0)
|
|
60
|
+
diff-lcs (1.6.2)
|
|
61
|
+
drb (2.2.3)
|
|
62
|
+
erb (6.0.7)
|
|
63
|
+
ffi (1.17.4)
|
|
64
|
+
ffi (1.17.4-aarch64-linux-gnu)
|
|
65
|
+
ffi (1.17.4-aarch64-linux-musl)
|
|
66
|
+
ffi (1.17.4-arm-linux-gnu)
|
|
67
|
+
ffi (1.17.4-arm-linux-musl)
|
|
68
|
+
ffi (1.17.4-arm64-darwin)
|
|
69
|
+
ffi (1.17.4-x86-linux-gnu)
|
|
70
|
+
ffi (1.17.4-x86-linux-musl)
|
|
71
|
+
ffi (1.17.4-x86_64-darwin)
|
|
72
|
+
ffi (1.17.4-x86_64-linux-gnu)
|
|
73
|
+
ffi (1.17.4-x86_64-linux-musl)
|
|
74
|
+
i18n (1.15.2)
|
|
61
75
|
concurrent-ruby (~> 1.0)
|
|
62
|
-
|
|
76
|
+
io-console (0.9.4)
|
|
77
|
+
irb (1.18.0)
|
|
78
|
+
pp (>= 0.6.0)
|
|
79
|
+
prism (>= 1.3.0)
|
|
80
|
+
rdoc (>= 4.0.0)
|
|
81
|
+
reline (>= 0.4.2)
|
|
82
|
+
json (3.0.2)
|
|
83
|
+
logger (1.7.0)
|
|
63
84
|
memoist3 (1.0.0)
|
|
64
|
-
|
|
65
|
-
minitest (
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
mini_mime (1.1.5)
|
|
86
|
+
minitest (6.0.6)
|
|
87
|
+
drb (~> 2.0)
|
|
88
|
+
prism (~> 1.5)
|
|
89
|
+
mize (0.6.1)
|
|
90
|
+
multi_json (1.21.2)
|
|
91
|
+
multi_test (1.1.0)
|
|
68
92
|
path (2.1.0)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
pp (0.6.4)
|
|
94
|
+
prettyprint
|
|
95
|
+
prettyprint (0.2.0)
|
|
96
|
+
prism (1.9.0)
|
|
97
|
+
rake (13.4.2)
|
|
98
|
+
rbs (4.2.0)
|
|
99
|
+
logger
|
|
100
|
+
prism (>= 1.6.0)
|
|
101
|
+
tsort
|
|
102
|
+
rdoc (8.1.0)
|
|
103
|
+
erb
|
|
104
|
+
prism (>= 1.6.0)
|
|
105
|
+
rbs (>= 4.0.0)
|
|
106
|
+
tsort
|
|
107
|
+
readline (0.0.4)
|
|
108
|
+
reline
|
|
109
|
+
reline (0.7.0)
|
|
110
|
+
io-console (~> 0.5)
|
|
111
|
+
rspec (3.13.2)
|
|
76
112
|
rspec-core (~> 3.13.0)
|
|
77
113
|
rspec-expectations (~> 3.13.0)
|
|
78
114
|
rspec-mocks (~> 3.13.0)
|
|
79
|
-
rspec-core (3.13.
|
|
115
|
+
rspec-core (3.13.6)
|
|
80
116
|
rspec-support (~> 3.13.0)
|
|
81
117
|
rspec-expectations (3.13.5)
|
|
82
118
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
83
119
|
rspec-support (~> 3.13.0)
|
|
84
|
-
rspec-mocks (3.13.
|
|
120
|
+
rspec-mocks (3.13.8)
|
|
85
121
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
86
122
|
rspec-support (~> 3.13.0)
|
|
87
|
-
rspec-support (3.13.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
json (>= 1.8, < 3)
|
|
91
|
-
simplecov-html (~> 0.10.0)
|
|
92
|
-
simplecov-html (0.10.2)
|
|
123
|
+
rspec-support (3.13.7)
|
|
124
|
+
securerandom (0.4.1)
|
|
125
|
+
simplecov (1.3.1)
|
|
93
126
|
sync (0.5.0)
|
|
94
|
-
sys-uname (1.
|
|
127
|
+
sys-uname (1.5.1)
|
|
95
128
|
ffi (~> 1.1)
|
|
96
129
|
memoist3 (~> 1.0.0)
|
|
97
|
-
term-ansicolor (1.11.
|
|
98
|
-
tins (~> 1
|
|
99
|
-
thor (1.
|
|
100
|
-
|
|
101
|
-
tins (1.42.0)
|
|
130
|
+
term-ansicolor (1.11.3)
|
|
131
|
+
tins (~> 1)
|
|
132
|
+
thor (1.5.0)
|
|
133
|
+
tins (1.59.0)
|
|
102
134
|
bigdecimal
|
|
135
|
+
irb
|
|
136
|
+
mize (~> 0.6)
|
|
137
|
+
readline
|
|
103
138
|
sync
|
|
139
|
+
tsort (0.2.0)
|
|
104
140
|
tzinfo (2.0.6)
|
|
105
141
|
concurrent-ruby (~> 1.0)
|
|
142
|
+
uri (1.1.1)
|
|
106
143
|
|
|
107
144
|
PLATFORMS
|
|
108
|
-
|
|
145
|
+
aarch64-linux-gnu
|
|
146
|
+
aarch64-linux-musl
|
|
147
|
+
arm-linux-gnu
|
|
148
|
+
arm-linux-musl
|
|
149
|
+
arm64-darwin
|
|
150
|
+
ruby
|
|
151
|
+
x86-linux-gnu
|
|
152
|
+
x86-linux-musl
|
|
153
|
+
x86_64-darwin
|
|
154
|
+
x86_64-linux-gnu
|
|
155
|
+
x86_64-linux-musl
|
|
109
156
|
|
|
110
157
|
DEPENDENCIES
|
|
111
|
-
activesupport (~>
|
|
112
|
-
awesome_print (~> 1.
|
|
113
|
-
|
|
114
|
-
cucumber (~>
|
|
158
|
+
activesupport (~> 8.1)
|
|
159
|
+
awesome_print (~> 1.9)
|
|
160
|
+
coveralls_reborn (~> 1.0)
|
|
161
|
+
cucumber (~> 11.1)
|
|
115
162
|
finitio!
|
|
116
|
-
multi_json (~> 1.
|
|
163
|
+
multi_json (~> 1.21)
|
|
117
164
|
path (>= 2.1, < 3.0)
|
|
118
|
-
rake (~> 13.
|
|
119
|
-
rspec (~> 3.
|
|
165
|
+
rake (~> 13.4)
|
|
166
|
+
rspec (~> 3.13)
|
|
120
167
|
|
|
121
168
|
BUNDLED WITH
|
|
122
|
-
2.
|
|
169
|
+
2.6.9
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[](https://github.com/enspirit/finitio-rb/actions/workflows/integration.yml)
|
|
2
|
+
[](https://rubygems.org/gems/finitio)
|
|
3
|
+
[](https://coveralls.io/github/enspirit/finitio-rb?branch=master)
|
|
4
4
|
|
|
5
5
|
# Finitio(-rb)
|
|
6
6
|
|
|
@@ -11,6 +11,21 @@ schema" but the right way. For more information about *Finitio* itself, see
|
|
|
11
11
|
`finitio-rb` is the ruby binding of *Finitio*. It allows defining data schemas
|
|
12
12
|
and validating and coercing data against them in an idiomatic ruby way.
|
|
13
13
|
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
gem install finitio
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or, in a `Gemfile`:
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
gem 'finitio', '~> 1.0'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`finitio-rb` requires Ruby 3.2 or later, and is tested against 3.2, 3.3, 3.4
|
|
27
|
+
and 4.0.
|
|
28
|
+
|
|
14
29
|
## Example
|
|
15
30
|
|
|
16
31
|
```ruby
|
|
@@ -29,13 +44,22 @@ FIO
|
|
|
29
44
|
|
|
30
45
|
# Let load some JSON document
|
|
31
46
|
data = JSON.parse <<-JSON
|
|
32
|
-
{ "name": "Finitio", "at": "
|
|
47
|
+
{ "name": "Finitio", "at": "2014-03-01T12:00:00Z" }
|
|
33
48
|
JSON
|
|
34
49
|
|
|
35
50
|
# And try dressing that data
|
|
36
51
|
puts schema.dress(data)
|
|
37
52
|
```
|
|
38
53
|
|
|
54
|
+
Dressing either returns the data coerced to its ruby representation -- here,
|
|
55
|
+
`at` comes back as a real `DateTime` -- or raises a `Finitio::TypeError`
|
|
56
|
+
explaining what does not match:
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
schema.dress({ "name" => " ", "at" => "2014-03-01T12:00:00Z" })
|
|
60
|
+
# => Finitio::TypeError: Invalid Default ` `
|
|
61
|
+
```
|
|
62
|
+
|
|
39
63
|
## ADTs with internal contracts
|
|
40
64
|
|
|
41
65
|
`finitio-rb` tries to provide an idiomatic binding for ruby developers. In
|
|
@@ -112,7 +136,7 @@ Posint = .Integer(i | i >= 0)
|
|
|
112
136
|
|
|
113
137
|
```
|
|
114
138
|
# parent.fio
|
|
115
|
-
@import ./child
|
|
139
|
+
@import ./child
|
|
116
140
|
|
|
117
141
|
# Child's types are available inside the system, but not outside it, that
|
|
118
142
|
# is, imported types are not themselves exported
|
|
@@ -120,7 +144,7 @@ Byte = Posint(i | i <= 255 )
|
|
|
120
144
|
```
|
|
121
145
|
|
|
122
146
|
```
|
|
123
|
-
@import ./parent
|
|
147
|
+
@import ./parent
|
|
124
148
|
|
|
125
149
|
# This will work
|
|
126
150
|
HalfByte = Byte(i | i <= 128)
|
|
@@ -129,6 +153,14 @@ HalfByte = Byte(i | i <= 128)
|
|
|
129
153
|
Posint(i | i <= 128)
|
|
130
154
|
```
|
|
131
155
|
|
|
156
|
+
Note that the path is written **without** the `.fio` extension: the resolver
|
|
157
|
+
appends it, so `@import ./child.fio` looks for `child.fio.fio` and fails.
|
|
158
|
+
|
|
159
|
+
Relative paths are resolved against the file the system was loaded from, so
|
|
160
|
+
the schema has to come from one — `Finitio.system(Pathname.new('parent.fio'))`
|
|
161
|
+
rather than `Finitio.system(File.read('parent.fio'))`, which has no path to
|
|
162
|
+
resolve against.
|
|
163
|
+
|
|
132
164
|
See the next section about the standard library if you need to share types
|
|
133
165
|
without relying on relative paths.
|
|
134
166
|
|
|
@@ -184,6 +216,60 @@ Then, a Finitio schema will have access to the types defined in your extension:
|
|
|
184
216
|
@import myrubygem/advanced
|
|
185
217
|
```
|
|
186
218
|
|
|
219
|
+
## Generating a JSON Schema
|
|
220
|
+
|
|
221
|
+
Finitio types can be projected to a JSON Schema, which is useful to expose a
|
|
222
|
+
schema to consumers that do not speak Finitio (API documentation, client-side
|
|
223
|
+
validation, ...). The feature ships in a separate file, to be required
|
|
224
|
+
explicitly:
|
|
225
|
+
|
|
226
|
+
```ruby
|
|
227
|
+
require 'finitio'
|
|
228
|
+
require 'finitio/json_schema'
|
|
229
|
+
|
|
230
|
+
schema = Finitio.system <<-FIO
|
|
231
|
+
@import finitio/data
|
|
232
|
+
|
|
233
|
+
Person = { name: String, age: Integer }
|
|
234
|
+
Person
|
|
235
|
+
FIO
|
|
236
|
+
|
|
237
|
+
schema.fetch('Person').to_json_schema
|
|
238
|
+
# => {
|
|
239
|
+
# => type: "object",
|
|
240
|
+
# => properties: {
|
|
241
|
+
# => name: { type: "string" },
|
|
242
|
+
# => age: { type: "integer" }
|
|
243
|
+
# => },
|
|
244
|
+
# => required: ["name", "age"]
|
|
245
|
+
# => }
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
The projection is necessarily lossy: JSON Schema cannot express Finitio's
|
|
249
|
+
constraints, ADTs or recursive types faithfully. Two metadata attributes let
|
|
250
|
+
you steer it:
|
|
251
|
+
|
|
252
|
+
* `description` on an attribute is carried over to the generated schema.
|
|
253
|
+
* `jsonSchemaType` on a type stops the generation there and uses the given
|
|
254
|
+
type as-is, which is the way out for types that have no useful projection.
|
|
255
|
+
|
|
256
|
+
## Generating data
|
|
257
|
+
|
|
258
|
+
`Finitio::Generation` produces random data conforming to a type, which is
|
|
259
|
+
handy for tests and fixtures:
|
|
260
|
+
|
|
261
|
+
```ruby
|
|
262
|
+
require 'finitio'
|
|
263
|
+
require 'finitio/generation'
|
|
264
|
+
|
|
265
|
+
Finitio::Generation.new.call(schema.fetch('Person'))
|
|
266
|
+
# => { name: "e6f4a1c0b2d3", age: 418561 }
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Generation can be fine-tuned by passing generators by type name, or through
|
|
270
|
+
`examples` metadata on the type definitions themselves. See
|
|
271
|
+
`lib/finitio/generation.rb` for the available options.
|
|
272
|
+
|
|
187
273
|
## About representations
|
|
188
274
|
|
|
189
275
|
The `Rep` representation function mapping *Finitio* types to ruby classes is
|
data/finitio.gemspec
CHANGED
|
@@ -7,9 +7,17 @@ Gem::Specification.new do |s|
|
|
|
7
7
|
s.version = $version
|
|
8
8
|
s.summary = "Finitio - in Ruby"
|
|
9
9
|
s.description = "Implements the Finitio information language in Ruby."
|
|
10
|
-
s.homepage = "https://
|
|
10
|
+
s.homepage = "https://www.finitio.io"
|
|
11
11
|
s.authors = ["Bernard Lambeau"]
|
|
12
12
|
s.email = ["blambeau@gmail.com"]
|
|
13
|
+
s.licenses = ["MIT"]
|
|
14
|
+
s.metadata = {
|
|
15
|
+
"homepage_uri" => "https://www.finitio.io",
|
|
16
|
+
"source_code_uri" => "https://github.com/enspirit/finitio-rb",
|
|
17
|
+
"changelog_uri" => "https://github.com/enspirit/finitio-rb/blob/master/CHANGELOG.md",
|
|
18
|
+
"bug_tracker_uri" => "https://github.com/enspirit/finitio-rb/issues",
|
|
19
|
+
"documentation_uri" => "https://www.finitio.io/reference/0.4.x/type-system",
|
|
20
|
+
}
|
|
13
21
|
s.require_paths = ["lib"]
|
|
14
22
|
here = File.expand_path(File.dirname(__FILE__))
|
|
15
23
|
s.files = File.readlines(File.join(here, 'Manifest.txt')).
|
|
@@ -20,16 +28,18 @@ Gem::Specification.new do |s|
|
|
|
20
28
|
s.bindir = "bin"
|
|
21
29
|
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
|
22
30
|
|
|
31
|
+
s.required_ruby_version = ">= 3.2"
|
|
32
|
+
|
|
23
33
|
s.add_dependency("citrus", ">= 3.0", "< 4.0")
|
|
24
34
|
|
|
25
|
-
s.add_development_dependency("rake", "~> 13.
|
|
26
|
-
s.add_development_dependency("rspec", "~> 3.
|
|
27
|
-
s.add_development_dependency("cucumber", "~>
|
|
28
|
-
s.add_development_dependency('activesupport', '~>
|
|
35
|
+
s.add_development_dependency("rake", "~> 13.4")
|
|
36
|
+
s.add_development_dependency("rspec", "~> 3.13")
|
|
37
|
+
s.add_development_dependency("cucumber", "~> 11.1")
|
|
38
|
+
s.add_development_dependency('activesupport', '~> 8.1')
|
|
29
39
|
s.add_development_dependency("path", ">= 2.1", "< 3.0")
|
|
30
|
-
s.add_development_dependency("awesome_print", "~> 1.
|
|
31
|
-
s.add_development_dependency("
|
|
32
|
-
s.add_development_dependency("multi_json", "~> 1.
|
|
40
|
+
s.add_development_dependency("awesome_print", "~> 1.9")
|
|
41
|
+
s.add_development_dependency("coveralls_reborn", "~> 1.0")
|
|
42
|
+
s.add_development_dependency("multi_json", "~> 1.21")
|
|
33
43
|
|
|
34
44
|
s.extensions = []
|
|
35
45
|
s.requirements = nil
|
|
@@ -3,9 +3,9 @@ module Finitio
|
|
|
3
3
|
|
|
4
4
|
NIL_TYPE = BuiltinType.new(NilClass)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
TRUE_TYPE = BuiltinType.new(TrueClass)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
FALSE_TYPE = BuiltinType.new(FalseClass)
|
|
9
9
|
|
|
10
10
|
BOOLEAN_TYPE = UnionType.new([TRUE_TYPE, FALSE_TYPE])
|
|
11
11
|
|
|
@@ -4,15 +4,13 @@ Nil = .NilClass
|
|
|
4
4
|
|
|
5
5
|
# Booleans
|
|
6
6
|
TrueClass = .TrueClass
|
|
7
|
-
FalseClass = .
|
|
7
|
+
FalseClass = .FalseClass
|
|
8
8
|
True = .TrueClass
|
|
9
9
|
False = .FalseClass
|
|
10
10
|
Boolean = .TrueClass|.FalseClass
|
|
11
11
|
|
|
12
12
|
# Numbers
|
|
13
13
|
Numeric = .Numeric
|
|
14
|
-
Fixnum = .Integer
|
|
15
|
-
Bignum = .Integer
|
|
16
14
|
Integer = .Integer
|
|
17
15
|
Float = .Float
|
|
18
16
|
Real = .Float
|
data/lib/finitio/version.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "The boolean aliases of the finitio/data stdlib" do
|
|
4
|
+
let(:schema){
|
|
5
|
+
Finitio.system <<~F
|
|
6
|
+
@import finitio/data
|
|
7
|
+
|
|
8
|
+
{ t: TrueClass, f: FalseClass, tt: True, ff: False, b: Boolean }
|
|
9
|
+
F
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
it 'dresses each alias with the value it stands for' do
|
|
13
|
+
expect(
|
|
14
|
+
schema.dress({t: true, f: false, tt: true, ff: false, b: true})
|
|
15
|
+
).to eql({t: true, f: false, tt: true, ff: false, b: true})
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'refuses true where a false is expected' do
|
|
19
|
+
expect(->(){
|
|
20
|
+
schema.dress({t: true, f: true, tt: true, ff: false, b: true})
|
|
21
|
+
}).to raise_error(Finitio::Error)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'refuses false where a true is expected' do
|
|
25
|
+
expect(->(){
|
|
26
|
+
schema.dress({t: false, f: false, tt: true, ff: false, b: true})
|
|
27
|
+
}).to raise_error(Finitio::Error)
|
|
28
|
+
end
|
|
29
|
+
end
|
data/tasks/gem.rake
CHANGED
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
# Installs rake tasks for gemming and packaging
|
|
2
2
|
#
|
|
3
|
-
# This file installs the 'rake package'
|
|
4
|
-
# (clobber_package, repackage, ...).
|
|
5
|
-
# from your .noespec file, and should therefore be configured there, under
|
|
6
|
-
# the variables/rake_tasks/gem entry, as illustrated below:
|
|
7
|
-
#
|
|
8
|
-
# variables:
|
|
9
|
-
# rake_tasks:
|
|
10
|
-
# gem:
|
|
11
|
-
# package_dir: pkg
|
|
12
|
-
# need_tar: false
|
|
13
|
-
# need_tar_gz: false
|
|
14
|
-
# need_tar_bz2: false
|
|
15
|
-
# need_zip: false
|
|
16
|
-
# ...
|
|
17
|
-
#
|
|
18
|
-
# If you have specific needs requiring manual intervention on this file,
|
|
19
|
-
# don't forget to set safe-override to false in your noe specification:
|
|
20
|
-
#
|
|
21
|
-
# template-info:
|
|
22
|
-
# manifest:
|
|
23
|
-
# tasks/gem.rake:
|
|
24
|
-
# safe-override: false
|
|
3
|
+
# This file installs the 'rake package' and 'rake gem' tasks and associates
|
|
4
|
+
# (clobber_package, repackage, ...). Edit it directly.
|
|
25
5
|
#
|
|
26
6
|
begin
|
|
27
7
|
require 'rubygems/package_task'
|
|
28
8
|
|
|
29
9
|
# Dynamically load the gem spec
|
|
30
10
|
gemspec_file = File.expand_path('../../finitio.gemspec', __FILE__)
|
|
31
|
-
gemspec = Kernel.eval(File.read(gemspec_file))
|
|
11
|
+
gemspec = Kernel.eval(File.read(gemspec_file), binding, gemspec_file)
|
|
32
12
|
|
|
33
13
|
Gem::PackageTask.new(gemspec) do |t|
|
|
34
14
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: finitio
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Bernard Lambeau
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: citrus
|
|
@@ -36,56 +35,56 @@ dependencies:
|
|
|
36
35
|
requirements:
|
|
37
36
|
- - "~>"
|
|
38
37
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '13.
|
|
38
|
+
version: '13.4'
|
|
40
39
|
type: :development
|
|
41
40
|
prerelease: false
|
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
42
|
requirements:
|
|
44
43
|
- - "~>"
|
|
45
44
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '13.
|
|
45
|
+
version: '13.4'
|
|
47
46
|
- !ruby/object:Gem::Dependency
|
|
48
47
|
name: rspec
|
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
|
50
49
|
requirements:
|
|
51
50
|
- - "~>"
|
|
52
51
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '3.
|
|
52
|
+
version: '3.13'
|
|
54
53
|
type: :development
|
|
55
54
|
prerelease: false
|
|
56
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
56
|
requirements:
|
|
58
57
|
- - "~>"
|
|
59
58
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: '3.
|
|
59
|
+
version: '3.13'
|
|
61
60
|
- !ruby/object:Gem::Dependency
|
|
62
61
|
name: cucumber
|
|
63
62
|
requirement: !ruby/object:Gem::Requirement
|
|
64
63
|
requirements:
|
|
65
64
|
- - "~>"
|
|
66
65
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '
|
|
66
|
+
version: '11.1'
|
|
68
67
|
type: :development
|
|
69
68
|
prerelease: false
|
|
70
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
70
|
requirements:
|
|
72
71
|
- - "~>"
|
|
73
72
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
73
|
+
version: '11.1'
|
|
75
74
|
- !ruby/object:Gem::Dependency
|
|
76
75
|
name: activesupport
|
|
77
76
|
requirement: !ruby/object:Gem::Requirement
|
|
78
77
|
requirements:
|
|
79
78
|
- - "~>"
|
|
80
79
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
80
|
+
version: '8.1'
|
|
82
81
|
type: :development
|
|
83
82
|
prerelease: false
|
|
84
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
84
|
requirements:
|
|
86
85
|
- - "~>"
|
|
87
86
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
87
|
+
version: '8.1'
|
|
89
88
|
- !ruby/object:Gem::Dependency
|
|
90
89
|
name: path
|
|
91
90
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,51 +111,51 @@ dependencies:
|
|
|
112
111
|
requirements:
|
|
113
112
|
- - "~>"
|
|
114
113
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: '1.
|
|
114
|
+
version: '1.9'
|
|
116
115
|
type: :development
|
|
117
116
|
prerelease: false
|
|
118
117
|
version_requirements: !ruby/object:Gem::Requirement
|
|
119
118
|
requirements:
|
|
120
119
|
- - "~>"
|
|
121
120
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: '1.
|
|
121
|
+
version: '1.9'
|
|
123
122
|
- !ruby/object:Gem::Dependency
|
|
124
|
-
name:
|
|
123
|
+
name: coveralls_reborn
|
|
125
124
|
requirement: !ruby/object:Gem::Requirement
|
|
126
125
|
requirements:
|
|
127
126
|
- - "~>"
|
|
128
127
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '0
|
|
128
|
+
version: '1.0'
|
|
130
129
|
type: :development
|
|
131
130
|
prerelease: false
|
|
132
131
|
version_requirements: !ruby/object:Gem::Requirement
|
|
133
132
|
requirements:
|
|
134
133
|
- - "~>"
|
|
135
134
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '0
|
|
135
|
+
version: '1.0'
|
|
137
136
|
- !ruby/object:Gem::Dependency
|
|
138
137
|
name: multi_json
|
|
139
138
|
requirement: !ruby/object:Gem::Requirement
|
|
140
139
|
requirements:
|
|
141
140
|
- - "~>"
|
|
142
141
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: '1.
|
|
142
|
+
version: '1.21'
|
|
144
143
|
type: :development
|
|
145
144
|
prerelease: false
|
|
146
145
|
version_requirements: !ruby/object:Gem::Requirement
|
|
147
146
|
requirements:
|
|
148
147
|
- - "~>"
|
|
149
148
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '1.
|
|
149
|
+
version: '1.21'
|
|
151
150
|
description: Implements the Finitio information language in Ruby.
|
|
152
151
|
email:
|
|
153
152
|
- blambeau@gmail.com
|
|
154
153
|
executables: []
|
|
155
154
|
extensions: []
|
|
156
155
|
extra_rdoc_files:
|
|
157
|
-
- README.md
|
|
158
156
|
- CHANGELOG.md
|
|
159
157
|
- LICENCE.md
|
|
158
|
+
- README.md
|
|
160
159
|
files:
|
|
161
160
|
- CHANGELOG.md
|
|
162
161
|
- Gemfile
|
|
@@ -336,6 +335,7 @@ files:
|
|
|
336
335
|
- spec/regression/test_dress_on_recursive_type.rb
|
|
337
336
|
- spec/regression/test_heading_extra_are_proxy_resolved.rb
|
|
338
337
|
- spec/regression/test_name_of_generic_types.rb
|
|
338
|
+
- spec/regression/test_stdlib_boolean_aliases.rb
|
|
339
339
|
- spec/spec_helper.rb
|
|
340
340
|
- spec/support/test_compare_attrs.rb
|
|
341
341
|
- spec/support/test_proc_with_code.rb
|
|
@@ -484,10 +484,15 @@ files:
|
|
|
484
484
|
- spec/type_factory/factory/test_tuple_type.rb
|
|
485
485
|
- tasks/gem.rake
|
|
486
486
|
- tasks/test.rake
|
|
487
|
-
homepage: https://
|
|
488
|
-
licenses:
|
|
489
|
-
|
|
490
|
-
|
|
487
|
+
homepage: https://www.finitio.io
|
|
488
|
+
licenses:
|
|
489
|
+
- MIT
|
|
490
|
+
metadata:
|
|
491
|
+
homepage_uri: https://www.finitio.io
|
|
492
|
+
source_code_uri: https://github.com/enspirit/finitio-rb
|
|
493
|
+
changelog_uri: https://github.com/enspirit/finitio-rb/blob/master/CHANGELOG.md
|
|
494
|
+
bug_tracker_uri: https://github.com/enspirit/finitio-rb/issues
|
|
495
|
+
documentation_uri: https://www.finitio.io/reference/0.4.x/type-system
|
|
491
496
|
rdoc_options: []
|
|
492
497
|
require_paths:
|
|
493
498
|
- lib
|
|
@@ -495,15 +500,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
495
500
|
requirements:
|
|
496
501
|
- - ">="
|
|
497
502
|
- !ruby/object:Gem::Version
|
|
498
|
-
version: '
|
|
503
|
+
version: '3.2'
|
|
499
504
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
500
505
|
requirements:
|
|
501
506
|
- - ">="
|
|
502
507
|
- !ruby/object:Gem::Version
|
|
503
508
|
version: '0'
|
|
504
509
|
requirements: []
|
|
505
|
-
rubygems_version: 3.
|
|
506
|
-
signing_key:
|
|
510
|
+
rubygems_version: 3.6.9
|
|
507
511
|
specification_version: 4
|
|
508
512
|
summary: Finitio - in Ruby
|
|
509
513
|
test_files:
|
|
@@ -553,6 +557,7 @@ test_files:
|
|
|
553
557
|
- spec/regression/test_dress_on_recursive_type.rb
|
|
554
558
|
- spec/regression/test_heading_extra_are_proxy_resolved.rb
|
|
555
559
|
- spec/regression/test_name_of_generic_types.rb
|
|
560
|
+
- spec/regression/test_stdlib_boolean_aliases.rb
|
|
556
561
|
- spec/spec_helper.rb
|
|
557
562
|
- spec/support/test_compare_attrs.rb
|
|
558
563
|
- spec/support/test_proc_with_code.rb
|