@@ -168,58 +168,56 @@ def mocked_time_stack_item
168168 end
169169end
170170
171- if RUBY_VERSION >= '2.1.0'
172- module Process #:nodoc:
173- class << self
174- alias_method :clock_gettime_without_mock , :clock_gettime
175-
176- def clock_gettime_mock_time ( clock_id , unit = :float_second )
177- mock_time = case clock_id
178- when Process ::CLOCK_MONOTONIC
179- mock_time_monotonic
180- when Process ::CLOCK_REALTIME
181- mock_time_realtime
182- end
183-
184- return clock_gettime_without_mock ( clock_id , unit ) unless Timecop . mock_process_clock? && mock_time
185-
186- divisor = case unit
187- when :float_second
188- 1_000_000_000.0
189- when :second
190- 1_000_000_000
191- when :float_millisecond
192- 1_000_000.0
193- when :millisecond
194- 1_000_000
195- when :float_microsecond
196- 1000.0
197- when :microsecond
198- 1000
199- when :nanosecond
200- 1
171+ module Process #:nodoc:
172+ class << self
173+ alias_method :clock_gettime_without_mock , :clock_gettime
174+
175+ def clock_gettime_mock_time ( clock_id , unit = :float_second )
176+ mock_time = case clock_id
177+ when Process ::CLOCK_MONOTONIC
178+ mock_time_monotonic
179+ when Process ::CLOCK_REALTIME
180+ mock_time_realtime
201181 end
202182
203- ( mock_time / divisor )
204- end
183+ return clock_gettime_without_mock ( clock_id , unit ) unless Timecop . mock_process_clock? && mock_time
184+
185+ divisor = case unit
186+ when :float_second
187+ 1_000_000_000.0
188+ when :second
189+ 1_000_000_000
190+ when :float_millisecond
191+ 1_000_000.0
192+ when :millisecond
193+ 1_000_000
194+ when :float_microsecond
195+ 1000.0
196+ when :microsecond
197+ 1000
198+ when :nanosecond
199+ 1
200+ end
201+
202+ ( mock_time / divisor )
203+ end
205204
206- alias_method :clock_gettime , :clock_gettime_mock_time
205+ alias_method :clock_gettime , :clock_gettime_mock_time
207206
208- private
207+ private
209208
210- def mock_time_monotonic
211- mocked_time_stack_item = Timecop . top_stack_item
212- mocked_time_stack_item . nil? ? nil : mocked_time_stack_item . monotonic
213- end
209+ def mock_time_monotonic
210+ mocked_time_stack_item = Timecop . top_stack_item
211+ mocked_time_stack_item . nil? ? nil : mocked_time_stack_item . monotonic
212+ end
214213
215- def mock_time_realtime
216- mocked_time_stack_item = Timecop . top_stack_item
214+ def mock_time_realtime
215+ mocked_time_stack_item = Timecop . top_stack_item
217216
218- return nil if mocked_time_stack_item . nil?
217+ return nil if mocked_time_stack_item . nil?
219218
220- t = mocked_time_stack_item . time
221- t . to_i * 1_000_000_000 + t . nsec
222- end
219+ t = mocked_time_stack_item . time
220+ t . to_i * 1_000_000_000 + t . nsec
223221 end
224222 end
225223end
0 commit comments