Class: BPM::Server

Inherits:
Rack::Server
  • Object
show all
Defined in:
lib/bpm/server.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, options = {}) ⇒ Server

Returns a new instance of Server.



9
10
11
12
13
14
15
# File 'lib/bpm/server.rb', line 9

def initialize(project, options={})
  options = default_options.merge(options)
  options[:server] ||= 'thin'
  @project = project
  @mode    = options[:mode] || :debug
  super options
end

Instance Attribute Details

#modeObject (readonly)

Returns the value of attribute mode.



28
29
30
# File 'lib/bpm/server.rb', line 28

def mode
  @mode
end

#projectObject (readonly)

Returns the value of attribute project.



27
28
29
# File 'lib/bpm/server.rb', line 27

def project
  @project
end

Class Method Details

.start(project, options = nil) ⇒ Object



17
18
19
# File 'lib/bpm/server.rb', line 17

def self.start(project, options=nil)
  new(project, options).start
end

Instance Method Details

#appObject



30
31
32
33
34
35
36
37
38
# File 'lib/bpm/server.rb', line 30

def app
  cur_project = @project
  cur_mode    = @mode

  @app ||= ::Rack::Builder.new do
    use BPM::Rack, cur_project, :mode => cur_mode
    run ::Rack::Directory.new cur_project.root_path
  end.to_app
end

#startObject



21
22
23
24
25
# File 'lib/bpm/server.rb', line 21

def start
  super
rescue Errno::EADDRINUSE
  raise BPM::Error, "Port #{options[:Port]} is already in use. Please use --port to specify a different port."
end