camille 0.4.3 → 0.5.1
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 +2 -2
- data/README.md +7 -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/types/union.rb +1 -1
- 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: 54ba62877d8151101a93641018cc5516967bac05b2c437accc5861bd50f640da
|
4
|
+
data.tar.gz: 7097f8975cce507a806ba77f022b79e797f6d607734d573fa3607de79ee03162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c17a00216823baa351ec0cb78f7e959c8c3ab17fd0533ba7f7265660024c08ac17f9086083519220589c9bd56480642b45b146b3b0aa1e4ac069c321d3b9f670
|
7
|
+
data.tar.gz: f95bce0848370d9934673cd9fb367d43d0851718e3d37871f8e8f0005efb1263cb9c0cd03c9040fbfc928d15b4e996273b75ed9cf5481ad2f6abf5cd546bda3a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.5.1
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
|
7
|
+
* Fixed the wrong error returned for `union.left`
|
8
|
+
|
9
|
+
## 0.5.0
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
* Pick and Omit now use a new syntax, so it can handle snake to camel case conversion correctly
|
14
|
+
|
3
15
|
## 0.4.3
|
4
16
|
|
5
17
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
camille (0.
|
4
|
+
camille (0.5.1)
|
5
5
|
rails (>= 6.1, < 8)
|
6
6
|
|
7
7
|
GEM
|
@@ -103,7 +103,7 @@ GEM
|
|
103
103
|
timeout
|
104
104
|
net-smtp (0.3.3)
|
105
105
|
net-protocol
|
106
|
-
nio4r (2.5.
|
106
|
+
nio4r (2.5.9)
|
107
107
|
nokogiri (1.14.2-x86_64-linux)
|
108
108
|
racc (~> 1.4)
|
109
109
|
racc (1.6.2)
|
data/README.md
CHANGED
@@ -29,6 +29,10 @@ Therefore, if the front-end requests the API by calling `data`, we have guarante
|
|
29
29
|
|
30
30
|
By using these request functions, we also don't need to know about HTTP verbs and paths. It's impossible to have unrecognized routes, since Camille will make sure that each function handled by the correct Rails action.
|
31
31
|
|
32
|
+
## Tutorial
|
33
|
+
|
34
|
+
There's a step by step tutorial for setting up and showcasing Camille: https://github.com/onyxblade/camille-tutorial.
|
35
|
+
|
32
36
|
## Installation
|
33
37
|
|
34
38
|
Add this line to your application's Gemfile:
|
@@ -158,9 +162,9 @@ params(
|
|
158
162
|
string_literal: 'hello',
|
159
163
|
# a custom type we defined above
|
160
164
|
product: Product,
|
161
|
-
# Pick and Omit
|
162
|
-
pick: Pick[{a: 1, b: 2},
|
163
|
-
omit: Omit[Product,
|
165
|
+
# Pick and Omit accepts a type and an array of symbols
|
166
|
+
pick: Pick[{a: 1, b: 2}, [:a, :b]],
|
167
|
+
omit: Omit[Product, [:id]]
|
164
168
|
)
|
165
169
|
```
|
166
170
|
|
@@ -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/types/union.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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 辻彩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|