Class: Schatz::Testers::IncrTest

Inherits:
Object
  • Object
show all
Defined in:
lib/schatz/testers/incr_test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, outputters = []) ⇒ IncrTest

Returns a new instance of IncrTest.



5
6
7
8
# File 'lib/schatz/testers/incr_test.rb', line 5

def  initialize(options={}, outputters=[])
  @options = options
  @outputters = outputters
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



4
5
6
# File 'lib/schatz/testers/incr_test.rb', line 4

def connections
  @connections
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/schatz/testers/incr_test.rb', line 4

def options
  @options
end

#outputObject

Returns the value of attribute output.



4
5
6
# File 'lib/schatz/testers/incr_test.rb', line 4

def output
  @output
end

Instance Method Details

#check_connections(connections) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/schatz/testers/incr_test.rb', line 10

def check_connections(connections)
  @connections = connections
  if @options[:direct_only]
    direct_check
  elsif @options[:proxy_only]
    links_check
  else
    direct_check
    links_check
  end
  @outputters.each { |outputter| outputter.generate }
end

#direct_checkObject



31
32
33
34
35
# File 'lib/schatz/testers/incr_test.rb', line 31

def direct_check
 match_gcm_connections.select { |c| c.direct? }.map do |connection|
    @outputters.each { |out| out.print(Input::ConnectionResult.new(connection).check) }
  end        
end


23
24
25
26
27
28
29
# File 'lib/schatz/testers/incr_test.rb', line 23

def links_check
  match_gcm_connections.select { |c| c.link? }.map do |connection|
    proxies.map do |proxy|
      @outputters.each { |out| out.print(Input::ConnectionResult.new(connection, proxy).check) }
    end                  
  end
end

#match_gcm_connectionsObject



37
38
39
# File 'lib/schatz/testers/incr_test.rb', line 37

def match_gcm_connections
 @options[:gcm] ? @connections.select { |c| c.gcm == @options[:gcm] } : @connections
end

#proxiesObject



41
42
43
# File 'lib/schatz/testers/incr_test.rb', line 41

def proxies
  @options[:proxies].values
end