fluent-plugin-currency 0.1.1 → 0.1.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
- SHA1:
3
- metadata.gz: 56746134ac0e471bbde4b7e43cf28f20e5c44218
4
- data.tar.gz: 56ca2bfcdca8ef16c6a65ec4f1c9e48b9716b58a
2
+ SHA256:
3
+ metadata.gz: cf27a929effc0081382e84cc9cdafa1cca7b70a7aacd9902c44157263e0eb5eb
4
+ data.tar.gz: bf092a424aafb08b2ffc83f710013d604d8f14d28a074d15f9121731354d5f83
5
5
  SHA512:
6
- metadata.gz: 98988762076f763da559b7fa3b579be119c877b521e8e30c77cdf129d6b0f1240cb5721c0e4c56cae0f08d3c4d59bcd4b2f69875b15c5731f4ebbe5817f34a19
7
- data.tar.gz: 9ea5465f2c6c46866aaef24dd2d344c5cc7d92f015d7f4550c123d03ec945c1a22b54857fe3bdc723e60ef2dd55a7e4724da0611a537f4be7411cd9a9f9712c1
6
+ metadata.gz: ac4b0fa6ba9d8d76686ae08c94e7c18d8a2629ace6c8bfc47929d8e6051bb4d192b50e5e457358ce71b10a70a058fbc4ca6693756e192b29c98300e54150458e
7
+ data.tar.gz: 92b37d3db0c9b92a280d15b83af41fd2830a8352dd38de993b3fca4a09bb35c57915f8d8b6bed265b4a9961d891703cca11ac2e03e3cdf1c4de1df1b169a2956
@@ -0,0 +1,17 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4
+
5
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6
+ ARG NODE_VERSION="none"
7
+ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8
+
9
+ # [Optional] Uncomment this section to install additional OS packages.
10
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
12
+
13
+ # [Optional] Uncomment this line to install additional gems.
14
+ # RUN gem install <your-gem-names-here>
15
+
16
+ # [Optional] Uncomment this line to install global node packages.
17
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,43 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM ruby:${VARIANT}
4
+
5
+ # Copy library scripts to execute
6
+ COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
7
+
8
+ # [Option] Install zsh
9
+ ARG INSTALL_ZSH="true"
10
+ # [Option] Upgrade OS packages to their latest versions
11
+ ARG UPGRADE_PACKAGES="true"
12
+ # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
13
+ ARG USERNAME=vscode
14
+ ARG USER_UID=1000
15
+ ARG USER_GID=$USER_UID
16
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
17
+ # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
18
+ && apt-get purge -y imagemagick imagemagick-6-common \
19
+ # Install common packages, non-root user, rvm, core build tools
20
+ && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
21
+ && bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
22
+ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
23
+
24
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
25
+ ARG NODE_VERSION="none"
26
+ ENV NVM_DIR=/usr/local/share/nvm
27
+ ENV NVM_SYMLINK_CURRENT=true \
28
+ PATH=${NVM_DIR}/current/bin:${PATH}
29
+ RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
30
+ && apt-get clean -y && rm -rf /var/lib/apt/lists/*
31
+
32
+ # Remove library scripts for final image
33
+ RUN rm -rf /tmp/library-scripts
34
+
35
+ # [Optional] Uncomment this section to install additional OS packages.
36
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
37
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
38
+
39
+ # [Optional] Uncomment this line to install additional gems.
40
+ # RUN gem install <your-gem-names-here>
41
+
42
+ # [Optional] Uncomment this line to install global node packages.
43
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,34 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/ruby
3
+ {
4
+ "name": "Ruby",
5
+ "build": {
6
+ "dockerfile": "Dockerfile",
7
+ "args": {
8
+ // Update 'VARIANT' to pick a Ruby version: 3, 3.0, 2, 2.7, 2.6
9
+ // Append -bullseye or -buster to pin to an OS version.
10
+ // Use -bullseye variants on local on arm64/Apple Silicon.
11
+ "VARIANT": "2.6",
12
+ // Options
13
+ "NODE_VERSION": "lts/*"
14
+ }
15
+ },
16
+
17
+ // Set *default* container specific settings.json values on container create.
18
+ "settings": {},
19
+
20
+ // Add the IDs of extensions you want installed when the container is created.
21
+ "extensions": [
22
+ "rebornix.Ruby"
23
+ ],
24
+
25
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
26
+ // "forwardPorts": [],
27
+
28
+ // Use 'postCreateCommand' to run commands after the container is created.
29
+ // "postCreateCommand": "ruby --version",
30
+
31
+ // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
32
+ "remoteUser": "vscode"
33
+
34
+ }
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/bin/console CHANGED
File without changes
data/bin/setup CHANGED
File without changes
File without changes
@@ -1,7 +1,7 @@
1
1
  module Fluent
2
2
  module Plugin
3
3
  module Currency
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
File without changes
@@ -1,98 +1,99 @@
1
- require 'fluent/filter'
2
- require 'net/http'
3
-
4
- module Fluent
5
- class CurrencyFilter < Filter
6
- # Register this filter as "passthru"
7
- Fluent::Plugin.register_filter('currency', self)
8
-
9
- # config_param works like other plugins
10
- config_param :price_key, :string, default: 'price'
11
- config_param :currency_key, :string, default: 'currency'
12
- config_param :dest_key, :string, default: 'price_usd'
13
- config_param :base_currency, :string, default: 'USD'
14
- config_param :converter_url, :string
15
-
16
- def configure(conf)
17
- super
18
- # do the usual configuration here
19
- testRequest()
20
- end
21
-
22
- def start
23
- super
24
- # This is the first method to be called when it starts running
25
- # Use it to allocate resources, etc.
26
- end
27
-
28
- def shutdown
29
- super
30
- # This method is called when Fluentd is shutting down.
31
- # Use it to free up resources, etc.
32
- end
33
-
34
- def filter(tag, time, record)
35
- # This method implements the filtering logic for individual filters
36
- # It is internal to this class and called by filter_stream unless
37
- # the user overrides filter_stream.
38
- #
39
- # Since our example is a pass-thru filter, it does nothing and just
40
- # returns the record as-is.
41
- # If returns nil, that records are ignored.
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)
49
- end
50
- end
51
- return record
52
- end
53
-
54
- def requestConverter(currency, price)
55
- begin
56
- url = @converter_url
57
- url += "?currency="
58
- url += currency
59
- url += "&base_currency="
60
- url += @base_currency
61
- url += "&price="
62
- url += price.to_s
63
- uri = URI(url)
64
- response = Net::HTTP.get(uri)
65
- return response.to_f
66
- rescue Errno::ECONNREFUSED
67
- return 0
68
- rescue SyntaxError
69
- raise
70
- end
71
- end
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
-
93
- def testRequest()
94
- uri = URI(@converter_url)
95
- Net::HTTP.get(uri)
96
- end
97
- end
1
+ require 'fluent/filter'
2
+ require 'net/http'
3
+
4
+ module Fluent
5
+ class CurrencyFilter < Filter
6
+ # Register this filter as "passthru"
7
+ Fluent::Plugin.register_filter('currency', self)
8
+
9
+ # config_param works like other plugins
10
+ config_param :price_key, :string, default: 'price'
11
+ config_param :currency_key, :string, default: 'currency'
12
+ config_param :dest_key, :string, default: 'price_usd'
13
+ config_param :base_currency, :string, default: 'USD'
14
+ config_param :converter_url, :string
15
+
16
+ def configure(conf)
17
+ super
18
+ # do the usual configuration here
19
+ testRequest()
20
+ end
21
+
22
+ def start
23
+ super
24
+ # This is the first method to be called when it starts running
25
+ # Use it to allocate resources, etc.
26
+ end
27
+
28
+ def shutdown
29
+ super
30
+ # This method is called when Fluentd is shutting down.
31
+ # Use it to free up resources, etc.
32
+ end
33
+
34
+ def filter(tag, time, record)
35
+ # This method implements the filtering logic for individual filters
36
+ # It is internal to this class and called by filter_stream unless
37
+ # the user overrides filter_stream.
38
+ #
39
+ # Since our example is a pass-thru filter, it does nothing and just
40
+ # returns the record as-is.
41
+ # If returns nil, that records are ignored.
42
+ source_price = getValueFromRecord(@price_key, record)
43
+ source_currency = getValueFromRecord(@currency_key, record)
44
+ source_price_in_usd = getValueFromRecord(@dest_key, record)
45
+
46
+ if source_price!=nil && source_currency!=nil && source_price_in_usd==nil
47
+ price = requestConverter(source_currency, source_price)
48
+ if price
49
+ setValueOnRecord(@dest_key, price, record)
50
+ end
51
+ end
52
+ return record
53
+ end
54
+
55
+ def requestConverter(currency, price)
56
+ begin
57
+ url = @converter_url
58
+ url += "?currency="
59
+ url += currency
60
+ url += "&base_currency="
61
+ url += @base_currency
62
+ url += "&price="
63
+ url += price.to_s
64
+ uri = URI(url)
65
+ response = Net::HTTP.get(uri)
66
+ return response.to_f
67
+ rescue Errno::ECONNREFUSED
68
+ return 0
69
+ rescue SyntaxError
70
+ raise
71
+ end
72
+ end
73
+
74
+ def setValueOnRecord(key, value, record)
75
+ fields = key.split(".")
76
+ fields.each do |f|
77
+ if f.equal?(fields.last)
78
+ record[f] = value
79
+ else
80
+ record = record[f]
81
+ end
82
+ end
83
+ end
84
+
85
+ def getValueFromRecord(key, record)
86
+ fields = key.split(".");
87
+ value = record
88
+ fields.each do |f|
89
+ value = value[f]
90
+ end
91
+ return value
92
+ end
93
+
94
+ def testRequest()
95
+ uri = URI(@converter_url)
96
+ Net::HTTP.get(uri)
97
+ end
98
+ end
98
99
  end
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.1
4
+ version: 0.1.2
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-15 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,6 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".devcontainer/Dockerfile"
49
+ - ".devcontainer/base.Dockerfile"
50
+ - ".devcontainer/devcontainer.json"
48
51
  - ".gitignore"
49
52
  - Gemfile
50
53
  - README.md
@@ -74,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
77
  - !ruby/object:Gem::Version
75
78
  version: '0'
76
79
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.6.14
80
+ rubygems_version: 3.0.3.1
79
81
  signing_key:
80
82
  specification_version: 4
81
83
  summary: fluent-plugin-currency