-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into multi-thread-gen-trial
- Loading branch information
Showing
15 changed files
with
222 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
require 'rack' | ||
require 'rack/builder' | ||
require 'rack/server' | ||
require 'awestruct/rack/app' | ||
require 'awestruct/rack/generate' | ||
|
||
module Awestruct | ||
module CLI | ||
class Server | ||
attr_reader :server | ||
|
||
def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT) | ||
def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT, generate_on_access=Options::DEFAULT_GENERATE_ON_ACCESS) | ||
@path = path | ||
@bind_addr = bind_addr | ||
@port = port | ||
@generate_on_access = generate_on_access | ||
end | ||
|
||
def run | ||
url = %(http://#{Options::LOCAL_HOSTS[@bind_addr] || @bind_addr}:#{@port}) | ||
msg = %(Starting preview server at #{url} (Press Ctrl-C to shutdown)) | ||
puts %(#{'*' * msg.length}\n#{msg}\n#{'*' * msg.length}\n) | ||
::Rack::Server::start( :app => Awestruct::Rack::App.new( @path ), | ||
:Port => @port, | ||
:Host => @bind_addr | ||
) | ||
|
||
path = @path | ||
generate_on_access = @generate_on_access | ||
app = ::Rack::Builder.new do | ||
use Awestruct::Rack::GenerateOnAccess if generate_on_access | ||
map "/" do | ||
run Awestruct::Rack::App.new( path ) | ||
end | ||
end | ||
|
||
::Rack::Server::start( :app => app, | ||
:Port => @port, | ||
:Host => @bind_addr | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.