Class: MockWS::RouteManager

Inherits:
Object
  • Object
show all
Extended by:
Carioca::Injector
Defined in:
lib/mockws/route_manager.rb

Constant Summary collapse

DEFAULT_STATUS =
200

Class Method Summary collapse

Class Method Details

.configure(service) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/mockws/route_manager.rb', line 17

def self.configure(service)
    @service = service
    output.info "Mock routes initialisation : "
    configuration.settings.services.select {|key,value| [:static,:inline].include? value[:type]}.each do |_key, definition|
        create_route(definition)    
    end
end

.get_response_time(value) ⇒ Object



10
11
12
13
14
# File 'lib/mockws/route_manager.rb', line 10

def self.get_response_time(value)
    return {value: value[:response_time], type: :static} if value.include? :response_time
    return {value: rand(1..value[:random_time]), type: :random} if value.include? :random_time
    return {value: 0, type: :instant} 
end

.get_sessionString

build a session number

Returns:

  • (String)

    Session number



27
28
29
# File 'lib/mockws/route_manager.rb', line 27

def self.get_session
    return "#{Time.now.to_i.to_s}#{rand(999)}"
end