grape_sorbet 0.0.3 → 0.0.5
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 +3 -3
- data/lib/grape_sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/grape_endpoints.rb +2 -6
- data/rbi/grape.rbi +106 -81
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06c4417253642117e5cc111ec8c478d5c86b12abaff504778c0dc9ca031f0e45
|
4
|
+
data.tar.gz: c93127be9f1ac682c30080c0e5614a37d9470168172cfcc64b44e25d61203fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c85f6e88f351c4ff58e8fd922f025b41cd38b05d9f773c42c0647128ff2bb525ce359791b21e5462c1119db943e5cee88502b9903236ddd45ef3c06d39c62c5
|
7
|
+
data.tar.gz: f504e9a4a9ee21cb7464802207cace234dfe270bd01e61f388eefc261ba39db8b96730f25d002f8fe4fc98daae75f22aaf678e0c594e16d138cf5eb10c0d0bb6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# grape_sorbet
|
2
2
|
|
3
3
|
[![Build Status](https://github.com/thatch-health/grape_sorbet/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/thatch-health/grape_sorbet/actions?query=branch%3Amain)
|
4
|
+
[![Gem Version ](https://img.shields.io/gem/v/grape_sorbet.svg?style=flat)](https://rubygems.org/gems/grape_sorbet)
|
4
5
|
|
5
6
|
grape_sorbet is a gem that provides hand written signatures and a Tapioca DSL compiler that makes it more pleasant to use the [Grape](https://github.com/ruby-grape/grape) API framework in Ruby projects that use the [Sorbet](https://sorbet.org/) typechecker.
|
6
7
|
|
@@ -9,12 +10,11 @@ grape_sorbet is a gem that provides hand written signatures and a Tapioca DSL co
|
|
9
10
|
|
10
11
|
Install the gem and add to the application's Gemfile by executing:
|
11
12
|
|
12
|
-
$ bundle add
|
13
|
+
$ bundle add grape_sorbet
|
13
14
|
|
14
15
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
15
16
|
|
16
|
-
$ gem install
|
17
|
-
$ gem specific_install https://github.com/thatch-health/grape_sorbet.git
|
17
|
+
$ gem install grape_sorbet
|
18
18
|
|
19
19
|
After installing the gem, make sure to run `bundle exec tapioca gem grape_sorbet` in your project to import the hand written signatures.
|
20
20
|
|
data/lib/grape_sorbet/version.rb
CHANGED
@@ -137,14 +137,10 @@ module Tapioca
|
|
137
137
|
def create_endpoint_class
|
138
138
|
superclass = "::Grape::Endpoint"
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
if helper_mods.any? { |mod| mod.name.nil? }
|
143
|
-
raise "Cannot compile Grape API with anonymous helpers"
|
144
|
-
end
|
140
|
+
named_helper_mods = constant.namespace_stackable(:helpers).reject { |mod| mod.name.nil? }
|
145
141
|
|
146
142
|
api.create_class(EndpointClassName, superclass_name: superclass) do |klass|
|
147
|
-
|
143
|
+
named_helper_mods.each do |mod|
|
148
144
|
klass.create_include(mod.name)
|
149
145
|
end
|
150
146
|
end
|
data/rbi/grape.rbi
CHANGED
@@ -2,102 +2,127 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module Grape
|
5
|
-
module DSL
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
module DSL
|
6
|
+
module Desc
|
7
|
+
# grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes
|
8
|
+
# at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent
|
9
|
+
# Sorbet from complaining that the DSL methods don't exist.
|
10
|
+
sig do
|
11
|
+
params(
|
12
|
+
description: String,
|
13
|
+
options: T.nilable(T::Hash[Symbol, T.untyped]),
|
14
|
+
config_block: T.nilable(T.proc.bind(T.untyped).void),
|
15
|
+
).void
|
16
|
+
end
|
17
|
+
def desc(description, options = T.unsafe(nil), &config_block); end
|
15
18
|
end
|
16
|
-
def desc(description, options = T.unsafe(nil), &config_block); end
|
17
|
-
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
module Helpers
|
21
|
+
module BaseHelper
|
22
|
+
sig { params(name: Symbol, block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
|
23
|
+
def params(name, &block); end
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
args: T.untyped,
|
29
|
-
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
30
|
-
).void
|
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
|
31
30
|
end
|
32
|
-
def delete(*args, &block); end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
args
|
38
|
-
|
39
|
-
).void
|
32
|
+
module RequestResponse
|
33
|
+
module ClassMethods
|
34
|
+
sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void }
|
35
|
+
def rescue_from(*args, &block); end
|
36
|
+
end
|
40
37
|
end
|
41
|
-
def get(*args, &block); end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
module Routing
|
40
|
+
module ClassMethods
|
41
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
42
|
+
sig do
|
43
|
+
params(
|
44
|
+
args: T.untyped,
|
45
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
46
|
+
).void
|
47
|
+
end
|
48
|
+
def delete(*args, &block); end
|
51
49
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
51
|
+
sig do
|
52
|
+
params(
|
53
|
+
args: T.untyped,
|
54
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
55
|
+
).void
|
56
|
+
end
|
57
|
+
def get(*args, &block); end
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
59
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
60
|
+
sig do
|
61
|
+
params(
|
62
|
+
args: T.untyped,
|
63
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
64
|
+
).void
|
65
|
+
end
|
66
|
+
def options(*args, &block); end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
68
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
69
|
+
sig do
|
70
|
+
params(
|
71
|
+
args: T.untyped,
|
72
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
73
|
+
).void
|
74
|
+
end
|
75
|
+
def patch(*args, &block); end
|
76
|
+
|
77
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
78
|
+
sig do
|
79
|
+
params(
|
80
|
+
args: T.untyped,
|
81
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
82
|
+
).void
|
83
|
+
end
|
84
|
+
def post(*args, &block); end
|
85
|
+
|
86
|
+
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
|
87
|
+
sig do
|
88
|
+
params(
|
89
|
+
args: T.untyped,
|
90
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
91
|
+
).void
|
92
|
+
end
|
93
|
+
def put(*args, &block); end
|
94
|
+
|
95
|
+
sig do
|
96
|
+
params(
|
97
|
+
methods: T.any(Symbol, String, T::Array[String]),
|
98
|
+
paths: T.nilable(T.any(String, T::Array[String])),
|
99
|
+
route_options: T.nilable(T::Hash[Symbol, T.untyped]),
|
100
|
+
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
|
101
|
+
).void
|
102
|
+
end
|
103
|
+
def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end
|
78
104
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
105
|
+
sig do
|
106
|
+
params(
|
107
|
+
param: Symbol,
|
108
|
+
options: T.nilable(T::Hash[Symbol, T.untyped]),
|
109
|
+
block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void),
|
110
|
+
).void
|
111
|
+
end
|
112
|
+
def route_param(param, options = T.unsafe(nil), &block); end
|
113
|
+
end
|
86
114
|
end
|
87
|
-
def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end
|
88
115
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
).void
|
116
|
+
module Validations
|
117
|
+
module ClassMethods
|
118
|
+
sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
|
119
|
+
def params(&block); end
|
120
|
+
end
|
95
121
|
end
|
96
|
-
def route_param(param, options = T.unsafe(nil), &block); end
|
97
122
|
end
|
98
123
|
|
99
|
-
|
100
|
-
sig {
|
101
|
-
def
|
124
|
+
class Endpoint
|
125
|
+
sig { returns(Grape::Request) }
|
126
|
+
def request; end
|
102
127
|
end
|
103
128
|
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.5
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
|
-
rubygems_version: 3.5.
|
101
|
+
rubygems_version: 3.5.13
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: Sorbet signatures and Tapioca DSL compiler for Grape.
|