libnotify 0.5.0 → 0.5.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 +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +1 -9
- data/Rakefile +18 -26
- data/lib/libnotify/api.rb +110 -0
- data/lib/libnotify/ffi.rb +35 -0
- data/lib/libnotify/version.rb +3 -0
- data/lib/libnotify.rb +3 -128
- data/libnotify.gemspec +15 -55
- data/test/helper.rb +2 -5
- data/test/test_libnotify.rb +85 -63
- metadata +27 -42
- data/Gemfile.lock +0 -38
- data/VERSION +0 -1
- data/test.watchr +0 -50
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,37 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
RUBIES = %w[ree 1.9.2 jruby]
|
5
|
+
|
1
6
|
require 'rake'
|
2
7
|
require 'rake/rdoctask'
|
3
8
|
require 'rubygems'
|
4
9
|
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |gem|
|
8
|
-
gem.name = "libnotify"
|
9
|
-
gem.summary = 'Ruby bindings for libnotify using FFI'
|
10
|
-
gem.email = "peter-libnotify@suschlik.de"
|
11
|
-
gem.homepage = "http://github.com/splattael/libnotify"
|
12
|
-
gem.authors = ["Peter Suschlik"]
|
13
|
-
|
14
|
-
gem.has_rdoc = true
|
15
|
-
gem.extra_rdoc_files = [ "README.rdoc" ]
|
16
|
-
|
17
|
-
gem.add_dependency "ffi", ">= 0.6.2"
|
18
|
-
|
19
|
-
gem.add_development_dependency "riot", "= 0.11.2"
|
20
|
-
gem.add_development_dependency "riot_notifier"
|
21
|
-
gem.add_development_dependency "yard"
|
22
|
-
|
23
|
-
gem.test_files = Dir.glob('test/test_*.rb')
|
24
|
-
end
|
25
|
-
Jeweler::GemcutterTasks.new
|
26
|
-
rescue LoadError
|
27
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
|
-
end
|
29
|
-
|
30
10
|
# Test
|
31
11
|
require 'rake/testtask'
|
32
12
|
desc 'Default: run unit tests.'
|
33
13
|
task :default => :test
|
34
|
-
task :test => :check_dependencies
|
35
14
|
|
36
15
|
Rake::TestTask.new(:test) do |test|
|
37
16
|
test.test_files = FileList.new('test/test_*.rb')
|
@@ -39,6 +18,19 @@ Rake::TestTask.new(:test) do |test|
|
|
39
18
|
test.verbose = true
|
40
19
|
end
|
41
20
|
|
21
|
+
desc "Test with several ruby versions"
|
22
|
+
task :"test:rubies" do
|
23
|
+
command = "bundle check || bundle install && rake"
|
24
|
+
RUBIES.each do |ruby|
|
25
|
+
rvm = "#{ruby}@libnotify"
|
26
|
+
puts "\n" * 3
|
27
|
+
puts "RVM: #{rvm}"
|
28
|
+
puts "=" * 40
|
29
|
+
|
30
|
+
system %{rvm #{rvm} exec bash -c '#{command}'}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
42
34
|
# Yard
|
43
35
|
begin
|
44
36
|
require 'yard'
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Libnotify
|
2
|
+
# API for Libnotify
|
3
|
+
#
|
4
|
+
# @see Libnotify
|
5
|
+
class API
|
6
|
+
include FFI
|
7
|
+
|
8
|
+
attr_reader :timeout, :icon_path
|
9
|
+
attr_accessor :summary, :body, :urgency, :append
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# List of globs to icons
|
13
|
+
attr_accessor :icon_dirs
|
14
|
+
end
|
15
|
+
|
16
|
+
self.icon_dirs = [
|
17
|
+
"/usr/share/icons/gnome/48x48/emblems",
|
18
|
+
"/usr/share/icons/gnome/256x256/emblems",
|
19
|
+
"/usr/share/icons/gnome/*/emblems"
|
20
|
+
]
|
21
|
+
|
22
|
+
# Creates a notification object.
|
23
|
+
#
|
24
|
+
# @see Libnotify.new
|
25
|
+
def initialize(options={}, &block)
|
26
|
+
set_defaults
|
27
|
+
options.each { |key, value| send("#{key}=", value) if respond_to?(key) }
|
28
|
+
yield(self) if block_given?
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_defaults
|
32
|
+
self.summary = self.body = ' '
|
33
|
+
self.urgency = :normal
|
34
|
+
self.timeout = nil
|
35
|
+
self.append = true
|
36
|
+
end
|
37
|
+
private :set_defaults
|
38
|
+
|
39
|
+
# Shows a notification.
|
40
|
+
#
|
41
|
+
# @see Libnotify.show
|
42
|
+
def show!
|
43
|
+
notify_init(self.class.to_s) or raise "notify_init failed"
|
44
|
+
notify = notify_notification_new(summary, body, icon_path, nil)
|
45
|
+
notify_notification_set_urgency(notify, urgency)
|
46
|
+
notify_notification_set_timeout(notify, timeout || -1)
|
47
|
+
if append
|
48
|
+
notify_notification_set_hint_string(notify, "x-canonical-append", "")
|
49
|
+
notify_notification_set_hint_string(notify, "append", "")
|
50
|
+
end
|
51
|
+
notify_notification_show(notify, nil)
|
52
|
+
ensure
|
53
|
+
notify_notification_clear_hints(notify) if append
|
54
|
+
end
|
55
|
+
|
56
|
+
# @todo Simplify timeout=
|
57
|
+
def timeout=(timeout)
|
58
|
+
@timeout = case timeout
|
59
|
+
when Float
|
60
|
+
timeout /= 10 if RUBY_VERSION == "1.8.6" # Strange workaround?
|
61
|
+
(timeout * 1000).to_i
|
62
|
+
when Fixnum
|
63
|
+
if timeout >= 100 # assume miliseconds
|
64
|
+
timeout
|
65
|
+
else
|
66
|
+
timeout * 1000
|
67
|
+
end
|
68
|
+
when NilClass, FalseClass
|
69
|
+
nil
|
70
|
+
else
|
71
|
+
timeout.to_s.to_i
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Sets icon path.
|
76
|
+
#
|
77
|
+
# Path can be absolute, relative (will be resolved) or an symbol.
|
78
|
+
#
|
79
|
+
# @todo document and refactor
|
80
|
+
def icon_path=(path)
|
81
|
+
case path
|
82
|
+
when /^\// # absolute
|
83
|
+
@icon_path = path
|
84
|
+
when String
|
85
|
+
# TODO refactor!
|
86
|
+
self.class.icon_dirs.map { |d| Dir[d] }.flatten.uniq.each do |dir|
|
87
|
+
full_path = File.join(dir, path)
|
88
|
+
if File.exist?(full_path)
|
89
|
+
@icon_path = full_path
|
90
|
+
return
|
91
|
+
end
|
92
|
+
end
|
93
|
+
@icon_path = path
|
94
|
+
when Symbol
|
95
|
+
self.icon_path = "#{path}.png"
|
96
|
+
else
|
97
|
+
@icon_path = nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Creates and shows a notification. It's a shortcut for +Libnotify.new(options).show!+.
|
102
|
+
#
|
103
|
+
# @see Libnotify.show
|
104
|
+
# @see Libnotify.new
|
105
|
+
def self.show(options={}, &block)
|
106
|
+
new(options, &block).show!
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Libnotify
|
2
|
+
# Raw FFI bindings.
|
3
|
+
module FFI
|
4
|
+
require 'ffi'
|
5
|
+
extend ::FFI::Library
|
6
|
+
|
7
|
+
def self.included(base)
|
8
|
+
ffi_lib %w[libnotify libnotify.so libnotify.so.1]
|
9
|
+
attach_functions!
|
10
|
+
rescue LoadError => e
|
11
|
+
warn e.message
|
12
|
+
end
|
13
|
+
|
14
|
+
enum :urgency, [ :low, :normal, :critical ]
|
15
|
+
|
16
|
+
def self.attach_functions!
|
17
|
+
attach_function :notify_init, [:string], :bool
|
18
|
+
attach_function :notify_uninit, [], :void
|
19
|
+
attach_function :notify_notification_new, [:string, :string, :string, :pointer], :pointer
|
20
|
+
attach_function :notify_notification_set_urgency, [:pointer, :urgency], :void
|
21
|
+
attach_function :notify_notification_set_timeout, [:pointer, :long], :void
|
22
|
+
attach_function :notify_notification_set_hint_string, [:pointer, :string, :string], :void
|
23
|
+
attach_function :notify_notification_clear_hints, [:pointer], :void
|
24
|
+
attach_function :notify_notification_show, [:pointer, :pointer], :bool
|
25
|
+
end
|
26
|
+
|
27
|
+
def method_missing(method, *args, &block)
|
28
|
+
if method.to_s =~ /^notify_/
|
29
|
+
warn "libnotify.so not found!"
|
30
|
+
end
|
31
|
+
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/libnotify.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'ffi'
|
2
|
-
|
3
1
|
# Ruby bindings for libnotify using FFI.
|
4
2
|
#
|
5
3
|
# See README.rdoc for usage examples.
|
@@ -8,7 +6,6 @@ require 'ffi'
|
|
8
6
|
# @see Libnotify.new
|
9
7
|
# @author Peter Suschlik
|
10
8
|
module Libnotify
|
11
|
-
|
12
9
|
# Creates a notification.
|
13
10
|
#
|
14
11
|
# @example Block syntax
|
@@ -55,129 +52,7 @@ module Libnotify
|
|
55
52
|
API.show(options, &block)
|
56
53
|
end
|
57
54
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
ffi_lib %w(libnotify libnotify.so libnotify.so.1)
|
63
|
-
|
64
|
-
enum :urgency, [ :low, :normal, :critical ]
|
65
|
-
|
66
|
-
attach_function :notify_init, [:string], :bool
|
67
|
-
attach_function :notify_uninit, [], :void
|
68
|
-
|
69
|
-
attach_function :notify_notification_new, [:string, :string, :string, :pointer], :pointer
|
70
|
-
attach_function :notify_notification_set_urgency, [:pointer, :urgency], :void
|
71
|
-
attach_function :notify_notification_set_timeout, [:pointer, :long], :void
|
72
|
-
attach_function :notify_notification_set_hint_string, [:pointer, :string, :string], :void
|
73
|
-
attach_function :notify_notification_clear_hints, [:pointer], :void
|
74
|
-
attach_function :notify_notification_show, [:pointer, :pointer], :bool
|
75
|
-
end
|
76
|
-
|
77
|
-
class API
|
78
|
-
include FFI
|
79
|
-
|
80
|
-
attr_reader :timeout, :icon_path
|
81
|
-
attr_accessor :summary, :body, :urgency, :append
|
82
|
-
|
83
|
-
class << self
|
84
|
-
# List of globs to icons
|
85
|
-
attr_accessor :icon_dirs
|
86
|
-
end
|
87
|
-
|
88
|
-
self.icon_dirs = [
|
89
|
-
"/usr/share/icons/gnome/48x48/emblems",
|
90
|
-
"/usr/share/icons/gnome/256x256/emblems",
|
91
|
-
"/usr/share/icons/gnome/*/emblems"
|
92
|
-
]
|
93
|
-
|
94
|
-
# Creates a notification object.
|
95
|
-
#
|
96
|
-
# @see Libnotify.new
|
97
|
-
def initialize(options={}, &block)
|
98
|
-
set_defaults
|
99
|
-
options.each { |key, value| send("#{key}=", value) if respond_to?(key) }
|
100
|
-
yield(self) if block_given?
|
101
|
-
end
|
102
|
-
|
103
|
-
def set_defaults
|
104
|
-
self.summary = self.body = ' '
|
105
|
-
self.urgency = :normal
|
106
|
-
self.timeout = nil
|
107
|
-
self.append = true
|
108
|
-
end
|
109
|
-
private :set_defaults
|
110
|
-
|
111
|
-
# Shows a notification.
|
112
|
-
#
|
113
|
-
# @see Libnotify.show
|
114
|
-
def show!
|
115
|
-
notify_init(self.class.to_s) or raise "notify_init failed"
|
116
|
-
notify = notify_notification_new(summary, body, icon_path, nil)
|
117
|
-
notify_notification_set_urgency(notify, urgency)
|
118
|
-
notify_notification_set_timeout(notify, timeout || -1)
|
119
|
-
if append
|
120
|
-
notify_notification_set_hint_string(notify, "x-canonical-append", "")
|
121
|
-
notify_notification_set_hint_string(notify, "append", "")
|
122
|
-
end
|
123
|
-
notify_notification_show(notify, nil)
|
124
|
-
ensure
|
125
|
-
notify_notification_clear_hints(notify) if append
|
126
|
-
end
|
127
|
-
|
128
|
-
# @todo Simplify timeout=
|
129
|
-
def timeout=(timeout)
|
130
|
-
@timeout = case timeout
|
131
|
-
when Float
|
132
|
-
timeout /= 10 if RUBY_VERSION == "1.8.6" # Strange workaround?
|
133
|
-
(timeout * 1000).to_i
|
134
|
-
when Fixnum
|
135
|
-
if timeout >= 100 # assume miliseconds
|
136
|
-
timeout
|
137
|
-
else
|
138
|
-
timeout * 1000
|
139
|
-
end
|
140
|
-
when NilClass, FalseClass
|
141
|
-
nil
|
142
|
-
else
|
143
|
-
timeout.to_s.to_i
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# Sets icon path.
|
148
|
-
#
|
149
|
-
# Path can be absolute, relative (will be resolved) or an symbol.
|
150
|
-
#
|
151
|
-
# @todo document and refactor
|
152
|
-
def icon_path=(path)
|
153
|
-
case path
|
154
|
-
when /^\// # absolute
|
155
|
-
@icon_path = path
|
156
|
-
when String
|
157
|
-
# TODO refactor!
|
158
|
-
self.class.icon_dirs.map { |d| Dir[d] }.flatten.uniq.each do |dir|
|
159
|
-
full_path = File.join(dir, path)
|
160
|
-
if File.exist?(full_path)
|
161
|
-
@icon_path = full_path
|
162
|
-
return
|
163
|
-
end
|
164
|
-
end
|
165
|
-
@icon_path = path
|
166
|
-
when Symbol
|
167
|
-
self.icon_path = "#{path}.png"
|
168
|
-
else
|
169
|
-
@icon_path = nil
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Creates and shows a notification. It's a shortcut for +Libnotify.new(options).show!+.
|
174
|
-
#
|
175
|
-
# @see Libnotify.show
|
176
|
-
# @see Libnotify.new
|
177
|
-
def self.show(options={}, &block)
|
178
|
-
new(options, &block).show!
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
182
|
-
|
55
|
+
autoload :VERSION, 'libnotify/version'
|
56
|
+
autoload :API, 'libnotify/api'
|
57
|
+
autoload :FFI, 'libnotify/ffi'
|
183
58
|
end
|
data/libnotify.gemspec
CHANGED
@@ -1,63 +1,23 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "libnotify"
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
6
|
+
s.name = "libnotify"
|
7
|
+
s.version = Libnotify::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Peter Suschlik"]
|
10
|
+
s.email = ["peter-libnotify@suschlik.de"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/libnotify"
|
12
|
+
s.summary = %q{Ruby bindings for libnotify using FFI}
|
9
13
|
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.email = %q{peter-libnotify@suschlik.de}
|
14
|
-
s.extra_rdoc_files = [
|
15
|
-
"README.rdoc"
|
16
|
-
]
|
17
|
-
s.files = [
|
18
|
-
".gitignore",
|
19
|
-
".rvmrc",
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"README.rdoc",
|
23
|
-
"Rakefile",
|
24
|
-
"VERSION",
|
25
|
-
"lib/libnotify.rb",
|
26
|
-
"libnotify.gemspec",
|
27
|
-
"libnotify.png",
|
28
|
-
"test.watchr",
|
29
|
-
"test/helper.rb",
|
30
|
-
"test/test_libnotify.rb"
|
31
|
-
]
|
32
|
-
s.homepage = %q{http://github.com/splattael/libnotify}
|
33
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
34
17
|
s.require_paths = ["lib"]
|
35
|
-
s.rubygems_version = %q{1.3.7}
|
36
|
-
s.summary = %q{Ruby bindings for libnotify using FFI}
|
37
|
-
s.test_files = [
|
38
|
-
"test/test_libnotify.rb"
|
39
|
-
]
|
40
18
|
|
41
|
-
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
|
-
s.specification_version = 3
|
19
|
+
s.add_runtime_dependency 'ffi', '~> 1.0'
|
44
20
|
|
45
|
-
|
46
|
-
|
47
|
-
s.add_development_dependency(%q<riot>, ["= 0.11.2"])
|
48
|
-
s.add_development_dependency(%q<riot_notifier>, [">= 0"])
|
49
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
50
|
-
else
|
51
|
-
s.add_dependency(%q<ffi>, [">= 0.6.2"])
|
52
|
-
s.add_dependency(%q<riot>, ["= 0.11.2"])
|
53
|
-
s.add_dependency(%q<riot_notifier>, [">= 0"])
|
54
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
55
|
-
end
|
56
|
-
else
|
57
|
-
s.add_dependency(%q<ffi>, [">= 0.6.2"])
|
58
|
-
s.add_dependency(%q<riot>, ["= 0.11.2"])
|
59
|
-
s.add_dependency(%q<riot_notifier>, [">= 0"])
|
60
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
61
|
-
end
|
21
|
+
s.add_development_dependency 'minitest'
|
22
|
+
s.add_development_dependency 'yard'
|
62
23
|
end
|
63
|
-
|
data/test/helper.rb
CHANGED
data/test/test_libnotify.rb
CHANGED
@@ -1,87 +1,109 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
class TestLibnotify < MiniTest::Unit::TestCase
|
4
|
+
def test_respond_to
|
5
|
+
assert_respond_to Libnotify, :new
|
6
|
+
assert_respond_to Libnotify, :show
|
7
|
+
end
|
5
8
|
|
6
|
-
|
7
|
-
|
9
|
+
def test_delegation
|
10
|
+
skip "test delegation using mock"
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
# old code
|
13
|
+
asserts("#new calls API#new") do
|
14
|
+
mock(Libnotify::API).new(hash_including(:body => "test")) { true }
|
15
|
+
Libnotify.new(:body => "test")
|
16
|
+
end
|
17
|
+
asserts("#show calls API#show") do
|
18
|
+
mock(Libnotify::API).show(hash_including(:body => "test")) { true }
|
19
|
+
Libnotify.show(:body => "test")
|
20
|
+
end
|
12
21
|
end
|
13
|
-
|
14
|
-
|
15
|
-
Libnotify
|
22
|
+
|
23
|
+
def test_version
|
24
|
+
assert defined?(Libnotify::VERSION), "version is defined"
|
25
|
+
assert Libnotify::VERSION
|
16
26
|
end
|
17
27
|
end
|
18
28
|
|
19
|
-
|
20
|
-
|
29
|
+
class TestLibnotifyAPI < MiniTest::Unit::TestCase
|
30
|
+
def test_without_options_and_block
|
31
|
+
assert_equal " ", libnotify.summary
|
32
|
+
assert_equal " ", libnotify.body
|
33
|
+
assert_equal :normal, libnotify.urgency
|
34
|
+
assert_nil libnotify.timeout
|
35
|
+
assert_nil libnotify.icon_path
|
36
|
+
assert libnotify.append
|
37
|
+
end
|
21
38
|
|
22
|
-
|
23
|
-
|
39
|
+
def test_with_options_and_block
|
40
|
+
libnotify(:summary => "hello", :body => "body", :invalid_option => 23) do |n|
|
41
|
+
n.body = "overwritten"
|
42
|
+
n.icon_path = "/path/to/icon"
|
43
|
+
n.append = false
|
44
|
+
end
|
24
45
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
asserts("icon_path is nil") { topic.icon_path }.nil
|
30
|
-
asserts("append is true") { topic.append }.equals(true)
|
46
|
+
assert_equal "hello", libnotify.summary
|
47
|
+
assert_equal "overwritten", libnotify.body
|
48
|
+
assert_equal "/path/to/icon", libnotify.icon_path
|
49
|
+
assert !libnotify.append
|
31
50
|
end
|
32
51
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
52
|
+
def test_timeout_setter
|
53
|
+
assert_timeout 2500, 2.5, "with float"
|
54
|
+
assert_timeout 100, 100, "with fixnum ms"
|
55
|
+
assert_timeout 101, 101, "with fixnum ms"
|
56
|
+
assert_timeout 1000, 1, "with fixnum seconds"
|
57
|
+
assert_timeout 99000, 99, "with fixnum seconds"
|
58
|
+
assert_timeout nil, nil, "with nil"
|
59
|
+
assert_timeout nil, false, "with false"
|
60
|
+
assert_timeout 2, :"2 s", "with to_s.to_i"
|
61
|
+
end
|
41
62
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
63
|
+
def test_icon_path_setter
|
64
|
+
Libnotify::API.icon_dirs << File.expand_path("../..", __FILE__)
|
65
|
+
assert_icon_path "/some/path/image.jpg", "/some/path/image.jpg", "with absolute path"
|
66
|
+
assert_icon_path "some-invalid-path.jpg", "some-invalid-path.jpg", "with non-existant relative path"
|
67
|
+
assert_icon_path %r{^/.*/libnotify.png}, "libnotify.png", "with relative path"
|
68
|
+
assert_icon_path %r{^/.*/libnotify.png}, :"libnotify", "with symbol"
|
46
69
|
end
|
47
70
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
def test_integration
|
72
|
+
skip "enable integration"
|
73
|
+
|
74
|
+
libnotify = Libnotify::API.new(:timeout => 0.5, :icon_path => :"emblem-favorite", :append => true)
|
75
|
+
|
76
|
+
[ :low, :normal, :critical ].each do |urgency|
|
77
|
+
libnotify.summary = "#{RUBY_VERSION} at #{RUBY_PLATFORM}"
|
78
|
+
libnotify.body = [ urgency, defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : '?' ].join(" ")
|
79
|
+
libnotify.urgency = urgency
|
80
|
+
libnotify.show!
|
81
|
+
end
|
59
82
|
end
|
60
83
|
|
61
|
-
|
62
|
-
setup { topic.new }
|
84
|
+
private
|
63
85
|
|
64
|
-
|
65
|
-
|
66
|
-
asserts("with relative path") { topic.icon_path = "emblem-favorite.png"; topic.icon_path }.equals("/usr/share/icons/gnome/48x48/emblems/emblem-favorite.png")
|
67
|
-
asserts("with symbol") { topic.icon_path = :"emblem-favorite"; topic.icon_path }.equals("/usr/share/icons/gnome/48x48/emblems/emblem-favorite.png")
|
86
|
+
def libnotify(options={}, &block)
|
87
|
+
@libnotify ||= Libnotify::API.new(options, &block)
|
68
88
|
end
|
69
89
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
90
|
+
def assert_timeout(expected, value, message)
|
91
|
+
assert_value_set :timeout, expected, value, message
|
92
|
+
end
|
93
|
+
|
94
|
+
def assert_icon_path(expected, value, message)
|
95
|
+
assert_value_set :icon_path, expected, value, message
|
96
|
+
end
|
75
97
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
98
|
+
def assert_value_set(attribute, expected, value, message)
|
99
|
+
libnotify.send("#{attribute}=", value)
|
100
|
+
got = libnotify.send(attribute)
|
101
|
+
case expected
|
102
|
+
when Regexp
|
103
|
+
assert_match expected, got, message
|
104
|
+
else
|
105
|
+
assert_equal expected, got, message
|
85
106
|
end
|
86
107
|
end
|
108
|
+
|
87
109
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libnotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 9
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Peter Suschlik
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-12 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,36 +24,19 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 15
|
30
30
|
segments:
|
31
|
+
- 1
|
31
32
|
- 0
|
32
|
-
|
33
|
-
- 2
|
34
|
-
version: 0.6.2
|
33
|
+
version: "1.0"
|
35
34
|
type: :runtime
|
36
35
|
version_requirements: *id001
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
37
|
+
name: minitest
|
39
38
|
prerelease: false
|
40
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - "="
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 55
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 11
|
49
|
-
- 2
|
50
|
-
version: 0.11.2
|
51
|
-
type: :development
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: riot_notifier
|
55
|
-
prerelease: false
|
56
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
57
40
|
none: false
|
58
41
|
requirements:
|
59
42
|
- - ">="
|
@@ -63,11 +46,11 @@ dependencies:
|
|
63
46
|
- 0
|
64
47
|
version: "0"
|
65
48
|
type: :development
|
66
|
-
version_requirements: *
|
49
|
+
version_requirements: *id002
|
67
50
|
- !ruby/object:Gem::Dependency
|
68
51
|
name: yard
|
69
52
|
prerelease: false
|
70
|
-
requirement: &
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
71
54
|
none: false
|
72
55
|
requirements:
|
73
56
|
- - ">="
|
@@ -77,36 +60,38 @@ dependencies:
|
|
77
60
|
- 0
|
78
61
|
version: "0"
|
79
62
|
type: :development
|
80
|
-
version_requirements: *
|
63
|
+
version_requirements: *id003
|
81
64
|
description:
|
82
|
-
email:
|
65
|
+
email:
|
66
|
+
- peter-libnotify@suschlik.de
|
83
67
|
executables: []
|
84
68
|
|
85
69
|
extensions: []
|
86
70
|
|
87
|
-
extra_rdoc_files:
|
88
|
-
|
71
|
+
extra_rdoc_files: []
|
72
|
+
|
89
73
|
files:
|
90
74
|
- .gitignore
|
91
75
|
- .rvmrc
|
76
|
+
- .travis.yml
|
92
77
|
- Gemfile
|
93
|
-
- Gemfile.lock
|
94
78
|
- README.rdoc
|
95
79
|
- Rakefile
|
96
|
-
- VERSION
|
97
80
|
- lib/libnotify.rb
|
81
|
+
- lib/libnotify/api.rb
|
82
|
+
- lib/libnotify/ffi.rb
|
83
|
+
- lib/libnotify/version.rb
|
98
84
|
- libnotify.gemspec
|
99
85
|
- libnotify.png
|
100
|
-
- test.watchr
|
101
86
|
- test/helper.rb
|
102
87
|
- test/test_libnotify.rb
|
103
88
|
has_rdoc: true
|
104
|
-
homepage: http://
|
89
|
+
homepage: http://rubygems.org/gems/libnotify
|
105
90
|
licenses: []
|
106
91
|
|
107
92
|
post_install_message:
|
108
|
-
rdoc_options:
|
109
|
-
|
93
|
+
rdoc_options: []
|
94
|
+
|
110
95
|
require_paths:
|
111
96
|
- lib
|
112
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -130,9 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
115
|
requirements: []
|
131
116
|
|
132
117
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.6.2
|
134
119
|
signing_key:
|
135
120
|
specification_version: 3
|
136
121
|
summary: Ruby bindings for libnotify using FFI
|
137
|
-
test_files:
|
138
|
-
|
122
|
+
test_files: []
|
123
|
+
|
data/Gemfile.lock
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
ffi (0.6.3)
|
5
|
-
rake (>= 0.8.7)
|
6
|
-
gemcutter (0.6.1)
|
7
|
-
git (1.2.5)
|
8
|
-
jeweler (1.4.0)
|
9
|
-
gemcutter (>= 0.1.0)
|
10
|
-
git (>= 1.2.5)
|
11
|
-
rubyforge (>= 2.0.0)
|
12
|
-
json_pure (1.4.6)
|
13
|
-
libnotify (0.2.0)
|
14
|
-
ffi (>= 0.6.2)
|
15
|
-
rake (0.8.7)
|
16
|
-
riot (0.11.2)
|
17
|
-
rr
|
18
|
-
term-ansicolor
|
19
|
-
riot_notifier (0.4.0)
|
20
|
-
libnotify (~> 0.2.0)
|
21
|
-
riot (~> 0.11.0)
|
22
|
-
rr (1.0.2)
|
23
|
-
rubyforge (2.0.4)
|
24
|
-
json_pure (>= 1.1.7)
|
25
|
-
term-ansicolor (1.0.5)
|
26
|
-
watchr (0.7)
|
27
|
-
yard (0.6.0)
|
28
|
-
|
29
|
-
PLATFORMS
|
30
|
-
ruby
|
31
|
-
|
32
|
-
DEPENDENCIES
|
33
|
-
ffi (>= 0.6.2)
|
34
|
-
jeweler
|
35
|
-
riot (= 0.11.2)
|
36
|
-
riot_notifier (~> 0.4.0)
|
37
|
-
watchr
|
38
|
-
yard
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.5.0
|
data/test.watchr
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/usr/bin/env watchr
|
2
|
-
|
3
|
-
#!/usr/bin/env watchr
|
4
|
-
|
5
|
-
def run(cmd)
|
6
|
-
puts(cmd)
|
7
|
-
system cmd
|
8
|
-
end
|
9
|
-
|
10
|
-
def run_test_file(file)
|
11
|
-
clear
|
12
|
-
run "ruby -rubygems -Ilib:test #{file}"
|
13
|
-
end
|
14
|
-
|
15
|
-
def run_tests
|
16
|
-
clear
|
17
|
-
run "rake"
|
18
|
-
end
|
19
|
-
|
20
|
-
def clear
|
21
|
-
system "clear"
|
22
|
-
end
|
23
|
-
|
24
|
-
def underscore(file)
|
25
|
-
file.gsub('/', '_')
|
26
|
-
end
|
27
|
-
|
28
|
-
@interrupted = false
|
29
|
-
|
30
|
-
Signal.trap 'QUIT' do
|
31
|
-
run_tests
|
32
|
-
end
|
33
|
-
|
34
|
-
Signal.trap 'INT' do
|
35
|
-
if @interrupted then
|
36
|
-
abort("\n")
|
37
|
-
else
|
38
|
-
puts "Interrupt a second time to quit"
|
39
|
-
@interrupted = true
|
40
|
-
Kernel.sleep 1.5
|
41
|
-
# raise Interrupt, nil # let the run loop catch it
|
42
|
-
run_tests
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
run_tests
|
47
|
-
|
48
|
-
watch('test/test_.*\.rb') {|md| run_test_file md[0] }
|
49
|
-
watch('lib/(.*)\.rb') {|md| run_test_file "test/test_#{underscore(md[1])}.rb" }
|
50
|
-
watch('test/helper.rb') { run_tests }
|