Class: Quark::Quark::Mock::MockRuntime
Constant Summary
DatawireQuarkCore::Static::Unassigned
Instance Attribute Summary collapse
Instance Method Summary
collapse
_lazy_statics, static, unlazy_statics
#to_s
Constructor Details
#initialize(runtime) ⇒ MockRuntime
Returns a new instance of MockRuntime.
846
847
848
849
850
851
852
|
# File 'lib/quark/mock.rb', line 846
def initialize(runtime)
self.__init_fields__
(self).runtime = runtime
nil
end
|
Instance Attribute Details
#_currentTime ⇒ Object
Returns the value of attribute _currentTime.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def _currentTime
@_currentTime
end
|
#_executed_tasks ⇒ Object
Returns the value of attribute _executed_tasks.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def _executed_tasks
@_executed_tasks
end
|
#events ⇒ Object
Returns the value of attribute events.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def events
@events
end
|
#executed ⇒ Object
Returns the value of attribute executed.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def executed
@executed
end
|
#runtime ⇒ Object
Returns the value of attribute runtime.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def runtime
@runtime
end
|
#tasks ⇒ Object
Returns the value of attribute tasks.
836
837
838
|
# File 'lib/quark/mock.rb', line 836
def tasks
@tasks
end
|
Instance Method Details
#__init_fields__ ⇒ Object
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
|
# File 'lib/quark/mock.rb', line 1039
def __init_fields__()
self.runtime = nil
self.events = ::DatawireQuarkCore::List.new([])
self.tasks = ::DatawireQuarkCore::List.new([])
self._executed_tasks = ::DatawireQuarkCore::List.new([])
self.executed = 0
self._currentTime = 1000000
nil
end
|
#_getClass ⇒ Object
983
984
985
986
987
988
|
# File 'lib/quark/mock.rb', line 983
def _getClass()
return "quark.mock.MockRuntime"
nil
end
|
#_getField(name) ⇒ Object
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
|
# File 'lib/quark/mock.rb', line 990
def _getField(name)
if ((name) == ("runtime"))
return (self).runtime
end
if ((name) == ("events"))
return (self).events
end
if ((name) == ("tasks"))
return (self).tasks
end
if ((name) == ("_executed_tasks"))
return (self)._executed_tasks
end
if ((name) == ("executed"))
return (self).executed
end
if ((name) == ("_currentTime"))
return (self)._currentTime
end
return nil
nil
end
|
#_setField(name, value) ⇒ Object
#advanceClock(ms) ⇒ Object
920
921
922
923
924
925
|
# File 'lib/quark/mock.rb', line 920
def advanceClock(ms)
@_currentTime = (@_currentTime) + (ms)
nil
end
|
#callSafely(callee, defaultResult) ⇒ Object
976
977
978
979
980
981
|
# File 'lib/quark/mock.rb', line 976
def callSafely(callee, defaultResult)
return (callee).call(nil)
nil
end
|
#codec ⇒ Object
906
907
908
909
910
911
|
# File 'lib/quark/mock.rb', line 906
def codec()
return @runtime.codec()
nil
end
|
#fail(message) ⇒ Object
962
963
964
965
966
967
|
# File 'lib/quark/mock.rb', line 962
def fail(message)
@runtime.fail(message)
nil
end
|
#logger(topic) ⇒ Object
969
970
971
972
973
974
|
# File 'lib/quark/mock.rb', line 969
def logger(topic)
return @runtime.logger(topic)
nil
end
|
#now ⇒ Object
913
914
915
916
917
918
|
# File 'lib/quark/mock.rb', line 913
def now()
return @_currentTime
nil
end
|
#open(url, handler) ⇒ Object
882
883
884
885
886
887
|
# File 'lib/quark/mock.rb', line 882
def open(url, handler)
(@events) << (::Quark.quark.mock.SocketEvent.new(url, handler))
nil
end
|
#pump ⇒ Object
Execute all currently scheduled tasks.
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
|
# File 'lib/quark/mock.rb', line 860
def pump()
size = (@tasks).size
idx = 0
while ((idx) < (size)) do
if ((@_executed_tasks)[idx])
idx = (idx) + (1)
next
end
wrapper = (@tasks)[idx]
next_ = ((@tasks)[idx]).task
if (((wrapper)._scheduledFor) <= (self.now()))
(@_executed_tasks)[idx] = (true)
next_.onExecute(self)
@executed = (@executed) + (1)
end
idx = (idx) + (1)
end
nil
end
|
#request(request, handler) ⇒ Object
889
890
891
892
893
894
|
# File 'lib/quark/mock.rb', line 889
def request(request, handler)
(@events) << (::Quark.quark.mock.RequestEvent.new(request, handler))
nil
end
|
#respond(request, response) ⇒ Object
955
956
957
958
959
960
|
# File 'lib/quark/mock.rb', line 955
def respond(request, response)
@runtime.fail("Runtime.respond not yet supported by the MockRuntime")
nil
end
|
#schedule(handler, delayInSeconds) ⇒ Object
896
897
898
899
900
901
902
903
904
|
# File 'lib/quark/mock.rb', line 896
def schedule(handler, delayInSeconds)
task = ::Quark.quark.mock.MockTask.new(handler, delayInSeconds)
(task)._scheduledFor = (self.now()) + (((1000.0) * (delayInSeconds)).round())
(@tasks) << (task)
(@_executed_tasks) << (false)
nil
end
|
#serveHTTP(url, servlet) ⇒ Object
941
942
943
944
945
946
|
# File 'lib/quark/mock.rb', line 941
def serveHTTP(url, servlet)
@runtime.fail("Runtime.serveHTTP not yet supported by the MockRuntime")
nil
end
|
#serveWS(url, servlet) ⇒ Object
948
949
950
951
952
953
|
# File 'lib/quark/mock.rb', line 948
def serveWS(url, servlet)
@runtime.fail("Runtime.serveWS not yet supported by the MockRuntime")
nil
end
|
#sleep(seconds) ⇒ Object
927
928
929
930
931
932
|
# File 'lib/quark/mock.rb', line 927
def sleep(seconds)
@runtime.sleep(seconds)
nil
end
|
#uuid ⇒ Object
934
935
936
937
938
939
|
# File 'lib/quark/mock.rb', line 934
def uuid()
return @runtime.uuid()
nil
end
|