Skip to content

Commit f063489

Browse files
author
jugyo
committed
Second commit to notify
1 parent 7846706 commit f063489

File tree

8 files changed

+63
-46
lines changed

8 files changed

+63
-46
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
notify
2+
======
3+
4+
The "notify" provides a function to notify on cross platform.
5+
6+
Feature
7+
---------
8+
9+
It supports followings:
10+
11+
- growl
12+
- notify-send
13+
14+
Installation
15+
---------
16+
17+
gem install notify
18+
19+
Usage
20+
---------
21+
22+
require 'notify'
23+
Notify.notify "title", "message"
24+
25+
Copyright
26+
---------
27+
28+
Copyright (c) 2010 jugyo. See LICENSE for details.

README.rdoc

Lines changed: 0 additions & 17 deletions
This file was deleted.

lib/notify.rb

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1-
require 'notify/notify-send'
2-
require 'notify/growl'
1+
unless defined? __DIR__
2+
__DIR__ = File.dirname(__FILE__)
3+
end
4+
5+
if ENV['NOTIFY']
6+
begin
7+
require File.join(__DIR__, "notify/#{ENV['NOTIFY']}")
8+
rescue LoadError
9+
end
10+
else
11+
unless defined? Notify
12+
Dir[File.join(__DIR__, "notify/*.rb")].each do |filename|
13+
require filename
14+
end
15+
end
16+
end
317

418
unless defined? Notify
519
module Notify
6-
def notify(text)
7-
$stderr.puts text
20+
def self.notify(title, message)
21+
$stderr.puts "#{title}: #{message}"
822
end
923
end
1024
end
11-
12-
include Notify

lib/notify/growl.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
# TODO
1+
begin
2+
require 'ruby-growl'
3+
4+
module Notify
5+
@@growl = Growl.new 'localhost', 'ruby', ['notify']
6+
def self.notify(title, message)
7+
@@growl.notify 'notify', title, message
8+
end
9+
end
10+
rescue LoadError
11+
end

lib/notify/notify-send.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
if RUBY_PLATFORM.downcase =~ /linux/ &&
2-
system('which notify-send 2>&1 > /dev/null')
1+
if RUBY_PLATFORM.downcase =~ /linux/ && system('which notify-send 2>&1 > /dev/null')
32
module Notify
4-
def notify(text)
5-
system 'notify-send', text
3+
def self.notify(title, message)
4+
system 'notify-send', title, message
65
end
76
end
87
end

sample.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
$:.unshift File.join(File.dirname(__FILE__), 'lib')
2+
require 'rubygems'
23
require 'notify'
3-
notify 'notify!'
4+
5+
Notify.notify 'title', 'message'

test/helper.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/test_notify.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)