rbs-src 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49e3f5f4a8aee7ee558855e658b47e01e4f17d3a24eaf0c167c26812e7fa4195
4
- data.tar.gz: 062ac2a5b37770592afa3c07c23c32b18259c679c6eae8de8b0f58dff4140928
3
+ metadata.gz: 8228a38c388aa1705ca70c266e411b621b45a7d86f296117bdfcb376befab15c
4
+ data.tar.gz: 1b0f0daf59afe755d0fada717eb9573fead9936a3e1c5f9728b5ad72a9ca7496
5
5
  SHA512:
6
- metadata.gz: cc36bedb368b369bc005a879486d1c70f684fb7bba77bcd6825324240a4b343441aacf6649cd1832cd50868b369dc6c9421c2080534bb4d9cbcd2dffd8a0b0c1
7
- data.tar.gz: 1bf8e0cd1e0c87a5b595e478fe18a7e99f9bc3a3336bfb62baa6bdf0347b2f29cf2718d8c36ffbd581e0e6a4e4d57bcd19a4220d681f42ceb3bbd00603704496
6
+ metadata.gz: 6c255dec49483e1822ff3c21ccd3078023a898aa11a4701e0be60b876d3f18558087fc1bdd2a2a44825fb125d07785af5e355e55347115fbff5c898e736725f5
7
+ data.tar.gz: acfebcd0ae86f99e212c83c0df51f7b05466e149748c4edd6c8604b6b197c620ec69222186a1d5b6c1f1b0e620f9f220aebb3bbee49c96099623adacee62e89c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs-src (0.5.0)
4
+ rbs-src (0.7.0)
5
5
  rainbow (~> 3.1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -45,9 +45,15 @@ Load gem dependencies from `rbs_collection.lock.yaml` and set up all repositorie
45
45
 
46
46
  If the git repository content is edited, it runs `git stash` and `git reset --hard`.
47
47
 
48
+ It accepts `--output` option to write the dependencies to a file.
49
+
50
+ $ rbs-src setup --output
51
+
52
+ You can load the dependencies to your type checkers from the file.
53
+
48
54
  #### For Steep users
49
55
 
50
- You need to edit your Steepfile to let the type checker stop using rbs-collection.
56
+ The recommended setup for Steep is the following:
51
57
 
52
58
  ```ruby
53
59
  # Steepfile
@@ -55,20 +61,33 @@ You need to edit your Steepfile to let the type checker stop using rbs-collectio
55
61
  target ... do
56
62
  # Existing config...
57
63
 
58
- # Add `#signature` call to support loading RBS files from symlinked directory
59
- signature "sig/rbs-src/*/*.rbs"
60
- signature "sig/rbs-src/*/[^_]*/**/*.rbs"
64
+ # Assume we use `rbs-src setup --output` to generate `rbs_src.dep` file
65
+ if (dep_path = Pathname("rbs_src.dep")).file?
66
+ # Stop loading libraries through rbs-collection
67
+ disable_collection()
61
68
 
62
- # Stop loading libraries through rbs-collection
63
- disable_collection()
69
+ signature "sig/rbs-src/*/*.rbs"
70
+ signature "sig/rbs-src/*/[^_]*/**/*.rbs"
64
71
 
65
- # Load standard libraries and gems manually
66
- library('abbrev')
67
- library('date')
68
- # ...
72
+ dep_path.readlines().each {|lib| library(lib.chomp) }
73
+ end
69
74
  end
70
75
  ```
71
76
 
77
+ In this setup, you can use Steep without using `rbs-src` until you run `rbs-src setup --output`.
78
+ Once you run `rbs-src setup --output`, it generates `rbs_src.dep` file and `Steepfile` loads the dependencies from the file.
79
+
80
+ ```sh
81
+ # When you install your rbs_collection dependencies
82
+ $ rbs collection install && rbs-src setup --output
83
+
84
+ # When you update your rbs_collection dependencies
85
+ $ rbs collection update && rbs-src setup --output
86
+
87
+ # When you stop using rbs-src
88
+ $ rm -rf rbs_src.dep tmp/rbs-src sig/rbs-src
89
+ ```
90
+
72
91
  ### rbs-src link
73
92
 
74
93
  The command clones and set up a symlink of a ruby gem, not loaded from `rbs_collection.lock.yaml`.
data/Steepfile CHANGED
@@ -6,10 +6,22 @@ target :lib do
6
6
  check "lib" # Directory name
7
7
 
8
8
  configure_code_diagnostics(D::Ruby.default) # `default` diagnostics setting (applies by default)
9
+
9
10
  # configure_code_diagnostics(D::Ruby.strict) # `strict` diagnostics setting
10
11
  # configure_code_diagnostics(D::Ruby.lenient) # `lenient` diagnostics setting
11
12
  # configure_code_diagnostics(D::Ruby.silent) # `silent` diagnostics setting
12
13
  # configure_code_diagnostics do |hash| # You can setup everything yourself
13
14
  # hash[D::Ruby::NoMethod] = :information
14
15
  # end
16
+
17
+ # `rbs-src setup -o` generates `rbs_src.dep` file
18
+ if (dep_path = Pathname("rbs_src.dep")).file?
19
+ # Stop loading libraries through rbs-collection
20
+ disable_collection()
21
+
22
+ signature "sig/rbs-src/*/*.rbs"
23
+ signature "sig/rbs-src/*/[^_]*/**/*.rbs"
24
+
25
+ dep_path.readlines().each {|lib| library(lib.chomp) }
26
+ end
15
27
  end
data/lib/rbs/src/cli.rb CHANGED
@@ -132,11 +132,13 @@ module Rbs
132
132
  rbs_collection_lock_path = RBS::Collection::Config.to_lockfile_path(RBS::Collection::Config::PATH)
133
133
  repository_prefix = Pathname("tmp/rbs-src")
134
134
  rbs_prefix = Pathname("sig/rbs-src")
135
+ output_path= nil #: Pathname?
135
136
 
136
137
  OptionParser.new do |opts|
137
138
  opts.on("--rbs-collection-lock=PATH", "The path to rbs_collection.lock.yaml (default: #{rbs_collection_lock_path})") { rbs_collection_lock_path = Pathname(_1) }
138
139
  opts.on("--repo-prefix=PREFIX", "The location to put repository in (default: #{repository_prefix})") { repository_prefix = Pathname(_1) }
139
140
  opts.on("--rbs-prefix=PREFIX", "The location to put symlinks in (default: #{rbs_prefix})") { rbs_prefix = Pathname(_1) }
141
+ opts.on("--output[=PATH]", "-o[PATH]", "The path to write the list of stdlib dependencies (default: rbs_src.dep)") {|path| output_path = Pathname(path || "rbs_src.dep") }
140
142
 
141
143
  opts.banner = <<~BANNER
142
144
  Usage: rbs-src setup [options]
@@ -201,17 +203,27 @@ module Rbs
201
203
 
202
204
  other_libs.sort_by! { _1[0] }
203
205
 
204
- unless other_libs.empty?
205
- runner.push "You have to load other libraries without rbs-collection:" do
206
- if has_gem?("steep")
207
- runner.puts "Add the following lines in your Steepfile:"
208
-
209
- other_libs.each do |name, version|
210
- runner.puts " library('#{name}')"
206
+ if output_path
207
+ runner.push "Writing dependencies to #{output_path}:" do
208
+ output_path.open("w") do |io|
209
+ other_libs.each do |name, _|
210
+ io.puts name
211
211
  end
212
- else
213
- other_libs.each do |name, version|
214
- runner.puts "-r #{name} \\"
212
+ end
213
+ end
214
+ else
215
+ unless other_libs.empty?
216
+ runner.push "You have to load other libraries without rbs-collection:" do
217
+ if has_gem?("steep")
218
+ runner.puts "Add the following lines in your Steepfile:"
219
+
220
+ other_libs.each do |name, version|
221
+ runner.puts " library('#{name}')"
222
+ end
223
+ else
224
+ other_libs.each do |name, version|
225
+ runner.puts "-r #{name} \\"
226
+ end
215
227
  end
216
228
  end
217
229
  end
data/lib/rbs/src/gem.rb CHANGED
@@ -19,8 +19,8 @@ module Rbs
19
19
  repository_root.join(repository_dir, name, version)
20
20
  end
21
21
 
22
- def rbs_path
23
- rbs_prefix + "#{name}-#{version}"
22
+ def rbs_path(suffix = version)
23
+ rbs_prefix + "#{name}-#{suffix}"
24
24
  end
25
25
 
26
26
  def status(runner, commit:)
@@ -50,7 +50,7 @@ module Rbs
50
50
  end
51
51
 
52
52
  runner.puts "💪 Checking out the commit #{commit}..."
53
- runner.execute!("git", "reset", "--hard", commit, chdir: repository_root)
53
+ runner.execute!("git", "checkout", commit, chdir: repository_root)
54
54
  end
55
55
 
56
56
  def clone(runner, repository_url:, commit:)
@@ -66,6 +66,9 @@ module Rbs
66
66
  end
67
67
 
68
68
  def link
69
+ Pathname.glob(rbs_path("*").to_s).each do |path|
70
+ File.unlink(path.to_s)
71
+ end
69
72
  File.symlink(repository_path.relative_path_from(rbs_path.parent), rbs_path)
70
73
  end
71
74
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rbs
4
4
  module Src
5
- VERSION = "0.5.0"
5
+ VERSION = "0.7.0"
6
6
  end
7
7
  end
data/sig/rbs/gem.rbs CHANGED
@@ -19,7 +19,7 @@ module Rbs
19
19
  def repository_path: () -> Pathname
20
20
 
21
21
  # The path of the directory in the `#rbs_prefix` that contains the RBS files of the gem
22
- def rbs_path: () -> Pathname
22
+ def rbs_path: (?String suffix) -> Pathname
23
23
 
24
24
  def clone: (CommandRunner, repository_url: String, commit: String?) -> void
25
25
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs-src
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-29 00:00:00.000000000 Z
11
+ date: 2023-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rainbow
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.4.6
80
+ rubygems_version: 3.4.10
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: rbs-src