Skip to content

Commit

Permalink
Merge pull request #196 from nils-a/bugfix/GH-194
Browse files Browse the repository at this point in the history
(#194) changed Require parameter to strings List
  • Loading branch information
nils-a authored Feb 2, 2023
2 parents a5d8c83 + 2614cfa commit b2c49b1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 6 additions & 4 deletions src/Cake.AsciiDoctorJ.Tests/SettingsExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Should_convert_all_extensions_to_arguments(Action<AsciiDoctorJRunner
setFlag(sut);

var actual = fixture.EvaluateArgs(sut);
actual.ShouldContain(expectedParam);
actual.ShouldBe(expectedParam);
}

[Theory]
Expand Down Expand Up @@ -71,7 +71,7 @@ private class TestData : IEnumerable<object[]>
yield return (s => s.WithVerbose(), "--verbose");
yield return (s => s.WithTimingsMode(), "--timings");
yield return (s => s.WithSectionNumbers(), "--section-numbers");
yield return (s => s.WithRequire(), "--require");
yield return (s => s.WithRequire("asciidoctor-epub3"), "--require asciidoctor-epub3");
yield return (s => s.WithQuiet(), "--quiet");
yield return (s => s.WithSuppressHeaderAndFooter(), "--no-header-footer");
yield return (s => s.WithCompact(), "--compact");
Expand Down Expand Up @@ -116,7 +116,7 @@ private class TestData : IEnumerable<object[]>
yield return (s => s.WithAttribute("foo", "bar"), "--attribute foo=bar");
yield return (s => s.WithAttributes(new Dictionary<string, string> { { "foo", "bar" }, { "bim", "bam" } }),
"--attribute foo=bar --attribute bim=bam");
yield return (s => s.WithInputFile(new FilePath("/foo.adoc")), "/foo.adoc");
yield return (s => s.WithInputFile(new FilePath("/foo.adoc")), "\"/foo.adoc\"");
yield return (s => s.WithInputFiles(new[] { new FilePath("/foo.adoc"), new FilePath("/bar.adoc") }),
"\"/foo.adoc\" \"/bar.adoc\"");
}
Expand All @@ -140,7 +140,6 @@ private class ArgSetterTestData : IEnumerable<object[]>
yield return (s => s.WithVerbose(), s => s.Verbose, true);
yield return (s => s.WithTimingsMode(), s => s.TimingsMode, true);
yield return (s => s.WithSectionNumbers(), s => s.SectionNumbers, true);
yield return (s => s.WithRequire(), s => s.Require, true);
yield return (s => s.WithQuiet(), s => s.Quiet, true);
yield return (s => s.WithSuppressHeaderAndFooter(), s => s.SuppressHeaderAndFooter, true);
yield return (s => s.WithCompact(), s => s.Compact, true);
Expand Down Expand Up @@ -168,6 +167,7 @@ private class ArgSetterTestData : IEnumerable<object[]>
var barAdoc = new FilePath("bar.adoc");
var fooBar = new KeyValuePair<string, string>("foo", "bar");
var bimBam = new KeyValuePair<string, string>("bim", "bam");
var libs = new[]{"some-library", "another-library"};
yield return (s => s.WithTemplateEngine("some-engine"), s => s.TemplateEngine, "some-engine");
yield return (s => s.WithTemplateDir(fooDir), s => s.TemplateDir, fooDir);
yield return (s => s.WithOutputFile(fooPdf), s => s.Output, fooPdf);
Expand All @@ -184,6 +184,8 @@ private class ArgSetterTestData : IEnumerable<object[]>
yield return (s => s.WithInputFile(fooAdoc), s => s.InputFiles, new[] { fooAdoc });
yield return (s => s.WithInputFiles(new[] { fooAdoc, barAdoc }), s => s.InputFiles,
new[] { fooAdoc, barAdoc });
yield return (s => s.WithRequire(libs), s => s.Require, libs);

}

public IEnumerator<object[]> GetEnumerator()
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.AsciiDoctorJ.Tests/SettingsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ private class TestData : IEnumerable<object[]>
yield return (s => s.Verbose = true, "--verbose");
yield return (s => s.TimingsMode = true, "--timings");
yield return (s => s.SectionNumbers = true, "--section-numbers");
yield return (s => s.Require = true, "--require");
yield return (s => s.Quiet = true, "--quiet");
yield return (s => s.SuppressHeaderAndFooter = true, "--no-header-footer");
yield return (s => s.Compact = true, "--compact");
Expand Down Expand Up @@ -70,6 +69,7 @@ private class TestData : IEnumerable<object[]>
yield return (s => s.Backend = "pdf", "--backend pdf");
yield return (s => s.Attributes.Add("foo", "bar"), "--attribute foo=bar");
yield return (s => s.InputFiles.Add(new FilePath("/foo.adoc")), "\"/foo.adoc\"");
yield return (s => s.Require.Add("asciidoctor-diagram"), "--require asciidoctor-diagram");
}

public IEnumerator<object[]> GetEnumerator()
Expand Down
7 changes: 4 additions & 3 deletions src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public AsciiDoctorJRunnerSettings()
LoadPath = new List<DirectoryPath>();
ClassPath = new List<DirectoryPath>();
Attributes = new Dictionary<string, string>();
Require = new List<string>();
}

/// <summary>
Expand Down Expand Up @@ -82,7 +83,7 @@ public AsciiDoctorJRunnerSettings()
/// require the specified library before executing the processor.
/// <para>corresponds to: -r, --require.</para>
/// </summary>
public bool Require { get; set; }
public IList<string> Require { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to
Expand Down Expand Up @@ -224,9 +225,9 @@ internal void Evaluate(ProcessArgumentBuilder args, ICakeEnvironment environment
// ReSharper enable PossibleNullReferenceException
}

if (Require)
foreach (var req in Require)
{
args.Append("--require");
args.Append("--require " + req);
}

if (Quiet)
Expand Down
5 changes: 3 additions & 2 deletions src/Cake.AsciiDoctorJ/AsciiDoctorJRunnerSettingsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;

using Cake.Core.IO;

Expand Down Expand Up @@ -124,9 +125,9 @@ public static AsciiDoctorJRunnerSettings WithSafeMode(this AsciiDoctorJRunnerSet
/// </summary>
/// <param name="this">The <see cref="AsciiDoctorJRunnerSettings"/> that extended by this.</param>
/// <returns>The reference to the <see cref="AsciiDoctorJRunnerSettings"/>.</returns>
public static AsciiDoctorJRunnerSettings WithRequire(this AsciiDoctorJRunnerSettings @this)
public static AsciiDoctorJRunnerSettings WithRequire(this AsciiDoctorJRunnerSettings @this, params string[] require)
{
@this.Require = true;
require.ToList().ForEach(@this.Require.Add);
return @this;
}

Expand Down

0 comments on commit b2c49b1

Please sign in to comment.