fluent-plugin-geoip 0.2.0 → 0.3.0

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.
data/README.md CHANGED
@@ -53,6 +53,7 @@ $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-geoip
53
53
  latitude ${latitude['host']}
54
54
  longitude ${longitude['host']}
55
55
  country_code3 ${country_code3['host']}
56
+ country_code2 ${country_code2['host']}
56
57
  country ${country_code['host']}
57
58
  country_name ${country_name['host']}
58
59
  dma ${dma_code['host']}
@@ -168,6 +169,7 @@ Provides these placeholders for adding field of geolocate results.
168
169
  * ${latitude[lookup_field]}
169
170
  * ${longitude[lookup_field]}
170
171
  * ${country_code3[lookup_field]}
172
+ * ${country_code2[lookup_field]}
171
173
  * ${country_code[lookup_field]}
172
174
  * ${country_name[lookup_field]}
173
175
  * ${dma_code[lookup_field]}
Binary file
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-geoip"
7
- spec.version = "0.2.0"
7
+ spec.version = "0.3.0"
8
8
  spec.authors = ["Kentaro Yoshida"]
9
9
  spec.email = ["y.ken.studio@gmail.com"]
10
10
  spec.summary = %q{Fluentd Output plugin to add information about geographical location of IP addresses with Maxmind GeoIP databases.}
@@ -6,7 +6,7 @@ class Fluent::GeoipOutput < Fluent::BufferedOutput
6
6
  REGEXP_JSON = /(^[\[\{].+[\]\}]$|^[\d\.\-]+$)/
7
7
  REGEXP_PLACEHOLDER_SINGLE = /^\$\{(?<geoip_key>-?[^\[]+)\['(?<record_key>-?[^']+)'\]\}$/
8
8
  REGEXP_PLACEHOLDER_SCAN = /(\$\{[^\}]+?\})/
9
- GEOIP_KEYS = %w(city latitude longitude country_code3 country_code country_name dma_code area_code region)
9
+ GEOIP_KEYS = %w(city latitude longitude country_code3 country_code2 country_code country_name dma_code area_code region)
10
10
 
11
11
  config_param :geoip_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
12
12
  config_param :geoip_lookup_key, :string, :default => 'host'
@@ -184,14 +184,14 @@ class GeoipOutputTest < Test::Unit::TestCase
184
184
  add_tag_prefix geoip.
185
185
  ], 'input.access')
186
186
  d1.run do
187
- d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.95.42'}})
187
+ d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.15.42'}})
188
188
  d1.emit({'message' => 'missing field'})
189
189
  end
190
190
  emits = d1.emits
191
191
  assert_equal 2, emits.length
192
192
  assert_equal 'geoip.access', emits[0][0] # tag
193
193
  assert_equal 'Mountain View', emits[0][2]['from_city']
194
- assert_equal 'Musashino', emits[0][2]['to_city']
194
+ assert_equal 'Tokorozawa', emits[0][2]['to_city']
195
195
  assert_equal nil, emits[1][2]['from_city']
196
196
  assert_equal nil, emits[1][2]['to_city']
197
197
  end
@@ -205,7 +205,7 @@ class GeoipOutputTest < Test::Unit::TestCase
205
205
  add_tag_prefix geoip.
206
206
  ], 'input.access')
207
207
  d1.run do
208
- d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.95.42'}})
208
+ d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.15.42'}})
209
209
  d1.emit({'from' => {'ip' => '66.102.3.80'}})
210
210
  d1.emit({'message' => 'missing field'})
211
211
  end
@@ -214,7 +214,7 @@ class GeoipOutputTest < Test::Unit::TestCase
214
214
  assert_equal 'geoip.access', emits[0][0] # tag
215
215
  assert_equal 'Mountain View', emits[0][2]['from_city']
216
216
  assert_equal 'United States', emits[0][2]['from_country']
217
- assert_equal 'Musashino', emits[0][2]['to_city']
217
+ assert_equal 'Tokorozawa', emits[0][2]['to_city']
218
218
  assert_equal 'Japan', emits[0][2]['to_country']
219
219
 
220
220
  assert_equal 'Mountain View', emits[1][2]['from_city']
@@ -307,7 +307,7 @@ class GeoipOutputTest < Test::Unit::TestCase
307
307
  tag geoip.${tag}
308
308
  ], 'input.access')
309
309
  d1.run do
310
- d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.95.42'}})
310
+ d1.emit({'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.15.42'}})
311
311
  d1.emit({'message' => 'missing field'})
312
312
  end
313
313
  emits = d1.emits
@@ -316,7 +316,7 @@ class GeoipOutputTest < Test::Unit::TestCase
316
316
  assert_equal 'geoip.access', emits[0][0] # tag
317
317
  assert_equal 'Mountain View', emits[0][2]['from_city']
318
318
  assert_equal 'United States', emits[0][2]['from_country']
319
- assert_equal 'Musashino', emits[0][2]['to_city']
319
+ assert_equal 'Tokorozawa', emits[0][2]['to_city']
320
320
  assert_equal 'Japan', emits[0][2]['to_country']
321
321
  assert_equal ['United States','Japan'], emits[0][2]['string_array']
322
322
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-geoip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-21 00:00:00.000000000 Z
12
+ date: 2014-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler