notifaction 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b93f9b046530813df21cebe204741f0b71704d8f
4
- data.tar.gz: 60fd3f89e8625ed13f4c12c238423c0cad59f89f
3
+ metadata.gz: 122a6f40d80d0d05e98fd6494288bb7dcf111677
4
+ data.tar.gz: df6ba02198ede8326019a6e656d51bcec7d00f41
5
5
  SHA512:
6
- metadata.gz: 35e64551ee8e81dd1be6f733da4b3395fa09055e3bd8c50914b76cac215df105a066d4cced1428c0bf864b35676c04c08d7191b9f4eac2104df3493c5a2f85d5
7
- data.tar.gz: 91113d241b3168ccb26e3f4937e2c0cc2d016859b51d66974f158095858f320a65c0d6f3db442d8d39d94b6aa010cce6491c2fcde96f1ba9d9665c48d92c5dbc
6
+ metadata.gz: 0968f3fb41fc5212435ce06b5677119510c0c05a9cbff9d6243c929c0d338be1b5990a0127a34bc41bac5656d182e1c5f9eb58568e74e048a850f9f4510c8f45
7
+ data.tar.gz: 3acdb921f0a32becab0886b4f73f73631d003744f5dbe8d97a968de00bf99a85656b9b8e64f3a3cacffd712e03196dbe3b1e0501a42d063eac40aaca82d01df9
data/lib/notify.rb CHANGED
@@ -109,7 +109,7 @@ class Notify
109
109
  puts Style.format(message, colour, style)
110
110
  end
111
111
 
112
- def osx_notification(message, title)
112
+ def self.osx_notification(message, title)
113
113
  begin
114
114
  @response = `osascript -e 'display notification "#{message}" with title "#{title}"'`
115
115
 
@@ -120,7 +120,7 @@ class Notify
120
120
  end
121
121
 
122
122
  # OSX system modal popup
123
- def osx_modal(message, title, icon = :caution)
123
+ def self.osx_modal(message, title, icon = :caution)
124
124
  begin
125
125
  @response = `osascript -e 'tell app "System Events" to display dialog "#{message}" buttons {"OK"} default button 1 with title "#{title}" with icon #{icon}'`
126
126
 
@@ -131,7 +131,7 @@ class Notify
131
131
  end
132
132
 
133
133
  # Linux system notification
134
- def notifysend(message, title)
134
+ def self.notifysend(message, title)
135
135
  begin
136
136
  @response = `notify-send "#{title}" "#{message}"`
137
137
 
@@ -141,7 +141,7 @@ class Notify
141
141
  end
142
142
  end
143
143
 
144
- def zenity(message, title)
144
+ def self.zenity(message, title)
145
145
  begin
146
146
  @response = `echo "message:#{message}" | zenity --notification --listen`
147
147
 
data/lib/plugin.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Plugin
2
- def validate
3
-
2
+ def self.num_lines(file)
3
+ File.foreach(file).inject(0) {|c, line| c+1}
4
4
  end
5
5
  end
@@ -1,7 +1,21 @@
1
1
  module Plugin
2
2
  class WorkingOn
3
3
  def send(message)
4
- ::Net::HTTP.post_form(URI(sprintf(api_endpoint, api_key)), :task => CGI.escapeHTML(message))
4
+ log = File.new('./wo-digest.log')
5
+
6
+ open(log, 'a') do |file|
7
+ file.write("#{message}\n")
8
+ end
9
+
10
+ # enough messages have been stored, send digest
11
+ if Plugin::num_lines(log) > 3
12
+ digest = open(log, 'r').read
13
+
14
+ Net::HTTP.post_form(URI(sprintf(api_endpoint, api_key)), :task => CGI.escapeHTML(digest.split("\n").uniq.join(', ')))
15
+
16
+ # reset digest after sending
17
+ File.truncate(log, 0)
18
+ end
5
19
  end
6
20
 
7
21
  def api_endpoint
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe