fluent-plugin-currency 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluent/plugin/currency/version.rb +1 -1
- data/lib/fluent/plugin/filter_currency.rb +29 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56746134ac0e471bbde4b7e43cf28f20e5c44218
|
4
|
+
data.tar.gz: 56ca2bfcdca8ef16c6a65ec4f1c9e48b9716b58a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98988762076f763da559b7fa3b579be119c877b521e8e30c77cdf129d6b0f1240cb5721c0e4c56cae0f08d3c4d59bcd4b2f69875b15c5731f4ebbe5817f34a19
|
7
|
+
data.tar.gz: 9ea5465f2c6c46866aaef24dd2d344c5cc7d92f015d7f4550c123d03ec945c1a22b54857fe3bdc723e60ef2dd55a7e4724da0611a537f4be7411cd9a9f9712c1
|
@@ -7,9 +7,9 @@ module Fluent
|
|
7
7
|
Fluent::Plugin.register_filter('currency', self)
|
8
8
|
|
9
9
|
# config_param works like other plugins
|
10
|
-
config_param :price_key, :
|
10
|
+
config_param :price_key, :string, default: 'price'
|
11
11
|
config_param :currency_key, :string, default: 'currency'
|
12
|
-
config_param :
|
12
|
+
config_param :dest_key, :string, default: 'price_usd'
|
13
13
|
config_param :base_currency, :string, default: 'USD'
|
14
14
|
config_param :converter_url, :string
|
15
15
|
|
@@ -39,10 +39,13 @@ module Fluent
|
|
39
39
|
# Since our example is a pass-thru filter, it does nothing and just
|
40
40
|
# returns the record as-is.
|
41
41
|
# If returns nil, that records are ignored.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
source_price = getValueFromRecord(@price_key, record)
|
43
|
+
source_currency = getValueFromRecord(@currency_key, record)
|
44
|
+
|
45
|
+
if source_price!=nil && source_currency!=nil
|
46
|
+
price = requestConverter(source_currency, source_price)
|
47
|
+
if price
|
48
|
+
setValueOnRecord(@dest_key, price, record)
|
46
49
|
end
|
47
50
|
end
|
48
51
|
return record
|
@@ -67,6 +70,26 @@ module Fluent
|
|
67
70
|
end
|
68
71
|
end
|
69
72
|
|
73
|
+
def setValueOnRecord(key, value, record)
|
74
|
+
fields = key.split(".")
|
75
|
+
fields.each do |f|
|
76
|
+
if f.equal?(fields.last)
|
77
|
+
record[f] = value
|
78
|
+
else
|
79
|
+
record = record[f]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def getValueFromRecord(key, record)
|
85
|
+
fields = key.split(".");
|
86
|
+
value = record
|
87
|
+
fields.each do |f|
|
88
|
+
value = value[f]
|
89
|
+
end
|
90
|
+
return value
|
91
|
+
end
|
92
|
+
|
70
93
|
def testRequest()
|
71
94
|
uri = URI(@converter_url)
|
72
95
|
Net::HTTP.get(uri)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-currency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksey Pavlov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.6.
|
78
|
+
rubygems_version: 2.6.14
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: fluent-plugin-currency
|