camille 0.4.3 → 0.5.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 +6 -0
- data/README.md +3 -3
- data/lib/camille/pick_and_omit.rb +6 -20
- data/lib/camille/types/omit.rb +1 -1
- data/lib/camille/types/pick.rb +1 -1
- data/lib/camille/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acda60cf2aee3c70aadf0aa040f5b79832aa8fe44c8d92f8e305715a0edf7e36
|
4
|
+
data.tar.gz: 9c1b5c69c2638336c8341a2f9182d097f8276b8df21506365e69846aa71596f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4772765b95039fc3309e4eddd9a406cd0c1c94e9fca0c31e8dc283677ee9cc42620ba3acefbcc946818a44e1e78945eba798109e51bcf0ceccf6c858eff336a9
|
7
|
+
data.tar.gz: b90680ff5e4646237c856c26bc6c54bbccb3c2c38d69a670d95c81b7232d466ab95d27ffdd362829da985e204d648b9d81b7cfb83f51e989019324321fad4c9f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -158,9 +158,9 @@ params(
|
|
158
158
|
string_literal: 'hello',
|
159
159
|
# a custom type we defined above
|
160
160
|
product: Product,
|
161
|
-
# Pick and Omit
|
162
|
-
pick: Pick[{a: 1, b: 2},
|
163
|
-
omit: Omit[Product,
|
161
|
+
# Pick and Omit accepts a type and an array of symbols
|
162
|
+
pick: Pick[{a: 1, b: 2}, [:a, :b]],
|
163
|
+
omit: Omit[Product, [:id]]
|
164
164
|
)
|
165
165
|
```
|
166
166
|
|
@@ -14,24 +14,14 @@ module Camille
|
|
14
14
|
raise ArgumentError.new("Currently onle an object type or an alias of object type is supported in #{klass_name}. Got #{type.inspect}.")
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
when @keys.is_a?(Camille::Types::StringLiteral)
|
20
|
-
@keys_array = [@keys.value].map(&:to_sym)
|
21
|
-
when @keys.is_a?(Camille::Types::Union)
|
22
|
-
unfolded = unfold_union(@keys).flatten
|
23
|
-
if unfolded.all?{|x| x.is_a?(Camille::Types::StringLiteral)}
|
24
|
-
@keys_array = unfolded.map(&:value).map(&:to_sym)
|
25
|
-
else
|
26
|
-
raise ArgumentError.new("The second argument of #{klass_name} has to be a string literal or an union of string literals. Got #{keys.inspect}.")
|
27
|
-
end
|
28
|
-
else
|
29
|
-
raise ArgumentError.new("The second argument of #{klass_name} has to be a string literal or an union of string literals. Got #{keys.inspect}.")
|
17
|
+
unless keys.is_a?(::Array) && !keys.empty? && keys.all?{|x| x.is_a? Symbol}
|
18
|
+
raise ArgumentError.new("The second argument of #{klass_name} has to be an array of symbols. Got #{keys.inspect}.")
|
30
19
|
end
|
20
|
+
@keys = keys
|
31
21
|
end
|
32
22
|
|
33
23
|
def literal
|
34
|
-
"#{klass_name}<#{@type.literal}, #{
|
24
|
+
"#{klass_name}<#{@type.literal}, #{keys_in_literal}>"
|
35
25
|
end
|
36
26
|
|
37
27
|
def self.[] type, keys
|
@@ -39,12 +29,8 @@ module Camille
|
|
39
29
|
end
|
40
30
|
|
41
31
|
private
|
42
|
-
def
|
43
|
-
|
44
|
-
[unfold_union(type.left), unfold_union(type.right)]
|
45
|
-
else
|
46
|
-
[type]
|
47
|
-
end
|
32
|
+
def keys_in_literal
|
33
|
+
@keys.map{|k| "\"#{k.to_s.camelize(:lower)}\""}.join(' | ')
|
48
34
|
end
|
49
35
|
|
50
36
|
end
|
data/lib/camille/types/omit.rb
CHANGED
data/lib/camille/types/pick.rb
CHANGED
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 辻彩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.4.1
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Typed API schema for Rails with TypeScript codegen
|