fluent-plugin-time_parser 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -51,7 +51,7 @@ You must add at least one of these params.
51
51
 
52
52
  ### time_zone
53
53
 
54
- Necessary. time_parser uses the TZInfo (http://tzinfo.rubyforge.org/) library to handle time zones.
54
+ Optional. time_parser uses the TZInfo (http://tzinfo.rubyforge.org/) library to handle time zones.
55
55
 
56
56
  ### parsed_time_tag, parsed_hour_tag, parsed_date_tag
57
57
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'fluent-plugin-time_parser'
3
- gem.version = '0.0.4'
3
+ gem.version = '0.0.5'
4
4
  gem.authors = ['Carlos Donderis', 'Michael H. Oshita']
5
5
  gem.email = ['cdonderis@gmail.com', 'ijinpublic+github@gmail.com']
6
6
  gem.homepage = 'http://github.com/cads/fluent-plugin-time_parser'
@@ -7,7 +7,7 @@ module Fluent
7
7
  Fluent::Plugin.register_output('time_parser', self)
8
8
 
9
9
  config_param :key, :string, :default => 'time'
10
- config_param :time_zone, :string
10
+ config_param :time_zone, :string, :default => ''
11
11
  config_param :parsed_time_tag, :string, :default => 'parsed_time'
12
12
  config_param :parsed_hour_tag, :string, :default => 'parsed_hour'
13
13
  config_param :parsed_date_tag, :string, :default => 'parsed_date'
@@ -21,7 +21,6 @@ module Fluent
21
21
  !add_tag_suffix
22
22
  )
23
23
  raise ConfigError, "out_extract_query_params: At least one of remove_tag_prefix/remove_tag_suffix/add_tag_prefix/add_tag_suffix is required to be set."
24
- raise ConfigError, "You must specify a time zone" unless time_zone
25
24
  end
26
25
  end
27
26
 
@@ -44,19 +43,22 @@ module Fluent
44
43
 
45
44
  def filter_record(tag, time, record)
46
45
  begin
47
- original_time = DateTime.parse(record[key])
48
- tz = TZInfo::Timezone.get(time_zone.capitalize)
46
+ record_time = DateTime.parse(record[key])
49
47
 
50
- period = tz.period_for_utc(original_time)
51
- rational_offset = period.utc_total_offset_rational
48
+ if time_zone && time_zone != ""
49
+ tz = TZInfo::Timezone.get(time_zone.capitalize)
52
50
 
53
- converted_time = tz.utc_to_local(original_time).new_offset(rational_offset) -
54
- period.utc_total_offset_rational
51
+ period = tz.period_for_utc(record_time)
52
+ rational_offset = period.utc_total_offset_rational
55
53
 
56
- date = converted_time.to_date.to_s
57
- hour = converted_time.hour.to_s
54
+ record_time = tz.utc_to_local(record_time).new_offset(rational_offset) -
55
+ period.utc_total_offset_rational
58
56
 
59
- record[parsed_time_tag] = converted_time.to_s
57
+ end
58
+ date = record_time.to_date.to_s
59
+ hour = record_time.hour.to_s
60
+
61
+ record[parsed_time_tag] = record_time.to_s
60
62
  record[parsed_date_tag] = date
61
63
  record[parsed_hour_tag] = hour
62
64
 
@@ -22,34 +22,35 @@ class TimeParserOutputTest < Test::Unit::TestCase
22
22
  d = create_driver(%[
23
23
  key test
24
24
  add_tag_prefix extracted.
25
- time_zone Tokyo
25
+ time_zone Asia/Tokyo
26
26
  ])
27
27
  assert_equal 'test', d.instance.key
28
28
  assert_equal 'extracted.', d.instance.add_tag_prefix
29
- assert_equal 'Tokyo', d.instance.time_zone
29
+ assert_equal 'Asia/Tokyo', d.instance.time_zone
30
30
 
31
31
  #Default Key
32
32
  d = create_driver(%[
33
33
  add_tag_prefix extracted.
34
- time_zone Tokyo
34
+ time_zone Asia/Tokyo
35
35
  ])
36
36
  assert_equal 'time', d.instance.key
37
37
  assert_equal 'extracted.', d.instance.add_tag_prefix
38
- assert_equal 'Tokyo', d.instance.time_zone
38
+ assert_equal 'Asia/Tokyo', d.instance.time_zone
39
39
 
40
40
  #No Prefix
41
41
  assert_raise(Fluent::ConfigError) do
42
42
  create_driver(%[
43
- time_zone Tokyo
43
+ time_zone Asia/Tokyo
44
44
  ])
45
45
  end
46
+
46
47
  #No TimeZone
47
- assert_raise(Fluent::ConfigError) do
48
- create_driver(%[
49
- key test
50
- add_tag_prefix extracted.
51
- ])
52
- end
48
+ d = create_driver(%[
49
+ key test
50
+ add_tag_prefix extracted.
51
+ ])
52
+ assert_equal 'test', d.instance.key
53
+ assert_equal 'extracted.', d.instance.add_tag_prefix
53
54
  end
54
55
 
55
56
  def test_filter_record
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-time_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 1.8.24
132
+ rubygems_version: 1.8.25
133
133
  signing_key:
134
134
  specification_version: 3
135
135
  summary: Fluentd plugin to parse the time parameter.