fluent-plugin-pushover 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.
- checksums.yaml +15 -0
- data/.gitignore +4 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +14 -0
- data/README.md +6 -0
- data/Rakefile +10 -0
- data/fluent-plugin-pushover.gemspec +20 -0
- data/lib/fluent/plugin/out_pushover.rb +40 -0
- data/test/helper.rb +29 -0
- data/test/plugin/test_out_pushover.rb +36 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZmIzMDhhODJlODg3MDRhYjU3YWY2MzVjNjRjMGZhMjBlZTBhN2E0ZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDJhMGFjMDliNjI3MzQzN2FkZmNhNTIwNzljNDliMmRmNGM3ZWM4Ng==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODFiZjI4M2EyMzZiYTIxZGI2ZjIyOWViMmYyMjcyZmFkMmIwYmI1NDVlZDQx
|
10
|
+
ZmJhNTVhNTFkMDZhZGM5NGUwMzIwZDNjZWM4MTA1ODVkYWVjN2RjYjhjODhh
|
11
|
+
YWU1MDYyN2RjYTY2YjYxYThlOThhMmM4Yzg3ZTVjMTJmMzAwMzI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGVlYzAxYjg5YWRiZjg5MDVhNDcyM2Y0ZDFkODQ5NWRkODgwZjQ1YjFhNzU0
|
14
|
+
MzE3ZmRlZTQ5ZTM0MzQ4ZDlmNTYzOGQ4MDI4YWI4NmViMGIyMzZkYWU4MWU1
|
15
|
+
MWY5ZjgxYThiMmUyZDUxYmQ3MTExZTU5MzU1MjRiMzc4OTY1ZDQ=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2015 - Jan Karásek
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "fluent-plugin-pushover"
|
6
|
+
s.version = "0.0.3"
|
7
|
+
s.authors = ["Jan Karásek"]
|
8
|
+
s.email = ["devel@hkar.eu"]
|
9
|
+
s.homepage = "https://github.com/hkar/fluent-plugin-pushover"
|
10
|
+
s.summary = %q{Fluentd Output plugin to make a call with Pushover API.}
|
11
|
+
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
|
17
|
+
# specify any dependencies here; for example:
|
18
|
+
s.add_development_dependency "rake"
|
19
|
+
s.add_runtime_dependency "fluentd"
|
20
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Fluent::PushoverOutput < Fluent::Output
|
2
|
+
Fluent::Plugin.register_output('pushover', self)
|
3
|
+
|
4
|
+
config_param :account_token, :string
|
5
|
+
config_param :user_key, :string
|
6
|
+
|
7
|
+
PUSHOVER_ENDPOINT = 'https://api.pushover.net/1/messages.json'
|
8
|
+
|
9
|
+
# Define `log` method for v0.10.42 or earlier
|
10
|
+
unless method_defined?(:log)
|
11
|
+
define_method("log") { $log }
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
super
|
16
|
+
require 'net/http'
|
17
|
+
require 'uri'
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure(conf)
|
21
|
+
super
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def emit(tag, es, chain)
|
26
|
+
es.each do |time, record|
|
27
|
+
send(record['message'])
|
28
|
+
end
|
29
|
+
|
30
|
+
chain.next
|
31
|
+
end
|
32
|
+
|
33
|
+
def send(message)
|
34
|
+
begin
|
35
|
+
response = Net::HTTP.post_form(URI.parse(PUSHOVER_ENDPOINT), {'token' => @account_token, 'user' => @user_key, 'message' => message})
|
36
|
+
rescue => e
|
37
|
+
log.error "Pushover error: #{e.message}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
require 'test/unit'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'fluent/test'
|
16
|
+
unless ENV.has_key?('VERBOSE')
|
17
|
+
nulllogger = Object.new
|
18
|
+
nulllogger.instance_eval { |obj|
|
19
|
+
def method_missing(method, *args)
|
20
|
+
# pass
|
21
|
+
end
|
22
|
+
}
|
23
|
+
$log = nulllogger
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'fluent/plugin/out_pushover'
|
27
|
+
|
28
|
+
class Test::Unit::TestCase
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TwilioOutputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
account_token PUSHOVER_ACCOUNT_ID
|
10
|
+
user_key USER_KEY
|
11
|
+
]
|
12
|
+
|
13
|
+
def create_driver(conf=CONFIG, tag='test')
|
14
|
+
Fluent::Test::OutputTestDriver.new(Fluent::PushoverOutput, tag).configure(conf)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_configure
|
18
|
+
assert_raise(Fluent::ConfigError) {
|
19
|
+
d = create_driver('')
|
20
|
+
}
|
21
|
+
d = create_driver CONFIG
|
22
|
+
|
23
|
+
assert_equal 'PUSHOVER_ACCOUNT_ID', d.instance.account_token
|
24
|
+
assert_equal 'USER_KEY', d.instance.user_key
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_emit
|
28
|
+
d1 = create_driver(CONFIG, 'notify.call')
|
29
|
+
d1.run do
|
30
|
+
d1.emit({'message' => 'hello world.'})
|
31
|
+
end
|
32
|
+
emits = d1.emits
|
33
|
+
assert_equal 0, emits.length
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-pushover
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Karásek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fluentd
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- devel@hkar.eu
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .travis.yml
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- fluent-plugin-pushover.gemspec
|
55
|
+
- lib/fluent/plugin/out_pushover.rb
|
56
|
+
- test/helper.rb
|
57
|
+
- test/plugin/test_out_pushover.rb
|
58
|
+
homepage: https://github.com/hkar/fluent-plugin-pushover
|
59
|
+
licenses: []
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.6
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Fluentd Output plugin to make a call with Pushover API.
|
81
|
+
test_files: []
|