Class: Auger::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/auger/project.rb,
lib/auger/plugin/dns.rb,
lib/auger/plugin/http.rb,
lib/auger/plugin/redis.rb,
lib/auger/plugin/socket.rb,
lib/auger/plugin/telnet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Project

Returns a new instance of Project.



14
15
16
17
18
19
# File 'lib/auger/project.rb', line 14

def initialize(name)
  @name = name
  @servers = []
  @connections = []
  self
end

Instance Attribute Details

#connections(*roles) ⇒ Object

return all connections, or those matching list of roles; connections with no roles match all, or find intersection with roles list



54
55
56
# File 'lib/auger/project.rb', line 54

def connections
  @connections
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/auger/project.rb', line 6

def name
  @name
end

#servers(*roles) ⇒ Object

get list of server objects (optionally matching list of roles)



42
43
44
# File 'lib/auger/project.rb', line 42

def servers
  @servers
end

Class Method Details

.load(name, &block) ⇒ Object



8
9
10
11
12
# File 'lib/auger/project.rb', line 8

def self.load(name, &block)
  project = new(name)
  project.instance_eval(&block)
  project
end

Instance Method Details

#dns(port = 53, &block) ⇒ Object



6
7
8
# File 'lib/auger/plugin/dns.rb', line 6

def dns(port = 53, &block)
  @connections << Dns.load(port, &block)
end

#http(port = 80, &block) ⇒ Object



26
27
28
# File 'lib/auger/plugin/http.rb', line 26

def http(port = 80, &block)
  @connections << Http.load(port, &block)
end

#https(port = 443, &block) ⇒ Object



30
31
32
33
34
# File 'lib/auger/plugin/http.rb', line 30

def https(port = 443, &block)
  http = Http.load(port, &block)
  http.ssl(true)
  @connections << http
end

#redis(port = 6379, &block) ⇒ Object



7
8
9
# File 'lib/auger/plugin/redis.rb', line 7

def redis(port = 6379, &block)
  @connections << Auger::Redis.load(port, &block)
end

#server(*args) ⇒ Object

set server, or list of server names, with optional roles and options e.g. server server1, server2, :roleA, :roleB, options => values servers can be any combination in:

strings: passed through HostRange to make an array
array: or expressions that returns an array
block: returning an array (arrays will be flattened)

roles are symbols options are hash members, must be last args



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/auger/project.rb', line 29

def server(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  roles = args.select { |arg| arg.class == Symbol }
  servers =
    args.select { |arg| arg.class == String }.map { |arg| HostRange.parse(arg) } +
    args.select { |arg| arg.class == Array } +
    (block_given? ? yield : [])
  @servers += servers.flatten.map do |name|
    Auger::Server.new(name, *roles, options)
  end
end

#socket(port, &block) ⇒ Object



5
6
7
# File 'lib/auger/plugin/socket.rb', line 5

def socket(port, &block)
  @connections << Socket.load(port, &block)
end

#telnet(port = 23, &block) ⇒ Object



5
6
7
# File 'lib/auger/plugin/telnet.rb', line 5

def telnet(port = 23, &block)
  @connections << Telnet.load(port, &block)
end

#testsObject

return list of all test objects for this project



63
64
65
66
67
68
69
# File 'lib/auger/project.rb', line 63

def tests
  @connections.map do |connection|
    connection.requests.map do |request|
      request.tests.map { |test| test }
    end
  end.flatten
end