Sha256: d42df7af4f595ac2d3d3e4c88760309cc2886fd352971f7a2686ecb6e8258e32

Contents?: true

Size: 726 Bytes

Versions: 4

Compression:

Stored size: 726 Bytes

Contents

# encoding:utf-8
module LocalPac
  class Server
    attr_reader :port, :host, :path, :environment

    def initialize(listen, environment = 'development')
      uri = URI.parse(listen)

      @port        = uri.port
      @host        = uri.host
      @environment = environment
    rescue => e
      fail Exceptions::ServerListenStatementInvalid, "I cannot parse the listen statement: #{listen}. It is invalid: #{e.message}"
    end

    def start
      cmd = []
      cmd << 'rackup'
      cmd << "-E #{environment}"
      cmd << "-P #{LocalPac.config.pid_file}"
      cmd << "-o #{host}"
      cmd << "-p #{port}"
      cmd << ::File.expand_path('../../../config.ru', __FILE__)

      exec(cmd.join(" "))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
local_pac-0.2.3 lib/local_pac/server.rb
local_pac-0.2.2 lib/local_pac/server.rb
local_pac-0.2.1 lib/local_pac/server.rb
local_pac-0.2.0 lib/local_pac/server.rb