libnotify 0.6.0-universal-rubinius-1.2 → 0.7.0.pre2-universal-rubinius-1.2

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/README.rdoc CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  Ruby bindings for libnotify using FFI.
4
4
 
5
- Source[http://github.com/splattael/libnotify] |
6
- RDoc[http://rdoc.info/github/splattael/libnotify/master/file/README.rdoc]
5
+ Gem[https://rubygems.org/gems/libnotify] |
6
+ Source[https://github.com/splattael/libnotify] |
7
+ RDoc[http://rubydoc.info/github/splattael/libnotify/master/file/README.rdoc]
7
8
 
8
9
  http://github.com/splattael/libnotify/raw/master/libnotify.png
9
10
 
@@ -36,6 +37,15 @@ http://github.com/splattael/libnotify/raw/master/libnotify.png
36
37
  Libnotify.show(:icon_path => "emblem-default.png")
37
38
  Libnotify.show(:icon_path => :"emblem-default")
38
39
 
40
+ # Update pre-existing notification
41
+ n = Libnotify.new(:summary => "hello", :body => "world")
42
+ n.update # identical to show! if not shown before
43
+ Kernel.sleep 1
44
+ n.update(:body => "my love") do |notify|
45
+ notify.summary = "goodbye"
46
+ end
47
+
48
+
39
49
  == Installation
40
50
 
41
51
  gem install libnotify
@@ -54,9 +64,13 @@ You'll need libnotify. On Debian just type:
54
64
 
55
65
  == Authors
56
66
 
57
- * Peter Suschlik (http://github.com/splattael)
58
- * Dennis Collective (http://github.com/denniscollective)
59
- * Daniel Mack (http://github.com/zonque)
67
+ * Peter Suschlik (https://github.com/splattael)
68
+
69
+ == Contributors
70
+
71
+ * Dennis Collective (https://github.com/denniscollective)
72
+ * Daniel Mack (https://github.com/zonque)
73
+ * nuisanceofcats (https://github.com/nuisanceofcats)
60
74
 
61
75
  == License
62
76
 
@@ -64,4 +78,4 @@ MIT License[http://www.opensource.org/licenses/mit-license.php]
64
78
 
65
79
  == TODO
66
80
 
67
- * Mock FFI calls with rrriot. (test/test_libnotify.rb:61)
81
+ * refactor & test! (lib/libnotify/api.rb:21)
data/lib/libnotify.rb CHANGED
@@ -23,6 +23,14 @@ module Libnotify
23
23
  # @example Hash syntax
24
24
  # Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)
25
25
  #
26
+ # @example Update pre-existing notification
27
+ # n = Libnotify.new(:summary => "hello", :body => "world")
28
+ # n.update # identical to show! if not shown before
29
+ # Kernel.sleep 1
30
+ # n.update(:body => "my love") do |notify|
31
+ # notify.summary = "goodbye"
32
+ # end
33
+ #
26
34
  # @example Mixed syntax
27
35
  # Libnotify.new(options) do |n|
28
36
  # n.timeout = 1.5 # overrides :timeout in options
data/lib/libnotify/api.rb CHANGED
@@ -40,9 +40,14 @@ module Libnotify
40
40
  # @see Libnotify.new
41
41
  def initialize(options={}, &block)
42
42
  set_defaults
43
+ apply_options(options, &block)
44
+ end
45
+
46
+ def apply_options(options={}, &block)
43
47
  options.each { |key, value| send("#{key}=", value) if respond_to?(key) }
44
48
  yield(self) if block_given?
45
49
  end
50
+ private :apply_options
46
51
 
47
52
  def set_defaults
48
53
  self.summary = self.body = ' '
@@ -58,19 +63,30 @@ module Libnotify
58
63
  # @see Libnotify.show
59
64
  def show!
60
65
  notify_init(self.class.to_s) or raise "notify_init failed"
61
- notify = notify_notification_new(summary, body, icon_path, nil)
62
- notify_notification_set_urgency(notify, lookup_urgency(urgency))
63
- notify_notification_set_timeout(notify, timeout || -1)
66
+ @notification = notify_notification_new(summary, body, icon_path, nil)
67
+ notify_notification_set_urgency(@notification, lookup_urgency(urgency))
68
+ notify_notification_set_timeout(@notification, timeout || -1)
64
69
  if append
65
- notify_notification_set_hint_string(notify, "x-canonical-append", "")
66
- notify_notification_set_hint_string(notify, "append", "")
70
+ notify_notification_set_hint_string(@notification, "x-canonical-append", "")
71
+ notify_notification_set_hint_string(@notification, "append", "")
67
72
  end
68
73
  if transient
69
- notify_notification_set_hint_uint32(notify, "transient", 1)
74
+ notify_notification_set_hint_uint32(@notification, "transient", 1)
70
75
  end
71
- notify_notification_show(notify, nil)
76
+ notify_notification_show(@notification, nil)
72
77
  ensure
73
- notify_notification_clear_hints(notify) if (append || transient)
78
+ notify_notification_clear_hints(@notification) if (append || transient)
79
+ end
80
+
81
+ # Updates a previously shown notification.
82
+ def update(options={}, &block)
83
+ apply_options(options, &block)
84
+ if @notification
85
+ notify_notification_update(@notification, summary, body, icon_path, nil)
86
+ notify_notification_show(@notification, nil)
87
+ else
88
+ show!
89
+ end
74
90
  end
75
91
 
76
92
  # @todo Simplify timeout=
data/lib/libnotify/ffi.rb CHANGED
@@ -22,6 +22,7 @@ module Libnotify
22
22
  attach_function :notify_init, [:string], :bool
23
23
  attach_function :notify_uninit, [], :void
24
24
  attach_function :notify_notification_new, [:string, :string, :string, :pointer], :pointer
25
+ attach_function :notify_notification_update, [:pointer, :string, :string, :string, :pointer], :pointer
25
26
  attach_function :notify_notification_set_urgency, [:pointer, :int], :void
26
27
  attach_function :notify_notification_set_timeout, [:pointer, :long], :void
27
28
  attach_function :notify_notification_set_hint_string, [:pointer, :string, :string], :void
@@ -1,3 +1,3 @@
1
1
  module Libnotify
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0.pre2"
3
3
  end
@@ -71,6 +71,15 @@ class TestLibnotifyAPI < MiniTest::Unit::TestCase
71
71
  assert_icon_path %r{^/.*/libnotify.png}, :"libnotify", "with symbol"
72
72
  end
73
73
 
74
+ def test_update
75
+ libnotify(:summary => "hello", :body => "world").show!
76
+ libnotify.update(:summary => "hell") do |n|
77
+ n.body = "yeah"
78
+ end
79
+ assert_equal "hell", libnotify.summary
80
+ assert_equal "yeah", libnotify.body
81
+ end
82
+
74
83
  def test_integration
75
84
  skip "enable integration"
76
85
 
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libnotify
3
3
  version: !ruby/object:Gem::Version
4
- hash: 847552358
5
- prerelease:
4
+ hash: 3457254002499246919
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ - pre
11
+ - 2
12
+ version: 0.7.0.pre2
11
13
  platform: universal-rubinius-1.2
12
14
  authors:
13
15
  - Peter Suschlik
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-12-04 00:00:00 +01:00
20
+ date: 2012-01-02 00:00:00 +01:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
@@ -26,7 +28,7 @@ dependencies:
26
28
  requirements:
27
29
  - - ">="
28
30
  - !ruby/object:Gem::Version
29
- hash: 881230260
31
+ hash: 3
30
32
  segments:
31
33
  - 0
32
34
  version: "0"
@@ -40,7 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
43
- hash: 881230260
45
+ hash: 3
44
46
  segments:
45
47
  - 0
46
48
  version: "0"
@@ -54,7 +56,7 @@ dependencies:
54
56
  requirements:
55
57
  - - ~>
56
58
  - !ruby/object:Gem::Version
57
- hash: 1047025454
59
+ hash: 3
58
60
  segments:
59
61
  - 0
60
62
  - 7
@@ -74,7 +76,6 @@ extra_rdoc_files: []
74
76
  files:
75
77
  - .gitignore
76
78
  - .rvmrc
77
- - .travis.yml
78
79
  - Gemfile
79
80
  - LICENSE
80
81
  - README.rdoc
@@ -102,19 +103,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
104
  - - ">="
104
105
  - !ruby/object:Gem::Version
105
- hash: 881230260
106
+ hash: 3
106
107
  segments:
107
108
  - 0
108
109
  version: "0"
109
110
  required_rubygems_version: !ruby/object:Gem::Requirement
110
111
  none: false
111
112
  requirements:
112
- - - ">="
113
+ - - ">"
113
114
  - !ruby/object:Gem::Version
114
- hash: 881230260
115
+ hash: 25
115
116
  segments:
116
- - 0
117
- version: "0"
117
+ - 1
118
+ - 3
119
+ - 1
120
+ version: 1.3.1
118
121
  requirements: []
119
122
 
120
123
  rubyforge_project:
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- rvm:
2
- - ree
3
- - 1.9.2
4
- - jruby