camille 0.5.3 → 0.5.5

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: f58d6bc69ec0ca18561254ccd7a8cb48caf134bca3b65b3694e09eda2d480c86
4
- data.tar.gz: cf6a91b9ed549c095ec5b911e20fc92ea43c64b0634e3eaf9da8ebec29f7da24
3
+ metadata.gz: a587c953d4d716329e30ee94c7dfd2b67fcbb9d95b6aee5acc3a74ba7d8e2883
4
+ data.tar.gz: 28cf879c56d17ac119c2913c14d2ce09548c226b8f9120aa5fd5ccc3ab8334d0
5
5
  SHA512:
6
- metadata.gz: 3ecfa0f3d4753d480e70967c1da84a9442121226d942c81bb24398ebeef2520148efd4d14b702532f69148dc50a5d70e35ff3de418df6df99077f96573754281
7
- data.tar.gz: 0a39893452ae9461b50919c1cfa5a20cc29bf4b0e6c46b3bfd873128d71ff0b5329875755319104dbd071722941b935b2366476378b7d60238ddde990d01fa1c
6
+ metadata.gz: 64ca501f703b329e9c4a8872a237480a4a751ffdbb82cadfc7ca67a31fcaffffd6c18c26d5eff045f69600c6bf2e6f82c9607b47ce83dbb9333a5b6d67f40692
7
+ data.tar.gz: 5d8951b905ad94aecc0b10756c9ff16bb25f9b6ee791c57694ad7bfdfd2f0c27cebe6e980b975f3a0cb17b3afa25a750d0808cfad221729e7d1c50caeba20e8e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.4
4
+
5
+ ### Added
6
+
7
+ * Symbols are now accepted in string literal types
8
+
9
+ ### Changed
10
+
11
+ * Reverted previous change to use `{}` for omitted response type
12
+
3
13
  ## 0.5.3
4
14
 
5
15
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camille (0.5.3)
4
+ camille (0.5.4)
5
5
  rails (>= 6.1, < 8)
6
6
 
7
7
  GEM
@@ -12,7 +12,9 @@ module Camille
12
12
  end
13
13
 
14
14
  def signature
15
- @response_type ||= Camille::Types::Object.new({})
15
+ unless @response_type
16
+ raise UnknownResponseError.new("Endpoint lacking a `response` definition.")
17
+ end
16
18
  if @params_type
17
19
  "#{ActiveSupport::Inflector.camelize @name, false}(params: #{@params_type.literal}): Promise<#{@response_type.literal}>"
18
20
  else
@@ -1,6 +1,7 @@
1
1
  module Camille
2
2
  module Types
3
3
  class Object < Camille::BasicType
4
+ class ArgumentError < ::ArgumentError; end
4
5
  attr_reader :fields
5
6
 
6
7
  def initialize fields
@@ -43,6 +44,7 @@ module Camille
43
44
  private
44
45
  def normalize_fields fields
45
46
  fields.map do |key, value|
47
+ check_case_conversion_safe key
46
48
  type = Camille::Type.instance(value)
47
49
  if key.end_with?('?')
48
50
  new_key = remove_question_mark(key)
@@ -57,6 +59,13 @@ module Camille
57
59
  def remove_question_mark sym
58
60
  sym.to_s.gsub(/\?$/, '').to_sym
59
61
  end
62
+
63
+ def check_case_conversion_safe sym
64
+ str = sym.to_s
65
+ if str != str.camelize.underscore
66
+ raise ArgumentError.new("Only keys satisfying `key.to_s == key.to_s.caamelize.underscore` can be used.")
67
+ end
68
+ end
60
69
  end
61
70
  end
62
71
  end
@@ -14,7 +14,8 @@ module Camille
14
14
  end
15
15
 
16
16
  def check value
17
- unless value == @value
17
+ transformed = value.is_a?(Symbol) ? value.to_s : value
18
+ unless transformed == @value
18
19
  Camille::TypeError.new("Expected string literal #{@value.inspect}, got #{value.inspect}.")
19
20
  end
20
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camille
4
- VERSION = "0.5.3"
4
+ VERSION = "0.5.5"
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.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 辻彩
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-06 00:00:00.000000000 Z
11
+ date: 2023-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails