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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd8f26b87f7ddf2f3c951a19a24610abfe1bfac4f4da041568883cc371090895
4
- data.tar.gz: bbecf051c37ec9da1eae0920a6ec42c09d159feef1f2be734beaef2871af7410
3
+ metadata.gz: 9d5030e35bf654863f03d80dbd09f8adb03b335f3f66d52c745404f6344e7efc
4
+ data.tar.gz: 7cc7a7000f5ce205f8edabfa31046933b7c7e04a71b18a270a8a080b37ed0c71
5
5
  SHA512:
6
- metadata.gz: 53bb5fd170e71b21687dadba5ab1ce6c5a81bcb1a4ede09e280103cd81693fb8e9f41a3a15af630b2d48b62f150f29c1f222d8308fff2636135c5653d9ca3da3
7
- data.tar.gz: 47c9621bfdeb542e625f2115eb96b7d1d14fdecfd5f6cefe62bd6f92be2703d7e3e7518e96df26af3c692fb5887ac08ebe26db38eaeae8a8cfb059eeb07de839
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camille (0.5.9)
4
+ camille (0.5.11)
5
5
  rails (>= 6.1, < 8)
6
6
 
7
7
  GEM
@@ -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
@@ -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
- error, transformed = type.transform_and_check(value[key])
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, [error, transformed]]
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| "#{ActiveSupport::Inflector.camelize k.to_s, false}: #{v.literal}"}.join(', ')}}"
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 | Camille::Types::Undefined.new]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camille
4
- VERSION = "0.5.9"
4
+ VERSION = "0.5.11"
5
5
  end
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.9
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-08 00:00:00.000000000 Z
11
+ date: 2023-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails