finitio 0.0.1 → 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.
- data/CHANGELOG.md +22 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +64 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +11 -0
- data/README.md +148 -0
- data/Rakefile +11 -0
- data/finitio.gemspec +186 -0
- data/lib/finitio.rb +66 -0
- data/lib/finitio/Finitio/default.fio +29 -0
- data/lib/finitio/data_type.rb +29 -0
- data/lib/finitio/errors.rb +23 -0
- data/lib/finitio/support.rb +5 -0
- data/lib/finitio/support/attribute.rb +53 -0
- data/lib/finitio/support/collection_type.rb +25 -0
- data/lib/finitio/support/dress_helper.rb +68 -0
- data/lib/finitio/support/heading.rb +57 -0
- data/lib/finitio/support/type_factory.rb +184 -0
- data/lib/finitio/syntax.rb +50 -0
- data/lib/finitio/syntax/ad_type.rb +32 -0
- data/lib/finitio/syntax/any_type.rb +16 -0
- data/lib/finitio/syntax/attribute.rb +15 -0
- data/lib/finitio/syntax/builtin_type.rb +17 -0
- data/lib/finitio/syntax/constraint_def.rb +17 -0
- data/lib/finitio/syntax/constraints.rb +22 -0
- data/lib/finitio/syntax/contract.rb +37 -0
- data/lib/finitio/syntax/definitions.rb +18 -0
- data/lib/finitio/syntax/expression.rb +12 -0
- data/lib/finitio/syntax/external_pair.rb +17 -0
- data/lib/finitio/syntax/finitio.citrus +220 -0
- data/lib/finitio/syntax/finitio.sexp +114 -0
- data/lib/finitio/syntax/heading.rb +19 -0
- data/lib/finitio/syntax/inline_pair.rb +16 -0
- data/lib/finitio/syntax/lambda_expr.rb +15 -0
- data/lib/finitio/syntax/named_constraint.rb +17 -0
- data/lib/finitio/syntax/relation_type.rb +15 -0
- data/lib/finitio/syntax/seq_type.rb +16 -0
- data/lib/finitio/syntax/set_type.rb +16 -0
- data/lib/finitio/syntax/sub_type.rb +17 -0
- data/lib/finitio/syntax/support.rb +13 -0
- data/lib/finitio/syntax/system.rb +21 -0
- data/lib/finitio/syntax/tuple_type.rb +15 -0
- data/lib/finitio/syntax/type_def.rb +18 -0
- data/lib/finitio/syntax/type_ref.rb +17 -0
- data/lib/finitio/syntax/union_type.rb +16 -0
- data/lib/finitio/syntax/unnamed_constraint.rb +17 -0
- data/lib/finitio/system.rb +63 -0
- data/lib/finitio/type.rb +64 -0
- data/lib/finitio/type/ad_type.rb +112 -0
- data/lib/finitio/type/any_type.rb +47 -0
- data/lib/finitio/type/builtin_type.rb +56 -0
- data/lib/finitio/type/relation_type.rb +81 -0
- data/lib/finitio/type/seq_type.rb +51 -0
- data/lib/finitio/type/set_type.rb +52 -0
- data/lib/finitio/type/sub_type.rb +94 -0
- data/lib/finitio/type/tuple_type.rb +99 -0
- data/lib/finitio/type/union_type.rb +78 -0
- data/lib/finitio/version.rb +14 -0
- data/spec/acceptance/Finitio/test_default.rb +96 -0
- data/spec/acceptance/Finitio/test_parsing.rb +15 -0
- data/spec/acceptance/ad_type/test_in_finitio.rb +82 -0
- data/spec/acceptance/ad_type/test_in_ruby.rb +60 -0
- data/spec/spec_helper.rb +79 -0
- data/spec/unit/attribute/test_equality.rb +26 -0
- data/spec/unit/attribute/test_fetch_on.rb +50 -0
- data/spec/unit/attribute/test_initialize.rb +13 -0
- data/spec/unit/attribute/test_to_name.rb +10 -0
- data/spec/unit/heading/test_each.rb +28 -0
- data/spec/unit/heading/test_equality.rb +28 -0
- data/spec/unit/heading/test_initialize.rb +36 -0
- data/spec/unit/heading/test_size.rb +30 -0
- data/spec/unit/heading/test_to_name.rb +32 -0
- data/spec/unit/qrb/system.q +1 -0
- data/spec/unit/qrb/test_ast.rb +43 -0
- data/spec/unit/qrb/test_parse.rb +32 -0
- data/spec/unit/syntax/nodes/test_ad_type.rb +166 -0
- data/spec/unit/syntax/nodes/test_any_type.rb +30 -0
- data/spec/unit/syntax/nodes/test_attribute.rb +38 -0
- data/spec/unit/syntax/nodes/test_builtin_type.rb +44 -0
- data/spec/unit/syntax/nodes/test_comment.rb +26 -0
- data/spec/unit/syntax/nodes/test_constraint_def.rb +41 -0
- data/spec/unit/syntax/nodes/test_constraints.rb +86 -0
- data/spec/unit/syntax/nodes/test_contract.rb +134 -0
- data/spec/unit/syntax/nodes/test_expression.rb +43 -0
- data/spec/unit/syntax/nodes/test_heading.rb +58 -0
- data/spec/unit/syntax/nodes/test_named_constraint.rb +43 -0
- data/spec/unit/syntax/nodes/test_relation_type.rb +59 -0
- data/spec/unit/syntax/nodes/test_seq_type.rb +38 -0
- data/spec/unit/syntax/nodes/test_set_type.rb +38 -0
- data/spec/unit/syntax/nodes/test_spacing.rb +25 -0
- data/spec/unit/syntax/nodes/test_sub_type.rb +81 -0
- data/spec/unit/syntax/nodes/test_system.rb +48 -0
- data/spec/unit/syntax/nodes/test_tuple_type.rb +59 -0
- data/spec/unit/syntax/nodes/test_type_def.rb +33 -0
- data/spec/unit/syntax/nodes/test_type_ref.rb +37 -0
- data/spec/unit/syntax/nodes/test_union_type.rb +38 -0
- data/spec/unit/syntax/nodes/test_unnamed_constraint.rb +43 -0
- data/spec/unit/syntax/test_compile_type.rb +22 -0
- data/spec/unit/system/test_add_type.rb +47 -0
- data/spec/unit/system/test_dsl.rb +30 -0
- data/spec/unit/system/test_dup.rb +30 -0
- data/spec/unit/system/test_fetch.rb +42 -0
- data/spec/unit/system/test_get_type.rb +30 -0
- data/spec/unit/system/test_initialize.rb +10 -0
- data/spec/unit/test_finitio.rb +15 -0
- data/spec/unit/type/ad_type/test_default_name.rb +15 -0
- data/spec/unit/type/ad_type/test_dress.rb +55 -0
- data/spec/unit/type/ad_type/test_include.rb +22 -0
- data/spec/unit/type/ad_type/test_initialize.rb +40 -0
- data/spec/unit/type/ad_type/test_name.rb +20 -0
- data/spec/unit/type/any_type/test_default_name.rb +12 -0
- data/spec/unit/type/any_type/test_dress.rb +22 -0
- data/spec/unit/type/any_type/test_equality.rb +26 -0
- data/spec/unit/type/any_type/test_include.rb +22 -0
- data/spec/unit/type/any_type/test_initialize.rb +10 -0
- data/spec/unit/type/any_type/test_name.rb +24 -0
- data/spec/unit/type/builtin_type/test_default_name.rb +12 -0
- data/spec/unit/type/builtin_type/test_dress.rb +33 -0
- data/spec/unit/type/builtin_type/test_equality.rb +26 -0
- data/spec/unit/type/builtin_type/test_include.rb +22 -0
- data/spec/unit/type/builtin_type/test_initialize.rb +12 -0
- data/spec/unit/type/builtin_type/test_name.rb +24 -0
- data/spec/unit/type/relation_type/test_default_name.rb +16 -0
- data/spec/unit/type/relation_type/test_dress.rb +164 -0
- data/spec/unit/type/relation_type/test_equality.rb +32 -0
- data/spec/unit/type/relation_type/test_include.rb +46 -0
- data/spec/unit/type/relation_type/test_initialize.rb +26 -0
- data/spec/unit/type/relation_type/test_name.rb +24 -0
- data/spec/unit/type/seq_type/test_default_name.rb +14 -0
- data/spec/unit/type/seq_type/test_dress.rb +49 -0
- data/spec/unit/type/seq_type/test_equality.rb +26 -0
- data/spec/unit/type/seq_type/test_include.rb +43 -0
- data/spec/unit/type/seq_type/test_initialize.rb +28 -0
- data/spec/unit/type/seq_type/test_name.rb +24 -0
- data/spec/unit/type/set_type/test_default_name.rb +14 -0
- data/spec/unit/type/set_type/test_dress.rb +66 -0
- data/spec/unit/type/set_type/test_equality.rb +26 -0
- data/spec/unit/type/set_type/test_include.rb +43 -0
- data/spec/unit/type/set_type/test_initialize.rb +28 -0
- data/spec/unit/type/set_type/test_name.rb +24 -0
- data/spec/unit/type/sub_type/test_default_name.rb +14 -0
- data/spec/unit/type/sub_type/test_dress.rb +75 -0
- data/spec/unit/type/sub_type/test_equality.rb +34 -0
- data/spec/unit/type/sub_type/test_include.rb +34 -0
- data/spec/unit/type/sub_type/test_initialize.rb +16 -0
- data/spec/unit/type/sub_type/test_name.rb +24 -0
- data/spec/unit/type/tuple_type/test_default_name.rb +14 -0
- data/spec/unit/type/tuple_type/test_dress.rb +112 -0
- data/spec/unit/type/tuple_type/test_equality.rb +32 -0
- data/spec/unit/type/tuple_type/test_include.rb +38 -0
- data/spec/unit/type/tuple_type/test_initialize.rb +30 -0
- data/spec/unit/type/tuple_type/test_name.rb +24 -0
- data/spec/unit/type/union_type/test_default_name.rb +12 -0
- data/spec/unit/type/union_type/test_dress.rb +43 -0
- data/spec/unit/type/union_type/test_equality.rb +30 -0
- data/spec/unit/type/union_type/test_include.rb +28 -0
- data/spec/unit/type/union_type/test_initialize.rb +24 -0
- data/spec/unit/type/union_type/test_name.rb +20 -0
- data/spec/unit/type_factory/dsl/test_adt.rb +54 -0
- data/spec/unit/type_factory/dsl/test_any.rb +28 -0
- data/spec/unit/type_factory/dsl/test_attribute.rb +37 -0
- data/spec/unit/type_factory/dsl/test_attributes.rb +41 -0
- data/spec/unit/type_factory/dsl/test_builtin.rb +45 -0
- data/spec/unit/type_factory/dsl/test_relation.rb +85 -0
- data/spec/unit/type_factory/dsl/test_seq.rb +57 -0
- data/spec/unit/type_factory/dsl/test_set.rb +57 -0
- data/spec/unit/type_factory/dsl/test_subtype.rb +91 -0
- data/spec/unit/type_factory/dsl/test_tuple.rb +73 -0
- data/spec/unit/type_factory/dsl/test_union.rb +81 -0
- data/spec/unit/type_factory/factory/test_builtin.rb +24 -0
- data/spec/unit/type_factory/factory/test_seq_type.rb +44 -0
- data/spec/unit/type_factory/factory/test_set_type.rb +44 -0
- data/spec/unit/type_factory/factory/test_sub_type.rb +53 -0
- data/spec/unit/type_factory/factory/test_tuple_type.rb +43 -0
- data/tasks/gem.rake +73 -0
- data/tasks/test.rake +31 -0
- metadata +323 -7
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 0.4.0 / 2014-03-20
|
|
2
|
+
|
|
3
|
+
* Finitio(-rb) is born from the sources of Q(rb) 0.3.0
|
|
4
|
+
* Finitio.parse now recognizes Path-like objects (responding to :to_path),
|
|
5
|
+
allowing to parse files directly (through Pathname, Path, etc.).
|
|
6
|
+
|
|
7
|
+
# 0.3.0 / 2014-03-09
|
|
8
|
+
|
|
9
|
+
* Added AnyType abstraction, aka '.'
|
|
10
|
+
* Added support for external contracts in ADTs
|
|
11
|
+
* Added support for extracting an Abstract Syntax Tree from parsing result
|
|
12
|
+
* Allows camelCasing in constraint names
|
|
13
|
+
|
|
14
|
+
# 0.2.0 / 2014-03-04
|
|
15
|
+
|
|
16
|
+
* Fix dependencies in gemspec (judofyr)
|
|
17
|
+
|
|
18
|
+
# 0.1.0 / 2014-03-03
|
|
19
|
+
|
|
20
|
+
* Enhancements
|
|
21
|
+
|
|
22
|
+
* Birthday!
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
finitio (0.4.0)
|
|
5
|
+
citrus (~> 2.4)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
awesome_print (1.2.0)
|
|
11
|
+
builder (3.2.2)
|
|
12
|
+
citrus (2.4.1)
|
|
13
|
+
coveralls (0.7.0)
|
|
14
|
+
multi_json (~> 1.3)
|
|
15
|
+
rest-client
|
|
16
|
+
simplecov (>= 0.7)
|
|
17
|
+
term-ansicolor
|
|
18
|
+
thor
|
|
19
|
+
cucumber (1.3.8)
|
|
20
|
+
builder (>= 2.1.2)
|
|
21
|
+
diff-lcs (>= 1.1.3)
|
|
22
|
+
gherkin (~> 2.12.1)
|
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
|
24
|
+
multi_test (>= 0.0.2)
|
|
25
|
+
diff-lcs (1.2.5)
|
|
26
|
+
docile (1.1.3)
|
|
27
|
+
gherkin (2.12.2)
|
|
28
|
+
multi_json (~> 1.3)
|
|
29
|
+
mime-types (2.1)
|
|
30
|
+
multi_json (1.8.4)
|
|
31
|
+
multi_test (0.0.2)
|
|
32
|
+
path (1.3.3)
|
|
33
|
+
rake (10.1.1)
|
|
34
|
+
rest-client (1.6.7)
|
|
35
|
+
mime-types (>= 1.16)
|
|
36
|
+
rspec (2.14.1)
|
|
37
|
+
rspec-core (~> 2.14.0)
|
|
38
|
+
rspec-expectations (~> 2.14.0)
|
|
39
|
+
rspec-mocks (~> 2.14.0)
|
|
40
|
+
rspec-core (2.14.7)
|
|
41
|
+
rspec-expectations (2.14.4)
|
|
42
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
|
43
|
+
rspec-mocks (2.14.4)
|
|
44
|
+
simplecov (0.8.2)
|
|
45
|
+
docile (~> 1.1.0)
|
|
46
|
+
multi_json
|
|
47
|
+
simplecov-html (~> 0.8.0)
|
|
48
|
+
simplecov-html (0.8.0)
|
|
49
|
+
term-ansicolor (1.3.0)
|
|
50
|
+
tins (~> 1.0)
|
|
51
|
+
thor (0.18.1)
|
|
52
|
+
tins (1.0.0)
|
|
53
|
+
|
|
54
|
+
PLATFORMS
|
|
55
|
+
ruby
|
|
56
|
+
|
|
57
|
+
DEPENDENCIES
|
|
58
|
+
awesome_print (~> 1.2)
|
|
59
|
+
coveralls
|
|
60
|
+
cucumber (~> 1.3)
|
|
61
|
+
finitio!
|
|
62
|
+
path (~> 1.3)
|
|
63
|
+
rake (~> 10.0)
|
|
64
|
+
rspec (~> 2.14)
|
data/LICENCE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# The MIT Licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 - Bernard Lambeau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
[](https://travis-ci.org/blambeau/finitio-rb)
|
|
2
|
+
[](https://gemnasium.com/blambeau/finitio-rb)
|
|
3
|
+
[](https://codeclimate.com/github/blambeau/finitio-rb)
|
|
4
|
+
[](https://coveralls.io/r/blambeau/finitio-rb)
|
|
5
|
+
|
|
6
|
+
# Finitio(-rb)
|
|
7
|
+
|
|
8
|
+
*Finitio* is a language for capturing information structure. Think "JSON/XML
|
|
9
|
+
schema" but the right way. For more information about *Finitio* itself, see
|
|
10
|
+
[www.finitio.io](http://www.finitio.io)
|
|
11
|
+
|
|
12
|
+
`finitio-rb` is the ruby binding of *Finitio*. It allows defining data schemas
|
|
13
|
+
and validating and coercing data against them in an idiomatic ruby way.
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
require 'finitio'
|
|
19
|
+
require 'json'
|
|
20
|
+
|
|
21
|
+
# Let load a schema
|
|
22
|
+
schema = Finitio::DEFAULT_SYSTEM.parse <<-FIO
|
|
23
|
+
{
|
|
24
|
+
name: String( s | s.strip.size > 0 ),
|
|
25
|
+
at: DateTime
|
|
26
|
+
}
|
|
27
|
+
FIO
|
|
28
|
+
|
|
29
|
+
# Let load some JSON document
|
|
30
|
+
data = JSON.parse <<-JSON
|
|
31
|
+
{ "name": "Finitio", "at": "20142-03-01" }
|
|
32
|
+
JSON
|
|
33
|
+
|
|
34
|
+
# And try dressing that data
|
|
35
|
+
puts schema.dress(data)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## ADTs with internal contracts
|
|
39
|
+
|
|
40
|
+
`finitio-rb` tries to provide an idiomatic binding for ruby developers. In
|
|
41
|
+
particular, it uses a simple convention-over-configuration protocol for
|
|
42
|
+
information contracts. This protocol is easily described through an example.
|
|
43
|
+
The following ADT definition:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
Color = .Color <rgb> {r: Byte, g: Byte, b: Byte}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
expects the following ruby class:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
class Color
|
|
53
|
+
|
|
54
|
+
# Constructor & internal representation
|
|
55
|
+
def initialize(r, g, b)
|
|
56
|
+
@r, @g, @b = r, g, b
|
|
57
|
+
end
|
|
58
|
+
attr_reader :r, :g, :b
|
|
59
|
+
|
|
60
|
+
# Public dresser for the RGB information contract on the class
|
|
61
|
+
def self.rgb(tuple)
|
|
62
|
+
new(tuple[:r], tuple[:g], tuple[:b])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Public undresser on the instance
|
|
66
|
+
def to_rgb
|
|
67
|
+
{ r: @r, g: @g, b: @b }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# ...
|
|
71
|
+
|
|
72
|
+
end
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## ADTs with external contracts
|
|
76
|
+
|
|
77
|
+
When the scenario above is not possible or not wanted (would require core
|
|
78
|
+
extensions for instance), `finitio-rb` allows defining ADTs with external
|
|
79
|
+
contracts. The following ADT definition:
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
Color = .Color <rgb> {r: Byte, g: Byte, b: Byte} .RgbContract
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
expected the following ruby module:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
module RgbContract
|
|
89
|
+
|
|
90
|
+
def self.dress(tuple)
|
|
91
|
+
Color.new(tuple[:r], tuple[:g], tuple[:b])
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def self.undress(color)
|
|
95
|
+
{ r: color.r, g: color.g, b: color.b }
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## About representations
|
|
102
|
+
|
|
103
|
+
The `Rep` representation function mapping *Finitio* types to ruby classes is
|
|
104
|
+
as follows:
|
|
105
|
+
|
|
106
|
+
```ruby
|
|
107
|
+
# Any type is represented by Ruby's Object class
|
|
108
|
+
Rep(.) = Object
|
|
109
|
+
|
|
110
|
+
# Builtins are represented by the corresponding ruby class
|
|
111
|
+
Rep(.Builtin) = Builtin
|
|
112
|
+
|
|
113
|
+
# Sub types are represented by the same representation as the super type
|
|
114
|
+
Rep(SuperType( s | ... )) = Rep(SuperType)
|
|
115
|
+
|
|
116
|
+
# Unions are represented by the corresponding classes. The guaranteed result
|
|
117
|
+
# class is thus the least common super class (^) of the corresponding
|
|
118
|
+
# representations of candidate types
|
|
119
|
+
Rep(T1 | ... | Tn) = Rep(T1) ^ ... ^ Rep(Tn)
|
|
120
|
+
|
|
121
|
+
# Sequences are represented through ::Array.
|
|
122
|
+
Rep([ElmType]) = Array<Rep(ElmType)>
|
|
123
|
+
|
|
124
|
+
# Sets are represented through ::Set.
|
|
125
|
+
Rep({ElmType}) = Set<Rep(ElmType)>
|
|
126
|
+
|
|
127
|
+
# Tuples are represented through ruby ::Hash. Attribute names are always
|
|
128
|
+
# symbolized
|
|
129
|
+
Rep({Ai => Ti}) = Hash<Symbol => Rep(Ti)>
|
|
130
|
+
|
|
131
|
+
# Relations are represented through ruby ::Set of ::Hash.
|
|
132
|
+
Rep({{Ai => Ti}}) = Set<Hash<Symbol => Rep(Ti)>>
|
|
133
|
+
|
|
134
|
+
# Abstract data types are represented through the corresponding class when
|
|
135
|
+
# specified. ADTs behave as Union types if no class is bound.
|
|
136
|
+
Rep(.Builtin <rep> ...) = Builtin
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## About the default system
|
|
140
|
+
|
|
141
|
+
See `lib/finitio/Finitio/default.fio` for the precise definition of the default
|
|
142
|
+
system. In summary,
|
|
143
|
+
|
|
144
|
+
* Most ruby native (data) classes are already aliased to avoid explicit use of
|
|
145
|
+
builtins. In particular, `Integer`, `String`, etc.
|
|
146
|
+
* A `Boolean` union type also hides the TrueClass and FalseClass distinction.
|
|
147
|
+
* Date, Time and DateTime ADTs are also provided that perform common
|
|
148
|
+
conversions from JSON strings, through iso8601.
|
data/Rakefile
ADDED
data/finitio.gemspec
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# We require your library, mainly to have access to the VERSION number.
|
|
2
|
+
# Feel free to set $version manually.
|
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
4
|
+
require "finitio/version"
|
|
5
|
+
$version = Finitio::Version.to_s
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# This is your Gem specification. Default values are provided so that your library
|
|
9
|
+
# should be correctly packaged given what you have described in the .noespec file.
|
|
10
|
+
#
|
|
11
|
+
Gem::Specification.new do |s|
|
|
12
|
+
|
|
13
|
+
################################################################### ABOUT YOUR GEM
|
|
14
|
+
|
|
15
|
+
# Gem name (required)
|
|
16
|
+
s.name = "finitio"
|
|
17
|
+
|
|
18
|
+
# Gem version (required)
|
|
19
|
+
s.version = $version
|
|
20
|
+
|
|
21
|
+
# A short summary of this gem
|
|
22
|
+
#
|
|
23
|
+
# This is displayed in `gem list -d`.
|
|
24
|
+
s.summary = "Finitio - in Ruby"
|
|
25
|
+
|
|
26
|
+
# A long description of this gem (required)
|
|
27
|
+
#
|
|
28
|
+
# The description should be more detailed than the summary. For example,
|
|
29
|
+
# you might wish to copy the entire README into the description.
|
|
30
|
+
s.description = "Implements the Finitio information language in Ruby."
|
|
31
|
+
|
|
32
|
+
# The URL of this gem home page (optional)
|
|
33
|
+
s.homepage = "https://github.com/blambeau/finitio"
|
|
34
|
+
|
|
35
|
+
# Gem publication date (required but auto)
|
|
36
|
+
#
|
|
37
|
+
# Today is automatically used by default, uncomment only if
|
|
38
|
+
# you know what you do!
|
|
39
|
+
#
|
|
40
|
+
# s.date = Time.now.strftime('%Y-%m-%d')
|
|
41
|
+
|
|
42
|
+
# The license(s) for the library. Each license must be a short name, no
|
|
43
|
+
# more than 64 characters.
|
|
44
|
+
#
|
|
45
|
+
# s.licences = %w{}
|
|
46
|
+
|
|
47
|
+
# The rubyforge project this gem lives under (optional)
|
|
48
|
+
#
|
|
49
|
+
# s.rubyforge_project = nil
|
|
50
|
+
|
|
51
|
+
################################################################### ABOUT THE AUTHORS
|
|
52
|
+
|
|
53
|
+
# The list of author names who wrote this gem.
|
|
54
|
+
#
|
|
55
|
+
# If you are providing multiple authors and multiple emails they should be
|
|
56
|
+
# in the same order.
|
|
57
|
+
#
|
|
58
|
+
s.authors = ["Bernard Lambeau"]
|
|
59
|
+
|
|
60
|
+
# Contact emails for this gem
|
|
61
|
+
#
|
|
62
|
+
# If you are providing multiple authors and multiple emails they should be
|
|
63
|
+
# in the same order.
|
|
64
|
+
#
|
|
65
|
+
# NOTE: Somewhat strangly this attribute is always singular!
|
|
66
|
+
# Don't replace by s.emails = ...
|
|
67
|
+
s.email = ["blambeau@gmail.com"]
|
|
68
|
+
|
|
69
|
+
################################################################### PATHS, FILES, BINARIES
|
|
70
|
+
|
|
71
|
+
# Paths in the gem to add to $LOAD_PATH when this gem is
|
|
72
|
+
# activated (required).
|
|
73
|
+
#
|
|
74
|
+
# The default 'lib' is typically sufficient.
|
|
75
|
+
s.require_paths = ["lib"]
|
|
76
|
+
|
|
77
|
+
# Files included in this gem.
|
|
78
|
+
#
|
|
79
|
+
# By default, we take all files included in the Manifest.txt file on root
|
|
80
|
+
# of the project. Entries of the manifest are interpreted as Dir[...]
|
|
81
|
+
# patterns so that lazy people may use wilcards like lib/**/*
|
|
82
|
+
#
|
|
83
|
+
here = File.expand_path(File.dirname(__FILE__))
|
|
84
|
+
s.files = File.readlines(File.join(here, 'Manifest.txt')).
|
|
85
|
+
inject([]){|files, pattern| files + Dir[File.join(here, pattern.strip)]}.
|
|
86
|
+
collect{|x| x[(1+here.size)..-1]}
|
|
87
|
+
|
|
88
|
+
# Test files included in this gem.
|
|
89
|
+
#
|
|
90
|
+
s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
|
|
91
|
+
|
|
92
|
+
# The path in the gem for executable scripts (optional)
|
|
93
|
+
#
|
|
94
|
+
s.bindir = "bin"
|
|
95
|
+
|
|
96
|
+
# Executables included in the gem.
|
|
97
|
+
#
|
|
98
|
+
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
|
99
|
+
|
|
100
|
+
################################################################### REQUIREMENTS & INSTALL
|
|
101
|
+
# Remember the gem version requirements operators and schemes:
|
|
102
|
+
# = Equals version
|
|
103
|
+
# != Not equal to version
|
|
104
|
+
# > Greater than version
|
|
105
|
+
# < Less than version
|
|
106
|
+
# >= Greater than or equal to
|
|
107
|
+
# <= Less than or equal to
|
|
108
|
+
# ~> Approximately greater than
|
|
109
|
+
#
|
|
110
|
+
# Don't forget to have a look at http://lmgtfy.com/?q=Ruby+Versioning+Policies
|
|
111
|
+
# for setting your gem version.
|
|
112
|
+
#
|
|
113
|
+
# For your requirements to other gems, remember that
|
|
114
|
+
# ">= 2.2.0" (optimistic: specify minimal version)
|
|
115
|
+
# ">= 2.2.0", "< 3.0" (pessimistic: not greater than the next major)
|
|
116
|
+
# "~> 2.2" (shortcut for ">= 2.2.0", "< 3.0")
|
|
117
|
+
# "~> 2.2.0" (shortcut for ">= 2.2.0", "< 2.3.0")
|
|
118
|
+
#
|
|
119
|
+
s.add_dependency("citrus", "~> 2.4")
|
|
120
|
+
|
|
121
|
+
#
|
|
122
|
+
# One call to add_dependency('gem_name', 'gem version requirement') for each
|
|
123
|
+
# runtime dependency. These gems will be installed with your gem.
|
|
124
|
+
# One call to add_development_dependency('gem_name', 'gem version requirement')
|
|
125
|
+
# for each development dependency. These gems are required for developers
|
|
126
|
+
#
|
|
127
|
+
# We use Gemfile for development dependencies.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
# The version of ruby required by this gem
|
|
131
|
+
#
|
|
132
|
+
# Uncomment and set this if your gem requires specific ruby versions.
|
|
133
|
+
#
|
|
134
|
+
# s.required_ruby_version = ">= 0"
|
|
135
|
+
|
|
136
|
+
# The RubyGems version required by this gem
|
|
137
|
+
#
|
|
138
|
+
# s.required_rubygems_version = ">= 0"
|
|
139
|
+
|
|
140
|
+
# The platform this gem runs on. See Gem::Platform for details.
|
|
141
|
+
#
|
|
142
|
+
# s.platform = nil
|
|
143
|
+
|
|
144
|
+
# Extensions to build when installing the gem.
|
|
145
|
+
#
|
|
146
|
+
# Valid types of extensions are extconf.rb files, configure scripts
|
|
147
|
+
# and rakefiles or mkrf_conf files.
|
|
148
|
+
#
|
|
149
|
+
s.extensions = []
|
|
150
|
+
|
|
151
|
+
# External (to RubyGems) requirements that must be met for this gem to work.
|
|
152
|
+
# It’s simply information for the user.
|
|
153
|
+
#
|
|
154
|
+
s.requirements = nil
|
|
155
|
+
|
|
156
|
+
# A message that gets displayed after the gem is installed
|
|
157
|
+
#
|
|
158
|
+
# Uncomment and set this if you want to say something to the user
|
|
159
|
+
# after gem installation
|
|
160
|
+
#
|
|
161
|
+
s.post_install_message = nil
|
|
162
|
+
|
|
163
|
+
################################################################### SECURITY
|
|
164
|
+
|
|
165
|
+
# The key used to sign this gem. See Gem::Security for details.
|
|
166
|
+
#
|
|
167
|
+
# s.signing_key = nil
|
|
168
|
+
|
|
169
|
+
# The certificate chain used to sign this gem. See Gem::Security for
|
|
170
|
+
# details.
|
|
171
|
+
#
|
|
172
|
+
# s.cert_chain = []
|
|
173
|
+
|
|
174
|
+
################################################################### RDOC
|
|
175
|
+
|
|
176
|
+
# An ARGV style array of options to RDoc
|
|
177
|
+
#
|
|
178
|
+
# See 'rdoc --help' about this
|
|
179
|
+
#
|
|
180
|
+
s.rdoc_options = []
|
|
181
|
+
|
|
182
|
+
# Extra files to add to RDoc such as README
|
|
183
|
+
#
|
|
184
|
+
s.extra_rdoc_files = Dir["README.md"] + Dir["CHANGELOG.md"] + Dir["LICENCE.md"]
|
|
185
|
+
|
|
186
|
+
end
|