Skip to content

Commit

Permalink
Merge pull request #103 from ksss/depth-wild-card
Browse files Browse the repository at this point in the history
Support wild card to depth
  • Loading branch information
ksss authored Feb 3, 2025
2 parents e908ba0 + 3a4c24b commit d175493
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/orthoses/create_file_by_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def extract(name)
name.split('::')[0, @depth].join('::')
when Hash
found_key, found_index = @depth.find do |n, _|
name.start_with?(n)
n == '*' || name.start_with?(n)
end
case found_index
when nil
Expand Down
8 changes: 3 additions & 5 deletions lib/orthoses/create_file_by_name_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ def test_depth(t)
to: "tmp",
depth: {
"A" => 2,
"*" => 1
},
).call

a = Pathname("tmp/a.rbs")
aa = Pathname("tmp/a/a.rbs")
b = Pathname("tmp/b.rbs")
bb = Pathname("tmp/b/b.rbs")
c = Pathname("tmp/c.rbs")

[a, aa, b, bb, c].each do |file|
[a, aa, b, c].each do |file|
unless file.exist?
t.fatal("file not created `#{file}`")
end
Expand All @@ -155,8 +155,7 @@ class A::A::A
b_expect = <<~RBS
class B
end
RBS
bb_expect = <<~RBS
class B::B
end
RBS
Expand All @@ -169,7 +168,6 @@ class C
[a.read, a_expect],
[aa.read, aa_expect],
[b.read, b_expect],
[bb.read, bb_expect],
[c.read, c_expect],
].each do |actual, expect|
unless actual == expect
Expand Down

0 comments on commit d175493

Please sign in to comment.