Skip to content

Commit

Permalink
Bug/sdt/surfacelike (#226)
Browse files Browse the repository at this point in the history
* bug(sdt): fix SurfaceLike -> GridBased

* semver(sdt): patch number

* semver(gbif): precompile issue fixed
  • Loading branch information
tpoisot committed Apr 26, 2024
1 parent ab5d975 commit ca6679c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions GBIF/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GBIF"
uuid = "ee291a33-5a6c-5552-a3c8-0f29a1181037"
authors = ["Timothée Poisot <timothee.poisot@umontreal.ca>"]
version = "0.4.4"
version = "0.4.5"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -10,7 +10,7 @@ JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
HTTP = "0.8, 0.9, 1"
HTTP = "1"
JSON = "0.21"
Tables = "1.10"
julia = "1.8"
26 changes: 16 additions & 10 deletions GBIF/src/GBIF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ using JSON
using Dates
using Tables

function safeget(endpoint)
body = UInt8[]
rsp = HTTP.open("GET", endpoint) do http
while !eof(http)
append!(body, readavailable(http))
end
close(HTTP.Connections.getrawstream(http))
end
return rsp.status, String(body)
end

const gbifurl = "http://api.gbif.org/v1/"

"""
Expand All @@ -14,12 +25,8 @@ Returns an *array* of values that can be enumerated by the GBIF API.
"""
function enumerablevalues()
endpoint = GBIF.gbifurl * "enumeration/basic"
req = HTTP.get(endpoint)
if isequal(200)(req.status)
response = JSON.parse(String(req.body))
return convert(Vector{String}, response)
end
return nothing
st, bd = safeget(endpoint)
return isequal(200)(st) ? convert(Vector{String}, JSON.parse(bd)) : nothing
end

# We load the keys that can be enumerated when we load the package
Expand All @@ -33,10 +40,9 @@ For a given enumerable value (given as a string as reported by the output of the
function enumeratedvalues(enumerable::String)
if enumerable in GBIF.gbifenumkeys
endpoint = GBIF.gbifurl * "enumeration/basic/$(enumerable)"
req = HTTP.get(endpoint)
if isequal(200)(req.status)
response = JSON.parse(String(req.body))
return convert(Vector{String}, response)
st, bd = safeget(endpoint)
if isequal(200)(st)
return convert(Vector{String}, JSON.parse(bd))
else
throw(ErrorException("Unable to enumerate the value $(enumerable)"))
end
Expand Down

2 comments on commit ca6679c

@tpoisot
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register subdir="GBIF"

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/105678

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a GBIF-v0.4.5 -m "<description of version>" ca6679c530844b3f4b2be2b7930ac4fa48c29ff3
git push origin GBIF-v0.4.5

Please sign in to comment.