Skip to content

Commit

Permalink
Fix that allow to reference binary files
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-tihon committed Dec 5, 2014
1 parent 15da6e1 commit b422d98
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,22 @@ module DependenciesFileParser =
let private ``parse http source`` trimmed =
let parts = parseDependencyLine trimmed
let getParts (projectSpec:string) fileSpec =
let ``project spec`` =
let ``project spec`` =
match projectSpec.EndsWith("/") with
| false -> projectSpec
| true -> projectSpec.Substring(0, projectSpec.Length-1)
let splitted = ``project spec``.Split [|':'; '/'|]
let fileName = match String.IsNullOrEmpty(fileSpec) with
| true -> (splitted |> Seq.last) + ".fs"
let splitted = ``project spec``.Split([|':'; '/'|], StringSplitOptions.RemoveEmptyEntries)
let fileName = match String.IsNullOrEmpty fileSpec with
| true ->
let name = Seq.last splitted
if String.IsNullOrEmpty <| Path.GetExtension(name)
then name + ".fs" else name
| false -> fileSpec
match splitted |> Seq.truncate 6 |> Seq.toArray with
match splitted |> Seq.truncate 4 |> Seq.toArray with
//SourceFile(origin(url), (owner,project, commit), path)
| [| protocol; x; y; domain |] -> HttpLink(``project spec``), (domain, domain, None), fileName
| [| protocol; x; y; domain; project |] -> HttpLink(``project spec``), (domain,project, None), fileName
| [| protocol; x; y; owner; project; details |] -> HttpLink(``project spec``), (owner,project+"/"+details, None), fileName
| [| protocol; domain |] -> HttpLink(``project spec``), (domain, domain, None), fileName
| [| protocol; domain; project |] -> HttpLink(``project spec``), (domain,project, None), fileName
| [| protocol; owner; project; details |] -> HttpLink(``project spec``), (owner,project+"/"+details, None), fileName
| _ -> failwithf "invalid http-reference specification:%s %s" Environment.NewLine trimmed
match parts with
| [| _; projectSpec; |] -> getParts projectSpec String.Empty
Expand Down
19 changes: 19 additions & 0 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,25 @@ let ``should read http source file from config without quotes, parsing rules``()
Origin = ModuleResolver.SingleSourceFileOrigin.HttpLink "http://example/item/3/1"
Commit = None } ]

[<Test>]
let ``should read http binary references from config``() =
let config = """
http http://www.frijters.net/ikvmbin-8.0.5449.0.zip
http http://www.frijters.net/ikvmbin-8.0.5449.0.zip ikvmbin.zip"""
let dependencies = DependenciesFile.FromCode(config)
dependencies.RemoteFiles
|> shouldEqual
[ { Owner = "www.frijters.net"
Project = "ikvmbin-8.0.5449.0.zip"
Name = "ikvmbin-8.0.5449.0.zip"
Origin = ModuleResolver.SingleSourceFileOrigin.HttpLink "http://www.frijters.net/ikvmbin-8.0.5449.0.zip"
Commit = None }
{ Owner = "www.frijters.net"
Project = "ikvmbin-8.0.5449.0.zip"
Name = "ikvmbin.zip"
Origin = ModuleResolver.SingleSourceFileOrigin.HttpLink "http://www.frijters.net/ikvmbin-8.0.5449.0.zip"
Commit = None } ]


let configWithoutVersions = """
source "http://nuget.org/api/v2"
Expand Down

0 comments on commit b422d98

Please sign in to comment.