grape_sorbet 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +25 -20
- data/grape_sorbet.gemspec +3 -3
- data/lib/grape_sorbet/grape_entity_name.rb +89 -0
- data/lib/grape_sorbet/version.rb +1 -1
- data/lib/grape_sorbet.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4014b15113664de2c3ef60d30403fbe67f7d348d1f6c80fe7ac38d12b071646
|
4
|
+
data.tar.gz: 58c89b271a8ddec8a5d97a28044f8f46ad9259d2749371a96ca4c2a3362b235e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f306c2fd09fe53fe081259dfb9df0cbd47d0923040d8593f6ea15a5bf4fbb6d837b0ec46a08188a673b1b1b03fead58dbab121f565659f1f6a8336f252ae6a79
|
7
|
+
data.tar.gz: 6f57c28ba24c5d771d38203a29e856cb7e54726685ff3a027cc7da42450a210019f85596eceaa1e5d62a9bc7bd7a328d11076c45ecfeb8119db70be068265a9d
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
grape_sorbet (0.0.
|
4
|
+
grape_sorbet (0.0.9)
|
5
5
|
activesupport
|
6
6
|
grape (~> 2.0)
|
7
7
|
sorbet-runtime (~> 0.5.10741)
|
@@ -53,10 +53,13 @@ GEM
|
|
53
53
|
mustermann-grape (~> 1.1.0)
|
54
54
|
rack (>= 2)
|
55
55
|
zeitwerk
|
56
|
+
grape-entity (1.0.1)
|
57
|
+
activesupport (>= 3.0.0)
|
58
|
+
multi_json (>= 1.3.2)
|
56
59
|
i18n (1.14.5)
|
57
60
|
concurrent-ruby (~> 1.0)
|
58
61
|
io-console (0.7.2)
|
59
|
-
irb (1.
|
62
|
+
irb (1.14.0)
|
60
63
|
rdoc (>= 4.0.0)
|
61
64
|
reline (>= 0.4.2)
|
62
65
|
json (2.7.2)
|
@@ -67,6 +70,7 @@ GEM
|
|
67
70
|
builder
|
68
71
|
minitest (>= 5.0)
|
69
72
|
ruby-progressbar
|
73
|
+
multi_json (1.15.0)
|
70
74
|
mustermann (3.0.0)
|
71
75
|
ruby2_keywords (~> 0.0.1)
|
72
76
|
mustermann-grape (1.1.0)
|
@@ -74,14 +78,14 @@ GEM
|
|
74
78
|
mutex_m (0.2.0)
|
75
79
|
netrc (0.11.0)
|
76
80
|
parallel (1.25.1)
|
77
|
-
parser (3.3.
|
81
|
+
parser (3.3.4.0)
|
78
82
|
ast (~> 2.4.1)
|
79
83
|
racc
|
80
84
|
prism (0.30.0)
|
81
85
|
psych (5.1.2)
|
82
86
|
stringio
|
83
87
|
racc (1.8.0)
|
84
|
-
rack (3.1.
|
88
|
+
rack (3.1.7)
|
85
89
|
rainbow (3.1.1)
|
86
90
|
rake (13.2.1)
|
87
91
|
rbi (0.1.13)
|
@@ -94,20 +98,20 @@ GEM
|
|
94
98
|
io-console (~> 0.5)
|
95
99
|
rexml (3.3.1)
|
96
100
|
strscan
|
97
|
-
rubocop (1.
|
101
|
+
rubocop (1.65.0)
|
98
102
|
json (~> 2.3)
|
99
103
|
language_server-protocol (>= 3.17.0)
|
100
104
|
parallel (~> 1.10)
|
101
105
|
parser (>= 3.3.0.2)
|
102
106
|
rainbow (>= 2.2.2, < 4.0)
|
103
|
-
regexp_parser (>=
|
107
|
+
regexp_parser (>= 2.4, < 3.0)
|
104
108
|
rexml (>= 3.2.5, < 4.0)
|
105
109
|
rubocop-ast (>= 1.31.1, < 2.0)
|
106
110
|
ruby-progressbar (~> 1.7)
|
107
111
|
unicode-display_width (>= 2.4.0, < 3.0)
|
108
112
|
rubocop-ast (1.31.3)
|
109
113
|
parser (>= 3.3.1.0)
|
110
|
-
rubocop-minitest (0.35.
|
114
|
+
rubocop-minitest (0.35.1)
|
111
115
|
rubocop (>= 1.61, < 2.0)
|
112
116
|
rubocop-ast (>= 1.31.1, < 2.0)
|
113
117
|
rubocop-performance (1.21.1)
|
@@ -127,23 +131,23 @@ GEM
|
|
127
131
|
simplecov_json_formatter (~> 0.1)
|
128
132
|
simplecov-html (0.12.3)
|
129
133
|
simplecov_json_formatter (0.1.4)
|
130
|
-
sorbet (0.5.
|
131
|
-
sorbet-static (= 0.5.
|
132
|
-
sorbet-runtime (0.5.
|
133
|
-
sorbet-static (0.5.
|
134
|
-
sorbet-static (0.5.
|
135
|
-
sorbet-static (0.5.
|
136
|
-
sorbet-static-and-runtime (0.5.
|
137
|
-
sorbet (= 0.5.
|
138
|
-
sorbet-runtime (= 0.5.
|
139
|
-
spoom (1.3.
|
134
|
+
sorbet (0.5.11481)
|
135
|
+
sorbet-static (= 0.5.11481)
|
136
|
+
sorbet-runtime (0.5.11481)
|
137
|
+
sorbet-static (0.5.11481-aarch64-linux)
|
138
|
+
sorbet-static (0.5.11481-universal-darwin)
|
139
|
+
sorbet-static (0.5.11481-x86_64-linux)
|
140
|
+
sorbet-static-and-runtime (0.5.11481)
|
141
|
+
sorbet (= 0.5.11481)
|
142
|
+
sorbet-runtime (= 0.5.11481)
|
143
|
+
spoom (1.3.3)
|
140
144
|
erubi (>= 1.10.0)
|
141
|
-
prism (>= 0.
|
145
|
+
prism (>= 0.28.0)
|
142
146
|
sorbet-static-and-runtime (>= 0.5.10187)
|
143
147
|
thor (>= 0.19.2)
|
144
148
|
stringio (3.1.1)
|
145
149
|
strscan (3.1.0)
|
146
|
-
tapioca (0.15.
|
150
|
+
tapioca (0.15.1)
|
147
151
|
bundler (>= 2.2.25)
|
148
152
|
netrc (>= 0.11.0)
|
149
153
|
parallel (>= 1.21.0)
|
@@ -169,6 +173,7 @@ PLATFORMS
|
|
169
173
|
|
170
174
|
DEPENDENCIES
|
171
175
|
bundler-audit
|
176
|
+
grape-entity
|
172
177
|
grape_sorbet!
|
173
178
|
irb
|
174
179
|
minitest (~> 5.0)
|
@@ -185,4 +190,4 @@ DEPENDENCIES
|
|
185
190
|
tapioca
|
186
191
|
|
187
192
|
BUNDLED WITH
|
188
|
-
2.5.
|
193
|
+
2.5.15
|
data/grape_sorbet.gemspec
CHANGED
@@ -31,9 +31,9 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
# Uncomment to register a new dependency of your gem
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
34
|
+
spec.add_dependency("activesupport")
|
35
|
+
spec.add_dependency("grape", "~> 2.0")
|
36
|
+
spec.add_dependency("sorbet-runtime", "~> 0.5.10741")
|
37
37
|
|
38
38
|
# For more information and examples about making a new gem, check out our
|
39
39
|
# guide at: https://bundler.io/guides/creating_gem.html
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "sorbet-runtime"
|
5
|
+
|
6
|
+
module GrapeSorbet
|
7
|
+
# This is a patch for Grape::Entity to make it easier to define custom entity names when using Sorbet.
|
8
|
+
#
|
9
|
+
# This patch defines a class setter `entity_name=` that can be used to define a custom entity name in a single line,
|
10
|
+
# while still working as expected with grape-swagger:
|
11
|
+
# ```
|
12
|
+
# class Link < Grape::Entity
|
13
|
+
# self.entity_name = "LinkedStatus"
|
14
|
+
# end
|
15
|
+
# ```
|
16
|
+
#
|
17
|
+
# Without this patch, you would have to define a custom entity name like this:
|
18
|
+
# ```
|
19
|
+
# class Link < Grape::Entity
|
20
|
+
# extend T::Sig
|
21
|
+
#
|
22
|
+
# sig { returns(String) }
|
23
|
+
# def self.entity_name
|
24
|
+
# "LinkedStatus"
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
# ```
|
28
|
+
#
|
29
|
+
# or even more verbose, if you're using the `Style/ClassMethodsDefinitions` Rubocop rule with
|
30
|
+
# `EnforcedStyle: self_class`:
|
31
|
+
# ```
|
32
|
+
# class Link < Grape::Entity
|
33
|
+
# class << self
|
34
|
+
# extend T::Sig
|
35
|
+
#
|
36
|
+
# sig { returns(String) }
|
37
|
+
# def entity_name
|
38
|
+
# "LinkedStatus"
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# ```
|
43
|
+
module GrapeEntityName
|
44
|
+
extend T::Sig
|
45
|
+
|
46
|
+
include Kernel
|
47
|
+
|
48
|
+
# Sets the entity name.
|
49
|
+
#
|
50
|
+
# Used by grape-swagger to define a custom name to use in the OpenAPI schema instead of generating it from the
|
51
|
+
# fully qualified class name.
|
52
|
+
#
|
53
|
+
# @param entity_name [String] The custom entity name.
|
54
|
+
sig { params(entity_name: String).returns(String) }
|
55
|
+
attr_writer :entity_name
|
56
|
+
|
57
|
+
# Returns the custom entity name if one has been set (using `entity_name=`), otherwise raises an error.
|
58
|
+
#
|
59
|
+
# @return [String] The custom entity name.
|
60
|
+
# @raise [StandardError] If no custom entity name has been set.
|
61
|
+
sig { returns(String) }
|
62
|
+
def entity_name
|
63
|
+
@entity_name = T.let(@entity_name, T.nilable(String))
|
64
|
+
|
65
|
+
return @entity_name unless @entity_name.nil?
|
66
|
+
|
67
|
+
raise "entity_name has not been set for #{self}, call `#{self}.entity_name = \"...\"` to set it"
|
68
|
+
end
|
69
|
+
|
70
|
+
sig { params(method_name: T.any(String, Symbol), include_all: T.untyped).returns(T::Boolean) }
|
71
|
+
def respond_to?(method_name, include_all = false)
|
72
|
+
# grape-swagger checks if the model class responds to `:entity_name`, so we need to return false if
|
73
|
+
# `@entity_name` is nil (meaning `entity_name=` was never called).
|
74
|
+
if method_name.to_sym == :entity_name
|
75
|
+
return !!(defined?(@entity_name) && !@entity_name.nil?)
|
76
|
+
end
|
77
|
+
|
78
|
+
super
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
begin
|
84
|
+
require "grape-entity"
|
85
|
+
rescue LoadError
|
86
|
+
return
|
87
|
+
else
|
88
|
+
Grape::Entity.extend(GrapeSorbet::GrapeEntityName)
|
89
|
+
end
|
data/lib/grape_sorbet/version.rb
CHANGED
data/lib/grape_sorbet.rb
CHANGED
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.9
|
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-07-
|
11
|
+
date: 2024-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- Rakefile
|
73
73
|
- grape_sorbet.gemspec
|
74
74
|
- lib/grape_sorbet.rb
|
75
|
+
- lib/grape_sorbet/grape_entity_name.rb
|
75
76
|
- lib/grape_sorbet/version.rb
|
76
77
|
- lib/tapioca/dsl/compilers/grape_endpoints.rb
|
77
78
|
- lib/tapioca/dsl/helpers/grape_constants_helper.rb
|