Sha256: ba12f50644b42633645101242d245408264ce304e14538a52da6625a3746c760

Contents?: true

Size: 800 Bytes

Versions: 15

Compression:

Stored size: 800 Bytes

Contents

require 'rack'
require 'rack/server'
require 'awestruct/rack/app'

module Awestruct
  module CLI
    class Server
      attr_reader :server

      def initialize(path, bind_addr=Options::DEFAULT_BIND_ADDR, port=Options::DEFAULT_PORT)
        @path      = path
        @bind_addr = bind_addr
        @port      = port
      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
                             )
      end 
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
awestruct-0.5.6.beta8 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta7 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta6 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta5 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta4 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta3 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta2 lib/awestruct/cli/server.rb
awestruct-0.5.6.beta lib/awestruct/cli/server.rb
awestruct-0.5.5 lib/awestruct/cli/server.rb
awestruct-0.5.4.2 lib/awestruct/cli/server.rb
awestruct-0.5.4.1 lib/awestruct/cli/server.rb
awestruct-0.5.4 lib/awestruct/cli/server.rb
awestruct-0.5.4.rc3 lib/awestruct/cli/server.rb
awestruct-0.5.4.rc2 lib/awestruct/cli/server.rb
awestruct-0.5.4.rc lib/awestruct/cli/server.rb