rbs_activemodel 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ade04cb067767d6453e1eca795b184333487ea6a95a1da803e3728d9383942d7
4
+ data.tar.gz: 5f4311680e25d88fee12db6dfdda91e970bdfd1cccf78a66425090f79a2be589
5
+ SHA512:
6
+ metadata.gz: 277ba332f36746bee77ca64194efe2de9d72247e114d13e1d5f64e2acf130393156ee25c487eeac988253e26a0a8d338364b970827bbbb1edbb43e2febc8786b
7
+ data.tar.gz: af377a42d1a5cc85c070d1da916bb9bbd2a68cb2f1879063d4c18adc2dfbc3413b22c1d61981c274275a00fa4b7d54b09a2c95003cbbd821dec3bc24a3b6d073
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - 'spec/**/*.rb'
7
+
8
+ Metrics/MethodLength:
9
+ Max: 20
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Style/StringLiterals:
15
+ EnforcedStyle: double_quotes
16
+
17
+ Style/StringLiteralsInInterpolation:
18
+ EnforcedStyle: double_quotes
@@ -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,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: 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,50 @@
1
+ # rbs_activemodel
2
+
3
+ rbs_activemodel is a RBS generator for activemodel gem.
4
+
5
+ ## Installation
6
+
7
+ Add a new entry to your Gemfile and run `bundle install`:
8
+
9
+ group :deveopment do
10
+ gem 'rbs_activemodel', require: false
11
+ end
12
+
13
+ After the installation, please run run rake task generator:
14
+
15
+ bundle exec rails g rbs_activemodel:install
16
+
17
+ ## Usage
18
+
19
+ Run `rbs:activemodel:setup` task:
20
+
21
+ bundle exec rake rbs:activemodel:setup
22
+
23
+ Then rbs_activemodel will scan your source code and generate RBS files into
24
+ `sig/activemodel` directory.
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. You can also
29
+ run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`.
32
+
33
+ To release a new version, update the version number in `version.rb`, and then put
34
+ a git tag (ex. `git tag v1.0.0`) and push it to the GitHub. Then GitHub Actions
35
+ will release a new package to [rubygems.org](https://rubygems.org) automatically.
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tk0miya/rbs_activemodel.
40
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are
41
+ expected to adhere to the [code of conduct](https://github.com/tk0miya/rbs_activemodel/blob/main/CODE_OF_CONDUCT.md).
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Code of Conduct
48
+
49
+ Everyone interacting in the RbsActivemodel project's codebases, issue trackers is expected to
50
+ follow the [code of conduct](https://github.com/tk0miya/rbs_activemodel/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"
9
+
10
+ configure_code_diagnostics(D::Ruby.lenient)
11
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+
5
+ module RbsActivemodel
6
+ class InstallGenerator < Rails::Generators::Base
7
+ def create_raketask
8
+ create_file "lib/tasks/rbs_activemodel.rake", <<~RUBY
9
+ # frozen_string_literal: true
10
+
11
+ begin
12
+ require 'rbs_activemodel/rake_task'
13
+
14
+ RbsActivemodel::RakeTask.new do |task|
15
+ end
16
+ rescue LoadError
17
+ # failed to load rbs_activemodel. Skip to load rbs_activemodel tasks.
18
+ end
19
+ RUBY
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_model"
4
+ require "bigdecimal"
5
+ require "date"
6
+ require "rbs"
7
+
8
+ module RbsActivemodel
9
+ module ActiveModel
10
+ def self.all
11
+ ObjectSpace.each_object.select do |obj|
12
+ obj.is_a?(Class) && obj.ancestors.include?(::ActiveModel::Validations)
13
+ rescue StandardError
14
+ nil
15
+ end
16
+ end
17
+
18
+ def self.class_to_rbs(klass)
19
+ Generator.new(klass).generate
20
+ end
21
+
22
+ class Generator
23
+ MIXINS = [::ActiveModel::Model, ::ActiveModel::Attributes, ::ActiveModel::Validations].freeze
24
+ TYPES = {
25
+ big_integer: Integer,
26
+ binary: String,
27
+ boolean: :bool,
28
+ date: Date,
29
+ datetime: DateTime,
30
+ decimal: BigDecimal,
31
+ float: Float,
32
+ immutable_string: String,
33
+ integer: Integer,
34
+ string: String,
35
+ time: Time
36
+ }.freeze
37
+
38
+ def initialize(klass)
39
+ @klass = klass
40
+ @klass_name = klass.name || ""
41
+ end
42
+
43
+ def generate
44
+ return if mixins.empty?
45
+
46
+ format <<~RBS
47
+ #{header}
48
+ #{mixins}
49
+
50
+ #{attributes}
51
+ #{footer}
52
+ RBS
53
+ end
54
+
55
+ private
56
+
57
+ attr_reader :klass, :klass_name
58
+
59
+ def format(rbs)
60
+ parsed = RBS::Parser.parse_signature(rbs)
61
+ StringIO.new.tap do |out|
62
+ RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
63
+ end.string
64
+ end
65
+
66
+ def header
67
+ namespace = +""
68
+ klass_name.split("::").map do |mod_name|
69
+ namespace += "::#{mod_name}"
70
+ mod_object = Object.const_get(namespace)
71
+ case mod_object
72
+ when Class
73
+ if mod_object.superclass == Object
74
+ "class #{mod_name}"
75
+ else
76
+ superclass_name = mod_object.superclass&.name || "Object"
77
+ "class #{mod_name} < ::#{superclass_name}"
78
+ end
79
+ when Module
80
+ "module #{mod_name}"
81
+ else
82
+ raise "unreachable"
83
+ end
84
+ end.join("\n")
85
+ end
86
+
87
+ def mixins
88
+ MIXINS.each_with_object([]) do |mod, mixins|
89
+ if klass < mod
90
+ mixins << "include ::#{mod.name}"
91
+ mixins << "extend ::#{mod.name}::ClassMethods" if mod.const_defined?(:ClassMethods)
92
+ end
93
+ end.join("\n")
94
+ end
95
+
96
+ def attributes
97
+ return "" unless klass < ::ActiveModel::Attributes
98
+
99
+ # @type var model: untyped
100
+ model = klass
101
+ model.attribute_types.map do |name, type|
102
+ type = TYPES.fetch(type.type, :untyped)
103
+ type_name = type.is_a?(Class) ? type.name : type.to_s
104
+ suffix = "?" unless required_attribute?(name)
105
+ <<~RBS
106
+ def #{name}: () -> #{type_name}#{suffix}
107
+ def #{name}=: (#{type_name}#{suffix} value) -> #{type_name}#{suffix}
108
+ RBS
109
+ end.join("\n")
110
+ end
111
+
112
+ def required_attribute?(name)
113
+ return false unless klass < ::ActiveModel::Validations
114
+
115
+ klass.validators.any? do |v| # steep:ignore NoMethod
116
+ v.is_a?(::ActiveModel::Validations::PresenceValidator) && v.attributes.include?(name.to_sym)
117
+ end
118
+ end
119
+
120
+ def footer
121
+ "end\n" * klass.module_parents.size # steep:ignore
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "rake/tasklib"
5
+
6
+ module RbsActivemodel
7
+ class RakeTask < Rake::TaskLib
8
+ attr_accessor :name, :signature_root_dir
9
+
10
+ def initialize(name = :'rbs:activemodel', &block)
11
+ super()
12
+
13
+ @name = name
14
+ @signature_root_dir = Pathname(Rails.root / "sig/activemodel")
15
+
16
+ block&.call(self)
17
+
18
+ define_clean_task
19
+ define_generate_task
20
+ define_setup_task
21
+ end
22
+
23
+ def define_setup_task
24
+ desc "Run all tasks of rbs_activemodel"
25
+
26
+ deps = [:"#{name}:clean", :"#{name}:generate"]
27
+ task("#{name}:setup" => deps)
28
+ end
29
+
30
+ def define_generate_task
31
+ desc "Generate RBS files for activemodel gem"
32
+ task("#{name}:generate": :environment) do
33
+ require "rbs_activemodel" # load RbsActivemodel lazily
34
+
35
+ Rails.application.eager_load!
36
+
37
+ RbsActivemodel::ActiveModel.all.each do |klass|
38
+ rbs = RbsActivemodel::ActiveModel.class_to_rbs(klass)
39
+ next unless rbs
40
+
41
+ path = signature_root_dir / "app/models/#{klass.name&.underscore}.rbs"
42
+ path.dirname.mkpath
43
+ path.write(rbs)
44
+ end
45
+ end
46
+ end
47
+
48
+ def define_clean_task
49
+ desc "Clean RBS files for config gem"
50
+ task("#{name}:clean": :environment) do
51
+ signature_root_dir.rmtree if signature_root_dir.exist?
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsActivemodel
4
+ VERSION = "1.0.0"
5
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rbs_activemodel/active_model"
4
+ require_relative "rbs_activemodel/version"
5
+
6
+ module RbsActivemodel
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,280 @@
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: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
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: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
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: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
26
+ remote: https://github.com/ruby/gem_rbs_collection.git
27
+ repo_dir: gems
28
+ - name: activesupport
29
+ version: '7.0'
30
+ source:
31
+ type: git
32
+ name: ruby/gem_rbs_collection
33
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
34
+ remote: https://github.com/ruby/gem_rbs_collection.git
35
+ repo_dir: gems
36
+ - name: ast
37
+ version: '2.4'
38
+ source:
39
+ type: git
40
+ name: ruby/gem_rbs_collection
41
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
42
+ remote: https://github.com/ruby/gem_rbs_collection.git
43
+ repo_dir: gems
44
+ - name: base64
45
+ version: '0'
46
+ source:
47
+ type: stdlib
48
+ - name: bigdecimal
49
+ version: '0'
50
+ source:
51
+ type: stdlib
52
+ - name: cgi
53
+ version: '0'
54
+ source:
55
+ type: stdlib
56
+ - name: concurrent-ruby
57
+ version: '1.1'
58
+ source:
59
+ type: git
60
+ name: ruby/gem_rbs_collection
61
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
62
+ remote: https://github.com/ruby/gem_rbs_collection.git
63
+ repo_dir: gems
64
+ - name: connection_pool
65
+ version: '2.4'
66
+ source:
67
+ type: git
68
+ name: ruby/gem_rbs_collection
69
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
70
+ remote: https://github.com/ruby/gem_rbs_collection.git
71
+ repo_dir: gems
72
+ - name: date
73
+ version: '0'
74
+ source:
75
+ type: stdlib
76
+ - name: dbm
77
+ version: '0'
78
+ source:
79
+ type: stdlib
80
+ - name: erb
81
+ version: '0'
82
+ source:
83
+ type: stdlib
84
+ - name: fileutils
85
+ version: '0'
86
+ source:
87
+ type: stdlib
88
+ - name: i18n
89
+ version: '1.10'
90
+ source:
91
+ type: git
92
+ name: ruby/gem_rbs_collection
93
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
94
+ remote: https://github.com/ruby/gem_rbs_collection.git
95
+ repo_dir: gems
96
+ - name: io-console
97
+ version: '0'
98
+ source:
99
+ type: stdlib
100
+ - name: json
101
+ version: '0'
102
+ source:
103
+ type: stdlib
104
+ - name: logger
105
+ version: '0'
106
+ source:
107
+ type: stdlib
108
+ - name: minitest
109
+ version: '0'
110
+ source:
111
+ type: stdlib
112
+ - name: monitor
113
+ version: '0'
114
+ source:
115
+ type: stdlib
116
+ - name: mutex_m
117
+ version: '0'
118
+ source:
119
+ type: stdlib
120
+ - name: nokogiri
121
+ version: '1.11'
122
+ source:
123
+ type: git
124
+ name: ruby/gem_rbs_collection
125
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
126
+ remote: https://github.com/ruby/gem_rbs_collection.git
127
+ repo_dir: gems
128
+ - name: optparse
129
+ version: '0'
130
+ source:
131
+ type: stdlib
132
+ - name: parallel
133
+ version: '1.20'
134
+ source:
135
+ type: git
136
+ name: ruby/gem_rbs_collection
137
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
138
+ remote: https://github.com/ruby/gem_rbs_collection.git
139
+ repo_dir: gems
140
+ - name: parser
141
+ version: '3.2'
142
+ source:
143
+ type: git
144
+ name: ruby/gem_rbs_collection
145
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
146
+ remote: https://github.com/ruby/gem_rbs_collection.git
147
+ repo_dir: gems
148
+ - name: pathname
149
+ version: '0'
150
+ source:
151
+ type: stdlib
152
+ - name: pstore
153
+ version: '0'
154
+ source:
155
+ type: stdlib
156
+ - name: psych
157
+ version: '0'
158
+ source:
159
+ type: stdlib
160
+ - name: rack
161
+ version: '2.2'
162
+ source:
163
+ type: git
164
+ name: ruby/gem_rbs_collection
165
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
166
+ remote: https://github.com/ruby/gem_rbs_collection.git
167
+ repo_dir: gems
168
+ - name: rails-dom-testing
169
+ version: '2.0'
170
+ source:
171
+ type: git
172
+ name: ruby/gem_rbs_collection
173
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
174
+ remote: https://github.com/ruby/gem_rbs_collection.git
175
+ repo_dir: gems
176
+ - name: railties
177
+ version: '6.0'
178
+ source:
179
+ type: git
180
+ name: ruby/gem_rbs_collection
181
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
182
+ remote: https://github.com/ruby/gem_rbs_collection.git
183
+ repo_dir: gems
184
+ - name: rainbow
185
+ version: '3.0'
186
+ source:
187
+ type: git
188
+ name: ruby/gem_rbs_collection
189
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
190
+ remote: https://github.com/ruby/gem_rbs_collection.git
191
+ repo_dir: gems
192
+ - name: rake
193
+ version: '13.0'
194
+ source:
195
+ type: git
196
+ name: ruby/gem_rbs_collection
197
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
198
+ remote: https://github.com/ruby/gem_rbs_collection.git
199
+ repo_dir: gems
200
+ - name: rbs
201
+ version: 3.5.2
202
+ source:
203
+ type: rubygems
204
+ - name: rdoc
205
+ version: '0'
206
+ source:
207
+ type: stdlib
208
+ - name: regexp_parser
209
+ version: '2.8'
210
+ source:
211
+ type: git
212
+ name: ruby/gem_rbs_collection
213
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
214
+ remote: https://github.com/ruby/gem_rbs_collection.git
215
+ repo_dir: gems
216
+ - name: rubocop
217
+ version: '1.57'
218
+ source:
219
+ type: git
220
+ name: ruby/gem_rbs_collection
221
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
222
+ remote: https://github.com/ruby/gem_rbs_collection.git
223
+ repo_dir: gems
224
+ - name: rubocop-ast
225
+ version: '1.30'
226
+ source:
227
+ type: git
228
+ name: ruby/gem_rbs_collection
229
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
230
+ remote: https://github.com/ruby/gem_rbs_collection.git
231
+ repo_dir: gems
232
+ - name: securerandom
233
+ version: '0'
234
+ source:
235
+ type: stdlib
236
+ - name: singleton
237
+ version: '0'
238
+ source:
239
+ type: stdlib
240
+ - name: strscan
241
+ version: '0'
242
+ source:
243
+ type: stdlib
244
+ - name: tempfile
245
+ version: '0'
246
+ source:
247
+ type: stdlib
248
+ - name: thor
249
+ version: '1.2'
250
+ source:
251
+ type: git
252
+ name: ruby/gem_rbs_collection
253
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
254
+ remote: https://github.com/ruby/gem_rbs_collection.git
255
+ repo_dir: gems
256
+ - name: time
257
+ version: '0'
258
+ source:
259
+ type: stdlib
260
+ - name: timeout
261
+ version: '0'
262
+ source:
263
+ type: stdlib
264
+ - name: tsort
265
+ version: '0'
266
+ source:
267
+ type: stdlib
268
+ - name: tzinfo
269
+ version: '2.0'
270
+ source:
271
+ type: git
272
+ name: ruby/gem_rbs_collection
273
+ revision: 3ff00fb82aa9e9fc72eb60a8172f664f25e7cbad
274
+ remote: https://github.com/ruby/gem_rbs_collection.git
275
+ repo_dir: gems
276
+ - name: uri
277
+ version: '0'
278
+ source:
279
+ type: stdlib
280
+ gemfile_lock_path: Gemfile.lock
@@ -0,0 +1,19 @@
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
+ # # If you want to avoid installing rbs files for gems, you can specify them here.
18
+ # - name: GEM_NAME
19
+ # ignore: true
@@ -0,0 +1,26 @@
1
+ module RbsActivemodel
2
+ module ActiveModel
3
+ def self.all: () -> Array[Class]
4
+ def self.class_to_rbs: (Class klass) -> String?
5
+
6
+ class Generator
7
+ MIXINS: Array[Module]
8
+ TYPES: Hash[Symbol, untyped]
9
+
10
+ def initialize: (Class klass) -> void
11
+ def generate: () -> String?
12
+
13
+ private
14
+
15
+ attr_reader klass: Class
16
+ attr_reader klass_name: String
17
+
18
+ def format: (String rbs) -> String
19
+ def header: () -> String
20
+ def mixins: () -> String
21
+ def attributes: () -> String
22
+ def footer: () -> String
23
+ def required_attribute?: (String name) -> bool
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module RbsActivemodel
2
+ class RakeTask < Rake::TaskLib
3
+ attr_accessor name: Symbol
4
+ attr_accessor signature_root_dir: Pathname
5
+
6
+ def initialize: (?Symbol name) ?{ (self) -> void } -> void
7
+ def define_setup_task: () -> void
8
+ def define_generate_task: () -> void
9
+ def define_clean_task: () -> void
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module RbsActivemodel
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_activemodel
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-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
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
+ description: A RBS files generator for activemodel gem
56
+ email:
57
+ - i.tkomiya@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rubocop.yml"
63
+ - ".vscode/extensions.json"
64
+ - ".vscode/settings.json"
65
+ - CODE_OF_CONDUCT.md
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - Steepfile
70
+ - lib/generators/rbs_activemodel/install_generator.rb
71
+ - lib/rbs_activemodel.rb
72
+ - lib/rbs_activemodel/active_model.rb
73
+ - lib/rbs_activemodel/rake_task.rb
74
+ - lib/rbs_activemodel/version.rb
75
+ - rbs_collection.lock.yaml
76
+ - rbs_collection.yaml
77
+ - sig/rbs_activemodel.rbs
78
+ - sig/rbs_activemodel/active_model.rbs
79
+ - sig/rbs_activemodel/rake_task.rbs
80
+ homepage: https://github.com/tk0miya/rbs_activemodel
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ homepage_uri: https://github.com/tk0miya/rbs_activemodel
85
+ source_code_uri: https://github.com/tk0miya/rbs_activemodel
86
+ changelog_uri: https://github.com/tk0miya/rbs_activemodel
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 2.7.0
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.5.11
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: A RBS files generator for activemodel gem
106
+ test_files: []