Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rake/ext/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def pathmap(spec=nil, &block)
result << "%"
when /%(-?\d+)d/
result << pathmap_partial($1.to_i)
when /^%\{([^}]*)\}(\d*[dpfnxX])/
when /^%\{([^}]*)\}(-?\d+d|[dpfnxX])/
patterns, operator = $1, $2
result << pathmap("%" + operator).pathmap_replace(patterns, &block)
when /^%/
Expand Down
9 changes: 9 additions & 0 deletions test/test_rake_path_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def test_multiple_patterns
def test_partial_directory_selection_works_with_patterns
assert_equal "this/is/a/long",
"this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
assert_equal "long/dir",
"this/is/a/really/long/path/ok.rb".pathmap("%{path,dir}-2d")
end

def test_pattern_with_count_on_non_directory_operator
ex = assert_raises(ArgumentError) do
"dir/abc.rb".pathmap("%{a,x}-2f")
end
assert_match(/unknown.*pathmap.*spec.*-2f/i, ex.message)
end

def test_pattern_with_invalid_operator
Expand Down
Loading