libnotify 0.6.0 → 0.7.0.pre

Sign up to get free protection for your applications and to get access to all the features.
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
+ p notify_notification_update(@notification, summary, body, icon_path)
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.pre"
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")
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,70 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: libnotify
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.0
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 961916028
5
+ prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 0
10
+ - pre
11
+ version: 0.7.0.pre
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - Peter Suschlik
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2011-12-04 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2012-01-02 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: ffi
16
- requirement: &72263050 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 0
21
34
  version: 1.0.0
22
35
  type: :runtime
23
- prerelease: false
24
- version_requirements: *72263050
25
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
26
38
  name: minitest
27
- requirement: &72262800 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
28
41
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
33
49
  type: :development
34
- prerelease: false
35
- version_requirements: *72262800
36
- - !ruby/object:Gem::Dependency
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
37
52
  name: minitest-libnotify
38
- requirement: &72262520 !ruby/object:Gem::Requirement
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
39
55
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: '0'
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
44
63
  type: :development
45
- prerelease: false
46
- version_requirements: *72262520
47
- - !ruby/object:Gem::Dependency
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
48
66
  name: yard
49
- requirement: &72262250 !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
50
69
  none: false
51
- requirements:
70
+ requirements:
52
71
  - - ~>
53
- - !ruby/object:Gem::Version
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ - 7
77
+ - 0
54
78
  version: 0.7.0
55
79
  type: :development
56
- prerelease: false
57
- version_requirements: *72262250
80
+ version_requirements: *id004
58
81
  description:
59
- email:
82
+ email:
60
83
  - peter-libnotify@suschlik.de
61
84
  executables: []
85
+
62
86
  extensions: []
87
+
63
88
  extra_rdoc_files: []
64
- files:
89
+
90
+ files:
65
91
  - .gitignore
66
92
  - .rvmrc
67
- - .travis.yml
68
93
  - Gemfile
69
94
  - LICENSE
70
95
  - README.rdoc
@@ -80,27 +105,38 @@ files:
80
105
  - test/test_libnotify.rb
81
106
  homepage: http://rubygems.org/gems/libnotify
82
107
  licenses: []
108
+
83
109
  post_install_message:
84
110
  rdoc_options: []
85
- require_paths:
111
+
112
+ require_paths:
86
113
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
114
+ required_ruby_version: !ruby/object:Gem::Requirement
88
115
  none: false
89
- requirements:
90
- - - ! '>='
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
124
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
125
+ requirements:
126
+ - - ">"
127
+ - !ruby/object:Gem::Version
128
+ hash: 25
129
+ segments:
130
+ - 1
131
+ - 3
132
+ - 1
133
+ version: 1.3.1
99
134
  requirements: []
135
+
100
136
  rubyforge_project:
101
137
  rubygems_version: 1.8.10
102
138
  signing_key:
103
139
  specification_version: 3
104
140
  summary: Ruby bindings for libnotify using FFI
105
141
  test_files: []
106
- has_rdoc:
142
+
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- rvm:
2
- - ree
3
- - 1.9.2
4
- - jruby