rbs_activerecord 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +22 -0
  3. data/.vscode/extensions.json +6 -0
  4. data/.vscode/settings.json +12 -0
  5. data/CODE_OF_CONDUCT.md +132 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +49 -0
  8. data/Rakefile +14 -0
  9. data/Steepfile +9 -0
  10. data/lib/generators/rbs_activerecord/install_generator.rb +21 -0
  11. data/lib/rbs_activerecord/generator/active_storage/instance_methods.rb +57 -0
  12. data/lib/rbs_activerecord/generator/active_storage/scopes.rb +39 -0
  13. data/lib/rbs_activerecord/generator/associations.rb +118 -0
  14. data/lib/rbs_activerecord/generator/attributes.rb +95 -0
  15. data/lib/rbs_activerecord/generator/delegated_type/instance_methods.rb +66 -0
  16. data/lib/rbs_activerecord/generator/delegated_type/scopes.rb +44 -0
  17. data/lib/rbs_activerecord/generator/enum/base.rb +63 -0
  18. data/lib/rbs_activerecord/generator/enum/instance_methods.rb +51 -0
  19. data/lib/rbs_activerecord/generator/enum/scopes.rb +51 -0
  20. data/lib/rbs_activerecord/generator/pluck_overloads.rb +41 -0
  21. data/lib/rbs_activerecord/generator/scopes.rb +99 -0
  22. data/lib/rbs_activerecord/generator/secure_password.rb +54 -0
  23. data/lib/rbs_activerecord/generator.rb +143 -0
  24. data/lib/rbs_activerecord/model.rb +33 -0
  25. data/lib/rbs_activerecord/parser/evaluator.rb +48 -0
  26. data/lib/rbs_activerecord/parser/visitor.rb +67 -0
  27. data/lib/rbs_activerecord/parser.rb +30 -0
  28. data/lib/rbs_activerecord/rake_task.rb +61 -0
  29. data/lib/rbs_activerecord/utils.rb +58 -0
  30. data/lib/rbs_activerecord/version.rb +5 -0
  31. data/lib/rbs_activerecord.rb +27 -0
  32. data/rbs_collection.lock.yaml +352 -0
  33. data/rbs_collection.yaml +18 -0
  34. data/sig/generators/rbs_activerecord/install_generator.rbs +7 -0
  35. data/sig/rbs_activerecord/generator/active_storage/instance_methods.rbs +23 -0
  36. data/sig/rbs_activerecord/generator/active_storage/scopes.rbs +23 -0
  37. data/sig/rbs_activerecord/generator/associations.rbs +29 -0
  38. data/sig/rbs_activerecord/generator/attributes.rbs +28 -0
  39. data/sig/rbs_activerecord/generator/delegated_type/instance_methods.rbs +31 -0
  40. data/sig/rbs_activerecord/generator/delegated_type/scopes.rbs +26 -0
  41. data/sig/rbs_activerecord/generator/enum/base.rbs +19 -0
  42. data/sig/rbs_activerecord/generator/enum/instance_methods.rbs +26 -0
  43. data/sig/rbs_activerecord/generator/enum/scopes.rbs +26 -0
  44. data/sig/rbs_activerecord/generator/pluck_overloads.rbs +23 -0
  45. data/sig/rbs_activerecord/generator/scopes.rbs +27 -0
  46. data/sig/rbs_activerecord/generator/secure_password.rbs +22 -0
  47. data/sig/rbs_activerecord/generator.rbs +34 -0
  48. data/sig/rbs_activerecord/model.rbs +26 -0
  49. data/sig/rbs_activerecord/parser/evaluator.rbs +12 -0
  50. data/sig/rbs_activerecord/parser/visitor.rbs +27 -0
  51. data/sig/rbs_activerecord/parser.rbs +15 -0
  52. data/sig/rbs_activerecord/rake_task.rbs +19 -0
  53. data/sig/rbs_activerecord/utils.rbs +14 -0
  54. data/sig/rbs_activerecord/version.rbs +5 -0
  55. data/sig/rbs_activerecord.rbs +6 -0
  56. metadata +142 -0
@@ -0,0 +1,26 @@
1
+ # Generated from lib/rbs_activerecord/generator/delegated_type/scopes.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ module DelegatedType
6
+ class Scopes
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 delegated_types: () -> Array[Prism::CallNode]
20
+
21
+ # @rbs node: Prism::CallNode
22
+ def delegated_type: (Prism::CallNode node) -> String
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/rbs_activerecord/generator/enum/base.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ module Enum
6
+ class Base
7
+ private
8
+
9
+ # @rbs node: Prism::CallNode
10
+ def parse_arguments: (Prism::CallNode node) -> [ String?, Array[String | Symbol], Hash[Symbol, untyped] ]
11
+
12
+ # @rbs name: String
13
+ # @rbs value: untyped
14
+ # @rbs options: Hash[Symbol, untyped]
15
+ def enum_method_name: (String name, untyped value, Hash[Symbol, untyped] options) -> String
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # Generated from lib/rbs_activerecord/generator/enum/instance_methods.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ module Enum
6
+ class InstanceMethods < 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
@@ -0,0 +1,26 @@
1
+ # Generated from lib/rbs_activerecord/generator/enum/scopes.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ module Enum
6
+ class Scopes < 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
@@ -0,0 +1,23 @@
1
+ # Generated from lib/rbs_activerecord/generator/pluck_overloads.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ class PluckOverloads
6
+ include Utils
7
+
8
+ attr_reader model: RbsActiverecord::Model
9
+
10
+ # @rbs model: RbsActiverecord::Model
11
+ def initialize: (RbsActiverecord::Model model) -> void
12
+
13
+ def generate: () -> String
14
+
15
+ private
16
+
17
+ def overloads: () -> Array[String]
18
+
19
+ # @rbs column: untyped
20
+ def enum?: (untyped column) -> bool
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,27 @@
1
+ # Generated from lib/rbs_activerecord/generator/scopes.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ class Scopes
6
+ attr_reader model: RbsActiverecord::Model
7
+
8
+ attr_reader declarations: Array[Prism::CallNode]
9
+
10
+ # @rbs model: RbsActiverecord::Model
11
+ # @rbs delarations: Hash[String, Array[Prism::CallNode]]
12
+ def initialize: (RbsActiverecord::Model model, untyped declarations) -> void
13
+
14
+ def generate: () -> String
15
+
16
+ private
17
+
18
+ def scopes: () -> Array[Prism::CallNode]
19
+
20
+ # @rbs node: Prism::CallNode
21
+ def scope: (Prism::CallNode node) -> String
22
+
23
+ # @rbs node: Prism::LambdaNode | Prism::BlockNode
24
+ def lambda_params: (Prism::LambdaNode | Prism::BlockNode node) -> String
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ # Generated from lib/rbs_activerecord/generator/secure_password.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ class SecurePassword
6
+ attr_reader model: RbsActiverecord::Model
7
+
8
+ # @rbs model: RbsActiverecord::Model
9
+ def initialize: (RbsActiverecord::Model model) -> void
10
+
11
+ def generate: () -> String
12
+
13
+ private
14
+
15
+ def methods: () -> String
16
+
17
+ def secure_password_attributes: () -> Array[String]
18
+
19
+ def secure_password?: () -> bool
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ # Generated from lib/rbs_activerecord/generator.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Generator
5
+ include Utils
6
+
7
+ attr_reader klass: singleton(ActiveRecord::Base)
8
+
9
+ attr_reader klass_name: String
10
+
11
+ attr_reader model: RbsActiverecord::Model
12
+
13
+ # @rbs klass: singleton(ActiveRecord::Base)
14
+ def initialize: (singleton(ActiveRecord::Base) klass) -> void
15
+
16
+ def generate: () -> String
17
+
18
+ private
19
+
20
+ def primary_key_type: () -> String
21
+
22
+ @declarations: Hash[String, Array[Prism::CallNode]]
23
+
24
+ def declarations: () -> Hash[String, Array[Prism::CallNode]]
25
+
26
+ def header: () -> String
27
+
28
+ def footer: () -> String
29
+
30
+ def relation_methods: () -> String
31
+
32
+ def scope_class_methods: () -> String
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ # Generated from lib/rbs_activerecord/model.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Model
5
+ extend Forwardable
6
+
7
+ attr_reader klass: singleton(ActiveRecord::Base)
8
+
9
+ def attribute_types: () -> Hash[String, untyped]
10
+
11
+ def attribute_aliases: () -> Hash[String, String]
12
+
13
+ def columns: () -> Array[untyped]
14
+
15
+ def defined_enums: () -> Hash[String, untyped]
16
+
17
+ def reflect_on_all_associations: (Symbol) -> Array[untyped]
18
+
19
+ # @rbs klass: singleton(ActiveRecord::Base)
20
+ def initialize: (singleton(ActiveRecord::Base) klass) -> void
21
+
22
+ def filename: () -> String
23
+
24
+ def parents: () -> Array[singleton(ActiveRecord::Base)]
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ # Generated from lib/rbs_activerecord/parser/evaluator.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ module Parser
5
+ module Evaluator
6
+ def self.eval_node: (Prism::Node node) -> untyped
7
+
8
+ # @rbs node: Prism::Node
9
+ def eval_node: (Prism::Node node) -> untyped
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ # Generated from lib/rbs_activerecord/parser/visitor.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ module Parser
5
+ class Visitor < Prism::Visitor
6
+ attr_reader context: Array[Prism::ClassNode | Prism::ModuleNode]
7
+
8
+ attr_reader decls: Hash[String, Array[Prism::CallNode]]
9
+
10
+ def initialize: () -> void
11
+
12
+ def current_namespace: () -> String
13
+
14
+ # @rbs override
15
+ def visit_module_node: ...
16
+
17
+ # @rbs override
18
+ def visit_class_node: ...
19
+
20
+ # @rbs override
21
+ def visit_call_node: ...
22
+
23
+ # @rbs override
24
+ def visit_def_node: ...
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ # Generated from lib/rbs_activerecord/parser.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ module Parser
5
+ def self.parse: (String filename) -> Hash[String, Array[Prism::CallNode]]
6
+
7
+ def self.eval_node: (Prism::Node node) -> untyped
8
+
9
+ # @rbs filename: String
10
+ def parse: (String filename) -> Hash[String, Array[Prism::CallNode]]
11
+
12
+ # @rbs node: Prism::Node
13
+ def eval_node: (Prism::Node node) -> untyped
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # Generated from lib/rbs_activerecord/rake_task.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class RakeTask < Rake::TaskLib
5
+ attr_accessor name: untyped
6
+
7
+ attr_accessor signature_root_dir: untyped
8
+
9
+ # @rbs name: Symbol
10
+ # @rbs &block: (RakeTask) -> void
11
+ def initialize: (?Symbol name) { (RakeTask) -> void } -> void
12
+
13
+ def define_setup_task: () -> void
14
+
15
+ def define_clean_task: () -> void
16
+
17
+ def define_generate_task: () -> void
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ # Generated from lib/rbs_activerecord/utils.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ module Utils
5
+ # @rbs str: String
6
+ def format: (String str) -> String
7
+
8
+ # @rbs klass: singleton(ActiveRecord::Base)
9
+ def primary_key_type_for: (singleton(ActiveRecord::Base) klass) -> String
10
+
11
+ # @rbs type: Symbol
12
+ def sql_type_to_class: (Symbol type) -> String
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # Generated from lib/rbs_activerecord/version.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ VERSION: ::String
5
+ end
@@ -0,0 +1,6 @@
1
+ # Generated from lib/rbs_activerecord.rb with RBS::Inline
2
+
3
+ module RbsActiverecord
4
+ class Error < StandardError
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbs_activerecord
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-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: prism
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: railties
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 activerecord 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_activerecord/install_generator.rb
71
+ - lib/rbs_activerecord.rb
72
+ - lib/rbs_activerecord/generator.rb
73
+ - lib/rbs_activerecord/generator/active_storage/instance_methods.rb
74
+ - lib/rbs_activerecord/generator/active_storage/scopes.rb
75
+ - lib/rbs_activerecord/generator/associations.rb
76
+ - lib/rbs_activerecord/generator/attributes.rb
77
+ - lib/rbs_activerecord/generator/delegated_type/instance_methods.rb
78
+ - lib/rbs_activerecord/generator/delegated_type/scopes.rb
79
+ - lib/rbs_activerecord/generator/enum/base.rb
80
+ - lib/rbs_activerecord/generator/enum/instance_methods.rb
81
+ - lib/rbs_activerecord/generator/enum/scopes.rb
82
+ - lib/rbs_activerecord/generator/pluck_overloads.rb
83
+ - lib/rbs_activerecord/generator/scopes.rb
84
+ - lib/rbs_activerecord/generator/secure_password.rb
85
+ - lib/rbs_activerecord/model.rb
86
+ - lib/rbs_activerecord/parser.rb
87
+ - lib/rbs_activerecord/parser/evaluator.rb
88
+ - lib/rbs_activerecord/parser/visitor.rb
89
+ - lib/rbs_activerecord/rake_task.rb
90
+ - lib/rbs_activerecord/utils.rb
91
+ - lib/rbs_activerecord/version.rb
92
+ - rbs_collection.lock.yaml
93
+ - rbs_collection.yaml
94
+ - sig/generators/rbs_activerecord/install_generator.rbs
95
+ - sig/rbs_activerecord.rbs
96
+ - sig/rbs_activerecord/generator.rbs
97
+ - sig/rbs_activerecord/generator/active_storage/instance_methods.rbs
98
+ - sig/rbs_activerecord/generator/active_storage/scopes.rbs
99
+ - sig/rbs_activerecord/generator/associations.rbs
100
+ - sig/rbs_activerecord/generator/attributes.rbs
101
+ - sig/rbs_activerecord/generator/delegated_type/instance_methods.rbs
102
+ - sig/rbs_activerecord/generator/delegated_type/scopes.rbs
103
+ - sig/rbs_activerecord/generator/enum/base.rbs
104
+ - sig/rbs_activerecord/generator/enum/instance_methods.rbs
105
+ - sig/rbs_activerecord/generator/enum/scopes.rbs
106
+ - sig/rbs_activerecord/generator/pluck_overloads.rbs
107
+ - sig/rbs_activerecord/generator/scopes.rbs
108
+ - sig/rbs_activerecord/generator/secure_password.rbs
109
+ - sig/rbs_activerecord/model.rbs
110
+ - sig/rbs_activerecord/parser.rbs
111
+ - sig/rbs_activerecord/parser/evaluator.rbs
112
+ - sig/rbs_activerecord/parser/visitor.rbs
113
+ - sig/rbs_activerecord/rake_task.rbs
114
+ - sig/rbs_activerecord/utils.rbs
115
+ - sig/rbs_activerecord/version.rbs
116
+ homepage: https://github.com/tk0miya/rbs_activerecord
117
+ licenses:
118
+ - MIT
119
+ metadata:
120
+ homepage_uri: https://github.com/tk0miya/rbs_activerecord
121
+ source_code_uri: https://github.com/tk0miya/rbs_activerecord
122
+ changelog_uri: https://github.com/tk0miya/rbs_activerecord
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 3.1.0
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubygems_version: 3.5.22
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A RBS files generator for activerecord gem
142
+ test_files: []