Skip to content

Commit

Permalink
Fixed texts; updated assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcrenna committed Jun 6, 2013
1 parent f9c1905 commit a795318
Show file tree
Hide file tree
Showing 12 changed files with 209 additions and 15 deletions.
10 changes: 10 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<apikeys>
<add key="https://www.nuget.org" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAjCr5LM920U6lEU/CELaK7wAAAAACAAAAAAADZgAAwAAAABAAAADnmgw+mlQ2eTBiGK8bhJ8vAAAAAASAAACgAAAAEAAAAEhpMT18Rd0d8JdQEXMAPyEoAAAA96yyR59bEGMrL4hOm027DMHqqaBtlcsuCoG84gnlPyI1tbKIrXnZOhQAAADg4DsgkTd5gv3FIEMY/GCe86Kvhw==" />
<add key="http://nuget.gw.symbolsource.org/Public/NuGet" value="AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAjCr5LM920U6lEU/CELaK7wAAAAACAAAAAAADZgAAwAAAABAAAAAwv2wSYqzz6LV0tq2KpfkfAAAAAASAAACgAAAAEAAAAJuU95ELOYvqCM078yXz068oAAAAXlolusjNBgJtbe6l8T+x+a2mx1FW7HGLG+mEaNSnZjMlQlft8YIM7RQAAACeJvA+0CUHB+z2PC9DuhW1+d7tcw==" />
</apikeys>
</configuration>
143 changes: 143 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
<!-- Windows specific commands -->
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir>
</PropertyGroup>

<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
<PackagesDir>$(SolutionDir)packages</PackagesDir>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -o "$(PackagesDir)"</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)"
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

<Exec Command="$(RestoreCommand)"
LogStandardErrorAsError="true"
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)"
Condition=" '$(OS)' != 'Windows_NT' " />

<Exec Command="$(BuildCommand)"
LogStandardErrorAsError="true"
Condition=" '$(OS)' == 'Windows_NT' " />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);
Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>

<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
Binary file renamed email/email.1.1.0.nupkg → email/email.1.1.1.nupkg
Binary file not shown.
6 changes: 3 additions & 3 deletions email/email.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<package>
<metadata>
<id>email</id>
<version>1.1.0</version>
<version>1.1.1</version>
<authors>Daniel Crenna</authors>
<owners>Daniel Crenna</owners>
<description>Easily render and send emails in your applications. Supports templating, parallel delivery, observable folders, retry policy, backlog, and more.</description>
<summary>Easily render and send emails in your applications.</summary>
<language>en-US</language>
<projectUrl>http://github.com/danielcrenna/email</projectUrl>
<licenseUrl>https://github.com/danielcrenna/email/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/danielcrenna/webstack/tree/master/email</projectUrl>
<licenseUrl>https://github.com/danielcrenna/webstack/blob/master/email/LICENSE.md</licenseUrl>
<tags>email delivery</tags>
</metadata>
</package>
2 changes: 1 addition & 1 deletion email/pack-nuget.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
copy LICENSE.md bin
copy README.md bin
".nuget\NuGet.exe" pack email.nuspec -BasePath bin
"..\.nuget\NuGet.exe" pack email.nuspec -BasePath bin
2 changes: 1 addition & 1 deletion email/push-nuget.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
".nuget\NuGet.exe" push email.1.1.0.nupkg
"..\.nuget\NuGet.exe" push email.1.1.1.nupkg
3 changes: 2 additions & 1 deletion email/src/email.Tests/Delivery/DeliveryServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading;
using NUnit.Framework;
using email.Delivery;
using email.Providers;

namespace email.Tests.Delivery
{
Expand All @@ -21,7 +22,7 @@ public void Can_deliver_single_batch_of_messages_fully()

var config = new DeliveryConfiguration {BacklogFolder = "backlog", MaxDegreeOfParallelism = 10};

var service = new DeliveryService(new DirectoryEmailService(pickupDirectory), config);
var service = new DeliveryService(new DirectoryEmailProvider(pickupDirectory), config);
var messages = MessageFactory.EmailWithHtmlAndText(count);

service.Start();
Expand Down
27 changes: 25 additions & 2 deletions email/src/email.Tests/InMemoryEmailService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
using System.Collections.Generic;
using System.Linq;
using email.Providers;
using email.Templates;

namespace email.Tests
{
public class InMemoryEmailService : IEmailProvider
public class InMemoryEmailService : IEmailProvider, IEmailTemplateEngine
{
private readonly IEmailTemplateEngine _composer;
public ICollection<EmailMessage> Messages { get; private set; }

public InMemoryEmailService()
public InMemoryEmailService() : this(new DotLiquidEmailTemplateEngine())
{

}

public InMemoryEmailService(IEmailTemplateEngine composer)
{
_composer = composer;
Messages = new List<EmailMessage>();
}

Expand All @@ -26,5 +34,20 @@ public bool[] Send(IEnumerable<EmailMessage> messages)
{
return messages.Select(Send).ToArray();
}

public EmailMessage CreateTextEmail(string textTemplate, dynamic model)
{
return _composer.CreateTextEmail(textTemplate, model);
}

public EmailMessage CreateCombinedEmail(string htmlTemplate, string textTemplate, dynamic model)
{
return _composer.CreateCombinedEmail(htmlTemplate, textTemplate, model);
}

public EmailMessage CreateHtmlEmail(string htmlTemplate, dynamic model)
{
return _composer.CreateHtmlEmail(htmlTemplate, model);
}
}
}
3 changes: 2 additions & 1 deletion email/src/email.Tests/MessageTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.IO;
using NUnit.Framework;
using email.Providers;

namespace email.Tests
{
Expand All @@ -10,7 +11,7 @@ protected static void AssertDelivery(EmailMessage message)
var pickupDirectory = Path.Combine(Path.GetTempPath(), "pickup");
CreateOrCleanDirectory(pickupDirectory);

var service = new DirectoryEmailService(pickupDirectory);
var service = new DirectoryEmailProvider(pickupDirectory);
service.Send(message);

AssertFileCount(pickupDirectory, 1);
Expand Down
8 changes: 5 additions & 3 deletions email/src/email.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "email", "email\email.csproj
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C3A01DD3-29B2-48E5-BAE5-760EA891DED5}"
ProjectSection(SolutionItems) = preProject
email.nuspec = email.nuspec
LICENSE = LICENSE
README.md = README.md
..\email.nuspec = ..\email.nuspec
..\LICENSE.md = ..\LICENSE.md
..\pack-nuget.bat = ..\pack-nuget.bat
..\push-nuget.bat = ..\push-nuget.bat
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "email.Tests", "email.Tests\email.Tests.csproj", "{01F4FB59-0D5B-4D7C-BA9C-B70A43C47AD6}"
Expand Down
3 changes: 3 additions & 0 deletions email/src/email.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters /&gt;&lt;/data&gt;</s:String>
<s:String x:Key="/Default/FilterSettingsManager/AttributeFilterXml/@EntryValue">&lt;data /&gt;</s:String></wpf:ResourceDictionary>
17 changes: 14 additions & 3 deletions email/src/email/Templates/DotLiquidEmailTemplateEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public EmailMessage CreateTextEmail(string textTemplate, dynamic model)
{
var hash = HashExtensions.FromDynamic(model);
var textBody = PrepareBodyFromTemplate(textTemplate, hash);
dynamic wrapped = new SafeHash((Hash)hash);
var wrapped = WrapEmail(hash);
var email = new EmailMessage
{
From = wrapped.From,
Expand All @@ -31,7 +31,7 @@ public EmailMessage CreateCombinedEmail(string htmlTemplate, string textTemplate
var htmlBody = PrepareBodyFromTemplate(htmlTemplate, hash);
var textBody = PrepareBodyFromTemplate(textTemplate, hash);

dynamic wrapped = new SafeHash((Hash)hash);
var wrapped = WrapEmail(hash);
var email = new EmailMessage
{
From = wrapped.From,
Expand All @@ -49,7 +49,7 @@ public EmailMessage CreateHtmlEmail(string htmlTemplate, dynamic model)
var hash = HashExtensions.FromDynamic(model);
var htmlBody = PrepareBodyFromTemplate(htmlTemplate, hash);

dynamic wrapped = new SafeHash((Hash)hash);
var wrapped = WrapEmail(hash);
var email = new EmailMessage
{
From = wrapped.From,
Expand All @@ -61,6 +61,17 @@ public EmailMessage CreateHtmlEmail(string htmlTemplate, dynamic model)
return email;
}


private static dynamic WrapEmail(dynamic hash)
{
dynamic wrapped = new SafeHash((Hash)hash);
if (!(wrapped.To is List<string>))
{
wrapped.To = new List<string>(new[] { wrapped.To as string });
}
return wrapped;
}

private static string PrepareBodyFromTemplate(string template, dynamic hash)
{
string htmlBody = null;
Expand Down

0 comments on commit a795318

Please sign in to comment.