| 1 | |
package org.jbehave.core.io; |
| 2 | |
|
| 3 | |
import static org.apache.commons.lang.StringUtils.contains; |
| 4 | |
import static org.apache.commons.lang.StringUtils.substringAfterLast; |
| 5 | |
import static org.apache.commons.lang.StringUtils.substringBefore; |
| 6 | |
import static org.apache.commons.lang.WordUtils.capitalize; |
| 7 | |
|
| 8 | 426 | public class UnderscoredToCapitalized implements StoryNameResolver { |
| 9 | |
|
| 10 | |
public String resolveName(String path) { |
| 11 | 35 | String name = path; |
| 12 | 35 | if ( contains(name, '/') ){ |
| 13 | 2 | name = substringAfterLast(name, "/"); |
| 14 | 2 | name = substringBefore(name, "."); |
| 15 | 33 | } else if ( contains(name, '.') ){ |
| 16 | 16 | name = substringAfterLast(name, "."); |
| 17 | |
} |
| 18 | 35 | return capitalize(name.replace("_", " ")); |
| 19 | |
} |
| 20 | |
|
| 21 | |
} |