Class: Contentful::Bootstrap::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token) ⇒ Server

Returns a new instance of Server.



85
86
87
88
89
90
# File 'lib/contentful/bootstrap/server.rb', line 85

def initialize(token)
  @server = WEBrick::HTTPServer.new(Port: 5123)
  @server.mount '/', IndexController
  @server.mount '/oauth_callback', OAuthCallbackController
  @server.mount '/save_token', SaveTokenController, token
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



83
84
85
# File 'lib/contentful/bootstrap/server.rb', line 83

def server
  @server
end

Instance Method Details

#running?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/contentful/bootstrap/server.rb', line 100

def running?
  @server.status != :Stop
end

#startObject



92
93
94
# File 'lib/contentful/bootstrap/server.rb', line 92

def start
  Thread.new { @server.start }
end

#stopObject



96
97
98
# File 'lib/contentful/bootstrap/server.rb', line 96

def stop
  @server.shutdown
end