From b4d9345a8faee334d4bf5e14d7e3f8a45d6149cc Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Wed, 8 Aug 2018 16:27:44 -0400 Subject: [PATCH] Begin v0.2 --- .travis.yml | 2 +- Manifest.toml | 128 +++++++++++++++++++++++++++++++++++++++++++++++ Project.toml | 10 ++++ docs/make.jl | 2 +- src/DarkSky.jl | 14 +++--- test/runtests.jl | 11 ++-- 6 files changed, 153 insertions(+), 14 deletions(-) create mode 100644 Manifest.toml create mode 100644 Project.toml diff --git a/.travis.yml b/.travis.yml index 2eb7740..95790c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ os: - linux - osx julia: - - 0.6 + - 0.7 - nightly matrix: allow_failures: diff --git a/Manifest.toml b/Manifest.toml new file mode 100644 index 0000000..1a36818 --- /dev/null +++ b/Manifest.toml @@ -0,0 +1,128 @@ +[[ArgCheck]] +deps = ["Random", "Test"] +git-tree-sha1 = "301eb859a5f4130f6fa479c7ece618a3258bd993" +uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" +version = "0.7.0" + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[BinaryProvider]] +deps = ["Libdl", "Pkg", "SHA", "Test"] +git-tree-sha1 = "2883bc1b389e3d57a134796c39c788db3f298cef" +uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" +version = "0.4.0" + +[[Compat]] +deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"] +git-tree-sha1 = "277d3807440d9793421354b6680911fc95d91a84" +uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" +version = "1.0.1" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[DelimitedFiles]] +deps = ["Mmap"] +uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab" + +[[Distributed]] +deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[HTTP]] +deps = ["Base64", "Dates", "Distributed", "IniFile", "MbedTLS", "Sockets", "Test"] +git-tree-sha1 = "8a0f75e8b09df01d9f1ba9ad3fbf8b4983595d20" +uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3" +version = "0.6.14" + +[[IniFile]] +deps = ["Test"] +git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8" +uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f" +version = "0.5.0" + +[[InteractiveUtils]] +deps = ["LinearAlgebra", "Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JSON]] +deps = ["Dates", "Distributed", "Mmap", "Pkg", "Sockets", "Test", "Unicode"] +git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.19.0" + +[[LibGit2]] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[MbedTLS]] +deps = ["BinaryProvider", "Compat", "Pkg", "Sockets"] +git-tree-sha1 = "17d5a81dbb1e682d4ff707c01f0afe5948068fa6" +uuid = "739be429-bea8-5141-9913-cc70e7f3736d" +version = "0.6.0" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[SharedArrays]] +deps = ["Distributed", "Mmap", "Random", "Serialization"] +uuid = "1a1011a3-84de-559e-8e89-a11a2f7dc383" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[UUIDs]] +deps = ["Random"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..c5b600c --- /dev/null +++ b/Project.toml @@ -0,0 +1,10 @@ +name = "DarkSky" +uuid = "f47aef8c-9b43-11e8-049e-c55d9d9fa167" +authors = ["Ellis Valentiner "] +version = "0.2.0" + +[deps] +ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" +Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" +HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" +JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" diff --git a/docs/make.jl b/docs/make.jl index 9806b89..ef563ac 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -9,5 +9,5 @@ makedocs( deploydocs( deps = Deps.pip("pygments", "mkdocs", "mkdocs-material", "python-markdown-math"), repo = "github.com/ellisvalentiner/DarkSky.jl.git", - julia = "0.6" + julia = "0.7" ) diff --git a/src/DarkSky.jl b/src/DarkSky.jl index 6a9b1b5..422f580 100644 --- a/src/DarkSky.jl +++ b/src/DarkSky.jl @@ -1,13 +1,13 @@ -VERSION >= v"0.6.0" && __precompile__() +VERSION >= v"0.7.0" && __precompile__() module DarkSky using ArgCheck using HTTP using JSON -using Base.Dates +using Dates -Optional{T} = Union{T, Void} +Optional{T} = Union{T, Nothing} const SUPPORTED_LANGS = ["ar", "az", "be", "bg", "bs", "ca", "cs", "da", "de", "el", "en", "es", "et", "fi", "fr", "hr", "hu", "id", "is", "it", "ja", "ka", "kw", "nb", "nl", "pl", "pt", "ro", "ru", "sk", "sl", "sr", "sv", "tet", "tr", "uk", @@ -27,7 +27,7 @@ struct DarkSkyResponse flags::Optional{Dict} end DarkSkyResponse(x::Dict) = DarkSkyResponse((get.(x, String.(fieldnames(DarkSkyResponse)), nothing))...) -Dict(x::DarkSkyResponse) = Dict(String(f) => getfield(x, f) for f in fieldnames(x) if getfield(x, f) != nothing) +Dict(x::DarkSkyResponse) = Dict(String(f) => getfield(x, f) for f in fieldnames(typeof(x)) if getfield(x, f) != nothing) Base.convert(Dict, x::DarkSkyResponse) = Dict(x) function Base.show(io::IO, x::DarkSkyResponse) @@ -44,7 +44,7 @@ end function _get_json(url::String, out_type::String, verbose::Bool) response = HTTP.get(url) - verbose ? info(response) : nothing + verbose ? @info(response) : nothing if response.status == 200 out = JSON.Parser.parse(String(response.body)) if out_type == "DarkSkyResponse" @@ -69,7 +69,7 @@ Make a "Forecast Request", returns the current weather forecast for the next wee - `lang`: return summary properties in the desired language (optional). - `units`: return weather conditions in the requested units (optional). """ -function forecast(latitude::Float64, longitude::Float64; verbose::Bool=true, +function forecast(latitude::Float64, longitude::Float64; verbose::Bool=false, exclude::Optional{Array{String}}=nothing, extend::Optional{String}=nothing, lang::String="en", units::String="us", out_type::String="DarkSkyResponse") @argcheck in(lang, SUPPORTED_LANGS) @@ -99,7 +99,7 @@ the past or future. - `lang`: return summary properties in the desired language (optional). - `units`: return weather conditions in the requested units (optional). """ -function forecast(latitude::Float64, longitude::Float64, time::DateTime; verbose::Bool=true, +function forecast(latitude::Float64, longitude::Float64, time::DateTime; verbose::Bool=false, exclude::Optional{Array{String}}=nothing, lang::String="en", units::String="us", out_type::String="DarkSkyResponse") @argcheck in(lang, SUPPORTED_LANGS) diff --git a/test/runtests.jl b/test/runtests.jl index 9997970..dd66234 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,8 +1,9 @@ using DarkSky -using Base.Test +using Test +using Dates if haskey(ENV, "DARKSKY_API_KEY") - info("Dark Sky API key was found in your system environment variables, running tests...") + @info("Dark Sky API key was found in your system environment variables, running tests...") @test isa(forecast(42.3601, -71.0589), DarkSky.DarkSkyResponse) @test isa(forecast(42.3601, -71.0589, exclude=["currently"], extend="hourly"), DarkSky.DarkSkyResponse) response = forecast(42.3601, -71.0589, DateTime(2018, 3, 7, 0, 0, 0)); @@ -11,11 +12,11 @@ if haskey(ENV, "DARKSKY_API_KEY") @test longitude(response) === -71.0589 @test timezone(response) == "America/New_York" @test isa(currently(response), Dict{String, Any}) - @test isa(minutely(response), Void) + @test isa(minutely(response), Nothing) @test isa(daily(response), Dict{String, Any}) - @test isa(alerts(response), Array{Any, 1}) | isa(alerts(response), Void) + @test isa(alerts(response), Array{Any, 1}) | isa(alerts(response), Nothing) @test isa(flags(response), Dict{String, Any}) - @test isa(print(response), Void) + @test isa(print(response), Nothing) dict_response = forecast(42.3601, -71.0589, DateTime(2018, 3, 7, 0, 0, 0), out_type=""); @test Dict(response) == dict_response @test Dict(response) == convert(Dict, response)