fluent-plugin-time-cutoff 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ced312074114226376fedaf33671d11804667825d8a50430c1ac54137aac535
4
- data.tar.gz: c11dc8c0510a8adec9475bac1382a003255bdb8e3af7de6f8aba46defa60ff16
3
+ metadata.gz: 77b479a1cb54f5eb1a189032c5c0acfde4a99f0f813afb800ec84d39a4e09e2e
4
+ data.tar.gz: 3d27e8cee579842f6705467ddbd8577f47aa72db134f592a82676c01ef758166
5
5
  SHA512:
6
- metadata.gz: dd2ea5a6907c0b27e95580c0081030de242dcd3cb85ef4bbd79a99918c369ee53680187a866c78e12016ae47d1d534c2b4461a5b6bd522e3f0b2ef691a3c1fb2
7
- data.tar.gz: 6d39a4673c35dac85aff1e96d4575e87c03f807973acdaa86dca01b6e729f587fbeeec8939a4683e7491ebf0d5cef86fbb0e38f65b70aa90d259db5347188b98
6
+ metadata.gz: 12ea75e58112114c23637be4f19083324040a64bd1528f9628da85077316c52b285aaafd54162a50421da9eff4df4e02d08754399a20cde5f87f374ec357a258
7
+ data.tar.gz: c4731fb66d9b66fc6778a5a614e5534d2f600f61c15ab26adaa75687fdcede90ebccf9714a97b1be69d27761ecf412d2f66917834e9e46ecbb211d365a09d381
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'fluent-plugin-time-cutoff'
8
- spec.version = '0.1.3'
8
+ spec.version = '0.2.0'
9
9
  spec.authors = ['Qrator Labs', 'Serge Tkatchouk']
10
10
  spec.email = ['devops@qrator.net', 'st@qrator.net']
11
11
 
@@ -82,7 +82,10 @@ module Fluent
82
82
  when :epoch_float
83
83
  time.to_f
84
84
  when :iso8601
85
- time.to_time.strftime(TIME_ISO8601)
85
+ # NOTE: Time.at(int) is used instead of EventTime#to_time, which was
86
+ # only added to Fluentd in v1.8.0. This keeps us compatible with the
87
+ # older Fluentd releases declared in the gemspec.
88
+ Time.at(time.to_i).strftime(TIME_ISO8601)
86
89
  end
87
90
  end
88
91
 
@@ -119,15 +122,31 @@ module Fluent
119
122
  # @param time [Integer|Float] incoming event time
120
123
  # @return [Fluent::EventTime] event time normalized to Fluentd's internal format
121
124
  def normalize_time(time)
122
- case time.class
125
+ case time
123
126
  when Integer
124
127
  Fluent::EventTime.new(time)
125
128
  when Float
126
129
  time_int, time_frac = time.divmod(1)
127
130
  Fluent::EventTime.new(time_int, (time_frac * 10**9).to_i)
128
131
  else
129
- log.warn "Unknown time format given: \"#{time.inspect}\"."
130
- Fluent::EventTime.new(time.to_i) || Fluent::EventTime.now
132
+ log.warn "Unknown time format given (#{time.class}): \"#{time.inspect}\"."
133
+ numeric = coerce_to_number(time)
134
+ numeric ? normalize_time(numeric) : Fluent::EventTime.now
135
+ end
136
+ end
137
+
138
+ # Try to coerce an arbitrary value into a number, or return nil.
139
+ # Uses begin/rescue rather than the Integer()/Float() "exception:"
140
+ # keyword (Ruby 2.6+) so the plugin keeps working on older Rubies.
141
+ # @param value the value to coerce
142
+ # @return [Integer,Float,nil] the parsed number, or nil if not numeric
143
+ def coerce_to_number(value)
144
+ Integer(value)
145
+ rescue ArgumentError, TypeError
146
+ begin
147
+ Float(value)
148
+ rescue ArgumentError, TypeError
149
+ nil
131
150
  end
132
151
  end
133
152
 
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-time-cutoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qrator Labs
8
8
  - Serge Tkatchouk
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2025-11-24 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fluentd
@@ -92,7 +91,6 @@ homepage: https://github.com/QratorLabs/fluent-plugin-time-cutoff
92
91
  licenses:
93
92
  - MIT
94
93
  metadata: {}
95
- post_install_message:
96
94
  rdoc_options: []
97
95
  require_paths:
98
96
  - lib
@@ -107,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
105
  - !ruby/object:Gem::Version
108
106
  version: '0'
109
107
  requirements: []
110
- rubygems_version: 3.3.27
111
- signing_key:
108
+ rubygems_version: 4.0.9
112
109
  specification_version: 4
113
110
  summary: Fluentd time-based filter plugin.
114
111
  test_files: []