notifier 0.1.0 → 0.1.1

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.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .DS_Store
data/README.rdoc CHANGED
@@ -13,6 +13,25 @@ Send system notifications on several platforms with a simple and unified API. Cu
13
13
 
14
14
  gem install notifier
15
15
 
16
+ === Mac OS X
17
+
18
+ * Install Growl - http://growl.info/
19
+ * Install the growlnotify script located on the "Extras" directory
20
+ * Open the Growl Preference Panel (System > Growl) and activate "Listen for incoming notifications" and "Allow remote application registration" options on the Network tab.
21
+
22
+ === Linux
23
+
24
+ If you're a linux guy, you can choose one of these methods:
25
+
26
+ * Install libnotify-bin and its dependencies: <tt>sudo aptitude install libnotify-bin</tt>
27
+ * Install xosd-bin: <tt>sudo aptitude install xosd-bin</tt>
28
+ * KDE users don't need to install anything: Test Notifier will use +knotify+ or +kdialog+.
29
+
30
+ === Windows
31
+
32
+ * Install Snarl: download from http://www.fullphat.net
33
+ * Install ruby-snarl: <tt>gem install ruby-snarl</tt>
34
+
16
35
  == Usage
17
36
 
18
37
  Notifier will try to detect which notifiers are available in your system. So you can just send a message:
@@ -39,6 +58,20 @@ There are several helper methods that you can use in order to retrieve notifiers
39
58
  * <tt>Notifier.from_name(name)</tt>: find notifier by its name
40
59
  * <tt>Notifier.supported_notifier_from_name(name)</tt>: find a supported notifier by its name
41
60
 
61
+ == Creating custom notifiers
62
+
63
+ To create a new notifier, just create a module on <tt>Notifier</tt> namespace that implements the following interface:
64
+
65
+ module Notifier
66
+ module MyCustomNotifier
67
+ def self.supported?
68
+ end
69
+
70
+ def self.notify(options)
71
+ end
72
+ end
73
+ end
74
+
42
75
  == Maintainer
43
76
 
44
77
  * Nando Vieira - http://nandovieira.com.br
@@ -2,7 +2,7 @@ module Notifier
2
2
  module Growl
3
3
  extend self
4
4
 
5
- SCRIPT = File.dirname(__FILE__) + "/../../../resources/register-growl.scpt"
5
+ SCRIPT = File.dirname(__FILE__) + "/../../resources/register-growl.scpt"
6
6
  FILE = File.expand_path("~/.test_notifier-growl")
7
7
 
8
8
  def supported?
@@ -10,6 +10,8 @@ module Notifier
10
10
  end
11
11
 
12
12
  def notify(options)
13
+ register
14
+
13
15
  Thread.new do
14
16
  `growlnotify -n test_notifier --image #{options[:image]} -p 2 -m '#{options[:message]}' -t '#{options[:title]}'`
15
17
  end
@@ -2,24 +2,27 @@ module Notifier
2
2
  module OsdCat
3
3
  extend self
4
4
 
5
- FONT = "-bitstream-charter-bold-r-normal--33-240-100-100-p-206-iso8859-1"
6
- POSITION = "top"
7
- POSITION_OFFSET = "0"
8
- ALIGN = "center"
9
- COLORS = {
10
- :fail => "orange",
11
- :success => "green",
12
- :error => "red"
13
- }
14
-
15
5
  def supported?
16
6
  RUBY_PLATFORM =~ /(linux|freebsd)/ && `which osd_cat > /dev/null` && $? == 0
17
7
  end
18
8
 
19
9
  def notify(options)
20
- Thread.new do
21
- `echo #{options[:message].inspect} | osd_cat --font=#{FONT} --shadow=0 --pos=#{POSITION} -o #{POSITION_OFFSET} --delay=4 --outline=4 --align=#{ALIGN} -c #{COLORS[options[:status]]}`
22
- end
10
+ color = options.fetch(:color, "white")
11
+ message = options[:message].inspect.gsub(/!/, "\\!")
12
+ command = %W[
13
+ echo #{message} |
14
+ osd_cat
15
+ --shadow=0
16
+ --colour=#{color}
17
+ --pos=top
18
+ --offset=10
19
+ --align=center
20
+ --font=-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-*-*
21
+ --delay=5
22
+ --outline=4
23
+ ].join(" ")
24
+
25
+ Thread.new { `#{command}` }
23
26
  end
24
27
  end
25
28
  end
@@ -2,7 +2,7 @@ module Notifier
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
Binary file
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nando Vieira
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-12 00:00:00 -02:00
17
+ date: 2010-11-19 00:00:00 -02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -67,6 +67,7 @@ files:
67
67
  - lib/notifier/snarl.rb
68
68
  - lib/notifier/version.rb
69
69
  - notifier.gemspec
70
+ - resources/register-growl.scpt
70
71
  - test/notifier_test.rb
71
72
  - test/test_helper.rb
72
73
  has_rdoc: true