fluent-plugin-simplearithmetic 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 9896bc5f77125536a6e6efec0c519947c8b8c487
4
- data.tar.gz: 0416741cba7d514ed3bdaf97f063ad03a3d87f33
3
+ metadata.gz: 0729561faf0a6bdfe8b37615452a2db2207e0d9a
4
+ data.tar.gz: 3d5dbbf8965144c1c2b6403f38210d1532963399
5
5
  SHA512:
6
- metadata.gz: 6f18b7a4f4f43996d715a41231946bf83eecf67a2af69d096e82a5f72d60a7e0946c62a9a3c88482fc635b3dbd57d0905f95ba3718fdf6d35c89a2d7e4089ed7
7
- data.tar.gz: 2574ec4b858814077aa20b9ceb44a4d8f95588fc233ee661229495035394aec602132399e88e2cc35446071eec68ead80be5151540a34d2beb1070a044646f0f
6
+ metadata.gz: cf12f6164a95569664a573f10e52cfdddee25cefaa1ba73bf6dd95f71ce5504ec47cfe22b8b7b5798eb16421d4e7647708d63e8d37181ef6c76888bc7904d616
7
+ data.tar.gz: cecbe91a3a1f9ecabb386f2c285ff008f0d30c223772cbf79725f6c3da09b3417c571717d90430d2c41908a24d50d8e6b72b2995e774fbe29ee9cdb787350f34
data/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ fluent-plugin-simplearithmetic
2
+
3
+ Copyright 2014- Takahiro Kamatani
4
+
5
+ The portion of this product was originally developed by Muddy Dixon, for fluent-plugin-datacalculator.
6
+ fluent-plugin-datacalculator is licensed under Apache License v2.0 and available at https://github.com/muddydixon/fluent-plugin-datacalculator
data/README.md CHANGED
@@ -5,7 +5,7 @@ This fluentd output plugin helps you to calculate messages.
5
5
  This plugin is based on [fluent-plugin-datacalculator](https://github.com/muddydixon/fluent-plugin-datacalculator) written by Muddy Dixon. This plugin doesn't have a summarize function which provided by fluent-plugin-datacalculator.
6
6
 
7
7
 
8
- ## Installaion
8
+ ## Installation
9
9
 
10
10
  ```
11
11
  $ fluent-gem install fluent-plugin-simplearithmetic
@@ -120,22 +120,25 @@ All formulas will be evaluated as ruby sentences. Some json fields will not be f
120
120
 
121
121
  ```
122
122
  <formulas>
123
- var-1 a + b
124
- var$2 c * d
123
+ var-1 a + b
124
+ var$2 c * d
125
+ var@ "@@@"
125
126
  </formulas>
126
127
  ```
127
128
 
128
129
  will raise an syntax error in the initialize process of fluentd.
129
130
 
130
- To get rid of this case, you can set `replace_hyphen` and `replace_dollar` in the configuration and formulas.
131
+ To get rid of this case, you can set `replace_hyphen`, `replace_at` and `replace_dollar` in the configuration and formulas.
131
132
 
132
133
  ```
133
134
  replace_hyphen __H__
134
135
  replace_dollar __D__
136
+ replace_at __AT__
135
137
 
136
138
  <formulas>
137
- var__H__1 a + b
138
- var__D__2 c * d
139
+ var__H__1 a + b
140
+ var__D__2 c * d
141
+ var__AT__ "@@@"
139
142
  </formulas>
140
143
  ```
141
144
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-simplearithmetic"
6
- spec.version = "0.0.1"
6
+ spec.version = "0.0.2"
7
7
  spec.authors = ["Takahiro Kamatani"]
8
8
  spec.email = ["buhii314@gmail.com"]
9
9
  spec.description = %q{Fluent plugin to calculate messages.}
@@ -13,6 +13,7 @@ module Fluent
13
13
 
14
14
  config_param :replace_hyphen, :string, :default => '__HYPHON__'
15
15
  config_param :replace_dollar, :string, :default => '__DOLLAR__'
16
+ config_param :replace_at, :string, :default => '__AT__'
16
17
 
17
18
  attr_accessor :_formulas
18
19
 
@@ -91,7 +92,7 @@ module Fluent
91
92
  # 'var-1' -> 'var__HYPHEN__1'
92
93
  new_record = {}
93
94
  record.each_pair {|key, value|
94
- new_key = key.gsub('-', @replace_hyphen).gsub('$', @replace_dollar)
95
+ new_key = key.gsub('-', @replace_hyphen).gsub('$', @replace_dollar).gsub('@', @replace_at)
95
96
  new_record[new_key] = value
96
97
  }
97
98
  return new_record
@@ -101,7 +102,7 @@ module Fluent
101
102
  # 'var__HYPHEN__1' -> 'var-1'
102
103
  new_record = {}
103
104
  record.each_pair {|key, value|
104
- new_key = key.gsub(@replace_hyphen, '-').gsub(@replace_dollar, '$')
105
+ new_key = key.gsub(@replace_hyphen, '-').gsub(@replace_dollar, '$').gsub(@replace_at, '@')
105
106
  new_record[new_key] = value
106
107
  }
107
108
  new_record
@@ -50,19 +50,21 @@ class SimpleArithmeticOutputTest < Test::Unit::TestCase
50
50
  d1 = create_driver %[
51
51
  replace_hyphen __H__
52
52
  replace_dollar __D__
53
+ replace_at __AT__
53
54
  <formulas>
54
- var__H__1 __H__2 * var__D__3
55
- __D__3 __D__1 + __D__2
55
+ var__H__1 __H__2 * var__D__3
56
+ __D__3 __D__1 + __D__2
57
+ __AT__timestamp var__AT__
56
58
  </formulas>
57
59
  ]
58
60
  assert_equal '__H__', d1.instance.replace_hyphen
59
61
  assert_equal '__D__', d1.instance.replace_dollar
60
62
  d1.run do
61
63
  time = Time.parse("2011-01-02 13:14:15 UTC").to_i
62
- d1.emit({'-2'=>10, 'var$3'=>20}, time)
64
+ d1.emit({'-2'=>10, 'var$3'=>20, 'var@'=>'__at'}, time)
63
65
  d1.emit({'$1'=>10, '$2'=>20}, time)
64
66
  end
65
- assert_equal d1.emits[0][2], {"-2"=>10, "var$3"=>20, "var-1"=>200}
67
+ assert_equal d1.emits[0][2], {"-2"=>10, "var$3"=>20, "var-1"=>200, "var@"=>"__at", "@timestamp"=>"__at"}
66
68
  assert_equal d1.emits[1][2], {"$1"=>10, "$2"=>20, "$3"=>30}
67
69
  end
68
70
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-simplearithmetic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Kamatani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -48,6 +48,7 @@ files:
48
48
  - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
+ - NOTICE
51
52
  - README.md
52
53
  - Rakefile
53
54
  - fluent-plugin-simplearithmetic.gemspec