Skip to content

Commit 067a7f8

Browse files
committed
chore: add rbs gem and fix watcher/spec for type inference
- Add rbs gem dependency for E2E test RBS validation - Fix watcher to handle single file paths (not just directories) - Fix ir_spec to use keyword argument format (name: String)
1 parent 4736684 commit 067a7f8

4 files changed

Lines changed: 21 additions & 12 deletions

File tree

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gemspec
66

77
group :development, :test do
88
gem "rake", "~> 13.0"
9+
gem "rbs", "~> 3.0"
910
gem "rspec", "~> 3.0"
1011
gem "rspec_junit_formatter", "~> 0.6.0"
1112
gem "rubocop", require: false

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GEM
1818
listen (3.9.0)
1919
rb-fsevent (~> 0.10, >= 0.10.3)
2020
rb-inotify (~> 0.9, >= 0.9.10)
21+
logger (1.7.0)
2122
parallel (1.27.0)
2223
parser (3.3.10.0)
2324
ast (~> 2.4.1)
@@ -29,6 +30,8 @@ GEM
2930
rb-fsevent (0.11.2)
3031
rb-inotify (0.11.1)
3132
ffi (~> 1.0)
33+
rbs (3.10.0)
34+
logger
3235
regexp_parser (2.11.3)
3336
rspec (3.13.2)
3437
rspec-core (~> 3.13.0)
@@ -77,6 +80,7 @@ PLATFORMS
7780

7881
DEPENDENCIES
7982
rake (~> 13.0)
83+
rbs (~> 3.0)
8084
rspec (~> 3.0)
8185
rspec_junit_formatter (~> 0.6.0)
8286
rubocop

lib/t_ruby/watcher.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,21 @@ def find_source_files_by_extension(ext)
248248
files = []
249249

250250
# Always search in source_include directories only
251-
source_dirs = if @paths == [File.expand_path(".")]
252-
@config.source_include.map { |dir| File.expand_path(dir) }
253-
else
254-
@paths.map { |path| File.expand_path(path) }
255-
end
256-
257-
source_dirs.each do |dir|
258-
next unless Dir.exist?(dir)
259-
260-
Dir.glob(File.join(dir, "**", "*#{ext}")).each do |file|
261-
files << file unless @config.excluded?(file)
251+
source_paths = if @paths == [File.expand_path(".")]
252+
@config.source_include.map { |dir| File.expand_path(dir) }
253+
else
254+
@paths.map { |path| File.expand_path(path) }
255+
end
256+
257+
source_paths.each do |path|
258+
if File.file?(path)
259+
# Handle single file path
260+
files << path if path.end_with?(ext) && !@config.excluded?(path)
261+
elsif Dir.exist?(path)
262+
# Handle directory path
263+
Dir.glob(File.join(path, "**", "*#{ext}")).each do |file|
264+
files << file unless @config.excluded?(file)
265+
end
262266
end
263267
end
264268

spec/t_ruby/ir_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def greet(name: String): String
360360

361361
output = generator.generate(program)
362362

363-
expect(output).to include("def greet: (String name) -> String")
363+
expect(output).to include("def greet: (name: String) -> String")
364364
end
365365
end
366366

0 commit comments

Comments
 (0)