Skip to content

Commit

Permalink
Julia Formatting
Browse files Browse the repository at this point in the history
and fixed Compat issue.
  • Loading branch information
Nosferican committed Mar 24, 2020
1 parent 5f7eaf8 commit 7decdda
Show file tree
Hide file tree
Showing 59 changed files with 688 additions and 393 deletions.
123 changes: 123 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# This file is machine-generated - editing it directly is not advised

[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[HTTP]]
deps = ["Base64", "Dates", "IniFile", "MbedTLS", "Sockets"]
git-tree-sha1 = "cd60d9a575d3b70c026d7e714212fd4ecf86b4bb"
uuid = "cd3eb016-35fb-5094-929b-558a96fad6f3"
version = "0.8.13"

[[IniFile]]
deps = ["Test"]
git-tree-sha1 = "098e4d2c533924c921f9f9847274f2ad89e018b8"
uuid = "83e8ac13-25f8-5344-8a64-a9f2b223428f"
version = "0.5.0"

[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[JSON3]]
deps = ["Dates", "Mmap", "Parsers", "StructTypes", "Test", "UUIDs"]
git-tree-sha1 = "68cf28e37c70fd9a161dcaa13dc9e9209b415014"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.0.1"

[[LibGit2]]
deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"

[[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"

[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"

[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[MbedTLS]]
deps = ["Dates", "MbedTLS_jll", "Random", "Sockets"]
git-tree-sha1 = "a9e2221f06b42f56052f43ad7edecb01d0ef5ab4"
uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.1"

[[MbedTLS_jll]]
deps = ["Libdl", "Pkg"]
git-tree-sha1 = "066a4467008745eed36dad973ceb66405785a621"
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.16.0+1"

[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[OrderedCollections]]
deps = ["Random", "Serialization", "Test"]
git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.1.0"

[[Parameters]]
deps = ["OrderedCollections"]
git-tree-sha1 = "b62b2558efb1eef1fa44e4be5ff58a515c287e38"
uuid = "d96e819e-fc66-5662-9728-84c9c7592b0a"
version = "0.12.0"

[[Parsers]]
deps = ["Dates", "Test"]
git-tree-sha1 = "0c16b3179190d3046c073440d94172cfc3bb0553"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "0.3.12"

[[Pkg]]
deps = ["Dates", "LibGit2", "Libdl", "Logging", "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"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[StructTypes]]
deps = ["Dates", "UUIDs"]
git-tree-sha1 = "1ed04f622a39d2e5a6747c3a70be040c00333933"
uuid = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
version = "1.1.0"

[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[[UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"

[compat]
Documenter = "0.24"
HTTP = "0.8"
JSON3 = "0.1, 1.0"
JSON3 = "1"
Parameters = "0.12"
julia = "1"

Expand Down
33 changes: 20 additions & 13 deletions src/01_structs/01_Timeouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ Session Timeouts -- script: 50000, pageLoad: 100000, implicit: 5
```
"""
struct Timeouts
script::Int
pageLoad::Int
implicit::Int
function Timeouts(;script::Integer = 30_000,
pageLoad::Integer = 300_000,
implicit::Integer = 0)
script > 0 || throw(ArgumentError("script timeout should be a positive integer"))
pageLoad > 0 || throw(ArgumentError("pageLoad timeout should be a positive integer"))
implicit 0 || throw(ArgumentError("implicit timeout should be a non-negative integer"))
new(script, pageLoad, implicit)
end
script::Int
pageLoad::Int
implicit::Int
function Timeouts(;
script::Integer = 30_000,
pageLoad::Integer = 300_000,
implicit::Integer = 0,
)
script > 0 || throw(ArgumentError("script timeout should be a positive integer"))
pageLoad > 0 ||
throw(ArgumentError("pageLoad timeout should be a positive integer"))
implicit 0 ||
throw(ArgumentError("implicit timeout should be a non-negative integer"))
new(script, pageLoad, implicit)
end
end
summary(io::IO, obj::Timeouts) = print(io, "Session Timeouts")
function show(io::IO, obj::Timeouts)
print(io, summary(obj))
print(io, " -- script: $(obj.script), pageLoad: $(obj.pageLoad), implicit: $(obj.implicit)")
print(io, summary(obj))
print(
io,
" -- script: $(obj.script), pageLoad: $(obj.pageLoad), implicit: $(obj.implicit)",
)
end
JSON3.StructType(::Type{Timeouts}) = JSON3.Struct()
94 changes: 56 additions & 38 deletions src/01_structs/02_Proxy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,65 @@
The proxy configuration capability is a JSON Object nested within the primary capabilities.
According to the [W3C](https://www.w3.org/TR/webdriver/#proxy).
"""
struct Proxy{pAU <: Union{Nothing, AbstractString},
ftpP <: Union{Nothing, AbstractString},
httpP <: Union{Nothing, AbstractString},
nP <: Union{Nothing, AbstractVector{<:AbstractString}},
sslP <: Union{Nothing, AbstractString},
sP <: Union{Nothing, AbstractString},
sV <: Union{Nothing, Integer}
}
proxyType::String
proxyAutoconfigUrl::pAU
ftpProxy::ftpP
httpProxy::httpP
noProxy::nP
sslProxy::sslP
socksProxy::sP
socksVersion::sV
function Proxy(proxyType::AbstractString;
proxyAutoconfigUrl::Union{Nothing, AbstractString} = nothing,
ftpProxy::Union{Nothing, AbstractString} = nothing,
httpProxy::Union{Nothing, AbstractString} = nothing,
noProxy::Union{Nothing, AbstractVector{<:AbstractString}} = nothing,
sslProxy::Union{Nothing, AbstractString} = nothing,
socksProxy::Union{Nothing, AbstractString} = nothing,
socksVersion::Union{Nothing, Integer} = nothing)::Proxy
proxyType ["pac", "direct", "autodetect", "system", "manual"] ||
throw(ArgumentError("""valid proxyType values: "pac", "direct", "autodetect", "system", or "manual"."""))
proxyType == "pac" && isnothing(proxyAutoconfigUrl) && throw(ArgumentError("proxyAutoconfigUrl must be provided for proxyType pac"))
struct Proxy{
pAU<:Union{Nothing,AbstractString},
ftpP<:Union{Nothing,AbstractString},
httpP<:Union{Nothing,AbstractString},
nP<:Union{Nothing,AbstractVector{<:AbstractString}},
sslP<:Union{Nothing,AbstractString},
sP<:Union{Nothing,AbstractString},
sV<:Union{Nothing,Integer},
}
proxyType::String
proxyAutoconfigUrl::pAU
ftpProxy::ftpP
httpProxy::httpP
noProxy::nP
sslProxy::sslP
socksProxy::sP
socksVersion::sV
function Proxy(
proxyType::AbstractString;
proxyAutoconfigUrl::Union{Nothing,AbstractString} = nothing,
ftpProxy::Union{Nothing,AbstractString} = nothing,
httpProxy::Union{Nothing,AbstractString} = nothing,
noProxy::Union{Nothing,AbstractVector{<:AbstractString}} = nothing,
sslProxy::Union{Nothing,AbstractString} = nothing,
socksProxy::Union{Nothing,AbstractString} = nothing,
socksVersion::Union{Nothing,Integer} = nothing,
)::Proxy
proxyType ["pac", "direct", "autodetect", "system", "manual"] ||
throw(ArgumentError("""valid proxyType values: "pac", "direct", "autodetect", "system", or "manual"."""))
proxyType == "pac" &&
isnothing(proxyAutoconfigUrl) &&
throw(ArgumentError("proxyAutoconfigUrl must be provided for proxyType pac"))
if !isnothing(socksProxy)
isnothing(socksVersion) && throw(ArgumentError("socksVersion must be provided for socksProxy"))
0 socksVersion 255 || throw(ArgumentError("valid values for socksVersion: any integer between 0 and 255 inclusive."))
isnothing(socksVersion) &&
throw(ArgumentError("socksVersion must be provided for socksProxy"))
0 socksVersion 255 ||
throw(ArgumentError("valid values for socksVersion: any integer between 0 and 255 inclusive."))
end
new{typeof(proxyAutoconfigUrl),
typeof(ftpProxy),
typeof(httpProxy),
typeof(noProxy),
typeof(sslProxy),
typeof(socksProxy),
typeof(socksVersion)}(proxyType, proxyAutoconfigUrl, ftpProxy, httpProxy, noProxy, sslProxy, socksProxy, socksVersion)
end
new{
typeof(proxyAutoconfigUrl),
typeof(ftpProxy),
typeof(httpProxy),
typeof(noProxy),
typeof(sslProxy),
typeof(socksProxy),
typeof(socksVersion),
}(
proxyType,
proxyAutoconfigUrl,
ftpProxy,
httpProxy,
noProxy,
sslProxy,
socksProxy,
socksVersion,
)
end
end
summary(io::IO, obj::Proxy) = println(io, "Proxy")
function show(io::IO, obj::Proxy)
print(io, summary(obj))
print(io, summary(obj))
end
84 changes: 49 additions & 35 deletions src/01_structs/03_Capabilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,57 @@ Remote WebDriver Capabilities
browserName: chrome
```
"""
struct Capabilities{aIC <: Union{Nothing, Bool},
P <: Union{Nothing, Proxy},
sWR <: Union{Nothing, Bool},
sFI <: Union{Nothing, Bool}}
browserName::String
browserVersion::String
platformName::String
acceptInsecureCerts::aIC
pageLoadStrategy::String
proxy::P
setWindowRect::sWR
timeouts::Timeouts
strictFileInteractability::sFI
unhandledPromptBehavior::String
function Capabilities(browserName::AbstractString;
browserVersion::AbstractString = "",
platformName::AbstractString = "",
acceptInsecureCerts::Union{Nothing, Bool} = nothing,
pageLoadStrategy::AbstractString = "",
proxy::Union{Nothing, Proxy} = nothing,
setWindowRect::Union{Nothing, Bool} = nothing,
timeouts::Timeouts = Timeouts(),
strictFileInteractability::Union{Nothing, Bool} = nothing,
unhandledPromptBehavior::AbstractString = "dismiss and notify"
)
new{typeof(acceptInsecureCerts),
typeof(proxy),
typeof(setWindowRect),
typeof(strictFileInteractability)
}(browserName, browserVersion, platformName, acceptInsecureCerts, pageLoadStrategy, proxy, setWindowRect, timeouts, strictFileInteractability,
unhandledPromptBehavior)
end
struct Capabilities{
aIC<:Union{Nothing,Bool},
P<:Union{Nothing,Proxy},
sWR<:Union{Nothing,Bool},
sFI<:Union{Nothing,Bool},
}
browserName::String
browserVersion::String
platformName::String
acceptInsecureCerts::aIC
pageLoadStrategy::String
proxy::P
setWindowRect::sWR
timeouts::Timeouts
strictFileInteractability::sFI
unhandledPromptBehavior::String
function Capabilities(
browserName::AbstractString;
browserVersion::AbstractString = "",
platformName::AbstractString = "",
acceptInsecureCerts::Union{Nothing,Bool} = nothing,
pageLoadStrategy::AbstractString = "",
proxy::Union{Nothing,Proxy} = nothing,
setWindowRect::Union{Nothing,Bool} = nothing,
timeouts::Timeouts = Timeouts(),
strictFileInteractability::Union{Nothing,Bool} = nothing,
unhandledPromptBehavior::AbstractString = "dismiss and notify",
)
new{
typeof(acceptInsecureCerts),
typeof(proxy),
typeof(setWindowRect),
typeof(strictFileInteractability),
}(
browserName,
browserVersion,
platformName,
acceptInsecureCerts,
pageLoadStrategy,
proxy,
setWindowRect,
timeouts,
strictFileInteractability,
unhandledPromptBehavior,
)
end
end
summary(io::IO, obj::Capabilities) = println(io, "Remote WebDriver Capabilities")
function show(io::IO, obj::Capabilities)
print(io, summary(obj))
println(io, "browserName: $(obj.browserName)")
print(io, summary(obj))
println(io, "browserName: $(obj.browserName)")
end
JSON3.StructType(::Type{<:Capabilities}) = JSON3.Struct()
JSON3.omitempties(::Type{<:Capabilities}) = fieldnames(Capabilities)
omitempties(::Type{<:Capabilities}) = fieldnames(Capabilities)
Loading

0 comments on commit 7decdda

Please sign in to comment.