Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update grape.rbi #3

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.4 (2024-06-24)

- Update `grape.rbi`

## 0.0.3 (2024-06-05)

- Better support for callbacks
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
grape_sorbet (0.0.3)
grape_sorbet (0.0.4)
activesupport
grape (~> 2.0)
sorbet-runtime (~> 0.5.10741)
Expand Down
2 changes: 1 addition & 1 deletion lib/grape_sorbet/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# frozen_string_literal: true

module GrapeSorbet
VERSION = "0.0.3"
VERSION = "0.0.4"
end
184 changes: 102 additions & 82 deletions rbi/grape.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -2,102 +2,122 @@
# frozen_string_literal: true

module Grape
module DSL::Desc
# grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes
# at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent
# Sorbet from complaining that the DSL methods don't exist.
sig do
params(
description: String,
options: T.nilable(T::Hash[Symbol, T.untyped]),
config_block: T.nilable(T.proc.bind(T.untyped).void),
).void
module DSL
module Desc
# grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes
# at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent
# Sorbet from complaining that the DSL methods don't exist.
sig do
params(
description: String,
options: T.nilable(T::Hash[Symbol, T.untyped]),
config_block: T.nilable(T.proc.bind(T.untyped).void),
).void
end
def desc(description, options = T.unsafe(nil), &config_block); end
end
def desc(description, options = T.unsafe(nil), &config_block); end
end

module DSL::RequestResponse::ClassMethods
sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void }
def rescue_from(*args, &block); end
end

module DSL::Routing::ClassMethods
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
module Helpers
module BaseHelper
sig { params(name: Symbol, block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
def params(name, &block); end
end
end
def delete(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
module RequestResponse
module ClassMethods
sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void }
def rescue_from(*args, &block); end
end
end
def get(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def options(*args, &block); end
module Routing
module ClassMethods
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def delete(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def patch(*args, &block); end
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def get(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def post(*args, &block); end
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def options(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def put(*args, &block); end
# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def patch(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def post(*args, &block); end

# @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
sig do
params(
args: T.untyped,
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def put(*args, &block); end

sig do
params(
methods: T.any(Symbol, String, T::Array[String]),
paths: T.nilable(T.any(String, T::Array[String])),
route_options: T.nilable(T::Hash[Symbol, T.untyped]),
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
end
def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end

sig do
params(
methods: T.any(Symbol, String, T::Array[String]),
paths: T.nilable(T.any(String, T::Array[String])),
route_options: T.nilable(T::Hash[Symbol, T.untyped]),
block: T.nilable(T.proc.bind(Grape::Endpoint).void),
).void
sig do
params(
param: Symbol,
options: T.nilable(T::Hash[Symbol, T.untyped]),
block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void),
).void
end
def route_param(param, options = T.unsafe(nil), &block); end
end
end
def route(methods, paths = T.unsafe(nil), route_options = T.unsafe(nil), &block); end

sig do
params(
param: Symbol,
options: T.nilable(T::Hash[Symbol, T.untyped]),
block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void),
).void
module Validations
module ClassMethods
sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
def params(&block); end
end
end
def route_param(param, options = T.unsafe(nil), &block); end
end

module DSL::Validations::ClassMethods
sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
def params(&block); end
class Endpoint
sig { returns(Grape::Request) }
def request; end
end
end