rbs_activerecord 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.vscode/settings.json +2 -1
- data/README.md +35 -5
- data/lib/rbs_activerecord/generator/enum/mappings.rb +44 -0
- data/lib/rbs_activerecord/generator.rb +23 -3
- data/lib/rbs_activerecord/parser/evaluator.rb +5 -2
- data/lib/rbs_activerecord/parser/include_expander/module.rb +47 -0
- data/lib/rbs_activerecord/parser/include_expander.rb +82 -0
- data/lib/rbs_activerecord/parser/visitor.rb +1 -16
- data/lib/rbs_activerecord/parser.rb +8 -10
- data/lib/rbs_activerecord/version.rb +1 -1
- data/lib/rbs_activerecord.rb +3 -0
- data/rbs_collection.lock.yaml +29 -29
- data/sig/rbs_activerecord/generator/enum/mappings.rbs +26 -0
- data/sig/rbs_activerecord/parser/evaluator.rbs +1 -3
- data/sig/rbs_activerecord/parser/include_expander/module.rbs +29 -0
- data/sig/rbs_activerecord/parser/include_expander.rbs +32 -0
- data/sig/rbs_activerecord/parser.rbs +4 -6
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0ea3c8187e852192d22a16567b163eb0247b233d60503bee24527acbdc3a2cd
|
4
|
+
data.tar.gz: 73925718cdda63a38c982df326c6e34245f72a1bf7960415921ffb2105de6b66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d420a8c6d38af18a3928713eccd59403703cee04c7692a8c042eb381866af371b830501cecdca8a40e21797f620ae24d83428d3c86bd3b32954319b8c85fc9c3
|
7
|
+
data.tar.gz: 361fc238a0c34c0721f0ee12f54e1aa8a5a0d95aca361cbdb06e9e21220c1c15c36058b80c0c2a6c5e16aa76c2402d31eae6ce6a5a223a7f3747af2241b8e9ea
|
data/.vscode/settings.json
CHANGED
data/README.md
CHANGED
@@ -6,23 +6,53 @@ rbs_activerecord is a RBSGenerator for models built with ActiveRecord.
|
|
6
6
|
|
7
7
|
Add a new entry to your Gemfile and run `bundle install`:
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
group :development do
|
10
|
+
gem 'rbs_activerecord', require: false
|
11
|
+
end
|
12
12
|
|
13
13
|
After the installation, please run rake task generator:
|
14
14
|
|
15
|
-
|
15
|
+
bundle exec rails g rbs_activerecord:install
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
19
|
Run `rbs:activerecord:setup` task:
|
20
20
|
|
21
|
-
|
21
|
+
bundle exec rake rbs:activerecord:setup
|
22
22
|
|
23
23
|
Then rbs_activerecord will scan your code and generate RBS files into
|
24
24
|
`sig/activerecord` directory.
|
25
25
|
|
26
|
+
## The goal of rbs_activerecord
|
27
|
+
|
28
|
+
rbs_activerecord is an experimental project to enhance the type generation for ActiveRecord models.
|
29
|
+
It is strongly inspired by [rbs_rails](https://github.com/pocke/rbs_rails).
|
30
|
+
|
31
|
+
The goal of this gem is to give feedbacks to the rbs_rails project, and improving rbs_rails.
|
32
|
+
One of the large goals is merging this gem into rbs_rails.
|
33
|
+
|
34
|
+
Main differences between rbs_activerecord and rbs_rails are:
|
35
|
+
|
36
|
+
* New features
|
37
|
+
* Support Rails7 style enum definitions ([#268](https://github.com/pocke/rbs_rails/pull/268))
|
38
|
+
* Support STI (Single Table Inheritance) models ([#287](https://github.com/pocke/rbs_rails/pull/287))
|
39
|
+
* Inherits scope, enum and other definitions in the parent class to the child class
|
40
|
+
* Support has_and_belongs_to_many association ([#272](https://github.com/pocke/rbs_rails/pull/272))
|
41
|
+
* Support `alias_attribute` ([#263](https://github.com/pocke/rbs_rails/pull/263))
|
42
|
+
* Support generating model definitions within the concern module ([#209](https://github.com/pocke/rbs_rails/pull/209))
|
43
|
+
* Support extension ActiveRecord from 3rd party gems ([#254](https://github.com/pocke/rbs_rails/pull/254))
|
44
|
+
* ex. [kaminari-activerecord](https://github.com/ruby/gem_rbs_collection/pull/725)
|
45
|
+
* Support composite primary keys ([#275](https://github.com/pocke/rbs_rails/pull/275))
|
46
|
+
* Extend return types of #pluck ([#273](https://github.com/pocke/rbs_rails/pull/273))
|
47
|
+
* Override types of CollectionProxy ([#289](https://github.com/pocke/rbs_rails/pull/289))
|
48
|
+
* Bug fixes
|
49
|
+
* [#290](https://github.com/pocke/rbs_rails/pull/290)
|
50
|
+
* [#286](https://github.com/pocke/rbs_rails/pull/286)
|
51
|
+
* [#285](https://github.com/pocke/rbs_rails/pull/285)
|
52
|
+
* [#278](https://github.com/pocke/rbs_rails/pull/278)
|
53
|
+
* [#277](https://github.com/pocke/rbs_rails/pull/277)
|
54
|
+
* [#233](https://github.com/pocke/rbs_rails/pull/233)
|
55
|
+
|
26
56
|
## Development
|
27
57
|
|
28
58
|
After checking out the repo, run `bin/setup` to install dependencies. You can also
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
module Enum
|
6
|
+
class Mappings < Base
|
7
|
+
attr_reader :model #: RbsActiverecord::Model
|
8
|
+
attr_reader :declarations #: Array[Prism::CallNode]
|
9
|
+
|
10
|
+
# @rbs model: RbsActiverecord::Model
|
11
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
12
|
+
def initialize(model, declarations) #: void
|
13
|
+
@model = model
|
14
|
+
@declarations = declarations.fetch(model.klass.name.to_s, [])
|
15
|
+
|
16
|
+
super()
|
17
|
+
end
|
18
|
+
|
19
|
+
def generate #: String
|
20
|
+
<<~RBS.strip
|
21
|
+
module GeneratedEnumMappingMethods
|
22
|
+
#{enums.map { |node| enum(node) }.join("\n")}
|
23
|
+
end
|
24
|
+
RBS
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def enums #: Array[Prism::CallNode]
|
30
|
+
declarations.select { |node| node.name == :enum }
|
31
|
+
end
|
32
|
+
|
33
|
+
# @rbs node: Prism::CallNode
|
34
|
+
def enum(node) #: String
|
35
|
+
name, = parse_arguments(node)
|
36
|
+
|
37
|
+
return "" unless name
|
38
|
+
|
39
|
+
"def #{name.to_s.pluralize}: () -> ActiveSupport::HashWithIndifferentAccess[Symbol, untyped]"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "rails"
|
4
4
|
|
5
5
|
module RbsActiverecord
|
6
|
-
class Generator
|
6
|
+
class Generator # rubocop:disable Metrics/ClassLength
|
7
7
|
include Utils
|
8
8
|
|
9
9
|
attr_reader :klass #: singleton(ActiveRecord::Base)
|
@@ -17,7 +17,7 @@ module RbsActiverecord
|
|
17
17
|
@model = Model.new(klass)
|
18
18
|
end
|
19
19
|
|
20
|
-
def generate #: String # rubocop:disable Metrics/AbcSize
|
20
|
+
def generate #: String # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
21
21
|
format <<~RBS
|
22
22
|
#{header}
|
23
23
|
#{Attributes.new(model).generate}
|
@@ -31,9 +31,25 @@ module RbsActiverecord
|
|
31
31
|
#{DelegatedType::InstanceMethods.new(model, declarations).generate}
|
32
32
|
#{DelegatedType::Scopes.new(model, declarations).generate}
|
33
33
|
#{Enum::InstanceMethods.new(model, declarations).generate}
|
34
|
+
#{Enum::Mappings.new(model, declarations).generate}
|
34
35
|
#{Enum::Scopes.new(model, declarations).generate}
|
35
36
|
#{Scopes.new(model, declarations).generate}
|
36
37
|
|
38
|
+
module GeneratedCollectionProxyInstanceMethods[Model, PrimaryKey]
|
39
|
+
def build: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model
|
40
|
+
| (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model]
|
41
|
+
def create: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model
|
42
|
+
| (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model]
|
43
|
+
def create!: (?ActiveRecord::Associations::CollectionProxy::_EachPair attributes) ?{ () -> untyped } -> Model
|
44
|
+
| (Array[ActiveRecord::Associations::CollectionProxy::_EachPair] attributes) ?{ () -> untyped } -> Array[Model]
|
45
|
+
def reload: () -> Array[Model]
|
46
|
+
def replace: (Array[Model]) -> void
|
47
|
+
def delete: (*Model | PrimaryKey) -> Array[Model]
|
48
|
+
def destroy: (*Model | PrimaryKey) -> Array[Model]
|
49
|
+
def <<: (*Model | Array[Model]) -> self
|
50
|
+
def prepend: (*Model | Array[Model]) -> self
|
51
|
+
end
|
52
|
+
|
37
53
|
class ActiveRecord_Relation < ::ActiveRecord::Relation
|
38
54
|
include ::Enumerable[#{klass_name}]
|
39
55
|
include ::ActiveRecord::Relation::Methods[#{klass_name}, #{primary_key_type}]
|
@@ -46,10 +62,12 @@ module RbsActiverecord
|
|
46
62
|
include ::ActiveRecord::Relation::Methods[#{klass_name}, #{primary_key_type}]
|
47
63
|
#{relation_methods}
|
48
64
|
include GeneratedPluckOverloads
|
65
|
+
include GeneratedCollectionProxyInstanceMethods[#{klass_name}, #{primary_key_type}]
|
49
66
|
end
|
50
67
|
|
51
68
|
extend ::ActiveRecord::Base::ClassMethods[#{klass_name}, #{klass_name}::ActiveRecord_Relation, #{primary_key_type}]
|
52
69
|
#{scope_class_methods}
|
70
|
+
extend GeneratedEnumMappingMethods
|
53
71
|
extend GeneratedPluckOverloads
|
54
72
|
|
55
73
|
include GeneratedActiveStorageInstanceMethods
|
@@ -74,7 +92,9 @@ module RbsActiverecord
|
|
74
92
|
@declarations ||= begin
|
75
93
|
filename = Rails.root.join(model.filename)
|
76
94
|
if filename.exist?
|
77
|
-
Parser.
|
95
|
+
Parser.parse_file(filename.to_s).tap do |decls|
|
96
|
+
Parser::IncludeExpander.expand(model, decls)
|
97
|
+
end
|
78
98
|
else
|
79
99
|
{}
|
80
100
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module RbsActiverecord
|
4
4
|
module Parser
|
5
5
|
module Evaluator
|
6
|
-
# @rbs! def self.eval_node: (Prism::Node node) -> untyped
|
7
|
-
|
8
6
|
# @rbs node: Prism::Node
|
9
7
|
def eval_node(node) #: untyped # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
10
8
|
case node
|
@@ -31,6 +29,11 @@ module RbsActiverecord
|
|
31
29
|
[key, value]
|
32
30
|
end
|
33
31
|
end.to_h
|
32
|
+
when Prism::ConstantReadNode
|
33
|
+
node.name.to_s
|
34
|
+
when Prism::ConstantPathNode
|
35
|
+
parent = node.parent ? eval_node(node.parent) : nil
|
36
|
+
"#{parent}::#{node.name}"
|
34
37
|
when Prism::KeywordHashNode
|
35
38
|
node.elements.filter_map do |assoc|
|
36
39
|
case assoc
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
module Parser
|
5
|
+
class IncludeExpander
|
6
|
+
class Module
|
7
|
+
attr_reader :mod #: ::Module
|
8
|
+
attr_reader :name #: String
|
9
|
+
|
10
|
+
# @rbs mod: ::Module
|
11
|
+
# @rbs name: String
|
12
|
+
def initialize(mod, name) #: void
|
13
|
+
@mod = mod
|
14
|
+
@name = name
|
15
|
+
end
|
16
|
+
|
17
|
+
def concern? #: bool
|
18
|
+
mod.is_a?(::ActiveSupport::Concern)
|
19
|
+
end
|
20
|
+
|
21
|
+
def included_blocks #: Array[Prism::CallNode]
|
22
|
+
return [] unless concern?
|
23
|
+
|
24
|
+
declarations.select { |node| node.name == :included }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @rbs @declarations: Array[Prism::CallNode]
|
30
|
+
|
31
|
+
def declarations #: Array[Prism::CallNode]
|
32
|
+
@declarations ||= begin
|
33
|
+
path = source_location
|
34
|
+
return [] unless path && File.exist?(path)
|
35
|
+
|
36
|
+
declarations = Parser.parse_file(path)
|
37
|
+
declarations.fetch(name, [])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def source_location #: String?
|
42
|
+
Object.const_source_location(name)&.fetch(0)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
module Parser
|
5
|
+
class IncludeExpander
|
6
|
+
# @rbs model: RbsActiverecord::Model
|
7
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
8
|
+
def self.expand(model, declarations) #: void
|
9
|
+
new(model, declarations).expand
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :model #: RbsActiverecord::Model
|
13
|
+
attr_reader :declarations #: Hash[String, Array[Prism::CallNode]]
|
14
|
+
|
15
|
+
# @rbs model: RbsActiverecord::Model
|
16
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
17
|
+
def initialize(model, declarations) #: void
|
18
|
+
@model = model
|
19
|
+
@declarations = declarations
|
20
|
+
end
|
21
|
+
|
22
|
+
def expand #: void
|
23
|
+
declarations.each_value do |decls|
|
24
|
+
loop do
|
25
|
+
index = decls.index { |node| node.name == :include }
|
26
|
+
break unless index
|
27
|
+
|
28
|
+
included_module = decls.delete_at(index)
|
29
|
+
included_blocks = included_blocks_for(included_module)
|
30
|
+
included_blocks.reverse_each do |included|
|
31
|
+
decls.insert(index, *block_body_of(included))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
# @rbs node: Prism::CallNode
|
40
|
+
def included_blocks_for(node) #: Array[Prism::CallNode]
|
41
|
+
modules = node.arguments&.arguments.to_a
|
42
|
+
.map { |arg| Parser.eval_node(arg) }
|
43
|
+
.select { |mod| mod.is_a?(String) }
|
44
|
+
modules.flat_map do |modname|
|
45
|
+
mod = const_get(modname)
|
46
|
+
next [] unless mod
|
47
|
+
|
48
|
+
Module.new(mod, modname).included_blocks
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @rbs name: String
|
53
|
+
def const_get(name) #: ::Module?
|
54
|
+
path = model.klass.name.to_s.split("::")
|
55
|
+
|
56
|
+
loop do
|
57
|
+
modname = (path + [name]).join("::")
|
58
|
+
return Object.const_get(modname) if Object.const_defined?(modname)
|
59
|
+
break if path.empty?
|
60
|
+
|
61
|
+
path.pop
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# @rbs node: Prism::CallNode
|
66
|
+
def block_body_of(node) #: Array[Prism::CallNode]
|
67
|
+
case node.block
|
68
|
+
when Prism::BlockNode
|
69
|
+
case node.block.body
|
70
|
+
when Prism::StatementsNode
|
71
|
+
body = node.block.body.body #: Array[Prism::CallNode]
|
72
|
+
body.select { |n| n.is_a?(Prism::CallNode) }
|
73
|
+
else
|
74
|
+
[]
|
75
|
+
end
|
76
|
+
else
|
77
|
+
[]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -14,22 +14,7 @@ module RbsActiverecord
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def current_namespace #: String
|
17
|
-
context.
|
18
|
-
namespace = [] #: Array[Symbol?]
|
19
|
-
path = node.constant_path #: Prism::Node?
|
20
|
-
loop do
|
21
|
-
case path
|
22
|
-
when Prism::ConstantPathNode
|
23
|
-
namespace << path.name
|
24
|
-
path = path.parent
|
25
|
-
when Prism::ConstantReadNode
|
26
|
-
namespace << path.name
|
27
|
-
break
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
namespace.compact.reverse
|
32
|
-
end.join("::")
|
17
|
+
context.map { |node| Parser.eval_node(node.constant_path) }.join("::")
|
33
18
|
end
|
34
19
|
|
35
20
|
# @rbs override
|
@@ -4,16 +4,9 @@ require "prism"
|
|
4
4
|
|
5
5
|
module RbsActiverecord
|
6
6
|
module Parser
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
# @rbs!
|
11
|
-
# def self.parse: (String filename) -> Hash[String, Array[Prism::CallNode]]
|
12
|
-
# def self.eval_node: (Prism::Node node) -> untyped
|
13
|
-
|
14
|
-
# @rbs filename: String
|
15
|
-
def parse(filename) #: Hash[String, Array[Prism::CallNode]]
|
16
|
-
result = Prism.parse_file(filename)
|
7
|
+
# @rbs code: String
|
8
|
+
def parse(code) #: Hash[String, Array[Prism::CallNode]]
|
9
|
+
result = Prism.parse(code)
|
17
10
|
|
18
11
|
visitor = Visitor.new
|
19
12
|
visitor.visit(result.value)
|
@@ -21,6 +14,11 @@ module RbsActiverecord
|
|
21
14
|
end
|
22
15
|
module_function :parse
|
23
16
|
|
17
|
+
def parse_file(filename) #: Hash[String, Array[Prism::CallNode]]
|
18
|
+
File.open(filename) { |f| parse(f.read) }
|
19
|
+
end
|
20
|
+
module_function :parse_file
|
21
|
+
|
24
22
|
# @rbs node: Prism::Node
|
25
23
|
def eval_node(node) #: untyped
|
26
24
|
Evaluator.eval_node(node)
|
data/lib/rbs_activerecord.rb
CHANGED
@@ -11,6 +11,7 @@ require_relative "rbs_activerecord/generator/delegated_type/instance_methods"
|
|
11
11
|
require_relative "rbs_activerecord/generator/delegated_type/scopes"
|
12
12
|
require_relative "rbs_activerecord/generator/enum/base"
|
13
13
|
require_relative "rbs_activerecord/generator/enum/instance_methods"
|
14
|
+
require_relative "rbs_activerecord/generator/enum/mappings"
|
14
15
|
require_relative "rbs_activerecord/generator/enum/scopes"
|
15
16
|
require_relative "rbs_activerecord/generator/pluck_overloads"
|
16
17
|
require_relative "rbs_activerecord/generator/scopes"
|
@@ -18,6 +19,8 @@ require_relative "rbs_activerecord/generator/secure_password"
|
|
18
19
|
require_relative "rbs_activerecord/model"
|
19
20
|
require_relative "rbs_activerecord/parser"
|
20
21
|
require_relative "rbs_activerecord/parser/evaluator"
|
22
|
+
require_relative "rbs_activerecord/parser/include_expander"
|
23
|
+
require_relative "rbs_activerecord/parser/include_expander/module"
|
21
24
|
require_relative "rbs_activerecord/parser/visitor"
|
22
25
|
require_relative "rbs_activerecord/version"
|
23
26
|
|
data/rbs_collection.lock.yaml
CHANGED
@@ -6,7 +6,7 @@ gems:
|
|
6
6
|
source:
|
7
7
|
type: git
|
8
8
|
name: ruby/gem_rbs_collection
|
9
|
-
revision:
|
9
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
10
10
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
11
|
repo_dir: gems
|
12
12
|
- name: actionview
|
@@ -14,7 +14,7 @@ gems:
|
|
14
14
|
source:
|
15
15
|
type: git
|
16
16
|
name: ruby/gem_rbs_collection
|
17
|
-
revision:
|
17
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
18
18
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
19
19
|
repo_dir: gems
|
20
20
|
- name: activejob
|
@@ -22,7 +22,7 @@ gems:
|
|
22
22
|
source:
|
23
23
|
type: git
|
24
24
|
name: ruby/gem_rbs_collection
|
25
|
-
revision:
|
25
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
26
26
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
27
27
|
repo_dir: gems
|
28
28
|
- name: activemodel
|
@@ -30,7 +30,7 @@ gems:
|
|
30
30
|
source:
|
31
31
|
type: git
|
32
32
|
name: ruby/gem_rbs_collection
|
33
|
-
revision:
|
33
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
34
34
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
35
35
|
repo_dir: gems
|
36
36
|
- name: activerecord
|
@@ -38,7 +38,7 @@ gems:
|
|
38
38
|
source:
|
39
39
|
type: git
|
40
40
|
name: ruby/gem_rbs_collection
|
41
|
-
revision:
|
41
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
42
42
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
43
43
|
repo_dir: gems
|
44
44
|
- name: activestorage
|
@@ -46,7 +46,7 @@ gems:
|
|
46
46
|
source:
|
47
47
|
type: git
|
48
48
|
name: ruby/gem_rbs_collection
|
49
|
-
revision:
|
49
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
50
50
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
51
51
|
repo_dir: gems
|
52
52
|
- name: activesupport
|
@@ -54,7 +54,7 @@ gems:
|
|
54
54
|
source:
|
55
55
|
type: git
|
56
56
|
name: ruby/gem_rbs_collection
|
57
|
-
revision:
|
57
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
58
58
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
59
|
repo_dir: gems
|
60
60
|
- name: ast
|
@@ -62,7 +62,7 @@ gems:
|
|
62
62
|
source:
|
63
63
|
type: git
|
64
64
|
name: ruby/gem_rbs_collection
|
65
|
-
revision:
|
65
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
66
66
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
67
67
|
repo_dir: gems
|
68
68
|
- name: base64
|
@@ -74,7 +74,7 @@ gems:
|
|
74
74
|
source:
|
75
75
|
type: git
|
76
76
|
name: ruby/gem_rbs_collection
|
77
|
-
revision:
|
77
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
78
78
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
79
79
|
repo_dir: gems
|
80
80
|
- name: benchmark
|
@@ -94,7 +94,7 @@ gems:
|
|
94
94
|
source:
|
95
95
|
type: git
|
96
96
|
name: ruby/gem_rbs_collection
|
97
|
-
revision:
|
97
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
98
98
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
99
99
|
repo_dir: gems
|
100
100
|
- name: connection_pool
|
@@ -102,7 +102,7 @@ gems:
|
|
102
102
|
source:
|
103
103
|
type: git
|
104
104
|
name: ruby/gem_rbs_collection
|
105
|
-
revision:
|
105
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
106
106
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
107
107
|
repo_dir: gems
|
108
108
|
- name: date
|
@@ -130,7 +130,7 @@ gems:
|
|
130
130
|
source:
|
131
131
|
type: git
|
132
132
|
name: ruby/gem_rbs_collection
|
133
|
-
revision:
|
133
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
134
134
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
135
135
|
repo_dir: gems
|
136
136
|
- name: i18n
|
@@ -138,7 +138,7 @@ gems:
|
|
138
138
|
source:
|
139
139
|
type: git
|
140
140
|
name: ruby/gem_rbs_collection
|
141
|
-
revision:
|
141
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
142
142
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
143
143
|
repo_dir: gems
|
144
144
|
- name: io-console
|
@@ -158,7 +158,7 @@ gems:
|
|
158
158
|
source:
|
159
159
|
type: git
|
160
160
|
name: ruby/gem_rbs_collection
|
161
|
-
revision:
|
161
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
162
162
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
163
163
|
repo_dir: gems
|
164
164
|
- name: minitest
|
@@ -178,7 +178,7 @@ gems:
|
|
178
178
|
source:
|
179
179
|
type: git
|
180
180
|
name: ruby/gem_rbs_collection
|
181
|
-
revision:
|
181
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
182
182
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
183
183
|
repo_dir: gems
|
184
184
|
- name: openssl
|
@@ -194,7 +194,7 @@ gems:
|
|
194
194
|
source:
|
195
195
|
type: git
|
196
196
|
name: ruby/gem_rbs_collection
|
197
|
-
revision:
|
197
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
198
198
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
199
199
|
repo_dir: gems
|
200
200
|
- name: parser
|
@@ -202,7 +202,7 @@ gems:
|
|
202
202
|
source:
|
203
203
|
type: git
|
204
204
|
name: ruby/gem_rbs_collection
|
205
|
-
revision:
|
205
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
206
206
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
207
207
|
repo_dir: gems
|
208
208
|
- name: pathname
|
@@ -218,7 +218,7 @@ gems:
|
|
218
218
|
source:
|
219
219
|
type: git
|
220
220
|
name: ruby/gem_rbs_collection
|
221
|
-
revision:
|
221
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
222
222
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
223
223
|
repo_dir: gems
|
224
224
|
- name: rails-dom-testing
|
@@ -226,7 +226,7 @@ gems:
|
|
226
226
|
source:
|
227
227
|
type: git
|
228
228
|
name: ruby/gem_rbs_collection
|
229
|
-
revision:
|
229
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
230
230
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
231
231
|
repo_dir: gems
|
232
232
|
- name: rails-html-sanitizer
|
@@ -234,7 +234,7 @@ gems:
|
|
234
234
|
source:
|
235
235
|
type: git
|
236
236
|
name: ruby/gem_rbs_collection
|
237
|
-
revision:
|
237
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
238
238
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
239
239
|
repo_dir: gems
|
240
240
|
- name: railties
|
@@ -242,7 +242,7 @@ gems:
|
|
242
242
|
source:
|
243
243
|
type: git
|
244
244
|
name: ruby/gem_rbs_collection
|
245
|
-
revision:
|
245
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
246
246
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
247
247
|
repo_dir: gems
|
248
248
|
- name: rainbow
|
@@ -250,7 +250,7 @@ gems:
|
|
250
250
|
source:
|
251
251
|
type: git
|
252
252
|
name: ruby/gem_rbs_collection
|
253
|
-
revision:
|
253
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
254
254
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
255
255
|
repo_dir: gems
|
256
256
|
- name: rake
|
@@ -258,7 +258,7 @@ gems:
|
|
258
258
|
source:
|
259
259
|
type: git
|
260
260
|
name: ruby/gem_rbs_collection
|
261
|
-
revision:
|
261
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
262
262
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
263
263
|
repo_dir: gems
|
264
264
|
- name: rbs
|
@@ -274,7 +274,7 @@ gems:
|
|
274
274
|
source:
|
275
275
|
type: git
|
276
276
|
name: ruby/gem_rbs_collection
|
277
|
-
revision:
|
277
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
278
278
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
279
279
|
repo_dir: gems
|
280
280
|
- name: rubocop
|
@@ -282,7 +282,7 @@ gems:
|
|
282
282
|
source:
|
283
283
|
type: git
|
284
284
|
name: ruby/gem_rbs_collection
|
285
|
-
revision:
|
285
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
286
286
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
287
287
|
repo_dir: gems
|
288
288
|
- name: rubocop-ast
|
@@ -290,7 +290,7 @@ gems:
|
|
290
290
|
source:
|
291
291
|
type: git
|
292
292
|
name: ruby/gem_rbs_collection
|
293
|
-
revision:
|
293
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
294
294
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
295
295
|
repo_dir: gems
|
296
296
|
- name: securerandom
|
@@ -310,7 +310,7 @@ gems:
|
|
310
310
|
source:
|
311
311
|
type: git
|
312
312
|
name: ruby/gem_rbs_collection
|
313
|
-
revision:
|
313
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
314
314
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
315
315
|
repo_dir: gems
|
316
316
|
- name: tempfile
|
@@ -322,7 +322,7 @@ gems:
|
|
322
322
|
source:
|
323
323
|
type: git
|
324
324
|
name: ruby/gem_rbs_collection
|
325
|
-
revision:
|
325
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
326
326
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
327
327
|
repo_dir: gems
|
328
328
|
- name: time
|
@@ -342,7 +342,7 @@ gems:
|
|
342
342
|
source:
|
343
343
|
type: git
|
344
344
|
name: ruby/gem_rbs_collection
|
345
|
-
revision:
|
345
|
+
revision: 5fcf7d45b7c430a651c5996280d9991c781fcf14
|
346
346
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
347
347
|
repo_dir: gems
|
348
348
|
- name: uri
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/enum/mappings.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
module Enum
|
6
|
+
class Mappings < Base
|
7
|
+
attr_reader model: RbsActiverecord::Model
|
8
|
+
|
9
|
+
attr_reader declarations: Array[Prism::CallNode]
|
10
|
+
|
11
|
+
# @rbs model: RbsActiverecord::Model
|
12
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
13
|
+
def initialize: (RbsActiverecord::Model model, Hash[String, Array[Prism::CallNode]] declarations) -> void
|
14
|
+
|
15
|
+
def generate: () -> String
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def enums: () -> Array[Prism::CallNode]
|
20
|
+
|
21
|
+
# @rbs node: Prism::CallNode
|
22
|
+
def enum: (Prism::CallNode node) -> String
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,10 +3,8 @@
|
|
3
3
|
module RbsActiverecord
|
4
4
|
module Parser
|
5
5
|
module Evaluator
|
6
|
-
def self.eval_node: (Prism::Node node) -> untyped
|
7
|
-
|
8
6
|
# @rbs node: Prism::Node
|
9
|
-
def eval_node: (Prism::Node node) -> untyped
|
7
|
+
def self?.eval_node: (Prism::Node node) -> untyped
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/parser/include_expander/module.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
module Parser
|
5
|
+
class IncludeExpander
|
6
|
+
class Module
|
7
|
+
attr_reader mod: ::Module
|
8
|
+
|
9
|
+
attr_reader name: String
|
10
|
+
|
11
|
+
# @rbs mod: ::Module
|
12
|
+
# @rbs name: String
|
13
|
+
def initialize: (::Module mod, String name) -> void
|
14
|
+
|
15
|
+
def concern?: () -> bool
|
16
|
+
|
17
|
+
def included_blocks: () -> Array[Prism::CallNode]
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
@declarations: Array[Prism::CallNode]
|
22
|
+
|
23
|
+
def declarations: () -> Array[Prism::CallNode]
|
24
|
+
|
25
|
+
def source_location: () -> String?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/parser/include_expander.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
module Parser
|
5
|
+
class IncludeExpander
|
6
|
+
# @rbs model: RbsActiverecord::Model
|
7
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
8
|
+
def self.expand: (RbsActiverecord::Model model, Hash[String, Array[Prism::CallNode]] declarations) -> void
|
9
|
+
|
10
|
+
attr_reader model: RbsActiverecord::Model
|
11
|
+
|
12
|
+
attr_reader declarations: Hash[String, Array[Prism::CallNode]]
|
13
|
+
|
14
|
+
# @rbs model: RbsActiverecord::Model
|
15
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
16
|
+
def initialize: (RbsActiverecord::Model model, Hash[String, Array[Prism::CallNode]] declarations) -> void
|
17
|
+
|
18
|
+
def expand: () -> void
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# @rbs node: Prism::CallNode
|
23
|
+
def included_blocks_for: (Prism::CallNode node) -> Array[Prism::CallNode]
|
24
|
+
|
25
|
+
# @rbs name: String
|
26
|
+
def const_get: (String name) -> ::Module?
|
27
|
+
|
28
|
+
# @rbs node: Prism::CallNode
|
29
|
+
def block_body_of: (Prism::CallNode node) -> Array[Prism::CallNode]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -2,14 +2,12 @@
|
|
2
2
|
|
3
3
|
module RbsActiverecord
|
4
4
|
module Parser
|
5
|
-
|
5
|
+
# @rbs code: String
|
6
|
+
def self?.parse: (String code) -> Hash[String, Array[Prism::CallNode]]
|
6
7
|
|
7
|
-
def self
|
8
|
-
|
9
|
-
# @rbs filename: String
|
10
|
-
def parse: (String filename) -> Hash[String, Array[Prism::CallNode]]
|
8
|
+
def self?.parse_file: (untyped filename) -> Hash[String, Array[Prism::CallNode]]
|
11
9
|
|
12
10
|
# @rbs node: Prism::Node
|
13
|
-
def eval_node: (Prism::Node node) -> untyped
|
11
|
+
def self?.eval_node: (Prism::Node node) -> untyped
|
14
12
|
end
|
15
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi KOMIYA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/rbs_activerecord/generator/delegated_type/scopes.rb
|
79
79
|
- lib/rbs_activerecord/generator/enum/base.rb
|
80
80
|
- lib/rbs_activerecord/generator/enum/instance_methods.rb
|
81
|
+
- lib/rbs_activerecord/generator/enum/mappings.rb
|
81
82
|
- lib/rbs_activerecord/generator/enum/scopes.rb
|
82
83
|
- lib/rbs_activerecord/generator/pluck_overloads.rb
|
83
84
|
- lib/rbs_activerecord/generator/scopes.rb
|
@@ -85,6 +86,8 @@ files:
|
|
85
86
|
- lib/rbs_activerecord/model.rb
|
86
87
|
- lib/rbs_activerecord/parser.rb
|
87
88
|
- lib/rbs_activerecord/parser/evaluator.rb
|
89
|
+
- lib/rbs_activerecord/parser/include_expander.rb
|
90
|
+
- lib/rbs_activerecord/parser/include_expander/module.rb
|
88
91
|
- lib/rbs_activerecord/parser/visitor.rb
|
89
92
|
- lib/rbs_activerecord/rake_task.rb
|
90
93
|
- lib/rbs_activerecord/utils.rb
|
@@ -102,6 +105,7 @@ files:
|
|
102
105
|
- sig/rbs_activerecord/generator/delegated_type/scopes.rbs
|
103
106
|
- sig/rbs_activerecord/generator/enum/base.rbs
|
104
107
|
- sig/rbs_activerecord/generator/enum/instance_methods.rbs
|
108
|
+
- sig/rbs_activerecord/generator/enum/mappings.rbs
|
105
109
|
- sig/rbs_activerecord/generator/enum/scopes.rbs
|
106
110
|
- sig/rbs_activerecord/generator/pluck_overloads.rbs
|
107
111
|
- sig/rbs_activerecord/generator/scopes.rbs
|
@@ -109,6 +113,8 @@ files:
|
|
109
113
|
- sig/rbs_activerecord/model.rbs
|
110
114
|
- sig/rbs_activerecord/parser.rbs
|
111
115
|
- sig/rbs_activerecord/parser/evaluator.rbs
|
116
|
+
- sig/rbs_activerecord/parser/include_expander.rbs
|
117
|
+
- sig/rbs_activerecord/parser/include_expander/module.rbs
|
112
118
|
- sig/rbs_activerecord/parser/visitor.rbs
|
113
119
|
- sig/rbs_activerecord/rake_task.rbs
|
114
120
|
- sig/rbs_activerecord/utils.rbs
|