in src/Detector/Ruby/RubyDetector.cs [33:117]
public PlatformDetectorResult Detect(DetectorContext context)
{
bool isRubyApp = false;
string appDirectory = string.Empty;
bool gemfileExists = false;
var sourceRepo = context.SourceRepo;
string bundlerVersion = string.Empty;
bool configYmlFileExists = false;
if (sourceRepo.FileExists(RubyConstants.ConfigYmlFileName))
{
configYmlFileExists = true;
_logger.LogInformation($"Found {RubyConstants.ConfigYmlFileName} at the root of the repo. " );
}
if (!string.IsNullOrEmpty(_options.AppType))
{
_logger.LogInformation($"{nameof(_options.AppType)} is set to {_options.AppType}");
var appType = _options.AppType.ToLower();
if (appType.Contains(Constants.StaticSiteApplications)
&& configYmlFileExists)
{
isRubyApp = true;
_logger.LogInformation($"The ruby app was detected as a Jekyll static web app. ");
}
}
if (sourceRepo.FileExists(RubyConstants.GemFileName))
{
isRubyApp = true;
gemfileExists = true;
_logger.LogInformation($"Found {RubyConstants.GemFileName} at the root of the repo.");
}
else
{
_logger.LogDebug(
$"Could not find {RubyConstants.GemFileName} in repo");
}
if (!isRubyApp) {
var isRubyLikeApp = false;
if (sourceRepo.FileExists(RubyConstants.GemFileLockName))
{
isRubyLikeApp = true;
bundlerVersion = GetBundlerVersionFromGemFileLock(context);
_logger.LogInformation($"Found {RubyConstants.GemFileLockName} "
+ "at the root of the repo.");
}
if (sourceRepo.FileExists(RubyConstants.ConfigRubyFileName))
{
isRubyLikeApp = true;
_logger.LogInformation($"Found {RubyConstants.ConfigRubyFileName} "
+ "at the root of the repo.");
}
if (isRubyLikeApp) {
foreach (var iisStartupFile in RubyConstants.IisStartupFiles)
{
if (sourceRepo.FileExists(iisStartupFile))
{
_logger.LogDebug(
"App in repo is not a Ruby app as it has the file {iisStartupFile}",
iisStartupFile.Hash());
return null;
}
}
isRubyApp = true;
}
else
{
_logger.LogDebug("Could not find typical Ruby files in repo");
}
}
if (!isRubyApp)
{
_logger.LogDebug("App in repo is not a Ruby app");
return null;
}
var version = GetVersion(context);
return new RubyPlatformDetectorResult
{
Platform = RubyConstants.PlatformName,
PlatformVersion = version,
AppDirectory = appDirectory,
GemfileExists = gemfileExists,
BundlerVersion = bundlerVersion,
ConfigYmlFileExists = configYmlFileExists,
};
}