Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/kfuglsang/FAKE
Browse files Browse the repository at this point in the history
Conflicts:
	src/app/FakeLib/Globbing/Globbing.fs
  • Loading branch information
forki committed Aug 10, 2015
2 parents 4b5df64 + c39a9a7 commit 1075270
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/app/FakeLib/DynamicsNavFile.fs
Expand Up @@ -189,3 +189,33 @@ let splitNavisionFiles fileNames destDir =
use outputFile = new StreamWriter(Path.Combine(destDir, targetFile), false)
outputFile.Write(x.Source)
outputFile.Close()

/// Gets the version number for the specified version tag in a Dynamics NAV version tag list
let getTagVersionInVersionTagList (versionTag : string) (tagList : string) =
let versionTag = versionTag.ToUpper()
if tagList.ToUpper().Contains versionTag then
let tag = splitVersionTags tagList
|> Seq.find (fun x -> x.StartsWith versionTag)
tag.Replace(versionTag, "")
else
""

/// Gets the version number for the specified version tag in a Dynamics NAV object
let getTagVersionInObject (versionTag : string) sourceCode =
let tagList = getVersionTagList sourceCode
getTagVersionInVersionTagList versionTag tagList

/// Gets the highest version number for a specified version tag in a number of Dynamics NAV objects
let getHighestTagVersionInObjects (versionTag : string) sourceCode =
objectsInObjectString sourceCode
|> Seq.map (fun objectSourcecode -> getTagVersionInObject versionTag objectSourcecode.Source)
|> Seq.filter (fun version -> not (String.IsNullOrWhiteSpace(version)))
|> Seq.max

/// Gets the highest version number for a specified version tag in a number of Dynamics NAV objects in a set of object files
let getHighestTagVersionInFiles (versionTag : string) fileNames =
fileNames
|> Seq.map (fun fileName -> File.ReadAllText(fileName))
|> Seq.map (fun sourceCode -> getTagVersionInObject versionTag sourceCode)
|> Seq.filter (fun version -> not (String.IsNullOrWhiteSpace(version)))
|> Seq.max
2 changes: 1 addition & 1 deletion src/app/FakeLib/Globbing/Globbing.fs
Expand Up @@ -146,4 +146,4 @@ let isMatch pattern path : bool =
globRegexCache.TryAdd(pattern, compiled) |> ignore
compiled

regex.IsMatch(path)
regex.IsMatch(path)
20 changes: 20 additions & 0 deletions src/test/Test.FAKECore/NAVFiles/NAVVersionTagsSpecs.cs
Expand Up @@ -29,6 +29,26 @@ static IEnumerable<string> GetMissingRequiredTags(IEnumerable<string> requiredTa
}
}

public class CanGetVersionNumbers
{
It should_find_version_number = () =>
DynamicsNavFile.getTagVersionInVersionTagList("VU", "VU2.40.03,NTI.Nienburg,ARC5.10,MCN,NIW,PRE,AUS01").ShouldEqual("2.40.03");

It should_not_find_version_for_non_existing_tag = () =>
DynamicsNavFile.getTagVersionInVersionTagList("NAVW1", "VU2.40.03,NTI.Nienburg,ARC5.10,MCN,NIW,PRE,AUS01").ShouldBeEmpty();

It should_find_the_highest_version_number = () => {
var sourceCode = File.ReadAllText(@"NAVFiles/Table_3_and_4.txt");
DynamicsNavFile.getHighestTagVersionInObjects("NAVW1", sourceCode).ShouldEqual("7.10");
};

It should_find_the_highest_version_number_in_files = () =>
{
var files = new[] { @"NAVFiles/Codeunit_1.txt", @"NAVFiles/Table_3.txt" };
DynamicsNavFile.getHighestTagVersionInFiles("NAVW1", files).ShouldEqual("7.00");
};
}

public class CanDetectInvalidTags
{
It should_find_invalid_IssueNo = () =>
Expand Down

0 comments on commit 1075270

Please sign in to comment.