fluent-plugin-typecast 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -22,11 +22,11 @@ GEM
22
22
  nokogiri (~> 1.5.2)
23
23
  oauth2
24
24
  hashie (2.0.5)
25
- highline (1.6.19)
25
+ highline (1.6.20)
26
26
  http_parser.rb (0.5.3)
27
27
  httpauth (0.2.0)
28
28
  iobuffer (1.1.2)
29
- jeweler (1.8.7)
29
+ jeweler (1.8.8)
30
30
  builder
31
31
  bundler (~> 1.0)
32
32
  git (>= 1.2.5)
@@ -35,11 +35,11 @@ GEM
35
35
  nokogiri (= 1.5.10)
36
36
  rake
37
37
  rdoc
38
- json (1.8.0)
38
+ json (1.8.1)
39
39
  jwt (0.1.8)
40
40
  multi_json (>= 1.5)
41
41
  msgpack (0.4.7)
42
- multi_json (1.7.9)
42
+ multi_json (1.8.2)
43
43
  multi_xml (0.5.5)
44
44
  multipart-post (1.2.0)
45
45
  nokogiri (1.5.10)
data/README.rdoc CHANGED
@@ -1,16 +1,17 @@
1
1
  = fluent-plugin-typecast
2
2
 
3
- Description goes here.
3
+ typecast output plugin for fluentd.
4
4
 
5
5
  == Configuration
6
6
 
7
- [item_types] KEY:TYPE pairs separated by comma(,). support types:
8
-
9
- - integer
10
- - string
11
- - time
12
- - bool
13
- - array
7
+ [item_types]
8
+ KEY:TYPE pairs separated by comma(,). support types:
9
+ - integer
10
+ - float
11
+ - string
12
+ - time
13
+ - bool
14
+ - array
14
15
 
15
16
  [time_format] format for typecast to time
16
17
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fluent-plugin-typecast"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["MORIYA Taro"]
12
- s.date = "2013-08-29"
12
+ s.date = "2013-12-01"
13
13
  s.description = "typecast output plugin for fluentd"
14
14
  s.email = "taro.toys@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -32,11 +32,11 @@ Gem::Specification.new do |s|
32
32
  s.homepage = "http://github.com/tarom/fluent-plugin-typecast"
33
33
  s.licenses = ["Apache License 2.0"]
34
34
  s.require_paths = ["lib"]
35
- s.rubygems_version = "2.0.7"
35
+ s.rubygems_version = "1.8.25"
36
36
  s.summary = "typecast output plugin for fluentd"
37
37
 
38
38
  if s.respond_to? :specification_version then
39
- s.specification_version = 4
39
+ s.specification_version = 3
40
40
 
41
41
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
42
  s.add_runtime_dependency(%q<fluentd>, ["~> 0.10.0"])
@@ -22,6 +22,11 @@ class TypecastOutput < Output
22
22
  def configure(conf)
23
23
  super
24
24
  raise ConfigError, "typecast: 'prefix' or 'tag' is required" unless @tag or @prefix
25
+
26
+ @cast_procs = {}
27
+ @item_types.map {|key, type|
28
+ @cast_procs[key] = cast_proc(type)
29
+ }
25
30
  end
26
31
 
27
32
  def emit(tag, es, chain)
@@ -32,30 +37,32 @@ class TypecastOutput < Output
32
37
  "#{@prefix}.#{tag}"
33
38
  end
34
39
  es.each do |time, record|
35
- record.keys.each do |key|
36
- record[key] = cast(key, record[key])
40
+ record.each_key do |key|
41
+ if cast_proc = @cast_procs[key]
42
+ record[key] = cast_proc.call(record[key])
43
+ end
37
44
  end
38
45
  Fluent::Engine.emit(tag, time, record)
39
46
  end
40
47
  chain.next
41
48
  end
42
49
 
43
- def cast(key, value)
44
- case @item_types[key]
50
+ def cast_proc(key)
51
+ case key
45
52
  when 'string'
46
- value.to_s
53
+ Proc.new {|value| value.to_s }
47
54
  when 'integer'
48
- value.to_i
55
+ Proc.new {|value| value.to_i }
49
56
  when 'float'
50
- value.to_f
57
+ Proc.new {|value| value.to_f }
51
58
  when 'bool'
52
- Config.bool_value(value)
59
+ Proc.new {|value| Config.bool_value(value) }
53
60
  when 'time'
54
- Time.strptime(value, @time_format)
61
+ Proc.new {|value| Time.strptime(value, @time_format) }
55
62
  when 'array'
56
- value.split(/\s*,\s*/)
63
+ Proc.new {|value| value.split(/\s*,\s*/) }
57
64
  else
58
- value
65
+ Proc.new {|value| value }
59
66
  end
60
67
  end
61
68
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-typecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - MORIYA Taro
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-08-29 00:00:00.000000000 Z
12
+ date: 2013-12-01 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: fluentd
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rdoc
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: jeweler
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -74,25 +81,29 @@ files:
74
81
  homepage: http://github.com/tarom/fluent-plugin-typecast
75
82
  licenses:
76
83
  - Apache License 2.0
77
- metadata: {}
78
84
  post_install_message:
79
85
  rdoc_options: []
80
86
  require_paths:
81
87
  - lib
82
88
  required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
83
90
  requirements:
84
91
  - - ! '>='
85
92
  - !ruby/object:Gem::Version
86
93
  version: '0'
94
+ segments:
95
+ - 0
96
+ hash: 2044205134208786053
87
97
  required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
88
99
  requirements:
89
100
  - - ! '>='
90
101
  - !ruby/object:Gem::Version
91
102
  version: '0'
92
103
  requirements: []
93
104
  rubyforge_project:
94
- rubygems_version: 2.0.7
105
+ rubygems_version: 1.8.25
95
106
  signing_key:
96
- specification_version: 4
107
+ specification_version: 3
97
108
  summary: typecast output plugin for fluentd
98
109
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YWQ2YmQzMTk0YTVlYzE4NzcyY2JlMjY5ODYzMTZmMzY4ZWE1YmZlNw==
5
- data.tar.gz: !binary |-
6
- ZDBkOTQxMjVjOTczYjEyY2Y2MDA0ZWNiYjEyMzE2MjIwMjJlMWU5ZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjAyMWI5YmJjMTMyOGVmYjc3YmYxOGZlNTIxMWUzZjhjNzJmOWQ0NzVkZTJj
10
- ODFkN2EyNTgyYzZmOWU4NWJkMjVjMGYxNmViMWM2MTFmZDM0YWM3Y2E0NDFj
11
- NGQxNTIyMjU3MDExMzA3MzY4ZGQ0MzM1ZjhlNDg5OTIyMGY5N2I=
12
- data.tar.gz: !binary |-
13
- NDAxNzI1MDQ5M2YzYjRkZDhkMmJhNGMyOTI5OGM1NDQ4OTEyNTZkMWMxYzc5
14
- YjUxZmIwMmMyZjlkOGQ3YTFjYTc1YmVkY2QzYjgxOTY1MTlhYjkyNDU1N2Zi
15
- OTdlYTI4ZWVjMmM1ZGVjNjAzYjY2NzBiYmE3ZjAyMWM4NDIwNjI=