Module: Communist

Defined in:
lib/communist.rb,
lib/communist/const.rb,
lib/communist/server.rb,
lib/communist/version.rb,
lib/communist/null_server.rb

Defined Under Namespace

Modules: Const Classes: CommunistError, NullServer, Server

Constant Summary collapse

VERSION =
"0.3.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.appObject

Returns the value of attribute app.



13
14
15
# File 'lib/communist.rb', line 13

def app
  @app
end

.app_hostObject

Returns the value of attribute app_host.



9
10
11
# File 'lib/communist.rb', line 9

def app_host
  @app_host
end

.default_hostObject

Returns the value of attribute default_host.



10
11
12
# File 'lib/communist.rb', line 10

def default_host
  @default_host
end

.run_serverObject

Returns the value of attribute run_server.



12
13
14
# File 'lib/communist.rb', line 12

def run_server
  @run_server
end

.server_hostObject

Returns the value of attribute server_host.



11
12
13
# File 'lib/communist.rb', line 11

def server_host
  @server_host
end

.server_portObject

Returns the value of attribute server_port.



11
12
13
# File 'lib/communist.rb', line 11

def server_port
  @server_port
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Configure Communist options

Communist.configure do |config|
  config.server_host = 'http://localhost'
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Communist)

    the object that the method was called on



21
22
23
# File 'lib/communist.rb', line 21

def configure
  yield self
end

.run_default_server(app, port, &block) ⇒ Object

By default run thin or fall back on webrick



45
46
47
48
49
50
51
52
53
54
# File 'lib/communist.rb', line 45

def run_default_server(app, port, &block)
  begin
    require 'rack/handler/thin'
    Thin::Logging.silent = true
    Rack::Handler::Thin.run(app, :Port => port, &block)
  rescue LoadError
    require 'rack/handler/webrick'
    Rack::Handler::WEBrick.run(app, :Port => port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0), &block)
  end
end

.server(&block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/communist.rb', line 29

def server(&block)
  if block_given?
    @server = block
  else
    @server
  end
end

.server=(instance) ⇒ Object



25
26
27
# File 'lib/communist.rb', line 25

def server=(instance)
  @server = instance
end

.serversObject

Stores server instances.



39
40
41
# File 'lib/communist.rb', line 39

def servers
  @servers ||= {}
end