fix RubyBundlerAnalyzer.accept

This commit is contained in:
bjiang
2016-05-06 17:55:21 -04:00
parent 83f83d4eee
commit d5e8f54214
2 changed files with 13 additions and 2 deletions

View File

@@ -55,6 +55,16 @@ public class RubyBundlerAnalyzer extends RubyGemspecAnalyzer {
//Folder name that contains the gems by "bundle install" //Folder name that contains the gems by "bundle install"
private static final String GEMS = "gems"; private static final String GEMS = "gems";
/**
* Returns the name of the analyzer.
*
* @return the name of the analyzer.
*/
@Override
public String getName() {
return ANALYZER_NAME;
}
/** /**
* Only accept *.gemspec files generated by "bundle install --deployment" under "specifications" folder. * Only accept *.gemspec files generated by "bundle install --deployment" under "specifications" folder.
*/ */
@@ -64,7 +74,7 @@ public class RubyBundlerAnalyzer extends RubyGemspecAnalyzer {
boolean accepted = super.accept(pathname); boolean accepted = super.accept(pathname);
if(accepted == true) { if(accepted == true) {
File parentDir = pathname.getParentFile(); File parentDir = pathname.getParentFile();
accepted = parentDir != null && parentDir.exists() && parentDir.getName().equals(SPECIFICATIONS); accepted = parentDir != null && parentDir.getName().equals(SPECIFICATIONS);
} }
return accepted; return accepted;

View File

@@ -78,7 +78,8 @@ public class RubyBundlerAnalyzerTest extends BaseTest {
*/ */
@Test @Test
public void testSupportsFiles() { public void testSupportsFiles() {
assertThat(analyzer.accept(new File("test.gemspec")), is(true)); assertThat(analyzer.accept(new File("test.gemspec")), is(false));
assertThat(analyzer.accept(new File("specifications" + File.separator + "test.gemspec")), is(true));
} }
/** /**