jade-lang 0.7.0 → 0.8.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38f4067e761c85016ad9baa6c733e6567aa93eea5cc0ffb755c0ac469a6a0002
|
|
4
|
+
data.tar.gz: 97dd4372b13bcb7e23bdc3ac2dcbe231d067410e9a99634afbbd3bd1a485452e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 415bcc6027fbefa912960d30c004d3d442000b37d6b3e6a27485b9ef9a12685bad3dc79855f7ccd99378987ea38fb6810fafe8f371dad5c50ce9b605c464f756
|
|
7
|
+
data.tar.gz: 8891cbe3dfe48e80cdb2ae73ec96a13b09a3adc8287adf812e7a30639ca4918b417cc02e45148222bacd2f7b1d412b58ce78d15f783dceed0868d0175e194daf
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,21 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.8.0]
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `Assignable` also derives for structs, naming one column per field in
|
|
14
|
+
declaration order. A field renamed to dodge a keyword (`type_`) maps back to
|
|
15
|
+
the column it came from. Generic structs derive at the type they are applied
|
|
16
|
+
to. Inert unless jade-sql is loaded.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- The derived jade-sql interface is now `Sql.Assignable`, was `Sql.SqlMapper`.
|
|
21
|
+
It is matched by name, so jade-sql must move to the new name in the same
|
|
22
|
+
release.
|
|
23
|
+
|
|
9
24
|
## [0.7.0]
|
|
10
25
|
|
|
11
26
|
### Added
|
|
@@ -68,6 +83,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
68
83
|
anonymous record. A project that CI-checks committed artifacts will see a
|
|
69
84
|
diff.
|
|
70
85
|
|
|
86
|
+
|
|
71
87
|
## [0.6.0]
|
|
72
88
|
|
|
73
89
|
### Fixed
|
|
@@ -6,11 +6,11 @@ module Jade
|
|
|
6
6
|
# jade-sql's interface, derived here rather than there: the
|
|
7
7
|
# deriving framework is not extensible, and this stays inert
|
|
8
8
|
# without jade-sql, since nothing else names the interface.
|
|
9
|
-
module
|
|
9
|
+
module Assignable
|
|
10
10
|
extend self
|
|
11
11
|
include Helpers
|
|
12
12
|
|
|
13
|
-
INTERFACE = 'Sql.
|
|
13
|
+
INTERFACE = 'Sql.Assignable'
|
|
14
14
|
ASSIGNMENT = 'Sql.Assignment'
|
|
15
15
|
ASSIGNMENT_FIELDS = %w[col value_sql params].freeze
|
|
16
16
|
|
|
@@ -20,11 +20,11 @@ module Jade
|
|
|
20
20
|
return failed(constraint, entry_name) unless assignment_matches?(registry)
|
|
21
21
|
|
|
22
22
|
case constraint.type
|
|
23
|
-
in Type::Application(constructor: Type::Constructor(name:), args:
|
|
23
|
+
in Type::Application(constructor: Type::Constructor(name:), args:)
|
|
24
24
|
Symbol
|
|
25
25
|
.type_ref_from_qualified_name(name)
|
|
26
26
|
.then { registry.lookup(it) }
|
|
27
|
-
.then { derive_for(constraint, it, registry, lookup, entry_name) }
|
|
27
|
+
.then { derive_for(constraint, it, args, registry, lookup, entry_name) }
|
|
28
28
|
|
|
29
29
|
else
|
|
30
30
|
failed(constraint, entry_name)
|
|
@@ -47,11 +47,14 @@ module Jade
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def derive_for(constraint, symbol, registry, lookup, entry_name)
|
|
50
|
+
def derive_for(constraint, symbol, args, registry, lookup, entry_name)
|
|
51
51
|
case symbol
|
|
52
|
-
in Symbol::Union if single_payload?(symbol, registry)
|
|
52
|
+
in Symbol::Union if args.empty? && single_payload?(symbol, registry)
|
|
53
53
|
derive_union(constraint, symbol, registry, lookup, entry_name)
|
|
54
54
|
|
|
55
|
+
in Symbol::Struct
|
|
56
|
+
derive_struct(constraint, symbol, args, registry, lookup, entry_name)
|
|
57
|
+
|
|
55
58
|
else
|
|
56
59
|
failed(constraint, entry_name)
|
|
57
60
|
end
|
|
@@ -74,6 +77,43 @@ module Jade
|
|
|
74
77
|
.map { implementation(constraint, union_body(vs), it) }
|
|
75
78
|
end
|
|
76
79
|
|
|
80
|
+
def derive_struct(constraint, struct_sym, args, registry, lookup, entry_name)
|
|
81
|
+
fields = struct_fields(struct_sym, args, registry)
|
|
82
|
+
|
|
83
|
+
fields
|
|
84
|
+
.map { |_, type| Type.constraint('Encode.Encodable', type, nil) }
|
|
85
|
+
.map { lookup.call(it) }
|
|
86
|
+
.then { Results.sequence(it) }
|
|
87
|
+
.map { implementation(constraint, struct_body(fields), it) }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def struct_body(fields)
|
|
91
|
+
fields
|
|
92
|
+
.each_with_index
|
|
93
|
+
.map { |(name, _), idx| field_assignment(name, idx) }
|
|
94
|
+
.then { [:list, it] }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def field_assignment(name, idx)
|
|
98
|
+
[:call,
|
|
99
|
+
[:struct_constructor, ASSIGNMENT, 3],
|
|
100
|
+
[
|
|
101
|
+
column_name(name),
|
|
102
|
+
'?',
|
|
103
|
+
[:list,
|
|
104
|
+
[[:call, [:impl_arg, idx, 'encoder'], [[:access, [:var, 'f'], name.to_s]]]],
|
|
105
|
+
],
|
|
106
|
+
],
|
|
107
|
+
]
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def column_name(field)
|
|
111
|
+
field
|
|
112
|
+
.to_s
|
|
113
|
+
.then { it.end_with?('_') ? it.delete_suffix('_') : it }
|
|
114
|
+
.then { Lexer::KEYWORDS.include?(it) ? it : field.to_s }
|
|
115
|
+
end
|
|
116
|
+
|
|
77
117
|
def encodable_dep(variant, registry)
|
|
78
118
|
variant
|
|
79
119
|
.args
|
|
@@ -2,7 +2,7 @@ require_relative './deriving/helpers.rb'
|
|
|
2
2
|
require_relative './deriving/eq.rb'
|
|
3
3
|
require_relative './deriving/decodable.rb'
|
|
4
4
|
require_relative './deriving/encodable.rb'
|
|
5
|
-
require_relative './deriving/
|
|
5
|
+
require_relative './deriving/assignable.rb'
|
|
6
6
|
require_relative './deriving/show.rb'
|
|
7
7
|
|
|
8
8
|
module Jade
|
|
@@ -12,7 +12,7 @@ module Jade
|
|
|
12
12
|
module Deriving
|
|
13
13
|
extend self
|
|
14
14
|
|
|
15
|
-
DERIVERS = [Eq, Show, Decodable, Encodable,
|
|
15
|
+
DERIVERS = [Eq, Show, Decodable, Encodable, Assignable]
|
|
16
16
|
|
|
17
17
|
def derivable?(interface)
|
|
18
18
|
DERIVERS.any? { it.supports?(interface) }
|
data/lib/jade/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jade-lang
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Agustin Cornu
|
|
@@ -218,12 +218,12 @@ files:
|
|
|
218
218
|
- lib/jade/frontend/type_checking/canonicalize.rb
|
|
219
219
|
- lib/jade/frontend/type_checking/constraints.rb
|
|
220
220
|
- lib/jade/frontend/type_checking/constraints/deriving.rb
|
|
221
|
+
- lib/jade/frontend/type_checking/constraints/deriving/assignable.rb
|
|
221
222
|
- lib/jade/frontend/type_checking/constraints/deriving/decodable.rb
|
|
222
223
|
- lib/jade/frontend/type_checking/constraints/deriving/encodable.rb
|
|
223
224
|
- lib/jade/frontend/type_checking/constraints/deriving/eq.rb
|
|
224
225
|
- lib/jade/frontend/type_checking/constraints/deriving/helpers.rb
|
|
225
226
|
- lib/jade/frontend/type_checking/constraints/deriving/show.rb
|
|
226
|
-
- lib/jade/frontend/type_checking/constraints/deriving/sql_mapper.rb
|
|
227
227
|
- lib/jade/frontend/type_checking/definition.rb
|
|
228
228
|
- lib/jade/frontend/type_checking/env.rb
|
|
229
229
|
- lib/jade/frontend/type_checking/error.rb
|