Skip to content

Commit

Permalink
fixed app name cleanup to allow paths; v0.31.2; tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Jun 21, 2020
1 parent c2fe4f5 commit b06f397
Show file tree
Hide file tree
Showing 20 changed files with 293 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Genie"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
authors = ["Adrian Salceanu <[email protected]>"]
version = "0.31.1"
version = "0.31.2"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Expand Down
8 changes: 5 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ using Documenter

using Genie, Genie.App, Genie.AppServer, Genie.Assets
using Genie.Cache, Genie.Commands, Genie.Configuration, Genie.Cookies
using Genie.Encryption, Genie.FileTemplates, Genie.Generator
using Genie.Inflector, Genie.Input, Genie.Plugins
using Genie.Deploy, Genie.Encryption, Genie.Exceptions
using Genie.FileTemplates, Genie.Flash, Genie.Generator
using Genie.Headers, Genie.HTTPUtils, Genie.Inflector, Genie.Input, Genie.Plugins
using Genie.Renderer, Genie.Requests, Genie.Responses, Genie.Router
using Genie.Sessions, Genie.Toolbox, Genie.Util, Genie.WebChannels

push!(LOAD_PATH, "../../src",
"../../src/cache_adapters",
"../../src/session_adapters")
"../../src/session_adapters",
"../../src/renderers")

makedocs(sitename = "Genie - The Highly Productive Julia Web Framework", format = Documenter.HTML(prettyurls = false))
8 changes: 8 additions & 0 deletions docs/src/appserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@ CurrentModule = AppServer
```

```@docs
ServersCollection
SERVERS
startup
down
update_config
handle_request
setup_http_handler
setup_ws_handler
handle_ws_request
```
10 changes: 10 additions & 0 deletions docs/src/assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```@meta
CurrentModule = Assets
```

```@contents
```

```@docs
startup
```
12 changes: 12 additions & 0 deletions docs/src/commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
```@meta
CurrentModule = Commands
```

```@contents
```

```@docs
withcache
purge
purgeall
```
15 changes: 15 additions & 0 deletions docs/src/deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```@meta
CurrentModule = Cookies
```

```@contents
```

```@docs
get
get!!
set!
Dict
nullablevalue
getcookies
```
19 changes: 19 additions & 0 deletions docs/src/exceptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/filetemplates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/headers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/httputils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/inflector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
19 changes: 19 additions & 0 deletions docs/src/input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```@meta
CurrentModule = Genie
```

```@contents
```

```@docs
serve
newapp
loadapp
startup
newmodel
newcontroller
newresource
newmigration
newtablemigration
newtask
```
File renamed without changes.
22 changes: 22 additions & 0 deletions docs/src/responses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```@meta
CurrentModule = REPL
```

```@contents
```

```@docs
secret_token
copy_fullstack_app
copy_microstack_app
copy_db_support
copy_mvc_support
write_secrets_file
write_app_custom_files
install_app_dependencies
autostart_app
newapp
loadapp
setup_windows_bin_files
setup_nix_bin_files
```
25 changes: 24 additions & 1 deletion src/AppServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ import HTTP, HTTP.IOExtras, HTTP.Sockets
import Millboard, URIParser, Sockets, Distributed, Logging
import Genie

"""
ServersCollection(webserver::Union{Task,Nothing}, websockets::Union{Task,Nothing})
Represents a object containing references to Genie's web and websockets servers.
"""
mutable struct ServersCollection
webserver::Union{Task,Nothing}
websockets::Union{Task,Nothing}
end

"""
SERVERS
ServersCollection constant containing references to the current app's web and websockets servers.
"""
const SERVERS = ServersCollection(nothing, nothing)

### PRIVATE ###
Expand All @@ -32,7 +42,7 @@ Starts the web server.
# Examples
```julia-repl
julia> startup(8000, "127.0.0.1", async = false)
julia> up(8000, "127.0.0.1", async = false)
[ Info: Ready!
Web Server starting at http://127.0.0.1:8000
```
Expand Down Expand Up @@ -75,7 +85,15 @@ function startup(port::Int = Genie.config.server_port, host::String = Genie.conf
SERVERS
end

const up = startup


"""
update_config(port::Int, host::String, ws_port::Int) :: Nothing
Updates the corresponding Genie configurations to the corresponding values for
`port`, `host`, and `ws_port`, if these are passed as arguments when starting up the server.
"""
function update_config(port::Int, host::String, ws_port::Int) :: Nothing
Genie.config.server_port = port
Genie.config.server_host = host
Expand All @@ -85,6 +103,11 @@ function update_config(port::Int, host::String, ws_port::Int) :: Nothing
end


"""
downdown(; webserver::Bool = true, websockets::Bool = true) :: ServersCollection
Shuts down the servers optionally indicating which of the `webserver` and `websockets` servers to be stopped.
"""
function down(; webserver::Bool = true, websockets::Bool = true) :: ServersCollection
webserver && (@async Base.throwto(SERVERS.webserver, InterruptException()))
websockets && (@async Base.throwto(SERVERS.websockets, InterruptException()))
Expand Down
2 changes: 1 addition & 1 deletion src/Generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const JULIA_PATH = joinpath(Sys.BINDIR, "julia")


function validname(name::String)
filter(! isempty, [x.match for x in collect(eachmatch(r"[0-9a-zA-Z_]*", name))]) |> join
filter(! isempty, [x.match for x in collect(eachmatch(r"[0-9a-zA-Z_\\/:]*", name))]) |> join
end


Expand Down
2 changes: 0 additions & 2 deletions test/runtests

This file was deleted.

43 changes: 43 additions & 0 deletions test/tests_AppServer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@safetestset "AppServer functionality" begin

@safetestset "Start/stop servers" begin
using Genie
using Genie.AppServer

servers = Genie.AppServer.startup()
@test servers.webserver.state == :runnable
@test Genie.AppServer.SERVERS.webserver.state == :runnable

servers = Genie.AppServer.down()
sleep(1)
@test servers.webserver.state == :done
@test Genie.AppServer.SERVERS.webserver.state == :done

servers = Genie.AppServer.startup()
Genie.AppServer.down(; webserver = false)
sleep(1)
@test servers.webserver.state == :runnable
@test Genie.AppServer.SERVERS.webserver.state == :runnable

servers = Genie.AppServer.down(; webserver = true)
sleep(1)
@test servers.webserver.state == :done
@test Genie.AppServer.SERVERS.webserver.state == :done
end;

@safetestset "Update config when custom startup args" begin
using Genie
using Genie.AppServer

port = Genie.config.server_port
ws_port = Genie.config.websockets_port

Genie.AppServer.up(port+1_000; ws_port = ws_port+1_000)

@test Genie.config.server_port == port+1_000
@test Genie.config.websockets_port == ws_port+1_000

Genie.AppServer.down()
end;

end;

0 comments on commit b06f397

Please sign in to comment.