rbs_inline_data 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: 5b590372f180f2c8115503f7d93a8eee62b4a67098a278b9487a24e3f715710f
4
+ data.tar.gz: 9b17bc5d5b477670ea88acb82f6123f6e7c361a370a0589190e02015a417f4e3
5
+ SHA512:
6
+ metadata.gz: 4696211d602da66ccbf6c07a2ce2ad6f66e7e42c1f503c560a5c31b5b64bda3c0d46e357106f73ecc584788e09a15fee1fd5756c7a5bf0edac91d7616104a058
7
+ data.tar.gz: dff46a22e6c68c0d6624e8bead20ca70779752546859cd2fd2086ea02fdee028d10251095c43c89e42c566db62d42a8e6f5bd443197c02ec52320b7efd00c203
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
9
+
10
+ Layout/LeadingCommentSpace:
11
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-06-09
4
+
5
+ - Initial release
@@ -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 teppest1215@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/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # RbsInlineData
2
+
3
+ `rbs_inline_data` gem is a tool for generating RBS files corresponding to `Data.define` in the [rbs-inline](https://github.com/soutaro/rbs-inline) syntax.
4
+ This gem is intended to be used together with [rbs-inline](https://github.com/soutaro/rbs-inline).
5
+
6
+ Here is an example of how to use it:
7
+
8
+ ```rb
9
+ class User
10
+ Address = Data.define(
11
+ :city, #:: String
12
+ :street, #:: String
13
+ )
14
+ end
15
+ ```
16
+
17
+ This generates the following RBS file:
18
+
19
+ ```rbs
20
+ class User::Address
21
+ extend Data::_DataClass
22
+ attr_reader city: String
23
+ attr_reader street: String
24
+ def self.new: (*untyped) -> ::User::Address
25
+ | (**untyped) -> ::User::Address
26
+ | ...
27
+ end
28
+ ```
29
+
30
+ ## Installation
31
+
32
+ Install the gem and add to the application's Gemfile by executing:
33
+
34
+ $ bundle add rbs_inline_data --require=false
35
+
36
+ If bundler is not being used to manage dependencies, install the gem by executing:
37
+
38
+ $ gem install rbs_inline_data
39
+
40
+ ## Usage
41
+
42
+ To generate RBS files, run the following command:
43
+
44
+ # Print generated RBS files
45
+ $ bundle exec rbs-inline-data lib
46
+
47
+ # Save generated RBS files under sig/generated/data
48
+ $ bundle exec rbs-inline-data lib --output
49
+
50
+
51
+ ## Development
52
+
53
+ 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.
54
+
55
+ Run `rake rbs:setup` to prepare for type checking. Since this project includes implementations using `Data.define`, you can also verify the operation of `rbs-inline-data`.
56
+
57
+ 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).
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/euglena1215/rbs_inline_data. 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/euglena1215/rbs_inline_data/blob/main/CODE_OF_CONDUCT.md).
62
+
63
+ ## Code of Conduct
64
+
65
+ Everyone interacting in the RbsInlineData project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/euglena1215/rbs_inline_data/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[test rubocop]
13
+
14
+ namespace :rbs do
15
+ task setup: %i[clean inline inline_data]
16
+
17
+ task :clean do
18
+ sh "rm", "-rf", "sig/generated"
19
+ end
20
+
21
+ task :install do
22
+ sh "bundle", "exec", "rbs", "install"
23
+ end
24
+
25
+ task :inline do
26
+ sh "bundle", "exec", "rbs-inline", "lib", "--opt-out", "--output"
27
+ end
28
+
29
+ task :inline_data do
30
+ sh "bundle", "exec", "exe/rbs-inline-data", "lib", "--output"
31
+ end
32
+ end
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.strict) # `strict` diagnostics setting
11
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rbs_inline_data"
5
+ require "rbs_inline_data/cli"
6
+
7
+ RbsInlineData::CLI.new.run(ARGV)
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ require "rbs_inline_data/parser"
6
+ require "rbs_inline_data/writer"
7
+
8
+ module RbsInlineData
9
+ class CLI
10
+ #:: (Array[String]) -> void
11
+ def run(args)
12
+ # @type var output_path: Pathname?
13
+ output_path = nil
14
+
15
+ OptionParser.new do |opts|
16
+ opts.on("--output", "Output to stdout instead of writing to files") do
17
+ output_path = Pathname("sig/generated/data")
18
+ end
19
+ end.parse!(args)
20
+
21
+ targets = Pathname.glob(args[0]).flat_map do |path|
22
+ if path.directory?
23
+ Pathname.glob(path.join("**/*.rb").to_s)
24
+ else
25
+ path
26
+ end
27
+ end
28
+
29
+ targets.sort!
30
+ targets.uniq!
31
+
32
+ targets.each do |target|
33
+ result = Prism.parse_file(target.to_s)
34
+ definitions = Parser.parse(result)
35
+ Writer.write(definitions, output_path ? (output_path + target).sub_ext(".rbs") : nil)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "prism"
4
+
5
+ module RbsInlineData
6
+ class Parser < Prism::Visitor
7
+ # @rbs skip
8
+ TypedDefinition = Data.define(
9
+ :class_name, #:: String
10
+ :fields #:: Array[RbsInlineData::Parser::TypedField]
11
+ )
12
+ # @rbs skip
13
+ TypedField = Data.define(
14
+ :field_name, #:: String
15
+ :type #:: String
16
+ )
17
+
18
+ # @rbs @definitions: Array[RbsInlineData::Parser::TypedDefinition]
19
+ # @rbs @surronding_class_or_module: Array[Symbol]
20
+
21
+ #:: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
22
+ def initialize(definitions)
23
+ @definitions = definitions
24
+ @surronding_class_or_module = []
25
+ end
26
+
27
+ #:: (Prism::ParseResult) -> Array[RbsInlineData::Parser::TypedDefinition]
28
+ def self.parse(result)
29
+ # @type var definitions: Array[RbsInlineData::Parser::TypedDefinition]
30
+ definitions = []
31
+ instance = new(definitions)
32
+ result.value.accept(instance)
33
+ definitions
34
+ end
35
+
36
+ # @rbs override
37
+ def visit_class_node(node)
38
+ record_surrounding_class_or_module(node) { super }
39
+ end
40
+
41
+ # @rbs override
42
+ def visit_module_node(node)
43
+ record_surrounding_class_or_module(node) { super }
44
+ end
45
+
46
+ # @rbs override
47
+ def visit_constant_write_node(node)
48
+ if define_data?(node)
49
+ definition = extract_definition(node)
50
+ @definitions << definition if definition
51
+ end
52
+
53
+ super
54
+ end
55
+
56
+ private
57
+
58
+ #:: (Prism::ClassNode | Prism::ModuleNode) { (Prism::ClassNode | Prism::ModuleNode) -> void } -> void
59
+ def record_surrounding_class_or_module(node)
60
+ @surronding_class_or_module.push(node.constant_path.name)
61
+ yield(node)
62
+ ensure
63
+ @surronding_class_or_module.pop
64
+ end
65
+
66
+ #:: (Prism::ConstantWriteNode) -> bool
67
+ def define_data?(node)
68
+ node in {
69
+ value: Prism::CallNode[
70
+ receiver: (
71
+ Prism::ConstantReadNode[name: :Data] |
72
+ Prism::ConstantPathNode[parent: nil, name: :Data]
73
+ ),
74
+ name: :define,
75
+ ]
76
+ }
77
+ end
78
+
79
+ #:: (Prism::ConstantWriteNode) -> RbsInlineData::Parser::TypedDefinition?
80
+ def extract_definition(node)
81
+ source = node.slice
82
+ _, class_name, field_text = source.match(/\A([a-zA-Z0-9]+) ?= ?Data\.define\(([\n\s\w\W]+)\)\z/).to_a
83
+ return nil if field_text.nil? || class_name.nil?
84
+
85
+ class_name = "#{@surronding_class_or_module.join("::")}::#{class_name}"
86
+
87
+ fields = field_text.split("\n").map(&:strip).reject(&:empty?).map do |str|
88
+ case str
89
+ when /:(\w+),? #:: ([\w\:\[\]]+)/
90
+ [::Regexp.last_match(1), ::Regexp.last_match(2)]
91
+ when /:(\w+),?/
92
+ [::Regexp.last_match(1), "untyped"]
93
+ end
94
+ end.compact.map do |field_name, type|
95
+ TypedField.new(
96
+ field_name: field_name,
97
+ type: type
98
+ )
99
+ end
100
+
101
+ TypedDefinition.new(
102
+ class_name: class_name,
103
+ fields: fields
104
+ )
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsInlineData
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RbsInlineData
4
+ class Writer
5
+ #:: (Array[RbsInlineData::Parser::TypedDefinition], Pathname?) -> void
6
+ def self.write(definitions, output_path)
7
+ new(definitions).write(output_path)
8
+ end
9
+
10
+ # @rbs @definitions: Array[RbsInlineData::Parser::TypedDefinition]
11
+
12
+ #:: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
13
+ def initialize(definitions)
14
+ @definitions = definitions
15
+ end
16
+
17
+ #:: (Pathname?) -> void
18
+ def write(output_path)
19
+ return if @definitions.empty?
20
+
21
+ if output_path
22
+ output_path.parent.mkpath unless output_path.parent.directory?
23
+ output_path.write(build_rbs(@definitions))
24
+ else
25
+ puts build_rbs(@definitions)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ #:: (Array[RbsInlineData::Parser::TypedDefinition]) -> String
32
+ def build_rbs(definitions)
33
+ definitions.map do |definition|
34
+ <<~RBS
35
+ class #{definition.class_name}
36
+ extend Data::_DataClass
37
+ #{definition.fields.map { |field| "attr_reader #{field.field_name}: #{field.type}" }.join("\n ")}
38
+ def self.new: (*untyped) -> ::#{definition.class_name}
39
+ | (**untyped) -> ::#{definition.class_name}
40
+ | ...
41
+ end
42
+ RBS
43
+ end.join("\n")
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rbs_inline_data/version"
4
+
5
+ module RbsInlineData
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,124 @@
1
+ ---
2
+ path: ".gem_rbs_collection"
3
+ gems:
4
+ - name: ast
5
+ version: '2.4'
6
+ source:
7
+ type: git
8
+ name: ruby/gem_rbs_collection
9
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
10
+ remote: https://github.com/ruby/gem_rbs_collection.git
11
+ repo_dir: gems
12
+ - name: fileutils
13
+ version: '0'
14
+ source:
15
+ type: stdlib
16
+ - name: json
17
+ version: '0'
18
+ source:
19
+ type: stdlib
20
+ - name: logger
21
+ version: '0'
22
+ source:
23
+ type: stdlib
24
+ - name: minitest
25
+ version: '0'
26
+ source:
27
+ type: stdlib
28
+ - name: monitor
29
+ version: '0'
30
+ source:
31
+ type: stdlib
32
+ - name: mutex_m
33
+ version: '0'
34
+ source:
35
+ type: stdlib
36
+ - name: optparse
37
+ version: '0'
38
+ source:
39
+ type: stdlib
40
+ - name: parallel
41
+ version: '1.20'
42
+ source:
43
+ type: git
44
+ name: ruby/gem_rbs_collection
45
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
46
+ remote: https://github.com/ruby/gem_rbs_collection.git
47
+ repo_dir: gems
48
+ - name: parser
49
+ version: '3.2'
50
+ source:
51
+ type: git
52
+ name: ruby/gem_rbs_collection
53
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
54
+ remote: https://github.com/ruby/gem_rbs_collection.git
55
+ repo_dir: gems
56
+ - name: pathname
57
+ version: '0'
58
+ source:
59
+ type: stdlib
60
+ - name: prism
61
+ version: 0.29.0
62
+ source:
63
+ type: rubygems
64
+ - name: rainbow
65
+ version: '3.0'
66
+ source:
67
+ type: git
68
+ name: ruby/gem_rbs_collection
69
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
70
+ remote: https://github.com/ruby/gem_rbs_collection.git
71
+ repo_dir: gems
72
+ - name: rake
73
+ version: '13.0'
74
+ source:
75
+ type: git
76
+ name: ruby/gem_rbs_collection
77
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
78
+ remote: https://github.com/ruby/gem_rbs_collection.git
79
+ repo_dir: gems
80
+ - name: rbs
81
+ version: 3.5.1
82
+ source:
83
+ type: rubygems
84
+ - name: rbs-inline
85
+ version: 0.3.0
86
+ source:
87
+ type: rubygems
88
+ - name: rdoc
89
+ version: '0'
90
+ source:
91
+ type: stdlib
92
+ - name: regexp_parser
93
+ version: '2.8'
94
+ source:
95
+ type: git
96
+ name: ruby/gem_rbs_collection
97
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
98
+ remote: https://github.com/ruby/gem_rbs_collection.git
99
+ repo_dir: gems
100
+ - name: rubocop
101
+ version: '1.57'
102
+ source:
103
+ type: git
104
+ name: ruby/gem_rbs_collection
105
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
106
+ remote: https://github.com/ruby/gem_rbs_collection.git
107
+ repo_dir: gems
108
+ - name: rubocop-ast
109
+ version: '1.30'
110
+ source:
111
+ type: git
112
+ name: ruby/gem_rbs_collection
113
+ revision: 5de8f412fd310bc4ee27985347b798cb409a3b77
114
+ remote: https://github.com/ruby/gem_rbs_collection.git
115
+ repo_dir: gems
116
+ - name: strscan
117
+ version: '0'
118
+ source:
119
+ type: stdlib
120
+ - name: tsort
121
+ version: '0'
122
+ source:
123
+ type: stdlib
124
+ 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,17 @@
1
+ class RbsInlineData::Parser::TypedDefinition
2
+ extend Data::_DataClass
3
+ attr_reader class_name: String
4
+ attr_reader fields: Array[RbsInlineData::Parser::TypedField]
5
+ def self.new: (*untyped) -> ::RbsInlineData::Parser::TypedDefinition
6
+ | (**untyped) -> ::RbsInlineData::Parser::TypedDefinition
7
+ | ...
8
+ end
9
+
10
+ class RbsInlineData::Parser::TypedField
11
+ extend Data::_DataClass
12
+ attr_reader field_name: String
13
+ attr_reader type: String
14
+ def self.new: (*untyped) -> ::RbsInlineData::Parser::TypedField
15
+ | (**untyped) -> ::RbsInlineData::Parser::TypedField
16
+ | ...
17
+ end
@@ -0,0 +1,8 @@
1
+ # Generated from lib/rbs_inline_data/cli.rb with RBS::Inline
2
+
3
+ module RbsInlineData
4
+ class CLI
5
+ # :: (Array[String]) -> void
6
+ def run: (Array[String]) -> void
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ # Generated from lib/rbs_inline_data/parser.rb with RBS::Inline
2
+
3
+ module RbsInlineData
4
+ class Parser < Prism::Visitor
5
+ @definitions: Array[RbsInlineData::Parser::TypedDefinition]
6
+
7
+ @surronding_class_or_module: Array[Symbol]
8
+
9
+ # :: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
10
+ def initialize: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
11
+
12
+ # :: (Prism::ParseResult) -> Array[RbsInlineData::Parser::TypedDefinition]
13
+ def self.parse: (Prism::ParseResult) -> Array[RbsInlineData::Parser::TypedDefinition]
14
+
15
+ # @rbs override
16
+ def visit_class_node: ...
17
+
18
+ # @rbs override
19
+ def visit_module_node: ...
20
+
21
+ # @rbs override
22
+ def visit_constant_write_node: ...
23
+
24
+ private
25
+
26
+ # :: (Prism::ClassNode | Prism::ModuleNode) { (Prism::ClassNode | Prism::ModuleNode) -> void } -> void
27
+ def record_surrounding_class_or_module: (Prism::ClassNode | Prism::ModuleNode) { (Prism::ClassNode | Prism::ModuleNode) -> void } -> void
28
+
29
+ # :: (Prism::ConstantWriteNode) -> bool
30
+ def define_data?: (Prism::ConstantWriteNode) -> bool
31
+
32
+ # :: (Prism::ConstantWriteNode) -> RbsInlineData::Parser::TypedDefinition?
33
+ def extract_definition: (Prism::ConstantWriteNode) -> RbsInlineData::Parser::TypedDefinition?
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/rbs_inline_data/version.rb with RBS::Inline
2
+
3
+ module RbsInlineData
4
+ VERSION: ::String
5
+ end
@@ -0,0 +1,21 @@
1
+ # Generated from lib/rbs_inline_data/writer.rb with RBS::Inline
2
+
3
+ module RbsInlineData
4
+ class Writer
5
+ # :: (Array[RbsInlineData::Parser::TypedDefinition], Pathname?) -> void
6
+ def self.write: (Array[RbsInlineData::Parser::TypedDefinition], Pathname?) -> void
7
+
8
+ @definitions: Array[RbsInlineData::Parser::TypedDefinition]
9
+
10
+ # :: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
11
+ def initialize: (Array[RbsInlineData::Parser::TypedDefinition]) -> void
12
+
13
+ # :: (Pathname?) -> void
14
+ def write: (Pathname?) -> void
15
+
16
+ private
17
+
18
+ # :: (Array[RbsInlineData::Parser::TypedDefinition]) -> String
19
+ def build_rbs: (Array[RbsInlineData::Parser::TypedDefinition]) -> String
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ # Generated from lib/rbs_inline_data.rb with RBS::Inline
2
+
3
+ module RbsInlineData
4
+ class Error < StandardError
5
+ end
6
+ end
data/sig/patch.rbs ADDED
@@ -0,0 +1,11 @@
1
+ module Prism
2
+ class ClassNode
3
+ def constant_path: () -> Prism::ConstantReadNode
4
+ | ...
5
+ end
6
+
7
+ class ModuleNode
8
+ def constant_path: () -> Prism::ConstantReadNode
9
+ | ...
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_inline_data
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Teppei Shintani
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: prism
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: rbs
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
+ description: Support auto generation of RBS by `Data.define` in rbs-inline syntax
42
+ email:
43
+ - teppest1215@gmail.com
44
+ executables:
45
+ - rbs-inline-data
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
52
+ - README.md
53
+ - Rakefile
54
+ - Steepfile
55
+ - exe/rbs-inline-data
56
+ - lib/rbs_inline_data.rb
57
+ - lib/rbs_inline_data/cli.rb
58
+ - lib/rbs_inline_data/parser.rb
59
+ - lib/rbs_inline_data/version.rb
60
+ - lib/rbs_inline_data/writer.rb
61
+ - rbs_collection.lock.yaml
62
+ - rbs_collection.yaml
63
+ - sig/generated/data/lib/rbs_inline_data/parser.rbs
64
+ - sig/generated/rbs_inline_data.rbs
65
+ - sig/generated/rbs_inline_data/cli.rbs
66
+ - sig/generated/rbs_inline_data/parser.rbs
67
+ - sig/generated/rbs_inline_data/version.rbs
68
+ - sig/generated/rbs_inline_data/writer.rbs
69
+ - sig/patch.rbs
70
+ homepage: https://github.com/euglena1215/rbs_inline_data
71
+ licenses: []
72
+ metadata:
73
+ homepage_uri: https://github.com/euglena1215/rbs_inline_data
74
+ source_code_uri: https://github.com/euglena1215/rbs_inline_data
75
+ changelog_uri: https://github.com/euglena1215/rbs_inline_data/blob/main/CHANGELOG.md
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 3.3.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.5.9
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Support auto generation of RBS by `Data.define` in rbs-inline syntax
95
+ test_files: []