Class: Stickler::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/stickler/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stickler_root) ⇒ Server

Returns a new instance of Server.

Raises:



7
8
9
10
11
# File 'lib/stickler/server.rb', line 7

def initialize( stickler_root )
  @stickler_root = File.expand_path( stickler_root )
  raise ::Stickler::Error, "Stickler root directory '#{@stickler_root}' must already exist" unless File.directory?( @stickler_root )
  raise ::Stickler::Error, "Stickler root directory '#{@stickler_root}' must be writable" unless File.writable?( @stickler_root )
end

Instance Attribute Details

#stickler_rootObject (readonly)

The directory holding all the repositories



5
6
7
# File 'lib/stickler/server.rb', line 5

def stickler_root
  @stickler_root
end

Instance Method Details

#appObject



13
14
15
16
17
18
19
20
# File 'lib/stickler/server.rb', line 13

def app
  root = self.stickler_root
  Rack::Builder.app( Sinatra::Base.new ) do
    use Rack::CommonLogger
    use Stickler::Middleware::Server, :stickler_root => root
    use Stickler::Middleware::NotFound
  end
end