rbs_macros 0.1.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: f857911ae1a23094de7cf617b4c448d6c530a4da8686f8828017cb305b0aa5dd
4
+ data.tar.gz: 7965b1c8589b98f50da82514e571aad21c09fa10602af046b6d93a8183075882
5
+ SHA512:
6
+ metadata.gz: 56edf8c7e6414458a32750b7441631d2c7680bc33e110358decc802821e9706eb36d46756a20d371ad571ac26dbc2821399bf45ea76658bba6b7fa9a611ca02c
7
+ data.tar.gz: c9290797633b66a5a1033e0da910132dc7bdbec01a5910325132ced2684da9b85f66e633564fc5c64ba6fe428288ade81f9af19ed13a0f980a9413acd459cf0a
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,49 @@
1
+ inherit_from:
2
+ - .rubocop_new.yml
3
+
4
+ require:
5
+ - rubocop-minitest
6
+ - rubocop-rake
7
+
8
+ AllCops:
9
+ TargetRubyVersion: "3.2"
10
+
11
+ Naming/MethodParameterName:
12
+ Enabled: false
13
+
14
+ Style/LambdaCall:
15
+ Enabled: true
16
+ EnforcedStyle: braces
17
+
18
+ Style/StringLiterals:
19
+ Enabled: true
20
+ EnforcedStyle: double_quotes
21
+
22
+ Style/StringLiteralsInInterpolation:
23
+ Enabled: true
24
+ EnforcedStyle: double_quotes
25
+
26
+ Style/WordArray:
27
+ Enabled: true
28
+ EnforcedStyle: brackets
29
+
30
+ Layout/LineLength:
31
+ Max: 120
32
+
33
+ Metrics/AbcSize:
34
+ Max: 150
35
+
36
+ Metrics/BlockLength:
37
+ Max: 100
38
+
39
+ Metrics/CyclomaticComplexity:
40
+ Max: 50
41
+
42
+ Metrics/MethodLength:
43
+ Max: 200
44
+
45
+ Metrics/ModuleLength:
46
+ Max: 500
47
+
48
+ Metrics/PerceivedComplexity:
49
+ Max: 50
data/.rubocop_new.yml ADDED
@@ -0,0 +1,269 @@
1
+ Gemspec/DeprecatedAttributeAssignment: # new in 1.30
2
+ Enabled: true
3
+ Gemspec/DevelopmentDependencies: # new in 1.44
4
+ Enabled: true
5
+ Gemspec/RequireMFA: # new in 1.23
6
+ Enabled: true
7
+ Layout/LineContinuationLeadingSpace: # new in 1.31
8
+ Enabled: true
9
+ Layout/LineContinuationSpacing: # new in 1.31
10
+ Enabled: true
11
+ Layout/LineEndStringConcatenationIndentation: # new in 1.18
12
+ Enabled: true
13
+ Layout/SpaceBeforeBrackets: # new in 1.7
14
+ Enabled: true
15
+ Lint/AmbiguousAssignment: # new in 1.7
16
+ Enabled: true
17
+ Lint/AmbiguousOperatorPrecedence: # new in 1.21
18
+ Enabled: true
19
+ Lint/AmbiguousRange: # new in 1.19
20
+ Enabled: true
21
+ Lint/ConstantOverwrittenInRescue: # new in 1.31
22
+ Enabled: true
23
+ Lint/DeprecatedConstants: # new in 1.8
24
+ Enabled: true
25
+ Lint/DuplicateBranch: # new in 1.3
26
+ Enabled: true
27
+ Lint/DuplicateMagicComment: # new in 1.37
28
+ Enabled: true
29
+ Lint/DuplicateMatchPattern: # new in 1.50
30
+ Enabled: true
31
+ Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
32
+ Enabled: true
33
+ Lint/EmptyBlock: # new in 1.1
34
+ Enabled: true
35
+ Lint/EmptyClass: # new in 1.3
36
+ Enabled: true
37
+ Lint/EmptyInPattern: # new in 1.16
38
+ Enabled: true
39
+ Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
40
+ Enabled: true
41
+ Lint/ItWithoutArgumentsInBlock: # new in 1.59
42
+ Enabled: true
43
+ Lint/LambdaWithoutLiteralBlock: # new in 1.8
44
+ Enabled: true
45
+ Lint/LiteralAssignmentInCondition: # new in 1.58
46
+ Enabled: true
47
+ Lint/MixedCaseRange: # new in 1.53
48
+ Enabled: true
49
+ Lint/NoReturnInBeginEndBlocks: # new in 1.2
50
+ Enabled: true
51
+ Lint/NonAtomicFileOperation: # new in 1.31
52
+ Enabled: true
53
+ Lint/NumberedParameterAssignment: # new in 1.9
54
+ Enabled: true
55
+ Lint/OrAssignmentToConstant: # new in 1.9
56
+ Enabled: true
57
+ Lint/RedundantDirGlobSort: # new in 1.8
58
+ Enabled: true
59
+ Lint/RedundantRegexpQuantifiers: # new in 1.53
60
+ Enabled: true
61
+ Lint/RefinementImportMethods: # new in 1.27
62
+ Enabled: true
63
+ Lint/RequireRangeParentheses: # new in 1.32
64
+ Enabled: true
65
+ Lint/RequireRelativeSelfPath: # new in 1.22
66
+ Enabled: true
67
+ Lint/SymbolConversion: # new in 1.9
68
+ Enabled: true
69
+ Lint/ToEnumArguments: # new in 1.1
70
+ Enabled: true
71
+ Lint/TripleQuotes: # new in 1.9
72
+ Enabled: true
73
+ Lint/UnexpectedBlockArity: # new in 1.5
74
+ Enabled: true
75
+ Lint/UnmodifiedReduceAccumulator: # new in 1.1
76
+ Enabled: true
77
+ Lint/UselessRescue: # new in 1.43
78
+ Enabled: true
79
+ Lint/UselessRuby2Keywords: # new in 1.23
80
+ Enabled: true
81
+ Metrics/CollectionLiteralLength: # new in 1.47
82
+ Enabled: true
83
+ Naming/BlockForwarding: # new in 1.24
84
+ Enabled: true
85
+ Security/CompoundHash: # new in 1.28
86
+ Enabled: true
87
+ Security/IoMethods: # new in 1.22
88
+ Enabled: true
89
+ Style/ArgumentsForwarding: # new in 1.1
90
+ Enabled: true
91
+ Style/ArrayIntersect: # new in 1.40
92
+ Enabled: true
93
+ Style/CollectionCompact: # new in 1.2
94
+ Enabled: true
95
+ Style/ComparableClamp: # new in 1.44
96
+ Enabled: true
97
+ Style/ConcatArrayLiterals: # new in 1.41
98
+ Enabled: true
99
+ Style/DataInheritance: # new in 1.49
100
+ Enabled: true
101
+ Style/DirEmpty: # new in 1.48
102
+ Enabled: true
103
+ Style/DocumentDynamicEvalDefinition: # new in 1.1
104
+ Enabled: true
105
+ Style/EmptyHeredoc: # new in 1.32
106
+ Enabled: true
107
+ Style/EndlessMethod: # new in 1.8
108
+ Enabled: true
109
+ Style/EnvHome: # new in 1.29
110
+ Enabled: true
111
+ Style/ExactRegexpMatch: # new in 1.51
112
+ Enabled: true
113
+ Style/FetchEnvVar: # new in 1.28
114
+ Enabled: true
115
+ Style/FileEmpty: # new in 1.48
116
+ Enabled: true
117
+ Style/FileRead: # new in 1.24
118
+ Enabled: true
119
+ Style/FileWrite: # new in 1.24
120
+ Enabled: true
121
+ Style/HashConversion: # new in 1.10
122
+ Enabled: true
123
+ Style/HashExcept: # new in 1.7
124
+ Enabled: true
125
+ Style/IfWithBooleanLiteralBranches: # new in 1.9
126
+ Enabled: true
127
+ Style/InPatternThen: # new in 1.16
128
+ Enabled: true
129
+ Style/MagicCommentFormat: # new in 1.35
130
+ Enabled: true
131
+ Style/MapCompactWithConditionalBlock: # new in 1.30
132
+ Enabled: true
133
+ Style/MapToHash: # new in 1.24
134
+ Enabled: true
135
+ Style/MapToSet: # new in 1.42
136
+ Enabled: true
137
+ Style/MinMaxComparison: # new in 1.42
138
+ Enabled: true
139
+ Style/MultilineInPatternThen: # new in 1.16
140
+ Enabled: true
141
+ Style/NegatedIfElseCondition: # new in 1.2
142
+ Enabled: true
143
+ Style/NestedFileDirname: # new in 1.26
144
+ Enabled: true
145
+ Style/NilLambda: # new in 1.3
146
+ Enabled: true
147
+ Style/NumberedParameters: # new in 1.22
148
+ Enabled: true
149
+ Style/NumberedParametersLimit: # new in 1.22
150
+ Enabled: true
151
+ Style/ObjectThen: # new in 1.28
152
+ Enabled: true
153
+ Style/OpenStructUse: # new in 1.23
154
+ Enabled: true
155
+ Style/OperatorMethodCall: # new in 1.37
156
+ Enabled: true
157
+ Style/QuotedSymbols: # new in 1.16
158
+ Enabled: true
159
+ Style/RedundantArgument: # new in 1.4
160
+ Enabled: true
161
+ Style/RedundantArrayConstructor: # new in 1.52
162
+ Enabled: true
163
+ Style/RedundantConstantBase: # new in 1.40
164
+ Enabled: true
165
+ Style/RedundantCurrentDirectoryInPath: # new in 1.53
166
+ Enabled: true
167
+ Style/RedundantDoubleSplatHashBraces: # new in 1.41
168
+ Enabled: true
169
+ Style/RedundantEach: # new in 1.38
170
+ Enabled: true
171
+ Style/RedundantFilterChain: # new in 1.52
172
+ Enabled: true
173
+ Style/RedundantHeredocDelimiterQuotes: # new in 1.45
174
+ Enabled: true
175
+ Style/RedundantInitialize: # new in 1.27
176
+ Enabled: true
177
+ Style/RedundantLineContinuation: # new in 1.49
178
+ Enabled: true
179
+ Style/RedundantRegexpArgument: # new in 1.53
180
+ Enabled: true
181
+ Style/RedundantRegexpConstructor: # new in 1.52
182
+ Enabled: true
183
+ Style/RedundantSelfAssignmentBranch: # new in 1.19
184
+ Enabled: true
185
+ Style/RedundantStringEscape: # new in 1.37
186
+ Enabled: true
187
+ Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
188
+ Enabled: true
189
+ Style/SelectByRegexp: # new in 1.22
190
+ Enabled: true
191
+ Style/SingleLineDoEndBlock: # new in 1.57
192
+ Enabled: true
193
+ Style/StringChars: # new in 1.12
194
+ Enabled: true
195
+ Style/SuperWithArgsParentheses: # new in 1.58
196
+ Enabled: true
197
+ Style/SwapValues: # new in 1.1
198
+ Enabled: true
199
+ Style/YAMLFileRead: # new in 1.53
200
+ Enabled: true
201
+
202
+ Minitest/AssertInDelta: # new in 0.10
203
+ Enabled: true
204
+ Minitest/AssertKindOf: # new in 0.10
205
+ Enabled: true
206
+ Minitest/AssertOperator: # new in 0.32
207
+ Enabled: true
208
+ Minitest/AssertOutput: # new in 0.10
209
+ Enabled: true
210
+ Minitest/AssertPathExists: # new in 0.10
211
+ Enabled: true
212
+ Minitest/AssertPredicate: # new in 0.18
213
+ Enabled: true
214
+ Minitest/AssertRaisesCompoundBody: # new in 0.21
215
+ Enabled: true
216
+ Minitest/AssertRaisesWithRegexpArgument: # new in 0.22
217
+ Enabled: true
218
+ Minitest/AssertSame: # new in 0.26
219
+ Enabled: true
220
+ Minitest/AssertSilent: # new in 0.10
221
+ Enabled: true
222
+ Minitest/AssertWithExpectedArgument: # new in 0.11
223
+ Enabled: true
224
+ Minitest/AssertionInLifecycleHook: # new in 0.10
225
+ Enabled: true
226
+ Minitest/DuplicateTestRun: # new in 0.19
227
+ Enabled: true
228
+ Minitest/EmptyLineBeforeAssertionMethods: # new in 0.23
229
+ Enabled: true
230
+ Minitest/LifecycleHooksOrder: # new in 0.28
231
+ Enabled: true
232
+ Minitest/LiteralAsActualArgument: # new in 0.10
233
+ Enabled: true
234
+ Minitest/MultipleAssertions: # new in 0.10
235
+ Enabled: true
236
+ Minitest/NonExecutableTestMethod: # new in 0.34
237
+ Enabled: true
238
+ Minitest/NonPublicTestMethod: # new in 0.27
239
+ Enabled: true
240
+ Minitest/RedundantMessageArgument: # new in 0.34
241
+ Enabled: true
242
+ Minitest/RefuteInDelta: # new in 0.10
243
+ Enabled: true
244
+ Minitest/RefuteKindOf: # new in 0.10
245
+ Enabled: true
246
+ Minitest/RefuteOperator: # new in 0.32
247
+ Enabled: true
248
+ Minitest/RefutePathExists: # new in 0.10
249
+ Enabled: true
250
+ Minitest/RefutePredicate: # new in 0.18
251
+ Enabled: true
252
+ Minitest/RefuteSame: # new in 0.26
253
+ Enabled: true
254
+ Minitest/ReturnInTestMethod: # new in 0.31
255
+ Enabled: true
256
+ Minitest/SkipEnsure: # new in 0.20
257
+ Enabled: true
258
+ Minitest/SkipWithoutReason: # new in 0.24
259
+ Enabled: true
260
+ Minitest/TestFileName: # new in 0.26
261
+ Enabled: true
262
+ Minitest/TestMethodName: # new in 0.10
263
+ Enabled: true
264
+ Minitest/UnreachableAssertion: # new in 0.14
265
+ Enabled: true
266
+ Minitest/UnspecifiedException: # new in 0.10
267
+ Enabled: true
268
+ Minitest/UselessAssertion: # new in 0.26
269
+ Enabled: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-02-29
4
+
5
+ - Initial release. This version only contains a minimal API and
6
+ minimal working macro for `forwardable`.
@@ -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 ackie.h.gmai@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 Masaki Hara
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,123 @@
1
+ # rbs-macros
2
+
3
+ Rubyists💎 love metaprogramming.
4
+
5
+ **rbs-macros** bridges between [RBS](https://github.com/ruby/rbs) and metaprogramming,
6
+ by allowing you to define a macro,
7
+ which is then used to generate RBS definitions
8
+ based on macro invocations.
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ bundle add rbs-macros --group development,test --require false
14
+ ```
15
+
16
+ Or equivalently, add to Gemfile:
17
+
18
+ ```ruby
19
+ group :development, :test do
20
+ gem "rbs-macros", "~> [VERSION]", require: false
21
+ end
22
+ ```
23
+
24
+ Then run `bundle install`.
25
+
26
+ ## Usage
27
+
28
+ > [!NOTE]
29
+ > at the time of writing, rbs-macros is still in early development,
30
+ > and the API is subject to change.
31
+
32
+ Assumes you have already set up `rbs_collection.yaml` via `rbs collection init`.
33
+
34
+ Add to Rakefile:
35
+
36
+ ```ruby
37
+ desc "Generate RBS files using macros"
38
+ task :rbs_gen do
39
+ require "rbs_macros"
40
+ require "rbs_macros/macros/forwardable"
41
+ RbsMacros.run do |config|
42
+ lock_path = Pathname("rbs_collection.lock.yaml")
43
+ config.loader.add_collection(
44
+ RBS::Collection::Config::Lockfile.from_lockfile(
45
+ lockfile_path: lock_path,
46
+ data: YAML.load_file(lock_path.to_s)
47
+ )
48
+ )
49
+ config.macros << RbsMacros::Macros::ForwardableMacros.new
50
+ config.macros << RbsMacros::Macros::SingleForwardableMacros.new
51
+ end
52
+ end
53
+ ```
54
+
55
+ Then run:
56
+
57
+ ```
58
+ bundle exec rake rbs_gen
59
+ ```
60
+
61
+ ## Example
62
+
63
+ Suppose there are the following files:
64
+
65
+ ```ruby
66
+ # lib/array_wrapper.rb
67
+ class ArrayWrapper
68
+ extend Forwardable
69
+ def_delegators :@storage, :[], :size
70
+ end
71
+ ```
72
+
73
+ ```rbs
74
+ # sig/array_wrapper.rbs
75
+ class ArrayWrapper[T]
76
+ extend Forwardable
77
+ @storage: Array[T]
78
+ end
79
+ ```
80
+
81
+ Then the output will be:
82
+
83
+ ```rbs
84
+ # sig/generated/array_wrapper.rbs
85
+ class ArrayWrapper
86
+ def []: (::int index) -> T
87
+ | (::int start, ::int length) -> ::Array[T]?
88
+ | (::Range[::Integer?] range) -> ::Array[T]?
89
+
90
+ def size: () -> ::Integer
91
+ end
92
+ ```
93
+
94
+ ## Future plans
95
+
96
+ - You will be able to define sharable macros and included them in your gem.
97
+ For example, the `ffi` gem may include its own macros to generate RBS files for FFI definitions.
98
+ - Additionally, you will be able to load all the relevant macros based on the gem list in Gemfile.
99
+ - The behavior is currently largely dependent on the order the source files are processed.
100
+ I will try to stabilize it to some extent in the future.
101
+ - Possible new builtin macros:
102
+ - Improved `forwardable` macros
103
+ - `Struct`/`Data` macros
104
+ - FFI
105
+ - ActiveRecord
106
+
107
+ ## Development
108
+
109
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
110
+
111
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
112
+
113
+ ## Contributing
114
+
115
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wantedly/rbs_macros. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/wantedly/rbs_macros/blob/main/CODE_OF_CONDUCT.md).
116
+
117
+ ## License
118
+
119
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
120
+
121
+ ## Code of Conduct
122
+
123
+ Everyone interacting in the RbsMacros project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wantedly/rbs_macros/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.test_files = Dir["test/**/*_test.rb"]
8
+ end
9
+
10
+ require "rubocop/rake_task"
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ desc "Run Steep type checker"
15
+ task steep: :"steep:setup" do
16
+ sh "bundle exec steep check"
17
+ end
18
+ namespace :steep do
19
+ desc "Fetch necessary files for Steep"
20
+ task :setup do
21
+ sh "bundle exec rbs collection install"
22
+ end
23
+
24
+ desc "Generate RBS files using macros"
25
+ task :gen do
26
+ require "rbs_macros"
27
+ require "rbs_macros/macros/forwardable"
28
+ RbsMacros.run do |config|
29
+ lock_path = Pathname("rbs_collection.lock.yaml")
30
+ config.loader.add_collection(
31
+ RBS::Collection::Config::Lockfile.from_lockfile(
32
+ lockfile_path: lock_path,
33
+ data: YAML.load_file(lock_path.to_s)
34
+ )
35
+ )
36
+ config.macros << RbsMacros::Macros::SingleForwardableMacros.new
37
+ end
38
+ end
39
+ end
40
+
41
+ task default: %i[test rubocop steep]
data/Steepfile ADDED
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ D = Steep::Diagnostic
4
+
5
+ target :lib do
6
+ signature "sig"
7
+
8
+ check "lib"
9
+ configure_code_diagnostics(D::Ruby.strict)
10
+ # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
11
+ # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
12
+ # configure_code_diagnostics do |hash| # You can setup everything yourself
13
+ # hash[D::Ruby::NoMethod] = :information
14
+ # end
15
+ end
16
+
17
+ target :test do
18
+ signature "sig", "sig-private"
19
+
20
+ check "test"
21
+ configure_code_diagnostics(D::Ruby.strict)
22
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsMacros
4
+ # Configuration for RbsMacros execution
5
+ class Config
6
+ attr_reader :macros, :load_dirs, :sigs
7
+ attr_accessor :loader, :use_loader, :project, :output_dir
8
+
9
+ def initialize
10
+ @macros = []
11
+ @load_dirs = ["lib"]
12
+ @sigs = ["sig"]
13
+ @loader = RBS::EnvironmentLoader.new
14
+ @use_loader = true
15
+ @project = Project.new
16
+ @output_dir = "sig/generated"
17
+ end
18
+ end
19
+ end