Play

Check-in [a1c159f148]
Login
Overview
Comment:Implement conversion from String to PackagePath.
Timelines: family | ancestors | descendants | both | modules
Files: files | file ages | folders
SHA3-256: a1c159f14853b7c983fa3c09f57e33e8a1eb692a627060d377d7fda4a958c619
User & Date: robin.hansen on 2021-02-13 07:45:14
Other Links: branch diff | manifest | tags
Context
2021-02-13
10:20
Implement conversion from String to ModuleName. check-in: ddeb331151 user: robin.hansen tags: modules
07:45
Implement conversion from String to PackagePath. check-in: a1c159f148 user: robin.hansen tags: modules
2021-02-12
13:16
Implement conversion from String to SemanticVersion. check-in: d66b3a6dad user: robin.hansen tags: modules
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/Data/PackageMetadata.elm from [be30fcf924] to [fa02e88a13].

1
2

3
4
5
6
7
8
9
module Play.Data.PackageMetadata exposing (PackageMetadata)


import Play.Data.ModuleName as ModuleName exposing (ModuleName)
import Play.Data.PackageName as PackageName exposing (PackageName)
import Play.Data.PackagePath as PackagePath exposing (PackagePath)
import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)


type alias PackageMetadata =


>







1
2
3
4
5
6
7
8
9
10
module Play.Data.PackageMetadata exposing (PackageMetadata)

import Dict exposing (Dict)
import Play.Data.ModuleName as ModuleName exposing (ModuleName)
import Play.Data.PackageName as PackageName exposing (PackageName)
import Play.Data.PackagePath as PackagePath exposing (PackagePath)
import Play.Data.SemanticVersion as SemanticVersion exposing (SemanticVersion)


type alias PackageMetadata =

Modified src/Play/Data/PackagePath.elm from [88864ec89a] to [88408bbd3f].

1


2
3

4




5























module Play.Data.PackagePath exposing (PackagePath)





type PackagePath




    = PackagePath String























|
>
>
|

>

>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Play.Data.PackagePath exposing
    ( PackagePath(..)
    , fromString
    )


type PackagePath
    = Directory String
    | AllDirectoriesInDirectory String


fromString : String -> PackagePath
fromString str =
    let
        ctor =
            if String.endsWith "*" str then
                AllDirectoriesInDirectory

            else
                Directory

        charsToDrop =
            if String.endsWith "/*" str then
                2

            else if String.endsWith "*" str then
                1

            else if String.endsWith "/" str then
                1

            else
                0
    in
    ctor <| String.dropRight charsToDrop str

Added tests/Test/Data/PackagePath.elm version [ac067ac9fd].























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Test.Data.PackagePath exposing (suite)

import Expect
import Play.Data.PackagePath as PackagePath
import Test exposing (Test, describe, test)
import Test.PlayExpect as PlayExpect


suite : Test
suite =
    describe "PackagePath"
        [ test "Any path not ending in * is a directory" <|
            \_ ->
                Expect.equal
                    (PackagePath.Directory "/some/path")
                    (PackagePath.fromString "/some/path")
        , test "Any path ending in * is a recursive directory path" <|
            \_ ->
                Expect.equal
                    (PackagePath.AllDirectoriesInDirectory "/some/path")
                    (PackagePath.fromString "/some/path/*")
        , test "Final slash is removed" <|
            \_ ->
                Expect.equal
                    (PackagePath.Directory "/some/path")
                    (PackagePath.fromString "/some/path/")
        ]