rbs_rails 0.4.1 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +29 -0
  3. data/.gitignore +4 -1
  4. data/.gitmodules +0 -0
  5. data/CHANGELOG.md +17 -0
  6. data/Gemfile +2 -2
  7. data/README.md +28 -44
  8. data/Rakefile +2 -1
  9. data/Steepfile +12 -1
  10. data/bin/add-type-params.rb +2 -1
  11. data/bin/gem_rbs +94 -0
  12. data/bin/postprocess.rb +1 -1
  13. data/bin/rbs +29 -2
  14. data/bin/rbs-prototype-rb.rb +59 -6
  15. data/bin/setup +1 -0
  16. data/lib/rbs_rails.rb +4 -0
  17. data/lib/rbs_rails/active_record.rb +80 -46
  18. data/lib/rbs_rails/dependency_builder.rb +43 -0
  19. data/lib/rbs_rails/rake_task.rb +72 -0
  20. data/lib/rbs_rails/util.rb +25 -0
  21. data/lib/rbs_rails/version.rb +1 -1
  22. data/rbs_rails.gemspec +2 -2
  23. data/sig/fileutils.rbs +1 -0
  24. data/sig/rake.rbs +6 -0
  25. data/sig/rbs_rails/active_record.rbs +9 -2
  26. data/sig/rbs_rails/dependency_builder.rbs +9 -0
  27. data/sig/rbs_rails/rake_task.rbs +26 -0
  28. data/sig/rbs_rails/util.rbs +11 -0
  29. metadata +17 -48
  30. data/.travis.yml +0 -11
  31. data/assets/sig/action_controller.rbs +0 -49
  32. data/assets/sig/action_mailer.rbs +0 -8
  33. data/assets/sig/active_record.rbs +0 -137
  34. data/assets/sig/builtin.rbs +0 -7
  35. data/assets/sig/capybara.rbs +0 -14
  36. data/assets/sig/concurrent.rbs +0 -4
  37. data/assets/sig/erb.rbs +0 -4
  38. data/assets/sig/erubi.rbs +0 -4
  39. data/assets/sig/generated/actionpack.rbs +0 -11831
  40. data/assets/sig/generated/actionview.rbs +0 -10591
  41. data/assets/sig/generated/activejob.rbs +0 -1920
  42. data/assets/sig/generated/activemodel.rbs +0 -4214
  43. data/assets/sig/generated/activerecord-meta-programming.rbs +0 -98
  44. data/assets/sig/generated/activerecord.rbs +0 -24602
  45. data/assets/sig/generated/activesupport.rbs +0 -12613
  46. data/assets/sig/generated/railties.rbs +0 -4687
  47. data/assets/sig/i18n.rbs +0 -4
  48. data/assets/sig/libxml.rbs +0 -10
  49. data/assets/sig/minitest.rbs +0 -13
  50. data/assets/sig/nokogiri.rbs +0 -8
  51. data/assets/sig/patches/README.md +0 -4
  52. data/assets/sig/patches/for_actionpack.rbs +0 -74
  53. data/assets/sig/patches/for_actionview.rbs +0 -19
  54. data/assets/sig/patches/for_activemodel.rbs +0 -11
  55. data/assets/sig/patches/for_activerecord.rbs +0 -84
  56. data/assets/sig/patches/for_activesupport.rbs +0 -48
  57. data/assets/sig/patches/for_railties.rbs +0 -30
  58. data/assets/sig/pg.rbs +0 -5
  59. data/assets/sig/que.rbs +0 -4
  60. data/assets/sig/queue_classic.rbs +0 -4
  61. data/assets/sig/racc.rbs +0 -4
  62. data/assets/sig/rack-test.rbs +0 -6
  63. data/assets/sig/rack.rbs +0 -47
  64. data/assets/sig/rails.rbs +0 -14
  65. data/assets/sig/rdoc.rbs +0 -9
  66. data/assets/sig/sidekiq.rbs +0 -4
  67. data/assets/sig/sneakers.rbs +0 -4
  68. data/assets/sig/stdlib.rbs +0 -24
  69. data/assets/sig/sucker_punch.rbs +0 -4
  70. data/assets/sig/thor.rbs +0 -12
  71. data/assets/sig/tzinfo.rbs +0 -4
  72. data/bin/generate_rbs_from_rails_source_code.rb +0 -201
@@ -1,11 +1,12 @@
1
1
  module RbsRails::ActiveRecord
2
- def self.class_to_rbs: (untyped klass) -> untyped
2
+ def self.class_to_rbs: (untyped klass, ?dependencies: Array[String]) -> untyped
3
+ def self.generatable?: (untyped klass) -> boolish
3
4
  end
4
5
 
5
6
  class RbsRails::ActiveRecord::Generator
6
7
  @parse_model_file: nil | Parser::AST::Node
7
8
 
8
- def initialize: (singleton(ActiveRecord::Base) klass) -> untyped
9
+ def initialize: (singleton(ActiveRecord::Base) klass, dependencies: Array[String]) -> untyped
9
10
 
10
11
  def generate: () -> String
11
12
 
@@ -17,6 +18,8 @@ class RbsRails::ActiveRecord::Generator
17
18
 
18
19
  def header: () -> String
19
20
 
21
+ def footer: () -> String
22
+
20
23
  def associations: () -> String
21
24
 
22
25
  def has_many: () -> String
@@ -55,5 +58,9 @@ class RbsRails::ActiveRecord::Generator
55
58
 
56
59
  def optional: (String) -> String
57
60
 
61
+ private
62
+
58
63
  attr_reader klass: singleton(ActiveRecord::Base)
64
+
65
+ attr_reader klass_name: String
59
66
  end
@@ -0,0 +1,9 @@
1
+ module RbsRails
2
+ class DependencyBuilder
3
+ attr_reader deps: Array[String]
4
+
5
+ def initialize: () -> void
6
+
7
+ def build: () -> (String | nil)
8
+ end
9
+ end
@@ -0,0 +1,26 @@
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
+ attr_accessor signature_root_dir: Pathname
11
+
12
+ def initialize: (?::Symbol name) { (self) -> void } -> void
13
+
14
+ def def_all: () -> void
15
+
16
+ def def_copy_signature_files: () -> void
17
+
18
+ def def_generate_rbs_for_models: () -> void
19
+
20
+ def def_generate_rbs_for_path_helpers: () -> void
21
+
22
+ private
23
+
24
+ def setup_signature_root_dir!: () -> void
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module RbsRails
2
+ module Util
3
+ MODULE_NAME: UnboundMethod
4
+
5
+ extend Util
6
+
7
+ def module_name: (Module) -> String
8
+
9
+ def format_rbs: (String) -> String
10
+ end
11
+ 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.1
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-21 00:00:00.000000000 Z
11
+ date: 2021-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0.17'
33
+ version: '1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0.17'
40
+ version: '1'
41
41
  description: A RBS files generator for Rails application
42
42
  email:
43
43
  - kuwabara@pocke.me
@@ -45,57 +45,18 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".github/workflows/ci.yml"
48
49
  - ".gitignore"
49
- - ".travis.yml"
50
+ - ".gitmodules"
51
+ - CHANGELOG.md
50
52
  - Gemfile
51
53
  - LICENSE
52
54
  - README.md
53
55
  - Rakefile
54
56
  - Steepfile
55
- - assets/sig/action_controller.rbs
56
- - assets/sig/action_mailer.rbs
57
- - assets/sig/active_record.rbs
58
- - assets/sig/builtin.rbs
59
- - assets/sig/capybara.rbs
60
- - assets/sig/concurrent.rbs
61
- - assets/sig/erb.rbs
62
- - assets/sig/erubi.rbs
63
- - assets/sig/generated/actionpack.rbs
64
- - assets/sig/generated/actionview.rbs
65
- - assets/sig/generated/activejob.rbs
66
- - assets/sig/generated/activemodel.rbs
67
- - assets/sig/generated/activerecord-meta-programming.rbs
68
- - assets/sig/generated/activerecord.rbs
69
- - assets/sig/generated/activesupport.rbs
70
- - assets/sig/generated/railties.rbs
71
- - assets/sig/i18n.rbs
72
- - assets/sig/libxml.rbs
73
- - assets/sig/minitest.rbs
74
- - assets/sig/nokogiri.rbs
75
- - assets/sig/patches/README.md
76
- - assets/sig/patches/for_actionpack.rbs
77
- - assets/sig/patches/for_actionview.rbs
78
- - assets/sig/patches/for_activemodel.rbs
79
- - assets/sig/patches/for_activerecord.rbs
80
- - assets/sig/patches/for_activesupport.rbs
81
- - assets/sig/patches/for_railties.rbs
82
- - assets/sig/pg.rbs
83
- - assets/sig/que.rbs
84
- - assets/sig/queue_classic.rbs
85
- - assets/sig/racc.rbs
86
- - assets/sig/rack-test.rbs
87
- - assets/sig/rack.rbs
88
- - assets/sig/rails.rbs
89
- - assets/sig/rdoc.rbs
90
- - assets/sig/sidekiq.rbs
91
- - assets/sig/sneakers.rbs
92
- - assets/sig/stdlib.rbs
93
- - assets/sig/sucker_punch.rbs
94
- - assets/sig/thor.rbs
95
- - assets/sig/tzinfo.rbs
96
57
  - bin/add-type-params.rb
97
58
  - bin/console
98
- - bin/generate_rbs_from_rails_source_code.rb
59
+ - bin/gem_rbs
99
60
  - bin/postprocess.rb
100
61
  - bin/rbs
101
62
  - bin/rbs-prototype-rb.rb
@@ -103,14 +64,21 @@ files:
103
64
  - bin/to-ascii.rb
104
65
  - lib/rbs_rails.rb
105
66
  - lib/rbs_rails/active_record.rb
67
+ - lib/rbs_rails/dependency_builder.rb
106
68
  - lib/rbs_rails/path_helpers.rb
69
+ - lib/rbs_rails/rake_task.rb
70
+ - lib/rbs_rails/util.rb
107
71
  - lib/rbs_rails/version.rb
108
72
  - rbs_rails.gemspec
109
73
  - sig/fileutils.rbs
110
74
  - sig/parser.rbs
75
+ - sig/rake.rbs
111
76
  - sig/rbs_rails.rbs
112
77
  - sig/rbs_rails/active_record.rbs
78
+ - sig/rbs_rails/dependency_builder.rbs
113
79
  - sig/rbs_rails/path_helpers.rbs
80
+ - sig/rbs_rails/rake_task.rbs
81
+ - sig/rbs_rails/util.rbs
114
82
  - sig/rbs_rails/version.rbs
115
83
  homepage: https://github.com/pocke/rbs_rails
116
84
  licenses:
@@ -118,6 +86,7 @@ licenses:
118
86
  metadata:
119
87
  homepage_uri: https://github.com/pocke/rbs_rails
120
88
  source_code_uri: https://github.com/pocke/rbs_rails
89
+ changelog_uri: https://github.com/pocke/rbs_rails/blob/master/CHANGELOG.md
121
90
  post_install_message:
122
91
  rdoc_options: []
123
92
  require_paths:
@@ -133,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
102
  - !ruby/object:Gem::Version
134
103
  version: '0'
135
104
  requirements: []
136
- rubygems_version: 3.2.0.rc.2
105
+ rubygems_version: 3.3.0.dev
137
106
  signing_key:
138
107
  specification_version: 4
139
108
  summary: A RBS files generator for Rails application
@@ -1,11 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.6.5
5
- - 2.7.0
6
- - ruby-head
7
-
8
- before_install:
9
- - gem install bundler -v 2.1.4
10
-
11
- cache: bundler
@@ -1,49 +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
- module AbstractController
30
- class Base
31
- end
32
- end
33
-
34
- module ActionController
35
- class Metal < ::AbstractController::Base
36
- end
37
-
38
- class Base < Metal
39
- include _ActionController_API_and_Base
40
- extend _ActionController_API_and_Base_singletion
41
- extend ::ActionView::Layouts::ClassMethods
42
- end
43
-
44
- class API < Metal
45
- include _ActionController_API_and_Base
46
- extend _ActionController_API_and_Base_singletion
47
- end
48
- end
49
-
@@ -1,8 +0,0 @@
1
- module ActionMailer
2
- class Base
3
- # TODO
4
- # extend ActionView::Layouts::ClassMethods
5
-
6
- def self.default: (?Hash[Symbol, untyped] value) -> Hash[Symbol, untyped]
7
- end
8
- end
@@ -1,137 +0,0 @@
1
- module ActiveRecord
2
- end
3
-
4
- class ActiveRecord::Base
5
- def self.abstract_class=: (bool) -> void
6
- def self.scope: (Symbol, ^(*untyped) -> untyped ) -> void
7
- | (Symbol) { (*untyped) -> untyped } -> void
8
- def self.belongs_to: (Symbol, ?untyped, **untyped) -> void
9
- def self.has_many: (Symbol, ?untyped, **untyped) -> void
10
- def self.has_one: (Symbol, ?untyped, **untyped) -> void
11
- def self.transaction: [T] () { () -> T } -> T
12
- def self.create!: (**untyped) -> instance
13
- def self.validate: (*untyped) -> void
14
- def self.validates: (*untyped) -> void
15
- def self.enum: (Hash[Symbol, untyped]) -> void
16
-
17
- # callbacks
18
- def self.after_commit: (*untyped) -> void
19
- def self.after_create: (*untyped) -> void
20
- def self.after_destroy: (*untyped) -> void
21
- def self.after_rollback: (*untyped) -> void
22
- def self.after_save: (*untyped) -> void
23
- def self.after_update: (*untyped) -> void
24
- def self.after_validation: (*untyped) -> void
25
- def self.around_create: (*untyped) -> void
26
- def self.around_destroy: (*untyped) -> void
27
- def self.around_save: (*untyped) -> void
28
- def self.around_update: (*untyped) -> void
29
- def self.before_create: (*untyped) -> void
30
- def self.before_destroy: (*untyped) -> void
31
- def self.before_save: (*untyped) -> void
32
- def self.before_update: (*untyped) -> void
33
- def self.before_validation: (*untyped) -> void
34
-
35
- def self.columns: () -> Array[untyped]
36
- def self.reflect_on_all_associations: (?Symbol) -> Array[untyped]
37
-
38
- def will_save_change_to_attribute?: (String | Symbol attr_name, ?from: untyped, ?to: untyped) -> bool
39
-
40
- def save!: (?validate: bool, ?touch: bool) -> self
41
- def save: () -> bool
42
- def update!: (*untyped) -> self
43
- def update: (*untyped) -> bool
44
- def destroy!: () -> self
45
- def destroy: () -> bool
46
- def valid?: () -> bool
47
- def invalid?: () -> bool
48
- def errors: () -> untyped
49
- def []: (Symbol) -> untyped
50
- def []=: (Symbol, untyped) -> untyped
51
- end
52
-
53
- class ActiveRecord::Relation
54
- end
55
-
56
- class ActiveRecord::Associations::CollectionProxy
57
- end
58
-
59
- interface _ActiveRecord_Relation[Model]
60
- def all: () -> self
61
- def ids: () -> Array[Integer]
62
- def none: () -> self
63
- def pluck: (Symbol | String column) -> Array[untyped]
64
- | (*Symbol | String columns) -> Array[Array[untyped]]
65
- def where: (*untyped) -> self
66
- def not: (*untyped) -> self
67
- def exists?: (*untyped) -> bool
68
- def order: (*untyped) -> self
69
- def group: (*Symbol | String) -> untyped
70
- def distinct: () -> self
71
- def or: (self) -> self
72
- def merge: (self) -> self
73
- def joins: (*String | Symbol) -> self
74
- | (Hash[untyped, untyped]) -> self
75
- def left_joins: (*String | Symbol) -> self
76
- | (Hash[untyped, untyped]) -> self
77
- def left_outer_joins: (*String | Symbol) -> self
78
- | (Hash[untyped, untyped]) -> self
79
- def includes: (*String | Symbol) -> self
80
- | (Hash[untyped, untyped]) -> self
81
- def eager_load: (*String | Symbol) -> self
82
- | (Hash[untyped, untyped]) -> self
83
- def preload: (*String | Symbol) -> self
84
- | (Hash[untyped, untyped]) -> self
85
- def find_by: (*untyped) -> Model?
86
- def find_by!: (*untyped) -> Model
87
- def find: (Integer id) -> Model
88
- def first: () -> Model
89
- | (Integer count) -> Array[Model]
90
- def last: () -> Model
91
- | (Integer count) -> Array[Model]
92
- def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
93
- def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
94
- def destroy_all: () -> untyped
95
- def delete_all: () -> untyped
96
- def update_all: (*untyped) -> untyped
97
- def each: () { (Model) -> void } -> self
98
- end
99
-
100
- interface _ActiveRecord_Relation_ClassMethods[Model, Relation]
101
- def all: () -> Relation
102
- def ids: () -> Array[Integer]
103
- def none: () -> Relation
104
- def pluck: (Symbol | String column) -> Array[untyped]
105
- | (*Symbol | String columns) -> Array[Array[untyped]]
106
- def where: (*untyped) -> Relation
107
- def exists?: (*untyped) -> bool
108
- def order: (*untyped) -> Relation
109
- def group: (*Symbol | String) -> untyped
110
- def distinct: () -> self
111
- def or: (Relation) -> Relation
112
- def merge: (Relation) -> Relation
113
- def joins: (*String | Symbol) -> self
114
- | (Hash[untyped, untyped]) -> self
115
- def left_joins: (*String | Symbol) -> self
116
- | (Hash[untyped, untyped]) -> self
117
- def left_outer_joins: (*String | Symbol) -> self
118
- | (Hash[untyped, untyped]) -> self
119
- def includes: (*String | Symbol) -> self
120
- | (Hash[untyped, untyped]) -> self
121
- def eager_load: (*String | Symbol) -> self
122
- | (Hash[untyped, untyped]) -> self
123
- def preload: (*String | Symbol) -> self
124
- | (Hash[untyped, untyped]) -> self
125
- def find_by: (*untyped) -> Model?
126
- def find_by!: (*untyped) -> Model
127
- def find: (Integer id) -> Model
128
- def first: () -> Model
129
- | (Integer count) -> Array[Model]
130
- def last: () -> Model
131
- | (Integer count) -> Array[Model]
132
- def find_each: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (Model) -> void } -> nil
133
- def find_in_batches: (?batch_size: Integer, ?start: Integer, ?finish: Integer, ?error_on_ignore: bool) { (self) -> void } -> nil
134
- def destroy_all: () -> untyped
135
- def delete_all: () -> untyped
136
- def update_all: (*untyped) -> untyped
137
- end
@@ -1,7 +0,0 @@
1
- class Monitor
2
- end
3
- class MonitorMixin
4
- end
5
-
6
- module Singleton
7
- end
@@ -1,14 +0,0 @@
1
- module Capybara
2
- module DSL
3
- end
4
-
5
- module Minitest
6
- module Assertions
7
- end
8
- end
9
-
10
- module Poltergeist
11
- class Driver
12
- end
13
- end
14
- end