fluent-plugin-mobile-carrier 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +23 -0
- data/README.md +1 -1
- data/Rakefile +2 -2
- data/fluent-plugin-mobile-carrier.gemspec +7 -6
- data/lib/fluent/plugin/out_mobile_carrier.rb +12 -13
- data/test/plugin/test_out_mobile_carrier.rb +10 -11
- metadata +4 -6
- data/lib/fluent/plugin/.rubocop.yml +0 -12
- data/test/plugin/.rubocop.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77603c91b65cff28023d78f8e1a34e972c37128d
|
4
|
+
data.tar.gz: 4460ac4993a58655b27f59935f1f53193c5dd988
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7774298d16984bbc1fdbe0a2104956dc51a1369ad8e6a79272cbd41a33534ba69fdea76a079630eb7fd3a1c967d49d51291e088dffd473c6ccc08d63251e612
|
7
|
+
data.tar.gz: 9e04069a767bc6a4f18c50493e8649cb0856488257bdc791679f26fffe2127eed4ecd92a699a69a8a060fc77f3551758d18586a6e234293fa1de591f1e2f2f4a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
LineLength:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
MethodLength:
|
5
|
+
Enabled: true
|
6
|
+
CountComments: false
|
7
|
+
Max: 50
|
8
|
+
|
9
|
+
ClassAndModuleChildren:
|
10
|
+
EnforcedStyle: compact
|
11
|
+
SupportedStyles:
|
12
|
+
- nested
|
13
|
+
- compact
|
14
|
+
|
15
|
+
CyclomaticComplexity:
|
16
|
+
Max: 10
|
17
|
+
|
18
|
+
ClassLength:
|
19
|
+
CountComments: false
|
20
|
+
Max: 150
|
21
|
+
|
22
|
+
GlobalVars:
|
23
|
+
AllowedVariables: [$log]
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
-
require
|
2
|
+
require 'bundler/gem_tasks'
|
3
3
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
Rake::TestTask.new(:test) do |test|
|
@@ -8,4 +8,4 @@ Rake::TestTask.new(:test) do |test|
|
|
8
8
|
test.verbose = true
|
9
9
|
end
|
10
10
|
|
11
|
-
task :
|
11
|
+
task default: :test
|
@@ -1,18 +1,19 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require 'English'
|
2
3
|
|
3
4
|
Gem::Specification.new do |gem|
|
4
5
|
gem.name = 'fluent-plugin-mobile-carrier'
|
5
|
-
gem.version = '0.0.
|
6
|
+
gem.version = '0.0.4'
|
6
7
|
gem.authors = ['HARUYAMA Seigo']
|
7
8
|
gem.email = ['haruyama@unixuser.org']
|
8
|
-
gem.description = %q
|
9
|
-
gem.summary = %q
|
9
|
+
gem.description = %q(judge mobile carrier by ip address.)
|
10
|
+
gem.summary = %q(Fluentd plugin to judge mobile carrier by ip address.)
|
10
11
|
gem.homepage = 'http://github.com/haruyama/fluent-plugin-mobile-carrier'
|
11
12
|
gem.license = 'APLv2'
|
12
13
|
|
13
|
-
gem.files = `git ls-files`.split(
|
14
|
-
gem.executables = gem.files.grep(
|
15
|
-
gem.test_files = gem.files.grep(
|
14
|
+
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
|
15
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
16
17
|
gem.require_paths = ['lib']
|
17
18
|
|
18
19
|
gem.add_development_dependency 'rake'
|
@@ -18,7 +18,7 @@ class Fluent::MobileCarrierOutput < Fluent::Output
|
|
18
18
|
def configure(conf)
|
19
19
|
super
|
20
20
|
config = YAML.load_file(@config_yaml)
|
21
|
-
|
21
|
+
fail 'invalid yaml' unless config.is_a? Hash
|
22
22
|
@config = parse_config(config)
|
23
23
|
|
24
24
|
if !@tag && !@remove_prefix && !@add_prefix
|
@@ -55,20 +55,20 @@ class Fluent::MobileCarrierOutput < Fluent::Output
|
|
55
55
|
|
56
56
|
def parse_config(raw_config)
|
57
57
|
config = {}
|
58
|
-
raw_config.each
|
59
|
-
config[carrier] = ip_address_list.map
|
58
|
+
raw_config.each do |carrier, ip_address_list|
|
59
|
+
config[carrier] = ip_address_list.map do |ip_address|
|
60
60
|
TubeAddress.new(ip_address)
|
61
|
-
|
62
|
-
|
61
|
+
end
|
62
|
+
end
|
63
63
|
config
|
64
64
|
end
|
65
65
|
|
66
66
|
def judge_mobile_carrier(ip_address, config)
|
67
|
-
config.each
|
67
|
+
config.each do |carrier, ipaddr_list|
|
68
68
|
if ipaddr_list.any? { |ipaddr| ipaddr.include? ip_address }
|
69
69
|
return carrier
|
70
70
|
end
|
71
|
-
|
71
|
+
end
|
72
72
|
@unknown_carrier
|
73
73
|
end
|
74
74
|
|
@@ -86,10 +86,10 @@ end
|
|
86
86
|
|
87
87
|
# https://github.com/jordansissel/experiments/blob/master/ruby/ipaddr-is-slow/code.rb
|
88
88
|
class TubeAddress
|
89
|
-
|
89
|
+
IPV4MASK = 0xFFFFFFFF # 255.255.255.255
|
90
90
|
|
91
91
|
def initialize(addr)
|
92
|
-
@address, cidr, _ = addr.split(
|
92
|
+
@address, cidr, _ = addr.split('/') + ['32']
|
93
93
|
|
94
94
|
@address_int = self.class.ip_to_num(@address)
|
95
95
|
@cidr = cidr.to_i
|
@@ -98,7 +98,7 @@ class TubeAddress
|
|
98
98
|
|
99
99
|
def cidr_mask
|
100
100
|
# Convert /24 to 0xffffff00, etc
|
101
|
-
@cidr_mask ||=
|
101
|
+
@cidr_mask ||= IPV4MASK ^ ((1 << (32 - @cidr)) - 1)
|
102
102
|
end
|
103
103
|
|
104
104
|
def include?(addr)
|
@@ -107,11 +107,10 @@ class TubeAddress
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def self.ip_to_num(addr)
|
110
|
-
|
110
|
+
addr.split('.').reduce(0) { |a, e| (a << 8) + (e.to_i) }
|
111
111
|
end
|
112
112
|
|
113
113
|
def to_s
|
114
|
-
|
114
|
+
"#{@address}/#{@cidr}"
|
115
115
|
end
|
116
116
|
end
|
117
|
-
|
@@ -3,15 +3,15 @@ require 'helper'
|
|
3
3
|
# MobileCarrierOutput test
|
4
4
|
class Fluent::MobileCarrierOutputTest < Test::Unit::TestCase
|
5
5
|
# through & merge
|
6
|
-
CONFIG1 = %
|
6
|
+
CONFIG1 = %(
|
7
7
|
type mobile_carrier
|
8
8
|
remove_prefix test
|
9
9
|
add_prefix merged
|
10
10
|
config_yaml test/data/config1.yaml
|
11
11
|
key_name ip_address
|
12
|
-
|
12
|
+
)
|
13
13
|
|
14
|
-
CONFIG2 = %
|
14
|
+
CONFIG2 = %(
|
15
15
|
type mobile_carrier
|
16
16
|
remove_prefix test
|
17
17
|
add_prefix merged
|
@@ -19,30 +19,30 @@ config_yaml test/data/config1.yaml
|
|
19
19
|
key_name ip
|
20
20
|
unknown_carrier unknown
|
21
21
|
out_key_mobile_carrier mc
|
22
|
-
|
22
|
+
)
|
23
23
|
|
24
|
-
CONFIG_ERROR1 = %
|
24
|
+
CONFIG_ERROR1 = %(
|
25
25
|
type mobile_carrier
|
26
26
|
remove_prefix test
|
27
27
|
add_prefix merged
|
28
28
|
key_name ip_address
|
29
|
-
|
29
|
+
)
|
30
30
|
|
31
|
-
CONFIG_ERROR2 = %
|
31
|
+
CONFIG_ERROR2 = %(
|
32
32
|
type mobile_carrier
|
33
33
|
remove_prefix test
|
34
34
|
add_prefix merged
|
35
35
|
key_name ip_address
|
36
36
|
config_yaml test/data/not_found.yaml
|
37
|
-
|
37
|
+
)
|
38
38
|
|
39
|
-
CONFIG_ERROR3 = %
|
39
|
+
CONFIG_ERROR3 = %(
|
40
40
|
type mobile_carrier
|
41
41
|
remove_prefix test
|
42
42
|
add_prefix merged
|
43
43
|
key_name ip_address
|
44
44
|
config_yaml test/data/wrong.yaml
|
45
|
-
|
45
|
+
)
|
46
46
|
|
47
47
|
def create_driver(conf = CONFIG1, tag = 'test')
|
48
48
|
Fluent::Test::OutputTestDriver.new(Fluent::MobileCarrierOutput, tag).configure(conf)
|
@@ -129,5 +129,4 @@ config_yaml test/data/wrong.yaml
|
|
129
129
|
assert_equal 5, m['value']
|
130
130
|
assert_equal 'UNKNOWN', m['mobile_carrier']
|
131
131
|
end
|
132
|
-
|
133
132
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mobile-carrier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HARUYAMA Seigo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -46,18 +46,17 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".rubocop.yml"
|
49
50
|
- ".travis.yml"
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
53
54
|
- Rakefile
|
54
55
|
- fluent-plugin-mobile-carrier.gemspec
|
55
|
-
- lib/fluent/plugin/.rubocop.yml
|
56
56
|
- lib/fluent/plugin/out_mobile_carrier.rb
|
57
57
|
- test/data/config1.yaml
|
58
58
|
- test/data/wrong.yaml
|
59
59
|
- test/helper.rb
|
60
|
-
- test/plugin/.rubocop.yml
|
61
60
|
- test/plugin/test_out_mobile_carrier.rb
|
62
61
|
homepage: http://github.com/haruyama/fluent-plugin-mobile-carrier
|
63
62
|
licenses:
|
@@ -79,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
78
|
version: '0'
|
80
79
|
requirements: []
|
81
80
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.2.
|
81
|
+
rubygems_version: 2.2.2
|
83
82
|
signing_key:
|
84
83
|
specification_version: 4
|
85
84
|
summary: Fluentd plugin to judge mobile carrier by ip address.
|
@@ -87,5 +86,4 @@ test_files:
|
|
87
86
|
- test/data/config1.yaml
|
88
87
|
- test/data/wrong.yaml
|
89
88
|
- test/helper.rb
|
90
|
-
- test/plugin/.rubocop.yml
|
91
89
|
- test/plugin/test_out_mobile_carrier.rb
|
data/test/plugin/.rubocop.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
LineLength:
|
2
|
-
Enabled: false
|
3
|
-
|
4
|
-
MethodLength:
|
5
|
-
Enabled: true
|
6
|
-
CountComments: false # count full line comments?
|
7
|
-
Max: 50
|
8
|
-
|
9
|
-
FavorSprintf:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
MultilineBlocks:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
AvoidPerlBackrefs:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
PercentLiterals:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
BraceAfterPercent:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
ClassLength:
|
25
|
-
Enabled: false
|