camille 0.5.9 → 0.5.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/lib/camille/syntax.rb +32 -0
- data/lib/camille/types/object.rb +8 -5
- data/lib/camille/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d5030e35bf654863f03d80dbd09f8adb03b335f3f66d52c745404f6344e7efc
|
4
|
+
data.tar.gz: 7cc7a7000f5ce205f8edabfa31046933b7c7e04a71b18a270a8a080b37ed0c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 746548d7942f95c217ad8763add318a2dab939dbe2fb1abbd26d88b3c7da76023f58946a5622b15d5e3107ea7a88bfb919c78526eac78dbd6f9520d4f6e11469
|
7
|
+
data.tar.gz: 5460ccaaa044c4a4a1255b68d3df78e1f251931a725b26ff36155dd29695c0422097287c07efb0f405d2928aa088022c03fd8bbf64ed652c64f450a688c9d1c1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.5.11
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
|
7
|
+
* Optional fields are now preserved in generated TypeScript as having `?` suffix
|
8
|
+
|
9
|
+
## 0.5.10
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
* Added intersection and boolean literal support to `Camille::Syntax`
|
14
|
+
|
3
15
|
## 0.5.9
|
4
16
|
|
5
17
|
### Added
|
data/Gemfile.lock
CHANGED
data/lib/camille/syntax.rb
CHANGED
@@ -14,6 +14,10 @@ module Camille
|
|
14
14
|
def | other
|
15
15
|
Camille::Types::Union.new(Camille::Types::Object.new(self), other)
|
16
16
|
end
|
17
|
+
|
18
|
+
def & other
|
19
|
+
Camille::Types::Intersection.new(Camille::Types::Object.new(self), other)
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
refine ::Array do
|
@@ -71,5 +75,33 @@ module Camille
|
|
71
75
|
Camille::Types::Union.new(Camille::Types::StringLiteral.new(self), other)
|
72
76
|
end
|
73
77
|
end
|
78
|
+
|
79
|
+
refine TrueClass do
|
80
|
+
def [] key = NULL_VALUE
|
81
|
+
if key == NULL_VALUE
|
82
|
+
Camille::Types::BooleanLiteral.new(true)[]
|
83
|
+
else
|
84
|
+
super
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def | other
|
89
|
+
Camille::Types::Union.new(Camille::Types::BooleanLiteral.new(true), other)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
refine FalseClass do
|
94
|
+
def [] key = NULL_VALUE
|
95
|
+
if key == NULL_VALUE
|
96
|
+
Camille::Types::BooleanLiteral.new(false)[]
|
97
|
+
else
|
98
|
+
super
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def | other
|
103
|
+
Camille::Types::Union.new(Camille::Types::BooleanLiteral.new(false), other)
|
104
|
+
end
|
105
|
+
end
|
74
106
|
end
|
75
107
|
end
|
data/lib/camille/types/object.rb
CHANGED
@@ -14,11 +14,10 @@ module Camille
|
|
14
14
|
keys = (@fields.keys + value.keys).uniq
|
15
15
|
transform_and_check_results = keys.map do |key|
|
16
16
|
if type = @fields[key]
|
17
|
-
|
18
|
-
if @optional_keys.include?(key) && !error && transformed.nil?
|
17
|
+
if @optional_keys.include?(key) && value[key].nil?
|
19
18
|
nil
|
20
19
|
else
|
21
|
-
[key, [
|
20
|
+
[key, type.transform_and_check(value[key])]
|
22
21
|
end
|
23
22
|
else
|
24
23
|
[key, [nil, value[key]]]
|
@@ -43,7 +42,7 @@ module Camille
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def literal
|
46
|
-
"{#{@fields.map{|k,v| "#{
|
45
|
+
"{#{@fields.map{|k,v| "#{literal_key k}: #{v.literal}"}.join(', ')}}"
|
47
46
|
end
|
48
47
|
|
49
48
|
private
|
@@ -54,7 +53,7 @@ module Camille
|
|
54
53
|
if key.end_with?('?')
|
55
54
|
new_key = remove_question_mark(key)
|
56
55
|
@optional_keys << new_key
|
57
|
-
[new_key, type
|
56
|
+
[new_key, type]
|
58
57
|
else
|
59
58
|
[key, type]
|
60
59
|
end
|
@@ -65,6 +64,10 @@ module Camille
|
|
65
64
|
sym.to_s.gsub(/\?$/, '').to_sym
|
66
65
|
end
|
67
66
|
|
67
|
+
def literal_key key
|
68
|
+
"#{ActiveSupport::Inflector.camelize key.to_s, false}#{@optional_keys.include?(key) ? '?' : ''}"
|
69
|
+
end
|
70
|
+
|
68
71
|
def check_case_conversion_safe sym
|
69
72
|
str = sym.to_s
|
70
73
|
if str != str.camelize.underscore
|
data/lib/camille/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camille
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 辻彩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|