notifaction 0.3.0.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -9
- data/lib/notifaction/config.rb +1 -1
- data/lib/notifaction/type.rb +16 -8
- data/lib/notifaction/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9c48372819fc5caf672f85d8771cc8133c6db6f
|
4
|
+
data.tar.gz: 904d9e2f65ba36b8b7cc7630b6b1d9d2cbc9893d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6cbf68833817f4f0d58bcf49e4f723ad3ed997425f8b587760ce3a84402dd4432fb3ebf6e93b2a066b5afe66e3d0d69e8b842298a6bff046e0184a927a9d937
|
7
|
+
data.tar.gz: 86eb64d5339ff7af1dddab00f9a2d962cfb498a9f4a6a7ae785551aa9f9e8174e962a1e36cfb4708a4a0a8f711930aba76ee655aeb9b91ff9c3aab97741181e9
|
data/README.md
CHANGED
@@ -14,9 +14,9 @@ require 'notifaction'
|
|
14
14
|
# Other methods:
|
15
15
|
# - success (green)
|
16
16
|
# - info (blue)
|
17
|
-
# -
|
17
|
+
# - note (light blue)
|
18
18
|
# - warning (yellow)
|
19
|
-
# - spit (white)
|
19
|
+
# - spit (no colour/white)
|
20
20
|
begin
|
21
21
|
call_method
|
22
22
|
rescue => e
|
@@ -27,11 +27,15 @@ end
|
|
27
27
|
if install_successful
|
28
28
|
Notify.bubble("You can now proceed to use our software...", "Install Successful")
|
29
29
|
end
|
30
|
+
```
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
Plugins extend the base notification functionality, sending messages to online services. This example will show you how to send log information to a 3rd party service.
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# ~/.notifaction.yml
|
36
|
+
|
37
|
+
hooks:
|
38
|
+
- "https://api.yourwebsite.com/messages/receive?token=1am4t0k3n"
|
39
|
+
```
|
40
|
+
|
41
|
+
That's it. You will start receiving POST requests at the URL(s) listed in the `hooks` section of the configuration file.
|
data/lib/notifaction/config.rb
CHANGED
data/lib/notifaction/type.rb
CHANGED
@@ -4,7 +4,7 @@ require "uri"
|
|
4
4
|
module Notifaction
|
5
5
|
module Type
|
6
6
|
class Base
|
7
|
-
|
7
|
+
attr_reader :user_conf
|
8
8
|
|
9
9
|
#
|
10
10
|
# @since 0.3.0.1
|
@@ -27,16 +27,24 @@ module Notifaction
|
|
27
27
|
#
|
28
28
|
# @since 0.3.0
|
29
29
|
def fire_hooks(payload)
|
30
|
-
|
30
|
+
mux = Mutex.new
|
31
31
|
|
32
|
-
|
32
|
+
th = Thread.new do
|
33
|
+
mux.synchronize do
|
34
|
+
hooks = @user_conf.hooks
|
33
35
|
|
34
|
-
|
35
|
-
uri = URI.parse(uri)
|
36
|
+
return if hooks.nil?
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
hooks.each do |uri|
|
39
|
+
uri = URI.parse(uri)
|
40
|
+
|
41
|
+
response = Net::HTTP.post_form(uri, payload)
|
42
|
+
response.code.to_i < 300
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end.join.exit
|
46
|
+
|
47
|
+
th.status == false
|
40
48
|
end
|
41
49
|
end
|
42
50
|
end
|
data/lib/notifaction/version.rb
CHANGED