camille 0.5.10 → 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: 247a0f8bf5424ac104e9c4b71a073c4b7a6e38399434dc57a9a3b13f40b72d0b
4
- data.tar.gz: db54f6d86bab52b6f50bc09cc3aa42c4b2b9c00c10a484394de270bc4a1c8351
3
+ metadata.gz: 9d5030e35bf654863f03d80dbd09f8adb03b335f3f66d52c745404f6344e7efc
4
+ data.tar.gz: 7cc7a7000f5ce205f8edabfa31046933b7c7e04a71b18a270a8a080b37ed0c71
5
5
  SHA512:
6
- metadata.gz: aa084c1032e46b35a3330a5500bdf2a31dd19d57585ca7fd12bbd8c93083d1f2b5f9df1c53c68dd10ab53167d27fe8f4680cf4a7f8f8567f4e9dd3b279d13022
7
- data.tar.gz: be8d2cc143b82614cd99ef6d0b38c2fcc756152a9856db840e04595f1d566d97e8c01f51caadcb7ba88ff9d00924f3ff1e048a821b9a08f50a164c3047b8aba5
6
+ metadata.gz: 746548d7942f95c217ad8763add318a2dab939dbe2fb1abbd26d88b3c7da76023f58946a5622b15d5e3107ea7a88bfb919c78526eac78dbd6f9520d4f6e11469
7
+ data.tar.gz: 5460ccaaa044c4a4a1255b68d3df78e1f251931a725b26ff36155dd29695c0422097287c07efb0f405d2928aa088022c03fd8bbf64ed652c64f450a688c9d1c1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
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
+
3
9
  ## 0.5.10
4
10
 
5
11
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camille (0.5.10)
4
+ camille (0.5.11)
5
5
  rails (>= 6.1, < 8)
6
6
 
7
7
  GEM
@@ -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.10"
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.10
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