fluent-plugin-exec_placeholder 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8770082b98e23c1232d61d424415dedd6a443600
4
- data.tar.gz: 08e182e5667828cd1bd3334cdb5f2b9f31b3ba0d
3
+ metadata.gz: 9fa91e5d1ca2305bbdec8b3f9306bfd351f046d6
4
+ data.tar.gz: 6ad2d446115f6ff7768e3c42ff1330e2490d46f8
5
5
  SHA512:
6
- metadata.gz: d01cb0fd917288480dd0026c1d67c17a5bfbd4cd080866450b8f80fe8253baa499c064d79ee8fce9f1c75d5f28aa047e1a3faed985b07c0487e1a6a53fcdf1cb
7
- data.tar.gz: 772f18a0b075ccd17fc12f8ae59ba225e93a90457c7fc2d56b106f34db3052c6a1fd152e493ef02efca76221ddce12ac43bcb54dd0f25984f8c8c2eb2b283659
6
+ metadata.gz: be3895d3ab7149b3773250d0cca613bdea35b7de3461b66831790e4d3c42e43784a28438f9a062fd46f23498c3c5e6045ecf8987ce0cc66d9efe0ca7dc6175d7
7
+ data.tar.gz: 7f2a9e306b00b94209e87e878f7f37d1ba0af6db777100807339023ec1313fac0737ec26be82c7c65d9699a8114528231193d26f4ca73b544b80e678255c0841
@@ -1,15 +1,20 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - 2.1
7
-
8
- os:
9
- - linux
10
- - osx
4
+ - 2.0.*
5
+ - 2.1.*
6
+ - 2.2.*
7
+ - 2.3.0
11
8
 
12
9
  gemfile:
13
10
  - Gemfile
11
+ - Gemfile.fluentd.0.12
12
+
13
+ matrix:
14
+ exclude:
15
+ - rvm: 2.0.*
16
+ gemfile: Gemfile
17
+
18
+ before_install: gem update bundler
14
19
 
15
20
  script: 'bundle exec rake test'
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'fluentd', '~> 0.12.0'
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'kramdown'
8
+ end
@@ -2,9 +2,9 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-exec_placeholder"
5
- gem.version = "0.0.1"
6
- gem.summary = %q{ExecPlaceholder plugin for fluentd}
7
- gem.description = %q{ExecPlaceholder plugin for fluentd}
5
+ gem.version = "0.0.2"
6
+ gem.summary = %q{execute external command with placeholder plugin for fluentd}
7
+ gem.description = %q{execute external command with placeholder plugin for fluentd}
8
8
  gem.license = "MIT"
9
9
  gem.authors = ["toyama0919"]
10
10
  gem.email = "toyama0919@gmail.com"
@@ -17,10 +17,11 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency 'fluentd'
19
19
 
20
+ gem.add_development_dependency 'test-unit'
20
21
  gem.add_development_dependency 'bundler'
21
- gem.add_development_dependency 'pry', '~> 0.10.1'
22
- gem.add_development_dependency 'rake', '~> 10.3.2'
23
- gem.add_development_dependency 'rubocop', '~> 0.24.1'
24
- gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
25
- gem.add_development_dependency 'yard', '~> 0.8'
22
+ gem.add_development_dependency 'pry'
23
+ gem.add_development_dependency 'rake'
24
+ gem.add_development_dependency 'rubocop'
25
+ gem.add_development_dependency 'rubygems-tasks'
26
+ gem.add_development_dependency 'yard'
26
27
  end
@@ -15,7 +15,11 @@ module Fluent
15
15
 
16
16
  def configure(conf)
17
17
  super
18
- @erb = ERB.new(@command.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP))
18
+ command = @command.gsub('${tag}', '<%=tag %>')
19
+ command = command.gsub('${time}', '<%=time %>')
20
+ command = command.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP)
21
+ log.info(%Q{command => #{command}})
22
+ @erb = ERB.new(command)
19
23
  end
20
24
 
21
25
  def format(tag, time, record)
@@ -24,7 +28,7 @@ module Fluent
24
28
 
25
29
  def emit(tag, es, chain)
26
30
  es.each {|time, record|
27
- prog = @erb.result(binding)
31
+ prog = get_prog(tag, time, record)
28
32
  system(prog)
29
33
  ecode = $?.to_i
30
34
  if ecode != 0
@@ -33,5 +37,11 @@ module Fluent
33
37
  }
34
38
  chain.next
35
39
  end
40
+
41
+ private
42
+
43
+ def get_prog(tag, time, record)
44
+ @erb.result(binding)
45
+ end
36
46
  end
37
47
  end
@@ -4,30 +4,26 @@ class ExecPlaceholderOutputTest < Test::Unit::TestCase
4
4
  Fluent::Test.setup
5
5
  end
6
6
 
7
- CONFIG = %[
8
-
9
- ]
10
-
11
7
  def create_driver(conf = CONFIG, tag='test')
12
8
  Fluent::Test::OutputTestDriver.new(Fluent::ExecPlaceholderOutput, tag).configure(conf)
13
9
  end
14
10
 
15
11
  def test_configure
16
- d = create_driver(CONFIG + "\noutput_type json")
17
- assert_equal :json, d.instance.output_type
18
-
19
- assert_raise(Fluent::ConfigError) do
20
- d = create_driver(CONFIG)
21
- end
12
+ d = create_driver(%[
13
+ command /etc/init.d/httpd restart
14
+ ])
15
+ assert_equal "/etc/init.d/httpd restart", d.instance.command
22
16
  end
23
17
 
24
18
  def test_emit
25
- d1 = create_driver(CONFIG, 'input.access')
19
+ d1 = create_driver(%[
20
+ command echo ${tag}
21
+ ],
22
+ 'input.access'
23
+ )
26
24
  d1.run do
27
25
  d1.emit({'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
28
26
  d1.emit({'domain' => 'news.google.com', 'path' => '/', 'agent' => 'Googlebot-Mobile', 'response_time' => 900000})
29
27
  end
30
- emits = d1.emits
31
- assert_equal 5, emits.length
32
28
  end
33
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-exec_placeholder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - toyama0919
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-21 00:00:00.000000000 Z
11
+ date: 2016-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -42,73 +56,73 @@ dependencies:
42
56
  name: pry
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: 0.10.1
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: 0.10.1
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 10.3.2
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 10.3.2
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rubocop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - "~>"
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
- version: 0.24.1
89
+ version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - "~>"
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
- version: 0.24.1
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubygems-tasks
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '0.2'
103
+ version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '0.2'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: yard
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
- version: '0.8'
117
+ version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
- version: '0.8'
111
- description: ExecPlaceholder plugin for fluentd
124
+ version: '0'
125
+ description: execute external command with placeholder plugin for fluentd
112
126
  email: toyama0919@gmail.com
113
127
  executables: []
114
128
  extensions: []
@@ -120,6 +134,7 @@ files:
120
134
  - ".yardopts"
121
135
  - ChangeLog.md
122
136
  - Gemfile
137
+ - Gemfile.fluentd.0.12
123
138
  - LICENSE.txt
124
139
  - README.md
125
140
  - Rakefile
@@ -151,8 +166,7 @@ rubyforge_project:
151
166
  rubygems_version: 2.4.8
152
167
  signing_key:
153
168
  specification_version: 4
154
- summary: ExecPlaceholder plugin for fluentd
169
+ summary: execute external command with placeholder plugin for fluentd
155
170
  test_files:
156
171
  - test/helper.rb
157
172
  - test/plugin/test_out_exec_placeholder.rb
158
- has_rdoc: