Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added text file version resolver. #50

Merged
merged 1 commit into from
Feb 16, 2012
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ public static VersionResolver build(FileSystemAccess file_system, ConfigurationP
{
VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile);
VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver text_version_finder = new TextVersionResolver(file_system, configuration_property_holder.VersionFile);
VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder);
IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, script_number_version_finder };

IEnumerable<VersionResolver> resolvers = new List<VersionResolver> { xml_version_finder, dll_version_finder, text_version_finder, script_number_version_finder };

return new ComplexVersionResolver(resolvers);
}
Expand Down
52 changes: 52 additions & 0 deletions product/roundhouse/resolvers/TextVersionResolver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;

using roundhouse.infrastructure.filesystem;
using roundhouse.infrastructure.logging;

namespace roundhouse.resolvers
{
public class TextVersionResolver : VersionResolver
{
private readonly FileSystemAccess file_system;
private readonly string version_file;

public TextVersionResolver(FileSystemAccess file_system, string version_file)
{
this.file_system = file_system;
this.version_file = version_file;
}

public bool meets_criteria()
{
return version_file.EndsWith(".txt", StringComparison.OrdinalIgnoreCase);
}

public string resolve_version()
{
Log.bound_to(this).log_an_info_event_containing(
" Attempting to resolve version from text file {0}.", version_file);

string version = "0";
if (file_system.file_exists(version_file))
{
try
{
version = file_system.read_file_text(version_file);
Log.bound_to(this).log_an_info_event_containing(" Found version {0} from {1}.", version, version_file);
}
catch (Exception e)
{
Log.bound_to(this).log_an_error_event_containing(
"Unable to get version from text file {0}:{1}{2}", version_file, Environment.NewLine, e.Message);
}
}
else
{
Log.bound_to(this).log_a_warning_event_containing(
"Unable to get version from text file {0}. File doesn't exist.", version_file);
}

return version;
}
}
}
1 change: 1 addition & 0 deletions product/roundhouse/roundhouse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<Compile Include="parameters\IParameter.cs" />
<Compile Include="Migrate.cs" />
<Compile Include="resolvers\ScriptfileVersionResolver.cs" />
<Compile Include="resolvers\TextVersionResolver.cs" />
<Compile Include="RoundhousEFluentNHibernateDiffingType.cs" />
<Compile Include="RoundhouseMode.cs" />
<Compile Include="runners\RoundhouseNHibernateCompareRunner.cs" />
Expand Down