rbs_rails 0.2.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.gitmodules +3 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -2
- data/README.md +33 -35
- data/Rakefile +14 -1
- data/Steepfile +12 -1
- data/assets/sig/action_mailer.rbs +6 -3
- data/assets/sig/capybara.rbs +14 -0
- data/assets/sig/concurrent.rbs +4 -0
- data/assets/sig/erb.rbs +4 -0
- data/assets/sig/erubi.rbs +4 -0
- data/assets/sig/i18n.rbs +4 -0
- data/assets/sig/minitest.rbs +12 -1
- data/assets/sig/pg.rbs +5 -0
- data/assets/sig/que.rbs +4 -0
- data/assets/sig/queue_classic.rbs +4 -0
- data/assets/sig/racc.rbs +4 -0
- data/assets/sig/rack-test.rbs +6 -0
- data/assets/sig/rack.rbs +47 -0
- data/assets/sig/rails.rbs +7 -8
- data/assets/sig/rdoc.rbs +9 -0
- data/assets/sig/sidekiq.rbs +4 -0
- data/assets/sig/sneakers.rbs +4 -0
- data/assets/sig/stdlib.rbs +15 -5
- data/assets/sig/sucker_punch.rbs +4 -0
- data/assets/sig/thor.rbs +12 -0
- data/assets/sig/tzinfo.rbs +4 -0
- data/bin/add-type-params.rb +39 -13
- data/bin/postprocess.rb +137 -0
- data/bin/rbs +30 -0
- data/bin/rbs-prototype-rb.rb +195 -0
- data/bin/to-ascii.rb +5 -0
- data/lib/rbs_rails/active_record.rb +78 -33
- data/lib/rbs_rails/rake_task.rb +75 -0
- data/lib/rbs_rails/version.rb +1 -1
- data/rbs_rails.gemspec +1 -0
- data/sig/fileutils.rbs +1 -0
- data/sig/rake.rbs +6 -0
- data/sig/rbs_rails/active_record.rbs +4 -4
- data/sig/rbs_rails/rake_task.rbs +20 -0
- metadata +45 -12
- data/assets/sig/action_controller.rbs +0 -44
- data/assets/sig/action_view.rbs +0 -3
- data/assets/sig/active_record.rbs +0 -130
- data/assets/sig/generated/activemodel.rbs +0 -3877
- data/assets/sig/generated/activesupport.rbs +0 -11480
- data/bin/merge-duplicate-decls.rb +0 -30
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
|
4
|
+
module RbsRails
|
5
|
+
class RakeTask < Rake::TaskLib
|
6
|
+
attr_accessor :ignore_model_if, :name
|
7
|
+
|
8
|
+
def initialize(name = :rbs_rails, &block)
|
9
|
+
super()
|
10
|
+
|
11
|
+
@name = name
|
12
|
+
|
13
|
+
block.call(self) if block
|
14
|
+
|
15
|
+
def_copy_signature_files
|
16
|
+
def_generate_rbs_for_models
|
17
|
+
def_generate_rbs_for_path_helpers
|
18
|
+
def_all
|
19
|
+
end
|
20
|
+
|
21
|
+
def def_all
|
22
|
+
desc 'Run all tasks of rbs_rails'
|
23
|
+
|
24
|
+
deps = [:"#{name}:copy_signature_files", :"#{name}:generate_rbs_for_models", :"#{name}:generate_rbs_for_path_helpers"]
|
25
|
+
task("#{name}:all": deps)
|
26
|
+
end
|
27
|
+
|
28
|
+
def def_copy_signature_files
|
29
|
+
desc 'Copy RBS files for rbs_rails'
|
30
|
+
task("#{name}:copy_signature_files": :environment) do
|
31
|
+
require 'rbs_rails'
|
32
|
+
|
33
|
+
to = Rails.root.join('sig/rbs_rails/')
|
34
|
+
to.mkpath unless to.exist?
|
35
|
+
RbsRails.copy_signatures(to: to)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def def_generate_rbs_for_models
|
40
|
+
desc 'Generate RBS files for Active Record models'
|
41
|
+
task("#{name}:generate_rbs_for_models": :environment) do
|
42
|
+
require 'rbs_rails'
|
43
|
+
|
44
|
+
out_dir = Rails.root / 'sig'
|
45
|
+
out_dir.mkdir unless out_dir.exist?
|
46
|
+
|
47
|
+
Rails.application.eager_load!
|
48
|
+
|
49
|
+
|
50
|
+
# HACK: for steep
|
51
|
+
(_ = ::ActiveRecord::Base).descendants.each do |klass|
|
52
|
+
next if klass.abstract_class?
|
53
|
+
next if ignore_model_if&.call(klass)
|
54
|
+
|
55
|
+
path = out_dir / "app/models/#{klass.name.underscore}.rbs"
|
56
|
+
FileUtils.mkdir_p(path.dirname)
|
57
|
+
|
58
|
+
sig = RbsRails::ActiveRecord.class_to_rbs(klass)
|
59
|
+
path.write sig
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def def_generate_rbs_for_path_helpers
|
65
|
+
desc 'Generate RBS files for path helpers'
|
66
|
+
task("#{name}:generate_rbs_for_path_helpers": :environment) do
|
67
|
+
require 'rbs_rails'
|
68
|
+
|
69
|
+
out_path = Rails.root.join 'sig/path_helpers.rbs'
|
70
|
+
rbs = RbsRails::PathHelpers.generate
|
71
|
+
out_path.write rbs
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/rbs_rails/version.rb
CHANGED
data/rbs_rails.gemspec
CHANGED
data/sig/fileutils.rbs
CHANGED
data/sig/rake.rbs
ADDED
@@ -1,11 +1,11 @@
|
|
1
1
|
module RbsRails::ActiveRecord
|
2
|
-
def self.class_to_rbs: (untyped klass
|
2
|
+
def self.class_to_rbs: (untyped klass) -> untyped
|
3
3
|
end
|
4
4
|
|
5
5
|
class RbsRails::ActiveRecord::Generator
|
6
6
|
@parse_model_file: nil | Parser::AST::Node
|
7
7
|
|
8
|
-
def initialize: (singleton(ActiveRecord::Base) klass
|
8
|
+
def initialize: (singleton(ActiveRecord::Base) klass) -> untyped
|
9
9
|
|
10
10
|
def generate: () -> String
|
11
11
|
|
@@ -53,7 +53,7 @@ class RbsRails::ActiveRecord::Generator
|
|
53
53
|
|
54
54
|
def sql_type_to_class: (untyped t) -> untyped
|
55
55
|
|
56
|
-
|
56
|
+
def optional: (String) -> String
|
57
57
|
|
58
|
-
attr_reader
|
58
|
+
attr_reader klass: singleton(ActiveRecord::Base)
|
59
59
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RbsRails
|
2
|
+
class RakeTask < Rake::TaskLib
|
3
|
+
interface _Filter
|
4
|
+
def call: (Class) -> boolish
|
5
|
+
end
|
6
|
+
attr_accessor ignore_model_if: _Filter | nil
|
7
|
+
|
8
|
+
attr_accessor name: Symbol
|
9
|
+
|
10
|
+
def initialize: (?::Symbol name) { (self) -> void } -> void
|
11
|
+
|
12
|
+
def def_all: () -> void
|
13
|
+
|
14
|
+
def def_copy_signature_files: () -> void
|
15
|
+
|
16
|
+
def def_generate_rbs_for_models: () -> void
|
17
|
+
|
18
|
+
def def_generate_rbs_for_path_helpers: () -> void
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
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: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
27
41
|
description: A RBS files generator for Rails application
|
28
42
|
email:
|
29
43
|
- kuwabara@pocke.me
|
@@ -32,38 +46,57 @@ extensions: []
|
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
34
48
|
- ".gitignore"
|
49
|
+
- ".gitmodules"
|
35
50
|
- ".travis.yml"
|
36
51
|
- Gemfile
|
37
52
|
- LICENSE
|
38
53
|
- README.md
|
39
54
|
- Rakefile
|
40
55
|
- Steepfile
|
41
|
-
- assets/sig/action_controller.rbs
|
42
56
|
- assets/sig/action_mailer.rbs
|
43
|
-
- assets/sig/action_view.rbs
|
44
|
-
- assets/sig/active_record.rbs
|
45
57
|
- assets/sig/builtin.rbs
|
46
|
-
- assets/sig/
|
47
|
-
- assets/sig/
|
58
|
+
- assets/sig/capybara.rbs
|
59
|
+
- assets/sig/concurrent.rbs
|
60
|
+
- assets/sig/erb.rbs
|
61
|
+
- assets/sig/erubi.rbs
|
62
|
+
- assets/sig/i18n.rbs
|
48
63
|
- assets/sig/libxml.rbs
|
49
64
|
- assets/sig/minitest.rbs
|
50
65
|
- assets/sig/nokogiri.rbs
|
66
|
+
- assets/sig/pg.rbs
|
67
|
+
- assets/sig/que.rbs
|
68
|
+
- assets/sig/queue_classic.rbs
|
69
|
+
- assets/sig/racc.rbs
|
70
|
+
- assets/sig/rack-test.rbs
|
71
|
+
- assets/sig/rack.rbs
|
51
72
|
- assets/sig/rails.rbs
|
73
|
+
- assets/sig/rdoc.rbs
|
74
|
+
- assets/sig/sidekiq.rbs
|
75
|
+
- assets/sig/sneakers.rbs
|
52
76
|
- assets/sig/stdlib.rbs
|
77
|
+
- assets/sig/sucker_punch.rbs
|
78
|
+
- assets/sig/thor.rbs
|
79
|
+
- assets/sig/tzinfo.rbs
|
53
80
|
- bin/add-type-params.rb
|
54
81
|
- bin/console
|
55
|
-
- bin/
|
82
|
+
- bin/postprocess.rb
|
83
|
+
- bin/rbs
|
84
|
+
- bin/rbs-prototype-rb.rb
|
56
85
|
- bin/setup
|
86
|
+
- bin/to-ascii.rb
|
57
87
|
- lib/rbs_rails.rb
|
58
88
|
- lib/rbs_rails/active_record.rb
|
59
89
|
- lib/rbs_rails/path_helpers.rb
|
90
|
+
- lib/rbs_rails/rake_task.rb
|
60
91
|
- lib/rbs_rails/version.rb
|
61
92
|
- rbs_rails.gemspec
|
62
93
|
- sig/fileutils.rbs
|
63
94
|
- sig/parser.rbs
|
95
|
+
- sig/rake.rbs
|
64
96
|
- sig/rbs_rails.rbs
|
65
97
|
- sig/rbs_rails/active_record.rbs
|
66
98
|
- sig/rbs_rails/path_helpers.rbs
|
99
|
+
- sig/rbs_rails/rake_task.rbs
|
67
100
|
- sig/rbs_rails/version.rbs
|
68
101
|
homepage: https://github.com/pocke/rbs_rails
|
69
102
|
licenses:
|
@@ -71,7 +104,7 @@ licenses:
|
|
71
104
|
metadata:
|
72
105
|
homepage_uri: https://github.com/pocke/rbs_rails
|
73
106
|
source_code_uri: https://github.com/pocke/rbs_rails
|
74
|
-
post_install_message:
|
107
|
+
post_install_message:
|
75
108
|
rdoc_options: []
|
76
109
|
require_paths:
|
77
110
|
- lib
|
@@ -86,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
119
|
- !ruby/object:Gem::Version
|
87
120
|
version: '0'
|
88
121
|
requirements: []
|
89
|
-
rubygems_version: 3.2.
|
90
|
-
signing_key:
|
122
|
+
rubygems_version: 3.2.3
|
123
|
+
signing_key:
|
91
124
|
specification_version: 4
|
92
125
|
summary: A RBS files generator for Rails application
|
93
126
|
test_files: []
|
@@ -1,44 +0,0 @@
|
|
1
|
-
interface _ActionController_API_and_Base
|
2
|
-
def request: () -> untyped
|
3
|
-
def params: () -> untyped
|
4
|
-
def session: () -> untyped
|
5
|
-
def cookies: () -> untyped
|
6
|
-
def flash: () -> untyped
|
7
|
-
def render: (*untyped) -> void
|
8
|
-
def redirect_to: (*untyped) -> void
|
9
|
-
end
|
10
|
-
|
11
|
-
interface _ActionController_API_and_Base_singletion
|
12
|
-
# hooks
|
13
|
-
def before_action: (*untyped) -> void
|
14
|
-
def around_action: (*untyped) -> void
|
15
|
-
def after_action: (*untyped) -> void
|
16
|
-
def skip_before_action: (*untyped) -> void
|
17
|
-
def skip_around_action: (*untyped) -> void
|
18
|
-
def skip_after_action: (*untyped) -> void
|
19
|
-
def prepend_before_action: (*untyped) -> void
|
20
|
-
def prepend_around_action: (*untyped) -> void
|
21
|
-
def prepend_after_action: (*untyped) -> void
|
22
|
-
def append_before_action: (*untyped) -> void
|
23
|
-
def append_around_action: (*untyped) -> void
|
24
|
-
def append_after_action: (*untyped) -> void
|
25
|
-
|
26
|
-
def rescue_from: (*Class, ?with: Symbol | Proc) { (Exception) -> void } -> void
|
27
|
-
end
|
28
|
-
|
29
|
-
class AbstractController::Base
|
30
|
-
end
|
31
|
-
|
32
|
-
class ActionController::Metal < AbstractController::Base
|
33
|
-
end
|
34
|
-
|
35
|
-
class ActionController::Base < ActionController::Metal
|
36
|
-
include _ActionController_API_and_Base
|
37
|
-
extend _ActionController_API_and_Base_singletion
|
38
|
-
extend ActionView::Layouts::ClassMethods
|
39
|
-
end
|
40
|
-
|
41
|
-
class ActionController::API < ActionController::Metal
|
42
|
-
include _ActionController_API_and_Base
|
43
|
-
extend _ActionController_API_and_Base_singletion
|
44
|
-
end
|
data/assets/sig/action_view.rbs
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
class ActiveRecord::Base
|
2
|
-
def self.abstract_class=: (bool) -> void
|
3
|
-
def self.scope: (Symbol, ^(*untyped) -> untyped ) -> void
|
4
|
-
| (Symbol) { (*untyped) -> untyped } -> void
|
5
|
-
def self.belongs_to: (Symbol, ?untyped, **untyped) -> void
|
6
|
-
def self.has_many: (Symbol, ?untyped, **untyped) -> void
|
7
|
-
def self.has_one: (Symbol, ?untyped, **untyped) -> void
|
8
|
-
def self.transaction: [T] () { () -> T } -> T
|
9
|
-
def self.create!: (**untyped) -> instance
|
10
|
-
def self.validate: (*untyped) -> void
|
11
|
-
def self.validates: (*untyped) -> void
|
12
|
-
def self.enum: (Hash[Symbol, untyped]) -> void
|
13
|
-
|
14
|
-
# callbacks
|
15
|
-
def self.after_commit: (*untyped) -> void
|
16
|
-
def self.after_create: (*untyped) -> void
|
17
|
-
def self.after_destroy: (*untyped) -> void
|
18
|
-
def self.after_rollback: (*untyped) -> void
|
19
|
-
def self.after_save: (*untyped) -> void
|
20
|
-
def self.after_update: (*untyped) -> void
|
21
|
-
def self.after_validation: (*untyped) -> void
|
22
|
-
def self.around_create: (*untyped) -> void
|
23
|
-
def self.around_destroy: (*untyped) -> void
|
24
|
-
def self.around_save: (*untyped) -> void
|
25
|
-
def self.around_update: (*untyped) -> void
|
26
|
-
def self.before_create: (*untyped) -> void
|
27
|
-
def self.before_destroy: (*untyped) -> void
|
28
|
-
def self.before_save: (*untyped) -> void
|
29
|
-
def self.before_update: (*untyped) -> void
|
30
|
-
def self.before_validation: (*untyped) -> void
|
31
|
-
|
32
|
-
def self.columns: () -> Array[untyped]
|
33
|
-
def self.reflect_on_all_associations: (?Symbol) -> Array[untyped]
|
34
|
-
|
35
|
-
def will_save_change_to_attribute?: (String | Symbol attr_name, ?from: untyped, ?to: untyped) -> bool
|
36
|
-
|
37
|
-
def save!: () -> self
|
38
|
-
def save: () -> bool
|
39
|
-
def update!: (*untyped) -> self
|
40
|
-
def update: (*untyped) -> bool
|
41
|
-
def destroy!: () -> self
|
42
|
-
def destroy: () -> bool
|
43
|
-
def valid?: () -> bool
|
44
|
-
def invalid?: () -> bool
|
45
|
-
def errors: () -> untyped
|
46
|
-
def []: (Symbol) -> untyped
|
47
|
-
def []=: (Symbol, untyped) -> untyped
|
48
|
-
end
|
49
|
-
|
50
|
-
class ActiveRecord::Relation
|
51
|
-
end
|
52
|
-
|
53
|
-
class ActiveRecord::Associations::CollectionProxy
|
54
|
-
end
|
55
|
-
|
56
|
-
interface _ActiveRecord_Relation[Model]
|
57
|
-
def all: () -> self
|
58
|
-
def ids: () -> Array[Integer]
|
59
|
-
def none: () -> self
|
60
|
-
def pluck: (Symbol | String column) -> Array[untyped]
|
61
|
-
| (*Symbol | String columns) -> Array[Array[untyped]]
|
62
|
-
def where: (*untyped) -> self
|
63
|
-
def not: (*untyped) -> self
|
64
|
-
def exists?: (*untyped) -> bool
|
65
|
-
def order: (*untyped) -> self
|
66
|
-
def group: (*Symbol | String) -> untyped
|
67
|
-
def distinct: () -> self
|
68
|
-
def or: (self) -> self
|
69
|
-
def merge: (self) -> self
|
70
|
-
def joins: (*String | Symbol) -> self
|
71
|
-
| (Hash[untyped, untyped]) -> self
|
72
|
-
def left_joins: (*String | Symbol) -> self
|
73
|
-
| (Hash[untyped, untyped]) -> self
|
74
|
-
def left_outer_joins: (*String | Symbol) -> self
|
75
|
-
| (Hash[untyped, untyped]) -> self
|
76
|
-
def includes: (*String | Symbol) -> self
|
77
|
-
| (Hash[untyped, untyped]) -> self
|
78
|
-
def eager_load: (*String | Symbol) -> self
|
79
|
-
| (Hash[untyped, untyped]) -> self
|
80
|
-
def preload: (*String | Symbol) -> self
|
81
|
-
| (Hash[untyped, untyped]) -> self
|
82
|
-
def find_by: (*untyped) -> Model?
|
83
|
-
def find_by!: (*untyped) -> Model
|
84
|
-
def find: (Integer id) -> Model
|
85
|
-
def first: () -> Model
|
86
|
-
| (Integer count) -> Array[Model]
|
87
|
-
def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
|
88
|
-
def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
|
89
|
-
def destroy_all: () -> untyped
|
90
|
-
def delete_all: () -> untyped
|
91
|
-
def update_all: (*untyped) -> untyped
|
92
|
-
def each: () { (Model) -> void } -> self
|
93
|
-
end
|
94
|
-
|
95
|
-
interface _ActiveRecord_Relation_ClassMethods[Model, Relation]
|
96
|
-
def all: () -> Relation
|
97
|
-
def ids: () -> Array[Integer]
|
98
|
-
def none: () -> Relation
|
99
|
-
def pluck: (Symbol | String column) -> Array[untyped]
|
100
|
-
| (*Symbol | String columns) -> Array[Array[untyped]]
|
101
|
-
def where: (*untyped) -> Relation
|
102
|
-
def exists?: (*untyped) -> bool
|
103
|
-
def order: (*untyped) -> Relation
|
104
|
-
def group: (*Symbol | String) -> untyped
|
105
|
-
def distinct: () -> self
|
106
|
-
def or: (Relation) -> Relation
|
107
|
-
def merge: (Relation) -> Relation
|
108
|
-
def joins: (*String | Symbol) -> self
|
109
|
-
| (Hash[untyped, untyped]) -> self
|
110
|
-
def left_joins: (*String | Symbol) -> self
|
111
|
-
| (Hash[untyped, untyped]) -> self
|
112
|
-
def left_outer_joins: (*String | Symbol) -> self
|
113
|
-
| (Hash[untyped, untyped]) -> self
|
114
|
-
def includes: (*String | Symbol) -> self
|
115
|
-
| (Hash[untyped, untyped]) -> self
|
116
|
-
def eager_load: (*String | Symbol) -> self
|
117
|
-
| (Hash[untyped, untyped]) -> self
|
118
|
-
def preload: (*String | Symbol) -> self
|
119
|
-
| (Hash[untyped, untyped]) -> self
|
120
|
-
def find_by: (*untyped) -> Model?
|
121
|
-
def find_by!: (*untyped) -> Model
|
122
|
-
def find: (Integer id) -> Model
|
123
|
-
def first: () -> Model
|
124
|
-
| (Integer count) -> Array[Model]
|
125
|
-
def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
|
126
|
-
def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
|
127
|
-
def destroy_all: () -> untyped
|
128
|
-
def delete_all: () -> untyped
|
129
|
-
def update_all: (*untyped) -> untyped
|
130
|
-
end
|