lib/fluent/plugin/out_qqwry.rb in fluent-plugin-qqwry-0.0.1 vs lib/fluent/plugin/out_qqwry.rb in fluent-plugin-qqwry-0.0.2
- old
+ new
@@ -4,11 +4,11 @@
Fluent::Plugin.register_output('qqwry', self)
REGEXP_JSON = /(^[\[\{].+[\]\}]$|^[\d\.\-]+$)/
REGEXP_PLACEHOLDER_SINGLE = /^\$\{(?<qqwry_key>-?[^\[]+)\['(?<record_key>-?[^']+)'\]\}$/
REGEXP_PLACEHOLDER_SCAN = /(\$\{[^\}]+?\})/
- QQWRY_KEYS = %w(city latitude longitude country_code3 country_code country_name dma_code area_code region)
+ QQWRY_KEYS = %w(area country)
config_param :qqwry_database, :string, :default => File.dirname(__FILE__) + '/../../../data/qqwry.dat'
config_param :qqwry_lookup_key, :string, :default => 'host'
config_param :tag, :string, :default => nil
@@ -27,10 +27,11 @@
define_method("log") { $log }
end
def initialize
require 'qqwry'
+ require 'yajl'
super
end
def configure(conf)
@@ -157,10 +158,10 @@
def create_placeholder(geodata)
placeholder = {}
@placeholder_keys.each do |placeholder_key|
position = placeholder_key.match(REGEXP_PLACEHOLDER_SINGLE)
next if position.nil? or geodata[position[:record_key]].nil?
- placeholder.store(placeholder_key, geodata[position[:record_key]][position[:qqwry_key].to_sym])
+ placeholder.store(placeholder_key, geodata[position[:record_key]].send(position[:qqwry_key].to_sym))
end
return placeholder
end
end