camille 0.5.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/camille/basic_type.rb +2 -0
- data/lib/camille/{controller_extension.rb → controller.rb} +1 -1
- data/lib/camille/endpoint.rb +3 -1
- data/lib/camille/railtie.rb +2 -2
- data/lib/camille/types/boolean_literal.rb +27 -0
- data/lib/camille/types/string_literal.rb +2 -1
- data/lib/camille/version.rb +1 -1
- data/lib/camille.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ebcd5a9f0f1efd10108a596a8e4e442eb5afd3975728cd2ec51319563ae504e
|
4
|
+
data.tar.gz: '0889d8c954ef2983e27f7b9d97d396db0edb46251b6b55febc1f1427e9c3391f'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5247e53a9b76e8117247ef8d5e7c83d27cb57b3c8bf4971a5ee978e168e1e1e1c58a1348522ec7d2a4ab530d958d044c7c670a464e5cd5c02fadf046284e97c4
|
7
|
+
data.tar.gz: b64ab07566a56d4e407ec887af105493b4af9dd99c0fa4c1e32de32fce6e54d9e78ca375ba59377f8cecd0002f27bfc6822de2635612345ff67ea67efa305466
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
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
|
+
|
13
|
+
## 0.5.3
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
* Added boolean literal types
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
|
21
|
+
* Renamed `Camille::ControllerExtension` to `Camille::Controller`
|
22
|
+
|
3
23
|
## 0.5.2
|
4
24
|
|
5
25
|
### Added
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/camille/basic_type.rb
CHANGED
@@ -42,6 +42,8 @@ module Camille
|
|
42
42
|
Camille::Types::NumberLiteral.new(value)
|
43
43
|
when value.is_a?(::String)
|
44
44
|
Camille::Types::StringLiteral.new(value)
|
45
|
+
when value == true || value == false
|
46
|
+
Camille::Types::BooleanLiteral.new(value)
|
45
47
|
when value.is_a?(Camille::BasicType)
|
46
48
|
value
|
47
49
|
when value.is_a?(Class) && value < Camille::BasicType && value.directly_instantiable?
|
data/lib/camille/endpoint.rb
CHANGED
@@ -12,7 +12,9 @@ module Camille
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def signature
|
15
|
-
@response_type
|
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
|
data/lib/camille/railtie.rb
CHANGED
@@ -4,8 +4,8 @@ module Camille
|
|
4
4
|
class Railtie < ::Rails::Railtie
|
5
5
|
|
6
6
|
initializer "camille.configure_rails" do |app|
|
7
|
-
ActionController::API.include(Camille::
|
8
|
-
ActionController::Base.include(Camille::
|
7
|
+
ActionController::API.include(Camille::Controller)
|
8
|
+
ActionController::Base.include(Camille::Controller)
|
9
9
|
|
10
10
|
Camille::Loader.setup_zeitwerk_loader(app)
|
11
11
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Camille
|
2
|
+
module Types
|
3
|
+
class BooleanLiteral < Camille::BasicType
|
4
|
+
class ArgumentError < ::ArgumentError; end
|
5
|
+
|
6
|
+
attr_reader :value
|
7
|
+
|
8
|
+
def initialize value
|
9
|
+
if value == true || value == false
|
10
|
+
@value = value
|
11
|
+
else
|
12
|
+
raise ArgumentError.new("Expecting true or false, got #{value.inspect}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def check value
|
17
|
+
unless value == @value
|
18
|
+
Camille::TypeError.new("Expected boolean literal #{@value.inspect}, got #{value.inspect}.")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def literal
|
23
|
+
@value.to_s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -14,7 +14,8 @@ module Camille
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def check value
|
17
|
-
|
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
|
data/lib/camille/version.rb
CHANGED
data/lib/camille.rb
CHANGED
@@ -17,6 +17,7 @@ require_relative "camille/types/tuple"
|
|
17
17
|
require_relative "camille/types/any"
|
18
18
|
require_relative "camille/types/number_literal"
|
19
19
|
require_relative "camille/types/string_literal"
|
20
|
+
require_relative "camille/types/boolean_literal"
|
20
21
|
require_relative "camille/pick_and_omit"
|
21
22
|
require_relative "camille/types/pick"
|
22
23
|
require_relative "camille/types/omit"
|
@@ -29,7 +30,7 @@ require_relative "camille/schema"
|
|
29
30
|
require_relative "camille/schemas"
|
30
31
|
require_relative "camille/line"
|
31
32
|
require_relative "camille/railtie"
|
32
|
-
require_relative "camille/
|
33
|
+
require_relative "camille/controller"
|
33
34
|
require_relative "camille/loader"
|
34
35
|
require_relative "camille/configuration"
|
35
36
|
require_relative "camille/code_generator"
|
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.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 辻彩
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/camille/basic_type.rb
|
52
52
|
- lib/camille/code_generator.rb
|
53
53
|
- lib/camille/configuration.rb
|
54
|
-
- lib/camille/
|
54
|
+
- lib/camille/controller.rb
|
55
55
|
- lib/camille/endpoint.rb
|
56
56
|
- lib/camille/generators/install_generator.rb
|
57
57
|
- lib/camille/generators/schema_generator.rb
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/camille/types/any.rb
|
78
78
|
- lib/camille/types/array.rb
|
79
79
|
- lib/camille/types/boolean.rb
|
80
|
+
- lib/camille/types/boolean_literal.rb
|
80
81
|
- lib/camille/types/null.rb
|
81
82
|
- lib/camille/types/number.rb
|
82
83
|
- lib/camille/types/number_literal.rb
|