Class: Kintara::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/kintara/config.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Configuration) initialize(&block)

A new instance of Configuration



28
29
30
31
32
# File 'lib/kintara/config.rb', line 28

def initialize(&block)
    @listeners = []    # List of ports to listen on
    @log_level = :info # How much information should we log?
    @vhosts    = {}    # Hosts that we'll service
end

Instance Attribute Details

- (Object) listeners (readonly)

Returns the value of attribute listeners



26
27
28
# File 'lib/kintara/config.rb', line 26

def listeners
  @listeners
end

- (Object) log_level (readonly)

Returns the value of attribute log_level



26
27
28
# File 'lib/kintara/config.rb', line 26

def log_level
  @log_level
end

- (Object) vhosts (readonly)

Returns the value of attribute vhosts



26
27
28
# File 'lib/kintara/config.rb', line 26

def vhosts
  @vhosts
end

Instance Method Details

- (Object) listen_for_clients(*args)



50
51
52
53
54
55
# File 'lib/kintara/config.rb', line 50

def listen_for_clients(*args)
    listener      = prep_listener(*args)
    listener.kind = :c2s

    @listeners << listener
end

- (Object) listen_for_servers(*args)



57
58
59
60
61
62
# File 'lib/kintara/config.rb', line 57

def listen_for_servers(*args)
    listener      = prep_listener(*args)
    listener.kind = :s2s

    @listeners << listener
end

- (Object) logging(level)



38
39
40
# File 'lib/kintara/config.rb', line 38

def logging(level)
    @log_level = level.to_s
end

- (Object) prep_listener(port, host = '*')



42
43
44
45
46
47
48
# File 'lib/kintara/config.rb', line 42

def prep_listener(port, host = '*')
    listener         = OpenStruct.new
    listener.port    = port.to_i
    listener.bind_to = host.to_s

    listener
end

- (Object) verify



34
35
36
# File 'lib/kintara/config.rb', line 34

def verify
    # XXX - Configuration#verify
end

- (Object) virtual_host(name, &block)



68
69
70
71
72
73
74
75
76
# File 'lib/kintara/config.rb', line 68

def virtual_host(name, &block)
    vhost      = OpenStruct.new
    vhost.name = name

    vhost.extend(ConfigVirtualHost)
    vhost.instance_eval(&block)

    @vhosts[name] = vhost
end

- (Object) virtual_hosts(&block)



64
65
66
# File 'lib/kintara/config.rb', line 64

def virtual_hosts(&block)
    virtual_host(:all, &block)
end