notifaction 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: b53a7a52c1365daddea0965161d52cfe29e25cd2
4
- data.tar.gz: e85bb77a9f9b89680fb605ae79e0e18907529174
3
+ metadata.gz: f3e0679b219058befb39070d0e4f2fa4bb07deb2
4
+ data.tar.gz: 77d81a4e23b84e7b10e1ac5b22df25294f16d1d6
5
5
  SHA512:
6
- metadata.gz: 4e6f659236d07d4ba6c1d41c3ddc0f8931aa0f816ff71843112f827ebca2fa11be766db93ce227cbbcc2e2154a45eae708b1a4496b114311a3c6f4f8aed64776
7
- data.tar.gz: cbcd4588e31de407dfa9878b9441690569af4c53600d05717e4a901dbb5848872b4b8811ff16f0307d193a6767061d94475a06f7c06bbcfc993f3f9921583f24
6
+ metadata.gz: 906af35271e9cc86683203c3f9aee97e0e85958f094309242564c46effa619fe85c6ce1bf6680161b1f1d37b94444d3353ba828caca5ce556b5ab2750a0aec08
7
+ data.tar.gz: 159c6d79f20af9ff4d8accfcaad98e91ba95e3f5e9ce1942cc7642fe392436eb5277d746155e7e4fc20528e6108f8c3b259c5a2ef1023ae977865b31b1a68b8c
data/lib/notifaction.rb CHANGED
@@ -1,3 +1,10 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'time'
4
+ require 'rbconfig'
5
+ require 'net/http'
6
+ require 'cgi'
1
7
  require 'utils.rb'
2
8
  require 'style.rb'
9
+ require 'plugin.rb'
3
10
  require 'notify.rb'
data/lib/notify.rb CHANGED
@@ -1,5 +1,3 @@
1
- $:.unshift File.dirname(__FILE__)
2
-
3
1
  class Notify
4
2
  # Display a notification bubble
5
3
  def self.bubble(message, title)
@@ -70,10 +68,8 @@ class Notify
70
68
  end
71
69
 
72
70
  # Send status updates to WorkingOn
73
- def self.wo(message, print_info_message = false)
71
+ def self.workingon(message, print_info_message = false)
74
72
  begin
75
- require_relative "plugins/workingon.rb"
76
-
77
73
  plugin = Plugin::WorkingOn.new
78
74
  plugin.send(message)
79
75
 
@@ -81,7 +77,7 @@ class Notify
81
77
  info(message)
82
78
  end
83
79
  rescue Exception => e
84
- error("Error notifying WO - #{e.message}", self)
80
+ error("Error notifying WO - #{e.message}")
85
81
  end
86
82
  end
87
83
 
@@ -90,6 +86,23 @@ class Notify
90
86
  inline("\u2011 =============", :magenta)
91
87
  end
92
88
 
89
+ def self.configure
90
+ yield self if block_given?
91
+ end
92
+
93
+ # register new plugins
94
+ def self.plugins=(plugin_config_arr)
95
+ plugin_config_arr.each do |hash|
96
+ hash.each_pair do |plugin, key|
97
+ # include the requested plugin
98
+ require_relative "plugins/#{plugin.downcase}.rb"
99
+
100
+ plugin_instance = Plugin.const_get(plugin.to_sym).new
101
+ instance_variable_set("@#{plugin}_key".to_sym, key)
102
+ end
103
+ end
104
+ end
105
+
93
106
  private
94
107
  # Collate colour and style, build message string in format of
95
108
  # "\e[#{style};#{colour}m#{text}\e[0m"
@@ -103,7 +116,7 @@ class Notify
103
116
 
104
117
  $?.exitstatus == 0
105
118
  rescue SystemExit, Interrupt
106
- error("Interrupt caught, exiting", self)
119
+ error("Interrupt caught, exiting")
107
120
  end
108
121
  end
109
122
 
@@ -114,7 +127,7 @@ class Notify
114
127
 
115
128
  $?.exitstatus == 0
116
129
  rescue SystemExit, Interrupt
117
- error("Interrupt caught, exiting", self)
130
+ error("Interrupt caught, exiting")
118
131
  end
119
132
  end
120
133
 
@@ -125,7 +138,7 @@ class Notify
125
138
 
126
139
  $?.exitstatus == 0
127
140
  rescue SystemExit, Interrupt
128
- error("Interrupt caught, exiting", self)
141
+ error("Interrupt caught, exiting")
129
142
  end
130
143
  end
131
144
 
@@ -135,7 +148,7 @@ class Notify
135
148
 
136
149
  $?.exitstatus == 0
137
150
  rescue SystemExit, Interrupt
138
- error("Interrupt caught, exiting", self)
151
+ error("Interrupt caught, exiting")
139
152
  end
140
153
  end
141
154
  end
data/lib/plugin.rb ADDED
@@ -0,0 +1,5 @@
1
+ module Plugin
2
+ def validate
3
+
4
+ end
5
+ end
@@ -1,11 +1,15 @@
1
1
  module Plugin
2
2
  class WorkingOn
3
3
  def send(message)
4
- Net::HTTP.post_form(URI(sprintf(api_endpoint, $config.get[:wo_key])), :task => CGI.escapeHTML(message))
4
+ ::Net::HTTP.post_form(URI(sprintf(api_endpoint, api_key)), :task => CGI.escapeHTML(message))
5
5
  end
6
6
 
7
7
  def api_endpoint
8
8
  "https://api.workingon.co/hooks/incoming?token=%s"
9
9
  end
10
+
11
+ def api_key
12
+ Notify.instance_variable_get('@WorkingOn_key')
13
+ end
10
14
  end
11
15
  end
data/lib/utils.rb CHANGED
@@ -1,6 +1,3 @@
1
- require "time"
2
- require "rbconfig"
3
-
4
1
  class Utils
5
2
  def self.formatted_time(time = nil)
6
3
  if time.nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notifaction
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
  - Ryan Priebe
@@ -17,10 +17,11 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/notifaction.rb
20
- - lib/utils.rb
21
20
  - lib/notify.rb
22
- - lib/style.rb
21
+ - lib/plugin.rb
23
22
  - lib/plugins/workingon.rb
23
+ - lib/style.rb
24
+ - lib/utils.rb
24
25
  homepage: http://rubygems.org/gems/notifaction
25
26
  licenses:
26
27
  - MIT