rbs 2.8.4 → 3.0.0.dev.2

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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -3
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +17 -17
  5. data/README.md +1 -0
  6. data/Rakefile +66 -0
  7. data/core/array.rbs +1 -1
  8. data/core/builtin.rbs +1 -1
  9. data/core/hash.rbs +1 -1
  10. data/core/module.rbs +1 -1
  11. data/ext/rbs_extension/constants.c +18 -2
  12. data/ext/rbs_extension/constants.h +9 -1
  13. data/ext/rbs_extension/lexer.c +834 -777
  14. data/ext/rbs_extension/lexer.h +3 -1
  15. data/ext/rbs_extension/lexer.re +3 -1
  16. data/ext/rbs_extension/lexstate.c +4 -2
  17. data/ext/rbs_extension/parser.c +287 -57
  18. data/ext/rbs_extension/ruby_objs.c +71 -5
  19. data/ext/rbs_extension/ruby_objs.h +9 -2
  20. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  21. data/lib/rbs/ast/declarations.rb +49 -2
  22. data/lib/rbs/ast/directives.rb +39 -0
  23. data/lib/rbs/ast/members.rb +49 -15
  24. data/lib/rbs/cli.rb +38 -19
  25. data/lib/rbs/collection/config/lockfile.rb +115 -0
  26. data/lib/rbs/collection/config/lockfile_generator.rb +99 -53
  27. data/lib/rbs/collection/config.rb +12 -40
  28. data/lib/rbs/collection/installer.rb +9 -13
  29. data/lib/rbs/collection/sources/base.rb +2 -2
  30. data/lib/rbs/collection/sources/git.rb +135 -62
  31. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  32. data/lib/rbs/collection/sources/stdlib.rb +10 -13
  33. data/lib/rbs/collection/sources.rb +7 -1
  34. data/lib/rbs/collection.rb +1 -0
  35. data/lib/rbs/definition.rb +1 -1
  36. data/lib/rbs/definition_builder/ancestor_builder.rb +24 -8
  37. data/lib/rbs/definition_builder/method_builder.rb +3 -3
  38. data/lib/rbs/definition_builder.rb +456 -579
  39. data/lib/rbs/environment/use_map.rb +77 -0
  40. data/lib/rbs/environment.rb +356 -85
  41. data/lib/rbs/environment_loader.rb +20 -17
  42. data/lib/rbs/environment_walker.rb +1 -1
  43. data/lib/rbs/errors.rb +34 -37
  44. data/lib/rbs/locator.rb +3 -3
  45. data/lib/rbs/parser_aux.rb +8 -6
  46. data/lib/rbs/prototype/helpers.rb +29 -13
  47. data/lib/rbs/prototype/node_usage.rb +99 -0
  48. data/lib/rbs/prototype/rb.rb +3 -2
  49. data/lib/rbs/prototype/rbi.rb +6 -4
  50. data/lib/rbs/prototype/runtime.rb +25 -12
  51. data/lib/rbs/resolver/constant_resolver.rb +23 -7
  52. data/lib/rbs/resolver/type_name_resolver.rb +2 -1
  53. data/lib/rbs/sorter.rb +3 -3
  54. data/lib/rbs/substitution.rb +19 -0
  55. data/lib/rbs/test/setup.rb +1 -1
  56. data/lib/rbs/type_alias_dependency.rb +1 -1
  57. data/lib/rbs/type_alias_regularity.rb +3 -3
  58. data/lib/rbs/types.rb +1 -5
  59. data/lib/rbs/validator.rb +25 -3
  60. data/lib/rbs/variance_calculator.rb +2 -2
  61. data/lib/rbs/version.rb +1 -1
  62. data/lib/rbs/writer.rb +54 -19
  63. data/lib/rbs.rb +3 -2
  64. data/lib/rdoc_plugin/parser.rb +3 -3
  65. data/schema/members.json +15 -10
  66. data/sig/ancestor_graph.rbs +22 -2
  67. data/sig/collection/config/lockfile.rbs +80 -0
  68. data/sig/collection/config/lockfile_generator.rbs +53 -0
  69. data/sig/collection/config.rbs +5 -48
  70. data/sig/collection/installer.rbs +1 -1
  71. data/sig/collection/sources.rbs +76 -33
  72. data/sig/constant.rbs +1 -1
  73. data/sig/declarations.rbs +36 -3
  74. data/sig/definition.rbs +1 -1
  75. data/sig/definition_builder.rbs +94 -82
  76. data/sig/directives.rbs +61 -0
  77. data/sig/environment.rbs +150 -28
  78. data/sig/environment_loader.rbs +2 -2
  79. data/sig/errors.rbs +42 -0
  80. data/sig/members.rbs +31 -7
  81. data/sig/parser.rbs +8 -15
  82. data/sig/prototype/node_usage.rbs +20 -0
  83. data/sig/resolver/constant_resolver.rbs +1 -2
  84. data/sig/shims/bundler.rbs +31 -0
  85. data/sig/shims/rubygems.rbs +15 -0
  86. data/sig/shims.rbs +0 -22
  87. data/sig/substitution.rbs +6 -0
  88. data/sig/use_map.rbs +35 -0
  89. data/sig/validator.rbs +12 -5
  90. data/sig/writer.rbs +6 -2
  91. metadata +16 -9
  92. data/lib/rbs/constant_table.rb +0 -167
  93. data/lib/rbs/type_name_resolver.rb +0 -67
  94. data/sig/constant_table.rbs +0 -30
  95. data/sig/type_name_resolver.rbs +0 -26
@@ -67,7 +67,7 @@ TracePoint.trace :end do |tp|
67
67
 
68
68
  if class_name
69
69
  if filter.any? {|f| match(to_absolute_typename(f).to_s, class_name.to_s) } && skips.none? {|f| match(f, class_name.to_s) }
70
- if env.class_decls.key?(class_name)
70
+ if env.module_name?(class_name)
71
71
  logger.info "Setting up hooks for #{class_name}"
72
72
  tester.install!(tp.self, sample_size: sample_size, unchecked_classes: unchecked_classes)
73
73
  end
@@ -32,7 +32,7 @@ module RBS
32
32
  # Initialize dependencies as an empty hash
33
33
  @dependencies = {}
34
34
  # Iterate over alias declarations inserted into environment
35
- env.alias_decls.each do |name, entry|
35
+ env.type_alias_decls.each do |name, entry|
36
36
  # Construct a directed graph by recursively extracting type aliases
37
37
  @direct_dependencies[name] = direct_dependency(entry.decl.type)
38
38
  # Initialize dependencies with an empty hash
@@ -57,7 +57,7 @@ module RBS
57
57
  end
58
58
 
59
59
  def build_alias_type(name)
60
- entry = env.alias_decls[name] or return
60
+ entry = env.type_alias_decls[name] or return
61
61
  unless entry.decl.type_params.empty?
62
62
  as = entry.decl.type_params.each.map {|param| Types::Variable.new(name: param.name, location: nil) }
63
63
  Types::Alias.new(name: name, args: as, location: nil)
@@ -81,13 +81,13 @@ module RBS
81
81
  def each_mutual_alias_defs(&block)
82
82
  # @type var each_node: TSort::_EachNode[TypeName]
83
83
  each_node = __skip__ = -> (&block) do
84
- env.alias_decls.each_value do |decl|
84
+ env.type_alias_decls.each_value do |decl|
85
85
  block[decl.name]
86
86
  end
87
87
  end
88
88
  # @type var each_child: TSort::_EachChild[TypeName]
89
89
  each_child = __skip__ = -> (name, &block) do
90
- if env.alias_decls.key?(name)
90
+ if env.type_alias_decls.key?(name)
91
91
  type = builder.expand_alias1(name)
92
92
  each_alias_type(type) do |ty|
93
93
  block[ty.name]
data/lib/rbs/types.rb CHANGED
@@ -757,11 +757,7 @@ module RBS
757
757
 
758
758
  def to_s
759
759
  if name
760
- if Parser::KEYWORDS.include?(name.to_s)
761
- "#{type} `#{name}`"
762
- else
763
- "#{type} #{name}"
764
- end
760
+ "#{type} #{name}"
765
761
  else
766
762
  "#{type}"
767
763
  end
data/lib/rbs/validator.rb CHANGED
@@ -33,11 +33,12 @@ module RBS
33
33
 
34
34
  type_params = case type
35
35
  when Types::ClassInstance
36
- env.class_decls[type.name].type_params
36
+ entry = env.normalized_module_class_entry(type.name) or raise
37
+ entry.type_params
37
38
  when Types::Interface
38
39
  env.interface_decls[type.name].decl.type_params
39
40
  when Types::Alias
40
- env.alias_decls[type.name].decl.type_params
41
+ env.type_alias_decls[type.name].decl.type_params
41
42
  end
42
43
 
43
44
  InvalidTypeApplicationError.check!(
@@ -98,7 +99,8 @@ module RBS
98
99
  end
99
100
 
100
101
  def validate_method_definition(method_def, type_name:)
101
- method_def.types.each do |method_type|
102
+ method_def.overloads.each do |overload|
103
+ method_type = overload.method_type
102
104
  unless method_type.type_params.empty?
103
105
  loc = method_type.location&.aref(:type_params)
104
106
 
@@ -146,6 +148,26 @@ module RBS
146
148
  end
147
149
  end
148
150
 
151
+ def validate_class_alias(entry:)
152
+ case env.normalize_module_name?(entry.decl.new_name)
153
+ when nil
154
+ raise NoTypeFoundError.new(type_name: entry.decl.old_name, location: entry.decl.location&.[](:old_name))
155
+ when false
156
+ raise CyclicClassAliasDefinitionError.new(entry)
157
+ end
158
+
159
+ case entry
160
+ when Environment::ClassAliasEntry
161
+ unless env.class_entry(entry.decl.old_name)
162
+ raise InconsistentClassModuleAliasError.new(entry)
163
+ end
164
+ when Environment::ModuleAliasEntry
165
+ unless env.module_entry(entry.decl.old_name)
166
+ raise InconsistentClassModuleAliasError.new(entry)
167
+ end
168
+ end
169
+ end
170
+
149
171
  def type_alias_dependency
150
172
  @type_alias_dependency ||= TypeAliasDependency.new(env: env)
151
173
  end
@@ -108,7 +108,7 @@ module RBS
108
108
  end
109
109
 
110
110
  def in_type_alias(name:)
111
- decl = env.alias_decls[name].decl or raise
111
+ decl = env.type_alias_decls[name].decl or raise
112
112
  variables = decl.type_params.each.map(&:name)
113
113
  Result.new(variables: variables).tap do |result|
114
114
  type(decl.type, result: result, context: :covariant)
@@ -139,7 +139,7 @@ module RBS
139
139
  when Types::Interface
140
140
  env.interface_decls[type.name].decl.type_params
141
141
  when Types::Alias
142
- env.alias_decls[type.name].decl.type_params
142
+ env.type_alias_decls[type.name].decl.type_params
143
143
  end
144
144
 
145
145
  type.args.each.with_index do |ty, i|
data/lib/rbs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RBS
4
- VERSION = "2.8.4"
4
+ VERSION = "3.0.0.dev.2"
5
5
  end
data/lib/rbs/writer.rb CHANGED
@@ -39,21 +39,27 @@ module RBS
39
39
  end
40
40
  end
41
41
 
42
+ def format_annotation(annotation)
43
+ string = annotation.string
44
+ case
45
+ when string !~ /\}/
46
+ "%a{#{string}}"
47
+ when string !~ /\)/
48
+ "%a(#{string})"
49
+ when string !~ /\]/
50
+ "%a[#{string}]"
51
+ when string !~ /\>/
52
+ "%a<#{string}>"
53
+ when string !~ /\|/
54
+ "%a|#{string}|"
55
+ else
56
+ raise
57
+ end
58
+ end
59
+
42
60
  def write_annotation(annotations)
43
61
  annotations.each do |annotation|
44
- string = annotation.string
45
- case
46
- when string !~ /\}/
47
- puts "%a{#{string}}"
48
- when string !~ /\)/
49
- puts "%a(#{string})"
50
- when string !~ /\]/
51
- puts "%a[#{string}]"
52
- when string !~ /\>/
53
- puts "%a<#{string}>"
54
- when string !~ /\|/
55
- puts "%a|#{string}|"
56
- end
62
+ puts format_annotation(annotation)
57
63
  end
58
64
  end
59
65
 
@@ -70,7 +76,16 @@ module RBS
70
76
  end
71
77
  end
72
78
 
73
- def write(decls)
79
+ def write(contents)
80
+ dirs = contents.select {|c| c.is_a?(AST::Directives::Base) } #: Array[AST::Directives::t]
81
+ decls = contents.select {|c| c.is_a?(AST::Declarations::Base) } #: Array[AST::Declarations::t]
82
+
83
+ dirs.each do |dir|
84
+ write_directive(dir)
85
+ end
86
+
87
+ puts unless dirs.empty?
88
+
74
89
  [nil, *decls].each_cons(2) do |prev, decl|
75
90
  raise unless decl
76
91
 
@@ -79,6 +94,23 @@ module RBS
79
94
  end
80
95
  end
81
96
 
97
+ def write_directive(dir)
98
+ clauses = dir.clauses.map do |clause|
99
+ case clause
100
+ when AST::Directives::Use::SingleClause
101
+ if clause.new_name
102
+ "#{clause.type_name} as #{clause.new_name}"
103
+ else
104
+ "#{clause.type_name}"
105
+ end
106
+ when AST::Directives::Use::WildcardClause
107
+ "#{clause.namespace}*"
108
+ end
109
+ end
110
+
111
+ puts "use #{clauses.join(", ")}"
112
+ end
113
+
82
114
  def write_decl(decl)
83
115
  case decl
84
116
  when AST::Declarations::Class
@@ -128,7 +160,7 @@ module RBS
128
160
  write_comment decl.comment
129
161
  puts "#{decl.name}: #{decl.type}"
130
162
 
131
- when AST::Declarations::Alias
163
+ when AST::Declarations::TypeAlias
132
164
  write_comment decl.comment
133
165
  write_annotation decl.annotations
134
166
  write_loc_source(decl) {
@@ -289,17 +321,20 @@ module RBS
289
321
 
290
322
  string << prefix
291
323
 
292
- member.types.each.with_index do |type, index|
324
+ member.overloads.each.with_index do |overload, index|
293
325
  if index > 0
294
326
  string << padding
295
327
  string << "|"
296
328
  end
297
329
 
298
- string << " #{type}\n"
330
+ overload.annotations.each do |annotation|
331
+ string << " #{format_annotation(annotation)}"
332
+ end
333
+ string << " #{overload.method_type}\n"
299
334
  end
300
335
 
301
- if member.overload
302
- if member.types.size > 0
336
+ if member.overloading?
337
+ if member.overloads.size > 0
303
338
  string << padding
304
339
  string << "|"
305
340
  end
data/lib/rbs.rb CHANGED
@@ -17,10 +17,12 @@ require "rbs/type_name"
17
17
  require "rbs/types"
18
18
  require "rbs/method_type"
19
19
  require "rbs/ast/type_param"
20
+ require "rbs/ast/directives"
20
21
  require "rbs/ast/declarations"
21
22
  require "rbs/ast/members"
22
23
  require "rbs/ast/annotation"
23
24
  require "rbs/environment"
25
+ require "rbs/environment/use_map"
24
26
  require "rbs/environment_loader"
25
27
  require "rbs/builtin_names"
26
28
  require "rbs/definition"
@@ -32,14 +34,13 @@ require "rbs/substitution"
32
34
  require "rbs/constant"
33
35
  require "rbs/resolver/constant_resolver"
34
36
  require "rbs/resolver/type_name_resolver"
35
- require "rbs/constant_table"
36
37
  require "rbs/ast/comment"
37
38
  require "rbs/writer"
38
39
  require "rbs/prototype/helpers"
39
40
  require "rbs/prototype/rbi"
40
41
  require "rbs/prototype/rb"
41
42
  require "rbs/prototype/runtime"
42
- require "rbs/type_name_resolver"
43
+ require "rbs/prototype/node_usage"
43
44
  require "rbs/environment_walker"
44
45
  require "rbs/vendorer"
45
46
  require "rbs/validator"
@@ -14,8 +14,8 @@ module RBS
14
14
  end
15
15
 
16
16
  def scan
17
- ast = ::RBS::Parser.parse_signature(@content)
18
- ast.each do |decl|
17
+ _, _, decls = ::RBS::Parser.parse_signature(@content)
18
+ decls.each do |decl|
19
19
  parse_member(decl: decl, context: @top_level)
20
20
  end
21
21
  @top_level
@@ -74,7 +74,7 @@ module RBS
74
74
  method = RDoc::AnyMethod.new(nil, decl.name.to_s)
75
75
  method.singleton = decl.singleton?
76
76
  method.visibility = decl.visibility
77
- method.call_seq = decl.types.map { |type| "#{decl.name.to_s}#{type.to_s}" }.join("\n")
77
+ method.call_seq = decl.overloads.map {|overload| "#{decl.name.to_s}#{overload.method_type.to_s}" }.join("\n")
78
78
  if loc = decl.location
79
79
  method.start_collecting_tokens
80
80
  method.add_token({ line_no: 1, char_no: 1, kind: :on_comment, text: "# File #{@top_level.relative_name}, line(s) #{loc.start_line}:#{loc.end_line}\n" })
data/schema/members.json CHANGED
@@ -14,10 +14,21 @@
14
14
  "kind": {
15
15
  "enum": ["instance", "singleton", "singleton_instance"]
16
16
  },
17
- "types": {
17
+ "overloads": {
18
18
  "type": "array",
19
19
  "items": {
20
- "$ref": "methodType.json"
20
+ "type": "object",
21
+ "properties": {
22
+ "annotations": {
23
+ "type": "array",
24
+ "items": {
25
+ "$ref": "annotation.json"
26
+ }
27
+ },
28
+ "method_type": {
29
+ "$ref": "methodType.json"
30
+ }
31
+ }
21
32
  }
22
33
  },
23
34
  "comment": {
@@ -29,23 +40,17 @@
29
40
  "$ref": "annotation.json"
30
41
  }
31
42
  },
32
- "attributes": {
33
- "type": "array",
34
- "items": {
35
- "enum": ["incompatible"]
36
- }
37
- },
38
43
  "location": {
39
44
  "$ref": "location.json"
40
45
  },
41
- "overload": {
46
+ "overloading": {
42
47
  "type": "boolean"
43
48
  },
44
49
  "visibility": {
45
50
  "enum": ["public", "private", null]
46
51
  }
47
52
  },
48
- "required": ["member", "name", "kind", "types", "comment", "annotations", "location", "visibility"]
53
+ "required": ["member", "name", "kind", "overloads", "comment", "annotations", "location", "visibility", "overloading"]
49
54
  },
50
55
  "variable": {
51
56
  "title": "Declaration for instance variables and class variables",
@@ -1,4 +1,22 @@
1
1
  module RBS
2
+ # AncestorGraph is a utility class that helps iterating through ancestors and decendants of a class/module
3
+ #
4
+ # ```ruby
5
+ # graph = AncestorGraph.new(env: env, ancestor_builder: ancestor_builder)
6
+ #
7
+ # graph.each_parent(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
8
+ # graph.each_ancestor(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
9
+ #
10
+ # graph.each_child(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
11
+ # graph.each_descendant(AncestorGraph::InstanceNode.new(type_name: TypeName("::Object")))
12
+ # ```
13
+ #
14
+ # Note that the class works for class/module declarations.
15
+ # All of the *alias* classes/modules are ignored.
16
+ #
17
+ # * Alias classes/modules doesn't count as a parent nor child
18
+ # * Passing alias classes/modules to the method doesn't yield anything
19
+ #
2
20
  class AncestorGraph
3
21
  class InstanceNode
4
22
  attr_reader type_name: TypeName
@@ -19,8 +37,6 @@ module RBS
19
37
 
20
38
  def initialize: (env: Environment, ?ancestor_builder: DefinitionBuilder::AncestorBuilder) -> void
21
39
 
22
- def build: () -> void
23
-
24
40
  def each_parent: (node) { (node) -> void } -> void
25
41
  | (node) -> Enumerator[node, void]
26
42
 
@@ -33,6 +49,10 @@ module RBS
33
49
  def each_descendant: (node, ?yielded: Set[node]) { (node) -> void } -> void
34
50
  | (node) -> Enumerator[node, void]
35
51
 
52
+ private
53
+
54
+ def build: () -> void
55
+
36
56
  def build_ancestors: (node, DefinitionBuilder::AncestorBuilder::OneAncestors) -> void
37
57
 
38
58
  def register: (parent: node, child: node) -> void
@@ -0,0 +1,80 @@
1
+ module RBS
2
+ module Collection
3
+ class Config
4
+ # Lockfile represents the `rbs_collection.lock.yaml`, that contains configurations and *resolved* gems with their sources
5
+ #
6
+ class Lockfile
7
+ # Data structure stored in `rbs_collection.lock.yaml`
8
+ #
9
+ type lockfile_data = {
10
+ "sources" => Array[Sources::Git::source_entry]?, # null if empty
11
+ "path" => String,
12
+ "gems" => Array[library_data]?, # null if empty
13
+ "gemfile_lock_path" => String? # gemfile_lock_path is optional because older versions doesn't have it
14
+ }
15
+
16
+ type library_data = {
17
+ 'name' => String,
18
+ 'version' => String,
19
+ 'source' => Sources::source_entry
20
+ }
21
+
22
+ # In-memory data structure that represents a library
23
+ #
24
+ type library = {
25
+ name: String,
26
+ version: String,
27
+ source: Sources::t
28
+ }
29
+
30
+ attr_reader lockfile_path: Pathname
31
+
32
+ # Path of the directory where lockfile is saved in
33
+ #
34
+ # `lockfile_path.parent`
35
+ #
36
+ attr_reader lockfile_dir: Pathname
37
+
38
+ # Relative to lockfile_dir
39
+ #
40
+ attr_reader path: Pathname
41
+
42
+ # Relative to lockfile_dir
43
+ #
44
+ attr_reader gemfile_lock_path: Pathname?
45
+
46
+ attr_reader sources: Hash[String, Sources::Git]
47
+
48
+ attr_reader gems: Hash[String, library]
49
+
50
+ def initialize: (lockfile_path: Pathname, path: Pathname, gemfile_lock_path: Pathname?) -> void
51
+
52
+ # `lockfile_dir` + `path`
53
+ #
54
+ def fullpath: () -> Pathname
55
+
56
+ # `lockfile_dir` + `gemfile_lock_path`
57
+ #
58
+ %a{pure} def gemfile_lock_fullpath: () -> Pathname?
59
+
60
+ def to_lockfile: () -> lockfile_data
61
+
62
+ def each_source: () { (Sources::t) -> void } -> void
63
+ | () -> Enumerator[Sources::t, void]
64
+
65
+ def self.from_lockfile: (lockfile_path: Pathname, data: lockfile_data) -> Lockfile
66
+
67
+ # Validates if directories are set up correctly
68
+ #
69
+ # * Ensures if `path` is a directory
70
+ # * Ensures if `git` sources are set up correctly
71
+ #
72
+ def check_rbs_availability!: () -> void
73
+
74
+ private
75
+
76
+ def library_data: (library) -> library_data
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,53 @@
1
+ module RBS
2
+ module Collection
3
+ class Config
4
+ class LockfileGenerator
5
+ class GemfileLockMismatchError < StandardError
6
+ @expected: Pathname
7
+
8
+ @actual: Pathname
9
+
10
+ def initialize: (expected: Pathname, actual: Pathname) -> void
11
+
12
+ def message: () -> String
13
+ end
14
+
15
+ attr_reader config: Config
16
+
17
+ attr_reader lockfile: Lockfile
18
+ attr_reader existing_lockfile: Lockfile?
19
+
20
+ attr_reader definition: Bundler::Definition
21
+
22
+ # A hash table to look up a spec from name of the gem
23
+ attr_reader gem_hash: Hash[String, Bundler::LazySpecification]
24
+
25
+ def self.generate: (config: Config, definition: Bundler::Definition, ?with_lockfile: boolish) -> Lockfile
26
+
27
+ def initialize: (config: Config, definition: Bundler::Definition, with_lockfile: boolish) -> void
28
+
29
+ def generate: () -> void
30
+
31
+ private
32
+
33
+ # Ensure if current `gemfile_lock_path` is the same with the path saved in `lock`
34
+ #
35
+ def validate_gemfile_lock_path!: (lock: Lockfile?, gemfile_lock_path: Pathname) -> void
36
+
37
+ # Inserts a entry to lockfile of a gem and its dependencies, if not included in `ignored_gems:`
38
+ #
39
+ def assign_gem: (name: String, version: String?, src_data: Sources::source_entry?, ignored_gems: Set[String]) -> void
40
+
41
+ def assign_stdlib: (name: String, from_gem: String?) -> void
42
+
43
+ # Find a source of a gem from ones registered in `config.sources`
44
+ #
45
+ # Returns `nil` if no source contains the definition of the gem.
46
+ #
47
+ def find_source: (name: String) -> Sources::t?
48
+
49
+ def find_best_version: (version: String?, versions: Array[String]) -> Gem::Version
50
+ end
51
+ end
52
+ end
53
+ end
@@ -6,39 +6,6 @@ module RBS
6
6
  def initialize: () -> void
7
7
  end
8
8
 
9
- class LockfileGenerator
10
- attr_reader config: Config
11
- attr_reader lock: Config?
12
- attr_reader lock_path: Pathname
13
- attr_reader gemfile_lock: Bundler::LockfileParser
14
-
15
- type gem_queue_entry = { name: String, version: String? }
16
-
17
- @gem_queue: Array[gem_queue_entry]
18
-
19
- def self.generate: (config_path: Pathname, gemfile_lock_path: Pathname, ?with_lockfile: boolish) -> Config
20
-
21
- def initialize: (config_path: Pathname, gemfile_lock_path: Pathname, with_lockfile: boolish) -> void
22
-
23
- def generate: () -> Config
24
-
25
- private
26
-
27
- def validate_gemfile_lock_path!: (lock: Config?, gemfile_lock_path: Pathname) -> void
28
-
29
- def assign_gem: (name: String, version: String?) -> void
30
-
31
- def upsert_gem: (gem_entry? old, gem_entry new) -> void
32
-
33
- def gemfile_lock_gems: () { (untyped) -> void } -> void
34
-
35
- def remove_ignored_gems!: () -> void
36
-
37
- def find_source: (name: String) -> Sources::_Source?
38
-
39
- def find_best_version: (version: String?, versions: Array[String]) -> Gem::Version
40
- end
41
-
42
9
  PATH: Pathname
43
10
 
44
11
  type gem_entry = {
@@ -48,42 +15,32 @@ module RBS
48
15
  'source' => Sources::source_entry?
49
16
  }
50
17
 
51
- @config_path: Pathname
18
+ attr_reader config_path: Pathname
52
19
 
53
- @data: untyped
20
+ attr_reader data: untyped
54
21
 
55
22
  @sources: Array[Sources::_Source]
56
23
 
57
24
  def self.find_config_path: () -> Pathname?
58
25
 
59
- def self.generate_lockfile: (config_path: Pathname, gemfile_lock_path: Pathname, ?with_lockfile: boolish) -> Config
26
+ def self.generate_lockfile: (config_path: Pathname, definition: Bundler::Definition, ?with_lockfile: boolish) -> [Config, Lockfile]
60
27
 
61
28
  def self.from_path: (Pathname path) -> Config
62
29
 
63
- def self.lockfile_of: (Pathname config_path) -> Config?
64
-
65
30
  def self.to_lockfile_path: (Pathname config_path) -> Pathname
66
31
 
67
32
  # config_path is necessary to resolve relative repo_path
68
33
  def initialize: (untyped data, config_path: Pathname) -> void
69
34
 
70
- def add_gem: (gem_entry gem) -> void
71
-
72
35
  def gem: (String gem_name) -> gem_entry?
73
36
 
74
37
  def repo_path: () -> Pathname
75
38
 
76
- def sources: () -> Array[Sources::_Source]
39
+ def repo_path_data: () -> Pathname
77
40
 
78
- def dump_to: (Pathname) -> void
41
+ def sources: () -> Array[Sources::t]
79
42
 
80
43
  def gems: () -> Array[gem_entry]
81
-
82
- def gemfile_lock_path=: (Pathname) -> Pathname
83
-
84
- def gemfile_lock_path: () -> Pathname?
85
-
86
- def check_rbs_availability!: () -> void
87
44
  end
88
45
  end
89
46
  end
@@ -1,7 +1,7 @@
1
1
  module RBS
2
2
  module Collection
3
3
  class Installer
4
- attr_reader lockfile: Config
4
+ attr_reader lockfile: Config::Lockfile
5
5
  attr_reader stdout: CLI::_IO
6
6
 
7
7
  def initialize: (lockfile_path: Pathname, ?stdout: CLI::_IO) -> void