notify 0.3.0 → 0.4.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -1,24 +1,37 @@
1
- unless defined? __DIR__
2
- __DIR__ = File.dirname(__FILE__)
1
+ require 'fileutils'
2
+ require 'erb'
3
+
4
+ module Notify
5
+ def self.which(prog, path=ENV['PATH'])
6
+ if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin|cygwin/
7
+ path.split(File::PATH_SEPARATOR).each {|dir|
8
+ f = File.join(dir,prog+".exe")
9
+ return f if File.executable?(File.join(f)) && !File.directory?(f)
10
+ }
11
+ nil
12
+ else
13
+ return system("which #{prog} > /dev/null 2>&1")
14
+ end
15
+ end
16
+
17
+ def self.html_escape(text)
18
+ ERB::Util.html_escape(text)
19
+ end
3
20
  end
4
21
 
22
+ dir = File.dirname(__FILE__)
5
23
  if ENV['NOTIFY']
6
- begin
7
- require File.join(__DIR__, "notify/#{ENV['NOTIFY']}")
8
- rescue LoadError
9
- end
24
+ require File.join(dir, "notify/#{ENV['NOTIFY']}")
10
25
  else
11
- unless defined? Notify
12
- Dir[File.join(__DIR__, "notify/*.rb")].each do |filename|
13
- break if defined? Notify
14
- require filename
15
- end
26
+ Dir[File.join(dir, "notify/*.rb")].each do |filename|
27
+ break if Notify.methods.include?(:notify)
28
+ require filename
16
29
  end
17
30
  end
18
31
 
19
- unless defined? Notify
20
- module Notify
21
- def self.notify(title, message)
32
+ module Notify
33
+ unless methods.include?(:notify)
34
+ def self.notify(title, message, options = {})
22
35
  puts "#{title}: #{message}"
23
36
  end
24
37
  end
@@ -1,5 +1,5 @@
1
- if system('which growlnotify > /dev/null 2>&1')
2
- module Notify
1
+ module Notify
2
+ if which('growlnotify')
3
3
  def self.notify(title, message, option = {})
4
4
  system 'growlnotify', '-t', title, '-m', message
5
5
  end
@@ -1,5 +1,5 @@
1
- if system('which kdialog > /dev/null 2>&1')
2
- module Notify
1
+ module Notify
2
+ if which('kdialog')
3
3
  def self.notify(title, message, option = {})
4
4
  system 'kdialog', '--passivepopup', message, '--title',title
5
5
  end
@@ -0,0 +1,9 @@
1
+ module Notify
2
+ begin
3
+ require 'libnotify'
4
+ def self.notify(title, message, option={})
5
+ Libnotify.show(:summary => title, :body => html_escape(message), :icon_path => option[:icon])
6
+ end
7
+ rescue LoadError
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
- if system('which notify-send > /dev/null 2>&1')
2
- module Notify
1
+ module Notify
2
+ if which('notify-send')
3
3
  def self.notify(title, message, option = {})
4
- system 'notify-send', title, message
4
+ system 'notify-send', title, html_escape(message)
5
5
  end
6
6
  end
7
7
  end
@@ -1,11 +1,11 @@
1
- begin
2
- require 'ruby-growl'
1
+ module Notify
2
+ begin
3
+ require 'ruby-growl'
3
4
 
4
- module Notify
5
5
  @@growl = Growl.new 'localhost', 'ruby', ['notify']
6
6
  def self.notify(title, message, option = {})
7
7
  @@growl.notify 'notify', title, message, option[:priority] || 0, option[:sticky] || false
8
8
  end
9
+ rescue LoadError
9
10
  end
10
- rescue LoadError
11
11
  end
@@ -1,10 +1,10 @@
1
- begin
2
- require 'ruby_gntp'
1
+ module Notify
2
+ begin
3
+ require 'ruby_gntp'
3
4
 
4
- module Notify
5
5
  def self.notify(title, message, option = {})
6
6
  GNTP.notify :app_name => "ruby", :title => title, :text => message, :icon => option[:icon] || "", :sticky => option[:sticky] || false
7
7
  end
8
+ rescue LoadError
8
9
  end
9
- rescue LoadError
10
10
  end
@@ -0,0 +1,10 @@
1
+ module Notify
2
+ begin
3
+ require 'terminal-notifier'
4
+
5
+ def self.notify(title, message, options = {})
6
+ TerminalNotifier.notify(message, {:title => title}.merge(options))
7
+ end
8
+ rescue LoadError
9
+ end
10
+ end
@@ -0,0 +1,51 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "notify"
8
+ s.version = "0.4.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["jugyo"]
12
+ s.date = "2012-08-01"
13
+ s.description = "The \"notify\" provides a function to notify on cross platform."
14
+ s.email = "jugyo.org@gmail.com"
15
+ s.executables = ["notify"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ "LICENSE",
22
+ "README.md",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "bin/notify",
26
+ "lib/notify.rb",
27
+ "lib/notify/growlnotify.rb",
28
+ "lib/notify/kdialog.rb",
29
+ "lib/notify/libnotify.rb",
30
+ "lib/notify/notify-send.rb",
31
+ "lib/notify/ruby-growl.rb",
32
+ "lib/notify/ruby_gntp.rb",
33
+ "lib/notify/terminal-notifier.rb",
34
+ "notify.gemspec",
35
+ "sample.rb"
36
+ ]
37
+ s.homepage = "http://github.com/jugyo/notify"
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "1.8.23"
40
+ s.summary = "A function to notify on cross platform."
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ else
47
+ end
48
+ else
49
+ end
50
+ end
51
+
metadata CHANGED
@@ -1,33 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: notify
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 0
9
- version: 0.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - jugyo
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-09-29 00:00:00 +09:00
18
- default_executable: notify
12
+ date: 2012-08-01 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description: The "notify" provides a function to notify on cross platform.
22
15
  email: jugyo.org@gmail.com
23
- executables:
16
+ executables:
24
17
  - notify
25
18
  extensions: []
26
-
27
- extra_rdoc_files:
19
+ extra_rdoc_files:
28
20
  - LICENSE
29
21
  - README.md
30
- files:
22
+ files:
31
23
  - LICENSE
32
24
  - README.md
33
25
  - Rakefile
@@ -36,42 +28,35 @@ files:
36
28
  - lib/notify.rb
37
29
  - lib/notify/growlnotify.rb
38
30
  - lib/notify/kdialog.rb
39
- - lib/notify/lib_notify.rb
31
+ - lib/notify/libnotify.rb
40
32
  - lib/notify/notify-send.rb
41
33
  - lib/notify/ruby-growl.rb
42
34
  - lib/notify/ruby_gntp.rb
35
+ - lib/notify/terminal-notifier.rb
36
+ - notify.gemspec
43
37
  - sample.rb
44
- has_rdoc: true
45
38
  homepage: http://github.com/jugyo/notify
46
39
  licenses: []
47
-
48
40
  post_install_message:
49
- rdoc_options:
50
- - --charset=UTF-8
51
- require_paths:
41
+ rdoc_options: []
42
+ require_paths:
52
43
  - lib
53
- required_ruby_version: !ruby/object:Gem::Requirement
44
+ required_ruby_version: !ruby/object:Gem::Requirement
54
45
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- segments:
59
- - 0
60
- version: "0"
61
- required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
51
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- segments:
67
- - 0
68
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
69
56
  requirements: []
70
-
71
57
  rubyforge_project:
72
- rubygems_version: 1.3.7
58
+ rubygems_version: 1.8.23
73
59
  signing_key:
74
60
  specification_version: 3
75
61
  summary: A function to notify on cross platform.
76
62
  test_files: []
77
-
@@ -1,9 +0,0 @@
1
- begin
2
- require 'libnotify'
3
- module Notify
4
- def self.notify(title, message, option={})
5
- Libnotify.show(:summary => title, :body => message, :icon_path => option[:icon])
6
- end
7
- end
8
- rescue LoadError
9
- end