From 969e1e8cf306a695c7c0db8a20767464e4139706 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Tue, 14 Nov 2017 08:56:02 +0100 Subject: [PATCH] Use a plain optional argument for normalize_timestamp --- lib/rackstash/encoder/helper/timestamp.rb | 2 +- spec/rackstash/encoder/helper/timestamp_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rackstash/encoder/helper/timestamp.rb b/lib/rackstash/encoder/helper/timestamp.rb index 7f7f190..ecd30d5 100644 --- a/lib/rackstash/encoder/helper/timestamp.rb +++ b/lib/rackstash/encoder/helper/timestamp.rb @@ -28,7 +28,7 @@ module Rackstash # hash. By default, we use the `"@timestamp"` field. # @return [Hash] the given event with the `field` key set as an ISO 8601 # formatted time string. - def normalize_timestamp(event, field: FIELD_TIMESTAMP) #:doc: + def normalize_timestamp(event, field = FIELD_TIMESTAMP) #:doc: time = event[field] if time.is_a?(Time) || time.is_a?(DateTime) diff --git a/spec/rackstash/encoder/helper/timestamp_spec.rb b/spec/rackstash/encoder/helper/timestamp_spec.rb index 4b03d94..70b30cb 100644 --- a/spec/rackstash/encoder/helper/timestamp_spec.rb +++ b/spec/rackstash/encoder/helper/timestamp_spec.rb @@ -53,7 +53,7 @@ describe Rackstash::Encoder::Helper::Timestamp do event['@timestamp'] = Time.parse('2016-10-17 13:37:00 +03:00') event['custom'] = Time.parse('2016-10-17 20:42:00 +07:00') - expect(helper.normalize_timestamp(event, field: 'custom')).to match( + expect(helper.normalize_timestamp(event, 'custom')).to match( '@timestamp' => instance_of(Time), 'custom' => '2016-10-17T13:42:00.000000Z' )