fluent-plugin-geoblipper 0.0.2 → 0.0.3
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.
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = "fluent-plugin-geoblipper"
|
4
|
-
gem.version = "0.0.
|
4
|
+
gem.version = "0.0.3"
|
5
5
|
gem.authors = ["Sean Dick", "Change.org"]
|
6
6
|
gem.email = ["sean@change.org"]
|
7
7
|
gem.homepage = "https://github.com/seanmdick/fluent-plugin-geoblipper"
|
@@ -13,6 +13,7 @@ class Fluent::GeoBlipperOutput < Fluent::BufferedOutput
|
|
13
13
|
config_param :geodata_location, :string
|
14
14
|
config_param :max_entries, :integer, :default => -1
|
15
15
|
config_param :ip_key, :string, :default => 'ip'
|
16
|
+
config_param :extra_capture, :array, :default = []
|
16
17
|
|
17
18
|
def start
|
18
19
|
super
|
@@ -23,15 +24,24 @@ class Fluent::GeoBlipperOutput < Fluent::BufferedOutput
|
|
23
24
|
def format(tag, time, record)
|
24
25
|
address = record[@ip_key]
|
25
26
|
loc = @geodata.city(address)
|
26
|
-
|
27
|
-
|
27
|
+
extra = {}
|
28
|
+
extra_capture.each do |key|
|
29
|
+
extra[key] = record[key]
|
30
|
+
end
|
31
|
+
if loc
|
32
|
+
{latitude: loc.latitude, longitude: loc.longitude}.merge(extra).to_json + "\n"
|
33
|
+
else
|
34
|
+
""
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
def write(chunk)
|
31
39
|
chunk.open do |io|
|
32
|
-
items =
|
40
|
+
items = io.read.split("\n")
|
33
41
|
entries = items.slice(0..@max_entries).map {|item| JSON.parse(item) }
|
34
|
-
|
42
|
+
unless entries.empty?
|
43
|
+
@pubnub.publish(http_sync: true, message: entries, channel: @pubnub_channel)
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-geoblipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-05-
|
13
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fluentd
|