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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: afca4010268efe01d37b64b7cfd4bbd7f6266779a3a135ab04fe14869ab71daf
4
- data.tar.gz: ee494b0147c0b9d32ae90a5a1fba81218687b26396131a56ff9a1bb16306d693
3
+ metadata.gz: 06c4417253642117e5cc111ec8c478d5c86b12abaff504778c0dc9ca031f0e45
4
+ data.tar.gz: c93127be9f1ac682c30080c0e5614a37d9470168172cfcc64b44e25d61203fa9
5
5
  SHA512:
6
- metadata.gz: 122aa7dab2572d6df1cfc79a3ec7a80b652f5ad7d5d51d87b0e9077385e3fb8041fd75b190f76ce4c58b4f1aea575dd1194d505b21c5d9ff32d80b9fca1aa33a
7
- data.tar.gz: 4eb298722d0e14cb745a20917899825463fd50d6b87b0e1d9541566c9bc5961effec782c7ec767cacc9bcf37536596e0f885c3ae9eb5bdf60717f32d1833c341
6
+ metadata.gz: 7c85f6e88f351c4ff58e8fd922f025b41cd38b05d9f773c42c0647128ff2bb525ce359791b21e5462c1119db943e5cee88502b9903236ddd45ef3c06d39c62c5
7
+ data.tar.gz: f504e9a4a9ee21cb7464802207cace234dfe270bd01e61f388eefc261ba39db8b96730f25d002f8fe4fc98daae75f22aaf678e0c594e16d138cf5eb10c0d0bb6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.0.5 (2024-06-24)
2
+
3
+ - Ignore anonymous helpers
4
+
5
+ ## 0.0.4 (2024-06-24)
6
+
7
+ - Update `grape.rbi`
8
+
1
9
  ## 0.0.3 (2024-06-05)
2
10
 
3
11
  - Better support for callbacks
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape_sorbet (0.0.3)
4
+ grape_sorbet (0.0.5)
5
5
  activesupport
6
6
  grape (~> 2.0)
7
7
  sorbet-runtime (~> 0.5.10741)
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 r --github=https://github.com/thatch-health/grape_sorbet
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 specific_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
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module GrapeSorbet
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.5"
6
6
  end
@@ -137,14 +137,10 @@ module Tapioca
137
137
  def create_endpoint_class
138
138
  superclass = "::Grape::Endpoint"
139
139
 
140
- helper_mods = constant.namespace_stackable(:helpers)
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
- helper_mods.each do |mod|
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::Desc
6
- # grape evaluates config_block in the context of a dynamically created module that implements the DSL it exposes
7
- # at runtime. There's no good way to represent this statically, so block is just typed as T.untyped to prevent
8
- # Sorbet from complaining that the DSL methods don't exist.
9
- sig do
10
- params(
11
- description: String,
12
- options: T.nilable(T::Hash[Symbol, T.untyped]),
13
- config_block: T.nilable(T.proc.bind(T.untyped).void),
14
- ).void
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
- module DSL::RequestResponse::ClassMethods
20
- sig { params(args: T.untyped, block: T.proc.bind(Grape::Endpoint).void).void }
21
- def rescue_from(*args, &block); end
22
- end
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
- module DSL::Routing::ClassMethods
25
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
26
- sig do
27
- params(
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
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
35
- sig do
36
- params(
37
- args: T.untyped,
38
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
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
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
44
- sig do
45
- params(
46
- args: T.untyped,
47
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
48
- ).void
49
- end
50
- def options(*args, &block); end
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
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
53
- sig do
54
- params(
55
- args: T.untyped,
56
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
57
- ).void
58
- end
59
- def patch(*args, &block); end
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
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
62
- sig do
63
- params(
64
- args: T.untyped,
65
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
66
- ).void
67
- end
68
- def post(*args, &block); end
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
- # @shim: https://github.com/ruby-grape/grape/blob/v2.0.0/lib/grape/dsl/routing.rb#L148-L154
71
- sig do
72
- params(
73
- args: T.untyped,
74
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
75
- ).void
76
- end
77
- def put(*args, &block); end
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
- sig do
80
- params(
81
- methods: T.any(Symbol, String, T::Array[String]),
82
- paths: T.nilable(T.any(String, T::Array[String])),
83
- route_options: T.nilable(T::Hash[Symbol, T.untyped]),
84
- block: T.nilable(T.proc.bind(Grape::Endpoint).void),
85
- ).void
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
- sig do
90
- params(
91
- param: Symbol,
92
- options: T.nilable(T::Hash[Symbol, T.untyped]),
93
- block: T.nilable(T.proc.bind(T.class_of(Grape::API::Instance)).void),
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
- module DSL::Validations::ClassMethods
100
- sig { params(block: T.proc.bind(Grape::Validations::ParamsScope).void).void }
101
- def params(&block); end
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.3
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-05 00:00:00.000000000 Z
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.9
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.