From 2c695ce16589cedeca3bcdb52dbda442ba05c0af Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Fri, 30 Apr 2021 20:19:39 -0700 Subject: [PATCH] Rename functions. --- src/ApiHandler.elm | 8 ++++---- tests/ApiHandlerTests.elm | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/ApiHandler.elm b/src/ApiHandler.elm index 1d53bba3..77be007d 100644 --- a/src/ApiHandler.elm +++ b/src/ApiHandler.elm @@ -73,8 +73,8 @@ succeed a = -- Debug.todo "" -literalSegment : String -> Handler a constructor -> Handler a constructor -literalSegment segment (Handler pattern handler toString constructor) = +literal : String -> Handler a constructor -> Handler a constructor +literal segment (Handler pattern handler toString constructor) = Handler (pattern ++ segment) handler (\values -> toString values ++ segment) constructor @@ -134,7 +134,7 @@ slash (Handler pattern handler toString constructor) = -- b -captureNew : +capture : Handler (String -> a) constructor @@ -142,7 +142,7 @@ captureNew : Handler a (String -> constructor) -captureNew (Handler pattern previousHandler toString constructor) = +capture (Handler pattern previousHandler toString constructor) = Handler (pattern ++ "(.*)") --(Debug.todo "") diff --git a/tests/ApiHandlerTests.elm b/tests/ApiHandlerTests.elm index a15c216c..5acf9850 100644 --- a/tests/ApiHandlerTests.elm +++ b/tests/ApiHandlerTests.elm @@ -13,7 +13,7 @@ all = (\userId -> { body = "Data for user " ++ userId } ) - |> captureNew + |> capture |> tryMatch "123" |> Expect.equal (Just { body = "Data for user 123" }) , test "file with extension" <| @@ -22,8 +22,8 @@ all = (\userId -> { body = "Data for user " ++ userId } ) - |> captureNew - |> literalSegment ".json" + |> capture + |> literal ".json" |> tryMatch "124.json" |> Expect.equal (Just { body = "Data for user 124" }) , test "file path with multiple segments" <| @@ -32,10 +32,10 @@ all = (\userId -> { body = "Data for user " ++ userId } ) - |> literalSegment "users" + |> literal "users" |> slash - |> captureNew - |> literalSegment ".json" + |> capture + |> literal ".json" |> tryMatch "users/123.json" |> Expect.equal (Just { body = "Data for user 123" }) , test "routes" <| @@ -44,10 +44,10 @@ all = (\userId -> { body = "Data for user " ++ userId } ) - |> literalSegment "users" + |> literal "users" |> slash - |> captureNew - |> literalSegment ".json" + |> capture + |> literal ".json" |> withRoutes (\constructor -> [ constructor "100" @@ -65,12 +65,12 @@ all = (\userName repoName -> { body = "Data for user" } ) - |> literalSegment "repos" + |> literal "repos" |> slash - |> captureNew + |> capture |> slash - |> captureNew - |> literalSegment ".json" + |> capture + |> literal ".json" |> withRoutes (\a -> [ a "dillonkearns" "elm-pages" @@ -87,13 +87,13 @@ all = (\username repo branch -> { body = [ username, repo, branch ] |> String.join " - " } ) - |> literalSegment "repos" + |> literal "repos" |> slash - |> captureNew + |> capture |> slash - |> captureNew + |> capture |> slash - |> captureNew + |> capture |> withRoutes (\constructor -> [ constructor "dillonkearns" "elm-pages" "static-files" ]