camille 0.5.15 → 0.5.16

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: 61a549590ebc8eaaa9c8962ff9aee4b2e61c38eddd90bb03c6744bf8ef08b645
4
- data.tar.gz: 3e93ad48715beae1a358c7f25201e9ed1a286b058fc1f387815bef1362878fcc
3
+ metadata.gz: c64a49ba269a9488e2990dce715d59e21ec603bb09453bc07b48f1b29cf80183
4
+ data.tar.gz: 482a7672c68154b5ab94c68318b2672f02f76793ad08372570a1b5ec4049e7b8
5
5
  SHA512:
6
- metadata.gz: 86fcb85d6c7730071e3448f12121deec1d585e1d1f615087adbd73b23736282cb5a986bf97b51e8deda8c4862c836d34b5fa5bb3bec9108200d055d69b4ffa1e
7
- data.tar.gz: 427928b9da7d5665bd0e0874682afb4228a3ad8ceef13887c873baaacc8ec1becc45604988318b992b00db79897d3bd4727281072165e5e5d03fdb927655362c
6
+ metadata.gz: d6ba48e7bc89d06d8ad92eb375cac5d02d783fc35c5732215f068630b57918a5b0bfaccc89b76d49983b384fbac31e2bbbe208d14526ea37489864e2cb2cee67
7
+ data.tar.gz: cb52ae9bdfc4445c098040b576d1e6910da8b699a615bfea339ed2bf24b0b180408d67a53b03a1c6259aadf3bda9f407d25c5fc17a12fbd22fb42c0aa0b20637
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.16
4
+
5
+ ### Fixed
6
+
7
+ * Record keys will no longer be case converted
8
+
3
9
  ## 0.5.15
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.14)
4
+ camille (0.5.15)
5
5
  rails (>= 6.1, < 8)
6
6
 
7
7
  GEM
@@ -6,8 +6,8 @@ module Camille
6
6
  attr_accessor :ts_header, :ts_location
7
7
 
8
8
  def load_default_configurations
9
- self.response_key_converter = lambda do |symbol|
10
- symbol.to_s.camelize(:lower)
9
+ self.response_key_converter = lambda do |string|
10
+ string.camelize(:lower)
11
11
  end
12
12
 
13
13
  self.params_key_converter = lambda do |string|
@@ -25,9 +25,6 @@ module Camille
25
25
  Camille::TypeErrorPrinter.new(error).print(string_io)
26
26
  raise TypeError.new("\nType check failed for response.\n#{string_io.string}")
27
27
  else
28
- if transformed.is_a? Hash
29
- transformed.deep_transform_keys!{|k| Camille::KeyConverter.convert_response_key(k)}
30
- end
31
28
  super(json: transformed)
32
29
  end
33
30
  else
@@ -16,9 +16,9 @@ module Camille
16
16
  raise UnknownResponseError.new("Endpoint lacking a `response` definition.")
17
17
  end
18
18
  if @params_type
19
- "#{Camille::Configuration.response_key_converter.call(@name)}(params: #{@params_type.literal}): Promise<#{@response_type.literal}>"
19
+ "#{Camille::Configuration.response_key_converter.call(@name.to_s)}(params: #{@params_type.literal}): Promise<#{@response_type.literal}>"
20
20
  else
21
- "#{Camille::Configuration.response_key_converter.call(@name)}(): Promise<#{@response_type.literal}>"
21
+ "#{Camille::Configuration.response_key_converter.call(@name.to_s)}(): Promise<#{@response_type.literal}>"
22
22
  end
23
23
  end
24
24
 
@@ -7,7 +7,7 @@ module Camille
7
7
  if in_cache = RESPONSE_KEY_CACHE[key]
8
8
  in_cache
9
9
  else
10
- RESPONSE_KEY_CACHE[key] = Camille::Configuration.response_key_converter.call(key)
10
+ RESPONSE_KEY_CACHE[key] = Camille::Configuration.response_key_converter.call(key.to_s)
11
11
  end
12
12
  end
13
13
 
@@ -0,0 +1,7 @@
1
+ module Camille
2
+ class ObjectHash < Hash
3
+ def as_json options = nil
4
+ transform_keys{|k, _| Camille::KeyConverter.convert_response_key(k)}.as_json
5
+ end
6
+ end
7
+ end
@@ -30,7 +30,7 @@ module Camille
30
30
 
31
31
  private
32
32
  def keys_in_literal
33
- @keys.map{|k| "\"#{Camille::Configuration.response_key_converter.call(k)}\""}.join(' | ')
33
+ @keys.map{|k| "\"#{Camille::Configuration.response_key_converter.call(k.to_s)}\""}.join(' | ')
34
34
  end
35
35
 
36
36
  end
@@ -31,13 +31,13 @@ module Camille
31
31
  tree.map do |key, value|
32
32
  if value.is_a? ::Hash
33
33
  [
34
- Camille::Line.new("#{Camille::Configuration.response_key_converter.call(key)}: {"),
34
+ Camille::Line.new("#{Camille::Configuration.response_key_converter.call(key.to_s)}: {"),
35
35
  tree_literal_lines(value).map(&:do_indent),
36
36
  Camille::Line.new('},')
37
37
  ]
38
38
  else
39
39
  value.literal_lines.tap do |lines|
40
- lines.first.prepend("#{Camille::Configuration.response_key_converter.call(key)}: ")
40
+ lines.first.prepend("#{Camille::Configuration.response_key_converter.call(key.to_s)}: ")
41
41
  lines.last.append(',')
42
42
  end
43
43
  end
@@ -32,7 +32,7 @@ module Camille
32
32
  transformed = transform_and_check_results.map do |key, (error, transformed)|
33
33
  [key, transformed]
34
34
  end.to_h
35
- [nil, transformed]
35
+ [nil, Camille::ObjectHash[transformed]]
36
36
  else
37
37
  [Camille::TypeError.new(**errors.to_h), nil]
38
38
  end
@@ -65,7 +65,7 @@ module Camille
65
65
  end
66
66
 
67
67
  def literal_key key
68
- "#{Camille::Configuration.response_key_converter.call(key)}#{@optional_keys.include?(key) ? '?' : ''}"
68
+ "#{Camille::Configuration.response_key_converter.call(key.to_s)}#{@optional_keys.include?(key) ? '?' : ''}"
69
69
  end
70
70
 
71
71
  def check_key_conversion_safe sym
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camille
4
- VERSION = "0.5.15"
4
+ VERSION = "0.5.16"
5
5
  end
data/lib/camille.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "active_support"
4
4
 
5
5
  require_relative "camille/version"
6
+ require_relative "camille/object_hash"
6
7
  require_relative "camille/basic_type"
7
8
  require_relative "camille/types"
8
9
  require_relative "camille/types/number"
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.15
4
+ version: 0.5.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alyssa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-17 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -67,6 +67,7 @@ files:
67
67
  - lib/camille/line.rb
68
68
  - lib/camille/loader.rb
69
69
  - lib/camille/main_controller.rb
70
+ - lib/camille/object_hash.rb
70
71
  - lib/camille/pick_and_omit.rb
71
72
  - lib/camille/railtie.rb
72
73
  - lib/camille/schema.rb
@@ -100,7 +101,7 @@ licenses:
100
101
  metadata:
101
102
  homepage_uri: https://github.com/onyxblade/camille
102
103
  source_code_uri: https://github.com/onyxblade/camille
103
- post_install_message:
104
+ post_install_message:
104
105
  rdoc_options: []
105
106
  require_paths:
106
107
  - lib
@@ -115,8 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  - !ruby/object:Gem::Version
116
117
  version: '0'
117
118
  requirements: []
118
- rubygems_version: 3.4.1
119
- signing_key:
119
+ rubygems_version: 3.5.22
120
+ signing_key:
120
121
  specification_version: 4
121
122
  summary: Typed API schema for Rails with TypeScript codegen
122
123
  test_files: []