rbs_rails 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dependabot/config.yml +5 -0
- data/.github/workflows/ci.yml +11 -2
- data/.gitignore +1 -1
- data/CHANGELOG.md +30 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +179 -0
- data/README.md +11 -4
- data/Rakefile +4 -2
- data/Steepfile +1 -14
- data/bin/add-type-params.rb +1 -0
- data/bin/setup +1 -0
- data/lib/rbs_rails/active_record.rb +135 -18
- data/lib/rbs_rails/rake_task.rb +3 -14
- data/lib/rbs_rails/version.rb +1 -1
- data/rbs_collection.lock.yaml +132 -0
- data/rbs_collection.yaml +45 -0
- data/rbs_rails.gemspec +2 -2
- data/sig/activerecord.rbs +4 -0
- data/sig/rbs_rails/active_record.rbs +11 -0
- metadata +9 -29
- data/assets/sig/action_mailer.rbs +0 -8
- data/assets/sig/builtin.rbs +0 -7
- data/assets/sig/capybara.rbs +0 -14
- data/assets/sig/concurrent.rbs +0 -4
- data/assets/sig/erb.rbs +0 -4
- data/assets/sig/erubi.rbs +0 -4
- data/assets/sig/i18n.rbs +0 -4
- data/assets/sig/libxml.rbs +0 -10
- data/assets/sig/minitest.rbs +0 -13
- data/assets/sig/nokogiri.rbs +0 -8
- data/assets/sig/pg.rbs +0 -5
- data/assets/sig/que.rbs +0 -4
- data/assets/sig/queue_classic.rbs +0 -4
- data/assets/sig/racc.rbs +0 -4
- data/assets/sig/rack-test.rbs +0 -6
- data/assets/sig/rack.rbs +0 -47
- data/assets/sig/rails.rbs +0 -10
- data/assets/sig/rdoc.rbs +0 -9
- data/assets/sig/sidekiq.rbs +0 -4
- data/assets/sig/sneakers.rbs +0 -4
- data/assets/sig/stdlib.rbs +0 -24
- data/assets/sig/sucker_punch.rbs +0 -4
- data/assets/sig/thor.rbs +0 -12
- data/assets/sig/tzinfo.rbs +0 -4
- data/bin/gem_rbs +0 -94
- data/bin/rbs +0 -30
@@ -0,0 +1,132 @@
|
|
1
|
+
---
|
2
|
+
sources:
|
3
|
+
- name: ruby/gem_rbs_collection
|
4
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
5
|
+
revision: main
|
6
|
+
repo_dir: gems
|
7
|
+
path: ".gem_rbs_collection"
|
8
|
+
gems:
|
9
|
+
- name: pathname
|
10
|
+
version: '0'
|
11
|
+
source:
|
12
|
+
type: stdlib
|
13
|
+
- name: logger
|
14
|
+
version: '0'
|
15
|
+
source:
|
16
|
+
type: stdlib
|
17
|
+
- name: mutex_m
|
18
|
+
version: '0'
|
19
|
+
source:
|
20
|
+
type: stdlib
|
21
|
+
- name: date
|
22
|
+
version: '0'
|
23
|
+
source:
|
24
|
+
type: stdlib
|
25
|
+
- name: monitor
|
26
|
+
version: '0'
|
27
|
+
source:
|
28
|
+
type: stdlib
|
29
|
+
- name: singleton
|
30
|
+
version: '0'
|
31
|
+
source:
|
32
|
+
type: stdlib
|
33
|
+
- name: tsort
|
34
|
+
version: '0'
|
35
|
+
source:
|
36
|
+
type: stdlib
|
37
|
+
- name: time
|
38
|
+
version: '0'
|
39
|
+
source:
|
40
|
+
type: stdlib
|
41
|
+
- name: set
|
42
|
+
version: '0'
|
43
|
+
source:
|
44
|
+
type: stdlib
|
45
|
+
- name: rack
|
46
|
+
version: 2.2.2
|
47
|
+
source:
|
48
|
+
type: git
|
49
|
+
name: ruby/gem_rbs_collection
|
50
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
51
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
52
|
+
repo_dir: gems
|
53
|
+
- name: json
|
54
|
+
version: '0'
|
55
|
+
source:
|
56
|
+
type: stdlib
|
57
|
+
- name: strscan
|
58
|
+
version: '0'
|
59
|
+
source:
|
60
|
+
type: stdlib
|
61
|
+
- name: optparse
|
62
|
+
version: '0'
|
63
|
+
source:
|
64
|
+
type: stdlib
|
65
|
+
- name: actionpack
|
66
|
+
version: '6.0'
|
67
|
+
source:
|
68
|
+
type: git
|
69
|
+
name: ruby/gem_rbs_collection
|
70
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
71
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
72
|
+
repo_dir: gems
|
73
|
+
- name: actionview
|
74
|
+
version: '6.0'
|
75
|
+
source:
|
76
|
+
type: git
|
77
|
+
name: ruby/gem_rbs_collection
|
78
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
79
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
80
|
+
repo_dir: gems
|
81
|
+
- name: activejob
|
82
|
+
version: '6.0'
|
83
|
+
source:
|
84
|
+
type: git
|
85
|
+
name: ruby/gem_rbs_collection
|
86
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
87
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
88
|
+
repo_dir: gems
|
89
|
+
- name: activemodel
|
90
|
+
version: '6.0'
|
91
|
+
source:
|
92
|
+
type: git
|
93
|
+
name: ruby/gem_rbs_collection
|
94
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
95
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
96
|
+
repo_dir: gems
|
97
|
+
- name: activerecord
|
98
|
+
version: '6.0'
|
99
|
+
source:
|
100
|
+
type: git
|
101
|
+
name: ruby/gem_rbs_collection
|
102
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
103
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
104
|
+
repo_dir: gems
|
105
|
+
- name: activesupport
|
106
|
+
version: '6.0'
|
107
|
+
source:
|
108
|
+
type: git
|
109
|
+
name: ruby/gem_rbs_collection
|
110
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
111
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
112
|
+
repo_dir: gems
|
113
|
+
- name: parallel
|
114
|
+
version: '1.20'
|
115
|
+
source:
|
116
|
+
type: git
|
117
|
+
name: ruby/gem_rbs_collection
|
118
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
119
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
120
|
+
repo_dir: gems
|
121
|
+
- name: railties
|
122
|
+
version: '6.0'
|
123
|
+
source:
|
124
|
+
type: git
|
125
|
+
name: ruby/gem_rbs_collection
|
126
|
+
revision: 51880bed87fbc3dc8076fedb5cf798be05148220
|
127
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
128
|
+
repo_dir: gems
|
129
|
+
- name: rbs
|
130
|
+
version: 1.6.2
|
131
|
+
source:
|
132
|
+
type: rubygems
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- name: ruby/gem_rbs_collection
|
4
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
5
|
+
revision: main
|
6
|
+
repo_dir: gems
|
7
|
+
|
8
|
+
# A directory to install the downloaded RBSs
|
9
|
+
path: .gem_rbs_collection
|
10
|
+
|
11
|
+
gems:
|
12
|
+
# stdlibs
|
13
|
+
- name: 'pathname'
|
14
|
+
- name: 'logger'
|
15
|
+
- name: 'mutex_m'
|
16
|
+
- name: 'date'
|
17
|
+
- name: 'monitor'
|
18
|
+
- name: 'singleton'
|
19
|
+
- name: 'tsort'
|
20
|
+
- name: 'time'
|
21
|
+
- name: 'set'
|
22
|
+
|
23
|
+
# gems
|
24
|
+
- name: 'rack'
|
25
|
+
|
26
|
+
# RBS gem dependencies
|
27
|
+
- name: 'json'
|
28
|
+
- name: 'strscan'
|
29
|
+
- name: 'optparse'
|
30
|
+
|
31
|
+
# Ignores - Gemfile.lock contains them but their RBSs are unnecessary
|
32
|
+
- name: steep
|
33
|
+
ignore: true
|
34
|
+
- name: nokogiri
|
35
|
+
ignore: true
|
36
|
+
- name: ast
|
37
|
+
ignore: true
|
38
|
+
- name: rainbow
|
39
|
+
ignore: true
|
40
|
+
- name: listen
|
41
|
+
ignore: true
|
42
|
+
|
43
|
+
# ignore RBS Rails itself
|
44
|
+
- name: rbs_rails
|
45
|
+
ignore: true
|
data/rbs_rails.gemspec
CHANGED
@@ -14,12 +14,12 @@ Gem::Specification.new do |spec|
|
|
14
14
|
|
15
15
|
spec.metadata["homepage_uri"] = spec.homepage
|
16
16
|
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
-
|
17
|
+
spec.metadata["changelog_uri"] = "https://github.com/pocke/rbs_rails/blob/master/CHANGELOG.md"
|
18
18
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
21
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
23
|
end
|
24
24
|
spec.bindir = "exe"
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module RbsRails::ActiveRecord
|
2
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
|
@@ -11,6 +12,10 @@ class RbsRails::ActiveRecord::Generator
|
|
11
12
|
|
12
13
|
def klass_decl: () -> String
|
13
14
|
|
15
|
+
def pk_type: () -> String
|
16
|
+
|
17
|
+
def generated_relation_methods_decl: () -> String
|
18
|
+
|
14
19
|
def relation_decl: () -> String
|
15
20
|
|
16
21
|
def collection_proxy_decl: () -> String
|
@@ -27,6 +32,12 @@ class RbsRails::ActiveRecord::Generator
|
|
27
32
|
|
28
33
|
def belongs_to: () -> String
|
29
34
|
|
35
|
+
def delegated_type_scope: (singleton: bool) -> String
|
36
|
+
|
37
|
+
def delegated_type_instance: () -> String
|
38
|
+
|
39
|
+
def delegated_type_definitions: () -> Array[{ role: Symbol, types: Array[String] }]?
|
40
|
+
|
30
41
|
def enum_instance_methods: () -> String
|
31
42
|
|
32
43
|
def enum_scope_methods: (singleton: untyped `singleton`) -> String
|
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.9.0
|
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:
|
11
|
+
date: 2021-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -45,44 +45,20 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".dependabot/config.yml"
|
48
49
|
- ".github/workflows/ci.yml"
|
49
50
|
- ".gitignore"
|
50
51
|
- ".gitmodules"
|
51
52
|
- CHANGELOG.md
|
52
53
|
- Gemfile
|
54
|
+
- Gemfile.lock
|
53
55
|
- LICENSE
|
54
56
|
- README.md
|
55
57
|
- Rakefile
|
56
58
|
- Steepfile
|
57
|
-
- assets/sig/action_mailer.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/i18n.rbs
|
64
|
-
- assets/sig/libxml.rbs
|
65
|
-
- assets/sig/minitest.rbs
|
66
|
-
- assets/sig/nokogiri.rbs
|
67
|
-
- assets/sig/pg.rbs
|
68
|
-
- assets/sig/que.rbs
|
69
|
-
- assets/sig/queue_classic.rbs
|
70
|
-
- assets/sig/racc.rbs
|
71
|
-
- assets/sig/rack-test.rbs
|
72
|
-
- assets/sig/rack.rbs
|
73
|
-
- assets/sig/rails.rbs
|
74
|
-
- assets/sig/rdoc.rbs
|
75
|
-
- assets/sig/sidekiq.rbs
|
76
|
-
- assets/sig/sneakers.rbs
|
77
|
-
- assets/sig/stdlib.rbs
|
78
|
-
- assets/sig/sucker_punch.rbs
|
79
|
-
- assets/sig/thor.rbs
|
80
|
-
- assets/sig/tzinfo.rbs
|
81
59
|
- bin/add-type-params.rb
|
82
60
|
- bin/console
|
83
|
-
- bin/gem_rbs
|
84
61
|
- bin/postprocess.rb
|
85
|
-
- bin/rbs
|
86
62
|
- bin/rbs-prototype-rb.rb
|
87
63
|
- bin/setup
|
88
64
|
- bin/to-ascii.rb
|
@@ -93,7 +69,10 @@ files:
|
|
93
69
|
- lib/rbs_rails/rake_task.rb
|
94
70
|
- lib/rbs_rails/util.rb
|
95
71
|
- lib/rbs_rails/version.rb
|
72
|
+
- rbs_collection.lock.yaml
|
73
|
+
- rbs_collection.yaml
|
96
74
|
- rbs_rails.gemspec
|
75
|
+
- sig/activerecord.rbs
|
97
76
|
- sig/fileutils.rbs
|
98
77
|
- sig/parser.rbs
|
99
78
|
- sig/rake.rbs
|
@@ -110,6 +89,7 @@ licenses:
|
|
110
89
|
metadata:
|
111
90
|
homepage_uri: https://github.com/pocke/rbs_rails
|
112
91
|
source_code_uri: https://github.com/pocke/rbs_rails
|
92
|
+
changelog_uri: https://github.com/pocke/rbs_rails/blob/master/CHANGELOG.md
|
113
93
|
post_install_message:
|
114
94
|
rdoc_options: []
|
115
95
|
require_paths:
|
@@ -125,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
105
|
- !ruby/object:Gem::Version
|
126
106
|
version: '0'
|
127
107
|
requirements: []
|
128
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.3.0.dev
|
129
109
|
signing_key:
|
130
110
|
specification_version: 4
|
131
111
|
summary: A RBS files generator for Rails application
|
data/assets/sig/builtin.rbs
DELETED
data/assets/sig/capybara.rbs
DELETED
data/assets/sig/concurrent.rbs
DELETED
data/assets/sig/erb.rbs
DELETED
data/assets/sig/erubi.rbs
DELETED
data/assets/sig/i18n.rbs
DELETED
data/assets/sig/libxml.rbs
DELETED
data/assets/sig/minitest.rbs
DELETED
data/assets/sig/nokogiri.rbs
DELETED
data/assets/sig/pg.rbs
DELETED
data/assets/sig/que.rbs
DELETED
data/assets/sig/racc.rbs
DELETED
data/assets/sig/rack-test.rbs
DELETED
data/assets/sig/rack.rbs
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
module Rack
|
2
|
-
class Server
|
3
|
-
end
|
4
|
-
|
5
|
-
class Response
|
6
|
-
module Helpers
|
7
|
-
def location: () -> untyped
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class Request
|
12
|
-
module Helpers
|
13
|
-
end
|
14
|
-
|
15
|
-
module Env
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
module Session
|
20
|
-
module Abstract
|
21
|
-
class SessionHash
|
22
|
-
end
|
23
|
-
|
24
|
-
class PersistedSecure
|
25
|
-
class SecureSessionHash
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class Persisted
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class SessionId
|
34
|
-
end
|
35
|
-
|
36
|
-
class Dalli
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
module Cache
|
41
|
-
class MetaStore
|
42
|
-
end
|
43
|
-
|
44
|
-
class EntityStore
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/assets/sig/rails.rbs
DELETED
data/assets/sig/rdoc.rbs
DELETED
data/assets/sig/sidekiq.rbs
DELETED
data/assets/sig/sneakers.rbs
DELETED
data/assets/sig/stdlib.rbs
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module DRb
|
2
|
-
end
|
3
|
-
|
4
|
-
module DRb::DRbUndumped
|
5
|
-
end
|
6
|
-
|
7
|
-
module TSort
|
8
|
-
end
|
9
|
-
|
10
|
-
class SimpleDelegator
|
11
|
-
end
|
12
|
-
|
13
|
-
module Gem
|
14
|
-
class Version
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
module OpenSSL
|
19
|
-
class Cipher
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
module FileUtils
|
24
|
-
end
|
data/assets/sig/sucker_punch.rbs
DELETED
data/assets/sig/thor.rbs
DELETED
data/assets/sig/tzinfo.rbs
DELETED
data/bin/gem_rbs
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#!ruby
|
2
|
-
|
3
|
-
require 'net/http'
|
4
|
-
require 'json'
|
5
|
-
require 'securerandom'
|
6
|
-
require 'pathname'
|
7
|
-
|
8
|
-
TOKEN = ENV.fetch('GITHUB_ACCESS_TOKEN')
|
9
|
-
VERSION = "6.0.3.2"
|
10
|
-
|
11
|
-
def req(query)
|
12
|
-
http = Net::HTTP.new("api.github.com", 443)
|
13
|
-
http.use_ssl = true
|
14
|
-
header = {
|
15
|
-
"Authorization" => "Bearer #{TOKEN}",
|
16
|
-
'Content-Type' => 'application/json',
|
17
|
-
'User-Agent' => 'gem_rbs client',
|
18
|
-
}
|
19
|
-
resp = http.request_post('/graphql', JSON.generate(query), header)
|
20
|
-
JSON.parse(resp.body, symbolize_names: true).tap do |content|
|
21
|
-
raise content[:errors].inspect if content[:errors]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class QueryBuilder
|
26
|
-
attr_reader :variables
|
27
|
-
|
28
|
-
def initialize
|
29
|
-
@queries = []
|
30
|
-
@variables = {}
|
31
|
-
end
|
32
|
-
|
33
|
-
def add(query, variables)
|
34
|
-
query = query.dup
|
35
|
-
variables = variables.transform_keys do |key|
|
36
|
-
next key unless @variables.key?(key)
|
37
|
-
|
38
|
-
new_key = key + '_' + SecureRandom.hex(8)
|
39
|
-
query.gsub!(key, new_key)
|
40
|
-
new_key
|
41
|
-
end
|
42
|
-
|
43
|
-
@queries << query
|
44
|
-
@variables.merge!(variables)
|
45
|
-
end
|
46
|
-
|
47
|
-
def query
|
48
|
-
# TODO: variable type
|
49
|
-
"query(#{variables.keys.map { |v| "$#{v}: String!" }.join(',')}) { #{@queries.join("\n")} }"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
gems = %w[activesupport actionpack activejob activemodel actionview activerecord railties]
|
54
|
-
|
55
|
-
builder = QueryBuilder.new
|
56
|
-
gems.each do |gem|
|
57
|
-
path = "main:gems/#{gem}/#{VERSION}"
|
58
|
-
builder.add(<<~GRAPHQL, { 'path' => path })
|
59
|
-
#{gem}:repository(owner: "ruby", name: "gem_rbs") {
|
60
|
-
object(expression: $path) {
|
61
|
-
... on Tree {
|
62
|
-
entries {
|
63
|
-
name
|
64
|
-
object {
|
65
|
-
... on Blob {
|
66
|
-
isTruncated
|
67
|
-
text
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
}
|
74
|
-
GRAPHQL
|
75
|
-
end
|
76
|
-
|
77
|
-
resp = req(query: builder.query, variables: builder.variables)
|
78
|
-
|
79
|
-
resp[:data].each do |gem_name, gem_value|
|
80
|
-
gem_value.dig(:object, :entries).each do |entry|
|
81
|
-
fname = entry[:name]
|
82
|
-
if fname.end_with?('.rbs')
|
83
|
-
content =
|
84
|
-
if entry.dig(:object, :isTruncated)
|
85
|
-
`curl -H 'Accept: application/vnd.github.v3.raw' -H Authorization: token #{TOKEN} https://api.github.com/repos/ruby/gem_rbs/contents/gems/#{gem_name}/#{VERSION}/#{fname}`
|
86
|
-
else
|
87
|
-
entry.dig(:object, :text)
|
88
|
-
end
|
89
|
-
dir = Pathname("gem_rbs/gems/#{gem_name}/#{VERSION}")
|
90
|
-
dir.mkpath
|
91
|
-
dir.join(fname).write(content)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|