notifiers 1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -0
- data/README.markdown +7 -1
- data/lib/notifiers.rb +1 -0
- data/lib/notifiers/knotify.rb +22 -2
- data/notifiers.gemspec +1 -1
- data/spec/notifiers/knotify_spec.rb +44 -0
- data/spec/notifiers_spec.rb +2 -0
- metadata +5 -2
data/Gemfile
ADDED
data/README.markdown
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Notifiers
|
2
2
|
|
3
3
|
Use notifications in a simple and elegant way. :)
|
4
4
|
|
@@ -19,6 +19,12 @@ Use notifications in a simple and elegant way. :)
|
|
19
19
|
|
20
20
|
notify_send.image('my_image.png').message('Hi Growl').notify!
|
21
21
|
|
22
|
+
<b>Obs.: #notify_send is an alias to #lib_notify .</b>
|
23
|
+
|
24
|
+
## Knotify
|
25
|
+
|
26
|
+
knotify.title('Hello World').message('Hi!').notify!
|
27
|
+
|
22
28
|
# Why I created this gem?
|
23
29
|
|
24
30
|
## Only one explanation:
|
data/lib/notifiers.rb
CHANGED
data/lib/notifiers/knotify.rb
CHANGED
@@ -1,7 +1,27 @@
|
|
1
1
|
class Knotify
|
2
|
+
COMMAND = "dcop knotify default notify eventname"
|
2
3
|
|
3
|
-
def
|
4
|
-
|
4
|
+
def message(text)
|
5
|
+
@message = text
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
def title(text)
|
10
|
+
@title = text
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
command = "#{COMMAND}"
|
16
|
+
command << " '#{@title}'" if @title
|
17
|
+
command << " '#{@message}'" if @message
|
18
|
+
command << " '' ''"
|
19
|
+
command << " 12 1"
|
20
|
+
command
|
21
|
+
end
|
22
|
+
|
23
|
+
def notify!
|
24
|
+
system(to_s)
|
5
25
|
end
|
6
26
|
|
7
27
|
end
|
data/notifiers.gemspec
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Knotify do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@knotify = Knotify.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#message' do
|
10
|
+
it "should set the message instance variable" do
|
11
|
+
@knotify.message('Bulls on Parade')
|
12
|
+
@knotify.instance_variable_get(:@message).should == 'Bulls on Parade'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be possible to set the message instance variable" do
|
16
|
+
@knotify.message('Wake Up')
|
17
|
+
@knotify.instance_variable_get(:@message).should == 'Wake Up'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#title' do
|
22
|
+
|
23
|
+
it "should set the title" do
|
24
|
+
@knotify.title('Rage Against the Machine')
|
25
|
+
@knotify.instance_variable_get(:@title).should == 'Rage Against the Machine'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should be possible to set the title" do
|
29
|
+
@knotify.title('AudioSlave')
|
30
|
+
@knotify.instance_variable_get(:@title).should == 'AudioSlave'
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#to_s' do
|
36
|
+
|
37
|
+
it "should return the entire command" do
|
38
|
+
command = @knotify.title('Ruby').message('For the Win').to_s
|
39
|
+
command.should == "dcop knotify default notify eventname 'Ruby' 'For the Win' '' '' 12 1"
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/spec/notifiers_spec.rb
CHANGED
metadata
CHANGED
@@ -4,8 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
version:
|
9
|
+
version: 1.1.0
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- "Tom\xC3\xA1s D'Stefano"
|
@@ -13,7 +14,7 @@ autorequire:
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-30 00:00:00 -02:00
|
17
18
|
default_executable:
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|
@@ -58,6 +59,7 @@ extra_rdoc_files: []
|
|
58
59
|
files:
|
59
60
|
- .gitignore
|
60
61
|
- .infinity_test
|
62
|
+
- Gemfile
|
61
63
|
- README.markdown
|
62
64
|
- Tasks
|
63
65
|
- lib/notifiers.rb
|
@@ -66,6 +68,7 @@ files:
|
|
66
68
|
- lib/notifiers/notify_send.rb
|
67
69
|
- notifiers.gemspec
|
68
70
|
- spec/notifiers/growl_spec.rb
|
71
|
+
- spec/notifiers/knotify_spec.rb
|
69
72
|
- spec/notifiers/notify_send_spec.rb
|
70
73
|
- spec/notifiers_spec.rb
|
71
74
|
- spec/spec_helper.rb
|