grape_sorbet 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -3
- data/lib/grape_sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/grape_endpoints.rb +29 -7
- data/lib/tapioca/dsl/helpers/grape_constants_helper.rb +1 -0
- data/rbi/grape.rbi +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b090755b28d1fff8fb2de659c1196985f0904986ed09395964a636a0d8263645
|
4
|
+
data.tar.gz: a379078b3bad1bc4b16b67b5d0a417993b58d1302bf85656c6b1eb5a0d28eacd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c858df3843df3547fec4b9283a760704746d19d5fa79975dee8ca65204b5b8d3670a905c01ed123180be51eba01ed6fa73309209d58a97deb413a766c65e0e
|
7
|
+
data.tar.gz: f0e62315163f3d87326b6f967f7ecfe54c13005361e951549478acf12a313808c0a4424c061384fc2661a9b46f33e2a22a22e47f4d949d238f552611b91cd7f0
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -10,12 +10,11 @@ grape_sorbet is a gem that provides hand written signatures and a Tapioca DSL co
|
|
10
10
|
|
11
11
|
Install the gem and add to the application's Gemfile by executing:
|
12
12
|
|
13
|
-
$ bundle add
|
13
|
+
$ bundle add grape_sorbet
|
14
14
|
|
15
15
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
16
|
|
17
|
-
$ gem install
|
18
|
-
$ gem specific_install https://github.com/thatch-health/grape_sorbet.git
|
17
|
+
$ gem install grape_sorbet
|
19
18
|
|
20
19
|
After installing the gem, make sure to run `bundle exec tapioca gem grape_sorbet` in your project to import the hand written signatures.
|
21
20
|
|
data/lib/grape_sorbet/version.rb
CHANGED
@@ -67,8 +67,10 @@ module Tapioca
|
|
67
67
|
sig { override.void }
|
68
68
|
def decorate
|
69
69
|
create_classes_and_includes
|
70
|
-
|
70
|
+
|
71
71
|
create_callbacks_methods
|
72
|
+
create_request_response_methods
|
73
|
+
create_routing_methods
|
72
74
|
end
|
73
75
|
|
74
76
|
class << self
|
@@ -108,6 +110,14 @@ module Tapioca
|
|
108
110
|
)
|
109
111
|
end
|
110
112
|
|
113
|
+
sig { returns(RBI::Scope) }
|
114
|
+
def request_response_methods_module
|
115
|
+
@request_response_methods_module ||= T.let(
|
116
|
+
api.create_module(RequestResponseMethodsModuleName),
|
117
|
+
T.nilable(RBI::Scope),
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
111
121
|
sig { returns(RBI::Scope) }
|
112
122
|
def routing_methods_module
|
113
123
|
@routing_methods_module ||= T.let(
|
@@ -119,6 +129,7 @@ module Tapioca
|
|
119
129
|
sig { void }
|
120
130
|
def create_classes_and_includes
|
121
131
|
api.create_extend(CallbacksMethodsModuleName)
|
132
|
+
api.create_extend(RequestResponseMethodsModuleName)
|
122
133
|
api.create_extend(RoutingMethodsModuleName)
|
123
134
|
create_api_class
|
124
135
|
create_endpoint_class
|
@@ -137,14 +148,10 @@ module Tapioca
|
|
137
148
|
def create_endpoint_class
|
138
149
|
superclass = "::Grape::Endpoint"
|
139
150
|
|
140
|
-
|
141
|
-
|
142
|
-
if helper_mods.any? { |mod| mod.name.nil? }
|
143
|
-
raise "Cannot compile Grape API with anonymous helpers"
|
144
|
-
end
|
151
|
+
named_helper_mods = constant.namespace_stackable(:helpers).reject { |mod| mod.name.nil? }
|
145
152
|
|
146
153
|
api.create_class(EndpointClassName, superclass_name: superclass) do |klass|
|
147
|
-
|
154
|
+
named_helper_mods.each do |mod|
|
148
155
|
klass.create_include(mod.name)
|
149
156
|
end
|
150
157
|
end
|
@@ -163,6 +170,21 @@ module Tapioca
|
|
163
170
|
end
|
164
171
|
end
|
165
172
|
|
173
|
+
sig { void }
|
174
|
+
def create_request_response_methods
|
175
|
+
request_response_methods_module.create_method(
|
176
|
+
"rescue_from",
|
177
|
+
parameters: [
|
178
|
+
create_rest_param("args", type: "T.untyped"),
|
179
|
+
create_block_param(
|
180
|
+
"block",
|
181
|
+
type: "T.nilable(T.proc.bind(#{EndpointClassName}).params(e: Exception).void)",
|
182
|
+
),
|
183
|
+
],
|
184
|
+
return_type: "void",
|
185
|
+
)
|
186
|
+
end
|
187
|
+
|
166
188
|
sig { void }
|
167
189
|
def create_routing_methods
|
168
190
|
HTTP_VERB_METHODS.each do |verb|
|
@@ -8,6 +8,7 @@ module Tapioca
|
|
8
8
|
extend T::Sig
|
9
9
|
|
10
10
|
CallbacksMethodsModuleName = "GeneratedCallbacksMethods"
|
11
|
+
RequestResponseMethodsModuleName = "GeneratedRequestResponseMethods"
|
11
12
|
RoutingMethodsModuleName = "GeneratedRoutingMethods"
|
12
13
|
|
13
14
|
APIInstanceClassName = "PrivateAPIInstance"
|
data/rbi/grape.rbi
CHANGED
@@ -22,11 +22,16 @@ module Grape
|
|
22
22
|
sig { params(name: Symbol, block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
|
23
23
|
def params(name, &block); end
|
24
24
|
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
sig { params(new_modules: T.untyped, block: T.nilable(T.proc.bind(Grape::DSL::Helpers::BaseHelper).void)).void }
|
28
|
+
def helpers(*new_modules, &block); end
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
module RequestResponse
|
28
33
|
module ClassMethods
|
29
|
-
sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void }
|
34
|
+
sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).params(e: Exception).void).void }
|
30
35
|
def rescue_from(*args, &block); end
|
31
36
|
end
|
32
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape_sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thatch Health, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|