Module: EphemeralResponse::Configuration

Extended by:
Configuration
Included in:
Configuration
Defined in:
lib/ephemeral_response/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fixture_directoryObject



16
17
18
# File 'lib/ephemeral_response/configuration.rb', line 16

def fixture_directory
  @fixture_directory || "spec/fixtures/ephemeral_response"
end

#fixture_setObject

Returns the value of attribute fixture_set.



5
6
7
# File 'lib/ephemeral_response/configuration.rb', line 5

def fixture_set
  @fixture_set
end

#skip_expirationObject



62
63
64
# File 'lib/ephemeral_response/configuration.rb', line 62

def skip_expiration
  @skip_expiration || false
end

Instance Method Details

#debug_outputObject



29
30
31
# File 'lib/ephemeral_response/configuration.rb', line 29

def debug_output
  @debug_output ||= NullOutput.new
end

#debug_output=(io) ⇒ Object

Set an IO object to receive the debugging information.



21
22
23
24
25
26
27
# File 'lib/ephemeral_response/configuration.rb', line 21

def debug_output=(io)
  if io.respond_to?(:puts)
    @debug_output = io
  else
    raise Error, 'The debug_output object must respond to #puts'
  end
end

#effective_directoryObject



8
9
10
11
12
13
14
# File 'lib/ephemeral_response/configuration.rb', line 8

def effective_directory
  if fixture_set.nil? or fixture_set.to_s == 'default'
    fixture_directory
  else
    File.join(fixture_directory, fixture_set.to_s)
  end
end

#expirationObject



40
41
42
# File 'lib/ephemeral_response/configuration.rb', line 40

def expiration
  @expiration || one_day
end

#expiration=(expiration) ⇒ Object



33
34
35
36
37
38
# File 'lib/ephemeral_response/configuration.rb', line 33

def expiration=(expiration)
  if expiration.is_a?(Proc)
    expiration = instance_eval &expiration
  end
  @expiration = validate_expiration(expiration)
end

#host_registryObject



44
45
46
# File 'lib/ephemeral_response/configuration.rb', line 44

def host_registry
  @host_registry ||= Hash.new(proc {})
end

#register(host, &block) ⇒ Object



48
49
50
# File 'lib/ephemeral_response/configuration.rb', line 48

def register(host, &block)
  host_registry[host] = block
end

#resetObject



52
53
54
55
56
57
58
59
60
# File 'lib/ephemeral_response/configuration.rb', line 52

def reset
  @fixture_set = nil
  @expiration = nil
  @fixture_directory = nil
  @white_list = nil
  @skip_expiration = nil
  @host_registry = nil
  @debug_output = nil
end

#white_listObject



66
67
68
# File 'lib/ephemeral_response/configuration.rb', line 66

def white_list
  @white_list ||= []
end

#white_list=(*hosts) ⇒ Object



70
71
72
# File 'lib/ephemeral_response/configuration.rb', line 70

def white_list=(*hosts)
  @white_list = hosts.flatten
end