Upgrade library to Elm 0.19

This commit is contained in:
Correl Roush 2018-09-21 15:00:48 -04:00
parent 4a8cc6266b
commit 6ac7101d96
4 changed files with 52 additions and 53 deletions

View file

@ -1,18 +0,0 @@
{
"version": "3.0.1",
"summary": "A library for fetching data from paginated JSON REST APIs.",
"repository": "https://github.com/correl/elm-paginated.git",
"license": "MIT",
"source-directories": [
"src"
],
"exposed-modules": [
"Paginated"
],
"dependencies": {
"elm-community/maybe-extra": "4.0.0 <= v < 5.0.0",
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}

20
elm.json Normal file
View file

@ -0,0 +1,20 @@
{
"type": "package",
"name": "correl/elm-paginated",
"summary": "A library for fetching data from paginated JSON REST APIs.",
"license": "MIT",
"version": "3.0.1",
"exposed-modules": [
"Paginated"
],
"elm-version": "0.19.0 <= v < 0.20.0",
"dependencies": {
"elm/core": "1.0.0 <= v < 2.0.0",
"elm/http": "1.0.0 <= v < 2.0.0",
"elm/json": "1.0.0 <= v < 2.0.0",
"elm/regex": "1.0.0 <= v < 2.0.0",
"elm/time": "1.0.0 <= v < 2.0.0",
"elm-community/maybe-extra": "5.0.0 <= v < 6.0.0"
},
"test-dependencies": {}
}

View file

@ -1,10 +1,6 @@
module Paginated
exposing
( Request
, RequestOptions
, request
, get
, post
module Paginated exposing
( Request, get, post
, RequestOptions, request
, send
, toTask
)
@ -39,7 +35,6 @@ import Http
import Json.Decode exposing (Decoder)
import Paginated.Util
import Task exposing (Task)
import Time
{-| Describes an API request.
@ -50,7 +45,7 @@ type alias RequestOptions a =
, url : String
, body : Http.Body
, decoder : Decoder a
, timeout : Maybe Time.Time
, timeout : Maybe Float
, withCredentials : Bool
}
@ -128,8 +123,8 @@ send :
(Result Http.Error (List a) -> msg)
-> Request a
-> Cmd msg
send resultToMessage request =
toTask request
send resultToMessage request_ =
toTask request_
|> Task.attempt resultToMessage
@ -154,8 +149,8 @@ recurse =
Task.andThen
(\response ->
case response of
Partial request _ ->
httpRequest request
Partial request_ _ ->
httpRequest request_
|> Http.toTask
|> Task.map (update response)
|> recurse
@ -176,8 +171,8 @@ update old new =
( Partial _ oldItems, Complete newItems ) ->
Complete (oldItems ++ newItems)
( Partial _ oldItems, Partial request newItems ) ->
Partial request (oldItems ++ newItems)
( Partial _ oldItems, Partial request_ newItems ) ->
Partial request_ (oldItems ++ newItems)
{-| Convert a `Request` to a `Http.Request` that can then be sent via
@ -212,6 +207,7 @@ fromResponse options response =
Json.Decode.decodeString
(Json.Decode.list options.decoder)
response.body
|> Result.mapError Json.Decode.errorToString
nextPage : Maybe String
nextPage =
@ -232,7 +228,7 @@ fromResponse options response =
{-| Look up a header (case-insensitive)
-}
header : String -> Dict String String -> Maybe String
header header headers =
header name headers =
let
normalized =
Dict.toList headers
@ -240,6 +236,6 @@ header header headers =
|> Dict.fromList
key =
String.map Char.toLower header
String.map Char.toLower name
in
Dict.get key normalized

View file

@ -25,7 +25,7 @@ links s =
_ ->
Nothing
in
Regex.find Regex.All linkPattern s
Regex.find linkPattern s
|> List.map .submatches
|> List.map toTuples
|> Maybe.Extra.values
@ -34,4 +34,5 @@ links s =
linkPattern : Regex.Regex
linkPattern =
Regex.regex "<(.*?)>; rel=\"(.*?)\""
Regex.fromString "<(.*?)>; rel=\"(.*?)\""
|> Maybe.withDefault Regex.never