rbs_shrine 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8bb0ed7dead747c1d8086f099f495f7c50ae2e4a09c3cfa3eb454b81db5ab508
4
+ data.tar.gz: 75399eeb2ec24420911300d43f04a6d2a06116831623fb05f550cca40213d084
5
+ SHA512:
6
+ metadata.gz: 5a8dc5f2c83e4f906cfbfd9bee09af314a755bb2e35abd47813cc1217976a6d90fd934f741e83d8116e19efb41c3a2dec8038778e1322b4bca4f94d44d48800c
7
+ data.tar.gz: 0aa9efc8a334177cfc1389b0b0e3adc97fc6a1363f5b2f23fb51f2847bc1d6138aeb89e2a30221398415f0a9458381297b8681a8d4442c99c3cd437fcbe4d787
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.3
3
+
4
+ Style/Documentation:
5
+ Enabled: false
6
+
7
+ Style/StringLiterals:
8
+ Enabled: true
9
+ EnforcedStyle: double_quotes
10
+
11
+ Style/StringLiteralsInInterpolation:
12
+ Enabled: true
13
+ EnforcedStyle: double_quotes
14
+
15
+ Layout/BlockLength:
16
+ Exclude:
17
+ - "spec/**/*_spec.rb"
18
+
19
+ Layout/LineLength:
20
+ Max: 120
21
+
22
+ Layout/MethodLength:
23
+ Max: 20
24
+
25
+ Metrics/AbcSize:
26
+ Max: 20
@@ -0,0 +1,8 @@
1
+ {
2
+ "recommendations": [
3
+ "shopify.ruby-lsp",
4
+ "soutaro.steep-vscode",
5
+ "tk0miya.rspec-daemon",
6
+ "tk0miya.rbs-helper"
7
+ ]
8
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.defaultFormatter": "Shopify.ruby-lsp",
4
+ },
5
+ "rbs-helper.signature-directory": "sig"
6
+ }
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at i.tkomiya@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Takeshi KOMIYA
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # rbs_shrine
2
+
3
+ rbs_shrine is a RBS generator for [shrine](https://github.com/shrinerb/shrine)
4
+
5
+ ## Installation
6
+
7
+ Add a new entry to your Gemfile and run `bundle install`.
8
+
9
+ group :development do
10
+ gem 'rbs_shrine', require: false
11
+ end
12
+
13
+ After the installation, please run rake task generator:
14
+
15
+ bundle exec rails g rbs_shrine:install
16
+
17
+ ## Usage
18
+
19
+ Run `rbs:shrine:setup` task:
20
+
21
+ bundle exec rake rbs:shrine:setup
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also
26
+ run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`.
29
+ To release a new version, update the version number in `version.rb`, and then put
30
+ a git tag (ex. `git tag v1.0.0`) and push it to the GitHub. Then GitHub Actions
31
+ will release a new package to [rubygems.org](https://rubygems.org) automatically.
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tk0miya/rbs_shrine.
36
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are
37
+ expected to adhere to the [code of conduct](https://github.com/tk0miya/rbs_shrine/blob/main/CODE_OF_CONDUCT.md).
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+
43
+ ## Code of Conduct
44
+
45
+ Everyone interacting in the RbsShrine project's codebases and issue trackers is expected to
46
+ follow the [code of conduct](https://github.com/tk0miya/rbs_shrine/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task default: :rubocop
data/Steepfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ D = Steep::Diagnostic
4
+
5
+ target :lib do
6
+ signature "sig"
7
+
8
+ check "lib" # Directory name
9
+
10
+ configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
11
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+
5
+ module RbsShrine
6
+ class InstallGenerator < ::Rails::Generators::Base
7
+ def create_raketask
8
+ create_file "lib/tasks/rbs_shrine.rake", <<~RUBY
9
+ # frozen_string_literal: true
10
+
11
+ begin
12
+ require "rbs_shrine/rake_task"
13
+
14
+ RbsShrine::RakeTask.new
15
+ rescue LoadError
16
+ # failed to load rbs_shrine. Skip to load rbs_shrine tasks.
17
+ end
18
+ RUBY
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake/tasklib"
4
+
5
+ module RbsShrine
6
+ class RakeTask < Rake::TaskLib
7
+ attr_accessor :name, :signature_root_dir
8
+
9
+ def initialize(name = :'rbs:shrine', &block)
10
+ super()
11
+
12
+ @name = name
13
+ @signature_root_dir = Rails.root / "sig/rbs_shrine"
14
+
15
+ block&.call(self)
16
+
17
+ define_generate_task
18
+ define_clean_task
19
+ define_setup_task
20
+ end
21
+
22
+ def define_setup_task
23
+ desc "Run all tasks of rbs_shrine"
24
+
25
+ deps = [:"#{name}:clean", :"#{name}:generate"]
26
+ task("#{name}:setup" => deps)
27
+ end
28
+
29
+ def define_clean_task
30
+ desc "Clean RBS files for shrine models"
31
+ task "#{name}:clean" do
32
+ signature_root_dir.rmtree if signature_root_dir.exist?
33
+ end
34
+ end
35
+
36
+ def define_generate_task
37
+ desc "Generate RBS files for shrine models"
38
+ task("#{name}:generate": :environment) do
39
+ require "rbs_shrine/shrine" # load RbsShrine lazily
40
+
41
+ Rails.application.eager_load!
42
+
43
+ RbsShrine::Shrine.all.each do |klass|
44
+ rbs = RbsShrine::Shrine.class_to_rbs(klass)
45
+ path = signature_root_dir / "#{klass.name.to_s.underscore}.rbs"
46
+ path.dirname.mkpath
47
+ path.write(rbs)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rbs"
4
+
5
+ module RbsShrine
6
+ module Shrine
7
+ def self.all
8
+ ActiveRecord::Base.descendants.select { |model| model.ancestors.any?(::Shrine::Attachment) }
9
+ end
10
+
11
+ def self.class_to_rbs(klass)
12
+ Generator.new(klass).generate
13
+ end
14
+
15
+ class Generator
16
+ attr_reader :klass, :klass_name
17
+
18
+ def initialize(klass)
19
+ @klass = klass
20
+ @klass_name = klass.name || ""
21
+ end
22
+
23
+ def generate
24
+ format <<~RBS
25
+ #{header}
26
+ #{methods}
27
+ #{footer}
28
+ RBS
29
+ end
30
+
31
+ private
32
+
33
+ def format(rbs)
34
+ parsed = RBS::Parser.parse_signature(rbs)
35
+ StringIO.new.tap do |out|
36
+ RBS::Writer.new(out:).write(parsed[1] + parsed[2])
37
+ end.string
38
+ end
39
+
40
+ def header
41
+ namespace = +""
42
+ klass_name.split("::").map do |mod_name|
43
+ namespace += "::#{mod_name}"
44
+ mod_object = Object.const_get(namespace)
45
+ case mod_object
46
+ when Class
47
+ # @type var superclass: Class
48
+ superclass = _ = mod_object.superclass
49
+ superclass_name = superclass.name || "Object"
50
+
51
+ "class #{mod_name} < ::#{superclass_name}"
52
+ when Module
53
+ "module #{mod_name}"
54
+ else
55
+ raise "unreachable"
56
+ end
57
+ end.join("\n")
58
+ end
59
+
60
+ def footer
61
+ "end\n" * klass.module_parents.size
62
+ end
63
+
64
+ def methods
65
+ attachments.reverse.map do |attachment|
66
+ name = attachment.attachment_name
67
+ <<~RBS
68
+ def #{name}: () -> Shrine::UploadedFile
69
+ def #{name}=: (IO | String | Hash[untyped, untyped]) -> Shrine::UploadedFile
70
+ def #{name}_changed: () -> bool
71
+ def #{name}_url: () -> String
72
+ RBS
73
+ end.join("\n")
74
+ end
75
+
76
+ def attachments
77
+ @klass.ancestors.filter_map { |mod| mod if mod.is_a? ::Shrine::Attachment }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsShrine
4
+ VERSION = "1.0.0"
5
+ end
data/lib/rbs_shrine.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rbs_shrine/shrine"
4
+ require_relative "rbs_shrine/version"
5
+
6
+ module RbsShrine
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,296 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: actionpack
5
+ version: '6.0'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: actionview
13
+ version: '6.0'
14
+ source:
15
+ type: git
16
+ name: ruby/gem_rbs_collection
17
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
18
+ remote: https://github.com/ruby/gem_rbs_collection.git
19
+ repo_dir: gems
20
+ - name: activemodel
21
+ version: '7.0'
22
+ source:
23
+ type: git
24
+ name: ruby/gem_rbs_collection
25
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
26
+ remote: https://github.com/ruby/gem_rbs_collection.git
27
+ repo_dir: gems
28
+ - name: activerecord
29
+ version: '7.1'
30
+ source:
31
+ type: git
32
+ name: ruby/gem_rbs_collection
33
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
34
+ remote: https://github.com/ruby/gem_rbs_collection.git
35
+ repo_dir: gems
36
+ - name: activesupport
37
+ version: '7.0'
38
+ source:
39
+ type: git
40
+ name: ruby/gem_rbs_collection
41
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
42
+ remote: https://github.com/ruby/gem_rbs_collection.git
43
+ repo_dir: gems
44
+ - name: addressable
45
+ version: '2.8'
46
+ source:
47
+ type: git
48
+ name: ruby/gem_rbs_collection
49
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
50
+ remote: https://github.com/ruby/gem_rbs_collection.git
51
+ repo_dir: gems
52
+ - name: ast
53
+ version: '2.4'
54
+ source:
55
+ type: git
56
+ name: ruby/gem_rbs_collection
57
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
58
+ remote: https://github.com/ruby/gem_rbs_collection.git
59
+ repo_dir: gems
60
+ - name: base64
61
+ version: '0'
62
+ source:
63
+ type: stdlib
64
+ - name: bigdecimal
65
+ version: '0'
66
+ source:
67
+ type: stdlib
68
+ - name: cgi
69
+ version: '0'
70
+ source:
71
+ type: stdlib
72
+ - name: concurrent-ruby
73
+ version: '1.1'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: connection_pool
81
+ version: '2.4'
82
+ source:
83
+ type: git
84
+ name: ruby/gem_rbs_collection
85
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
86
+ remote: https://github.com/ruby/gem_rbs_collection.git
87
+ repo_dir: gems
88
+ - name: date
89
+ version: '0'
90
+ source:
91
+ type: stdlib
92
+ - name: dbm
93
+ version: '0'
94
+ source:
95
+ type: stdlib
96
+ - name: erb
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: fileutils
101
+ version: '0'
102
+ source:
103
+ type: stdlib
104
+ - name: i18n
105
+ version: '1.10'
106
+ source:
107
+ type: git
108
+ name: ruby/gem_rbs_collection
109
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
110
+ remote: https://github.com/ruby/gem_rbs_collection.git
111
+ repo_dir: gems
112
+ - name: io-console
113
+ version: '0'
114
+ source:
115
+ type: stdlib
116
+ - name: json
117
+ version: '0'
118
+ source:
119
+ type: stdlib
120
+ - name: logger
121
+ version: '0'
122
+ source:
123
+ type: stdlib
124
+ - name: minitest
125
+ version: '0'
126
+ source:
127
+ type: stdlib
128
+ - name: monitor
129
+ version: '0'
130
+ source:
131
+ type: stdlib
132
+ - name: mutex_m
133
+ version: '0'
134
+ source:
135
+ type: stdlib
136
+ - name: nokogiri
137
+ version: '1.11'
138
+ source:
139
+ type: git
140
+ name: ruby/gem_rbs_collection
141
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
142
+ remote: https://github.com/ruby/gem_rbs_collection.git
143
+ repo_dir: gems
144
+ - name: optparse
145
+ version: '0'
146
+ source:
147
+ type: stdlib
148
+ - name: parallel
149
+ version: '1.20'
150
+ source:
151
+ type: git
152
+ name: ruby/gem_rbs_collection
153
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
154
+ remote: https://github.com/ruby/gem_rbs_collection.git
155
+ repo_dir: gems
156
+ - name: parser
157
+ version: '3.2'
158
+ source:
159
+ type: git
160
+ name: ruby/gem_rbs_collection
161
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
162
+ remote: https://github.com/ruby/gem_rbs_collection.git
163
+ repo_dir: gems
164
+ - name: pathname
165
+ version: '0'
166
+ source:
167
+ type: stdlib
168
+ - name: pstore
169
+ version: '0'
170
+ source:
171
+ type: stdlib
172
+ - name: psych
173
+ version: '0'
174
+ source:
175
+ type: stdlib
176
+ - name: rack
177
+ version: '2.2'
178
+ source:
179
+ type: git
180
+ name: ruby/gem_rbs_collection
181
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
182
+ remote: https://github.com/ruby/gem_rbs_collection.git
183
+ repo_dir: gems
184
+ - name: rails-dom-testing
185
+ version: '2.0'
186
+ source:
187
+ type: git
188
+ name: ruby/gem_rbs_collection
189
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
190
+ remote: https://github.com/ruby/gem_rbs_collection.git
191
+ repo_dir: gems
192
+ - name: railties
193
+ version: '6.0'
194
+ source:
195
+ type: git
196
+ name: ruby/gem_rbs_collection
197
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
198
+ remote: https://github.com/ruby/gem_rbs_collection.git
199
+ repo_dir: gems
200
+ - name: rainbow
201
+ version: '3.0'
202
+ source:
203
+ type: git
204
+ name: ruby/gem_rbs_collection
205
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
206
+ remote: https://github.com/ruby/gem_rbs_collection.git
207
+ repo_dir: gems
208
+ - name: rake
209
+ version: '13.0'
210
+ source:
211
+ type: git
212
+ name: ruby/gem_rbs_collection
213
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
214
+ remote: https://github.com/ruby/gem_rbs_collection.git
215
+ repo_dir: gems
216
+ - name: rbs
217
+ version: 3.5.1
218
+ source:
219
+ type: rubygems
220
+ - name: rdoc
221
+ version: '0'
222
+ source:
223
+ type: stdlib
224
+ - name: regexp_parser
225
+ version: '2.8'
226
+ source:
227
+ type: git
228
+ name: ruby/gem_rbs_collection
229
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
230
+ remote: https://github.com/ruby/gem_rbs_collection.git
231
+ repo_dir: gems
232
+ - name: rubocop
233
+ version: '1.57'
234
+ source:
235
+ type: git
236
+ name: ruby/gem_rbs_collection
237
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
238
+ remote: https://github.com/ruby/gem_rbs_collection.git
239
+ repo_dir: gems
240
+ - name: rubocop-ast
241
+ version: '1.30'
242
+ source:
243
+ type: git
244
+ name: ruby/gem_rbs_collection
245
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
246
+ remote: https://github.com/ruby/gem_rbs_collection.git
247
+ repo_dir: gems
248
+ - name: securerandom
249
+ version: '0'
250
+ source:
251
+ type: stdlib
252
+ - name: shrine
253
+ version: '3.6'
254
+ source:
255
+ type: git
256
+ name: ruby/gem_rbs_collection
257
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
258
+ remote: https://github.com/ruby/gem_rbs_collection.git
259
+ repo_dir: gems
260
+ - name: singleton
261
+ version: '0'
262
+ source:
263
+ type: stdlib
264
+ - name: strscan
265
+ version: '0'
266
+ source:
267
+ type: stdlib
268
+ - name: tempfile
269
+ version: '0'
270
+ source:
271
+ type: stdlib
272
+ - name: thor
273
+ version: '1.2'
274
+ source:
275
+ type: git
276
+ name: ruby/gem_rbs_collection
277
+ revision: 3c1c5abbff9e53169dbee3ceb2919b66b4ec06bf
278
+ remote: https://github.com/ruby/gem_rbs_collection.git
279
+ repo_dir: gems
280
+ - name: time
281
+ version: '0'
282
+ source:
283
+ type: stdlib
284
+ - name: timeout
285
+ version: '0'
286
+ source:
287
+ type: stdlib
288
+ - name: tsort
289
+ version: '0'
290
+ source:
291
+ type: stdlib
292
+ - name: uri
293
+ version: '0'
294
+ source:
295
+ type: stdlib
296
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,17 @@
1
+ # Download sources
2
+ sources:
3
+ - type: git
4
+ name: ruby/gem_rbs_collection
5
+ remote: https://github.com/ruby/gem_rbs_collection.git
6
+ revision: main
7
+ repo_dir: gems
8
+
9
+ # You can specify local directories as sources also.
10
+ # - type: local
11
+ # path: path/to/your/local/repository
12
+
13
+ # A directory to install the downloaded RBSs
14
+ path: .gem_rbs_collection
15
+
16
+ gems:
17
+ - name: pathname
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rbs_shrine/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rbs_shrine"
7
+ spec.version = RbsShrine::VERSION
8
+ spec.authors = ["Takeshi KOMIYA"]
9
+ spec.email = ["i.tkomiya@gmail.com"]
10
+
11
+ spec.summary = "A RBS files generator for shrine gem"
12
+ spec.description = "A RBS files generator for shrine gem"
13
+ spec.homepage = "https://github.com/tk0miya/rbs_shrine"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.3.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = spec.homepage
20
+
21
+ spec.files = Dir.chdir(__dir__) do
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ (File.expand_path(f) == __FILE__) ||
24
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "activerecord"
32
+ spec.add_dependency "railties"
33
+ spec.add_dependency "rbs"
34
+ spec.add_dependency "shrine"
35
+ end
@@ -0,0 +1,5 @@
1
+ module RbsShrine
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ def create_raketask: () -> void
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module RbsShrine
2
+ class RakeTask < Rake::TaskLib
3
+ attr_accessor name: Symbol
4
+ attr_accessor signature_root_dir: Pathname
5
+
6
+ def initialize: (?Symbol name) ? { (RakeTask) -> void } -> void
7
+ def define_setup_task: () -> void
8
+ def define_clean_task: () -> void
9
+ def define_generate_task: () -> void
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ module RbsShrine
2
+ module Shrine
3
+ def self.all: () -> Array[singleton(ActiveRecord::Base)]
4
+ def self.class_to_rbs: (singleton(ActiveRecord::Base) klass) -> String
5
+
6
+ class Generator
7
+ attr_reader klass: singleton(ActiveRecord::Base)
8
+ attr_reader klass_name: String
9
+
10
+ def initialize: (singleton(ActiveRecord::Base) klass) -> void
11
+ def generate: () -> String
12
+
13
+ private
14
+
15
+ def format: (String rbs) -> String
16
+ def header: () -> String
17
+ def footer: () -> String
18
+ def methods: () -> String
19
+ def attachments: () -> Array[::Shrine::Attachment]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,4 @@
1
+ module RbsShrine
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_shrine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Takeshi KOMIYA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rbs
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: shrine
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A RBS files generator for shrine gem
70
+ email:
71
+ - i.tkomiya@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rubocop.yml"
77
+ - ".vscode/extensions.json"
78
+ - ".vscode/settings.json"
79
+ - CODE_OF_CONDUCT.md
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - Steepfile
84
+ - lib/generators/rbs_shrine/install_generator.rb
85
+ - lib/rbs_shrine.rb
86
+ - lib/rbs_shrine/rake_task.rb
87
+ - lib/rbs_shrine/shrine.rb
88
+ - lib/rbs_shrine/version.rb
89
+ - rbs_collection.lock.yaml
90
+ - rbs_collection.yaml
91
+ - rbs_shrine.gemspec
92
+ - sig/generators/rbs_shrine/install_generator.rbs
93
+ - sig/rbs_shrine.rbs
94
+ - sig/rbs_shrine/rake_task.rbs
95
+ - sig/rbs_shrine/shrine.rbs
96
+ homepage: https://github.com/tk0miya/rbs_shrine
97
+ licenses:
98
+ - MIT
99
+ metadata:
100
+ homepage_uri: https://github.com/tk0miya/rbs_shrine
101
+ source_code_uri: https://github.com/tk0miya/rbs_shrine
102
+ changelog_uri: https://github.com/tk0miya/rbs_shrine
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: 3.3.0
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.5.11
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: A RBS files generator for shrine gem
122
+ test_files: []