broke up EnvironmentProvider into different services

This commit is contained in:
Keivan Beigi 2013-06-27 17:04:52 -07:00
commit 6b0a24e28e
54 changed files with 549 additions and 560 deletions

View file

@ -5,6 +5,7 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Messaging;
using NzbDrone.Common.Serializer;
using NzbDrone.Core.Lifecycle;
@ -13,24 +14,24 @@ namespace NzbDrone.Api.Client
{
public class ClientSettings : IHandle<ApplicationStartedEvent>
{
private readonly EnvironmentProvider _environmentProvider;
private readonly IAppDirectoryInfo _appDirectoryInfo;
private static readonly Regex VersionRegex = new Regex(@"(?<=Version:\s')(.*)(?=')", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex BuildDateRegex = new Regex(@"(?<=BuildDate:\s)('.*')", RegexOptions.IgnoreCase | RegexOptions.Compiled);
public ClientSettings(EnvironmentProvider environmentProvider)
public ClientSettings(IAppDirectoryInfo appDirectoryInfo)
{
_environmentProvider = environmentProvider;
_appDirectoryInfo = appDirectoryInfo;
}
public void Handle(ApplicationStartedEvent message)
{
//TODO: Update the APIKey (when we have it)
var appFile = Path.Combine(_environmentProvider.StartUpPath, "UI", "app.js");
var appFile = Path.Combine(_appDirectoryInfo.StartUpPath, "UI", "app.js");
var contents = File.ReadAllText(appFile);
var version = _environmentProvider.Version;
var date = _environmentProvider.BuildDateTime;
var version = BuildInfo.Version;
var date = BuildInfo.BuildDateTime;
contents = VersionRegex.Replace(contents, version.ToString());
contents = BuildDateRegex.Replace(contents, date.ToUniversalTime().ToJson());