visionmedia-growl 0.0.5 → 0.0.6

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/Growl.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{growl}
5
- s.version = "0.0.5"
5
+ s.version = "0.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2009-04-08}
9
+ s.date = %q{2009-04-09}
10
10
  s.description = %q{growlnotify bindings}
11
11
  s.email = %q{tj@vision-media.ca}
12
- s.extra_rdoc_files = ["lib/growl/growl.rb", "lib/growl/version.rb", "lib/growl.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
- s.files = ["Growl.gemspec", "History.rdoc", "lib/growl/growl.rb", "lib/growl/version.rb", "lib/growl.rb", "Manifest", "Rakefile", "README.rdoc", "spec/fixtures/icon.icns", "spec/fixtures/image.png", "spec/growl_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "Todo.rdoc", "growl.gemspec"]
12
+ s.extra_rdoc_files = ["lib/growl/growl.rb", "lib/growl/images/error.png", "lib/growl/images/info.png", "lib/growl/images/ok.png", "lib/growl/images/warning.png", "lib/growl/version.rb", "lib/growl.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
13
+ s.files = ["examples/growl.rb", "Growl.gemspec", "History.rdoc", "lib/growl/growl.rb", "lib/growl/images/error.png", "lib/growl/images/info.png", "lib/growl/images/ok.png", "lib/growl/images/warning.png", "lib/growl/version.rb", "lib/growl.rb", "Manifest", "Rakefile", "README.rdoc", "spec/fixtures/icon.icns", "spec/fixtures/image.png", "spec/growl_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "Todo.rdoc", "growl.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/visionmedia/growl}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Growl", "--main", "README.rdoc"]
data/History.rdoc CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ === 0.0.6 / 2009-04-09
3
+
4
+ * Added #notify_{ok,info,warning,error} and images
5
+ * Added examples and updated docs
6
+ * Refactored Growl::Base.switch
7
+
2
8
  === 0.0.5 / 2009-04-08
3
9
 
4
10
  * Now returning nil when trying to instantiate Growl when not installed
data/Manifest CHANGED
@@ -1,6 +1,11 @@
1
+ examples/growl.rb
1
2
  Growl.gemspec
2
3
  History.rdoc
3
4
  lib/growl/growl.rb
5
+ lib/growl/images/error.png
6
+ lib/growl/images/info.png
7
+ lib/growl/images/ok.png
8
+ lib/growl/images/warning.png
4
9
  lib/growl/version.rb
5
10
  lib/growl.rb
6
11
  Manifest
data/README.rdoc CHANGED
@@ -9,11 +9,11 @@ Ruby growlnotify 'bindings'.
9
9
  notification.message = 'Hello World'
10
10
  notification.sticky!
11
11
  notification.icon = :jpeg
12
- notification.run
12
+ notification.run if Growl.installed?
13
13
 
14
14
  # OR
15
15
 
16
- Growl {
16
+ Growl.notify {
17
17
  self.message = 'Hello World'
18
18
  self.icon = :jpeg
19
19
  sticky!
@@ -21,7 +21,7 @@ Ruby growlnotify 'bindings'.
21
21
 
22
22
  # OR
23
23
 
24
- Growl do |n|
24
+ Growl.notify do |n|
25
25
  n.message = 'Hello World'
26
26
  n.icon = :jpeg
27
27
  n.stick!
@@ -29,15 +29,28 @@ Ruby growlnotify 'bindings'.
29
29
 
30
30
  # OR
31
31
 
32
- Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl
32
+ Growl.notify 'Foo', :icon => :jpeg, :title => 'Growl'
33
+
34
+ # OR
35
+
36
+ include Growl
37
+ notify 'Email received', :sticky => true
38
+
39
+ #Convenience methods
40
+
41
+ notify_ok 'Deployment successful'
42
+ notify_info 'Email received'
43
+ notify_warning 'Merge required'
44
+ notify_error 'Failed to send email', :sticky => true
33
45
 
34
46
  == Features
35
47
 
36
- * Check availability with Growl#installed?
37
- * Check dependencies with Growl#version
48
+ * Check availability with Growl.installed?
49
+ * Check dependencies with Growl.version
38
50
  * Use images, icon paths, application icons, or file format icons
39
51
  * Sticky a notification making it appear until explicitly closed
40
52
  * Set notification priority
53
+ * Convenience methods such as notify_ok, notify_warning, notify_error, and notify_info
41
54
  * Etc (consult growlnotify --help)
42
55
 
43
56
  == License:
data/Todo.rdoc CHANGED
@@ -1,6 +1,7 @@
1
1
 
2
2
  == Major:
3
3
 
4
+ * Fix priority, and have constants
4
5
  * Switch aliases since appIcon is ... lame
5
6
  * Allow the icon switch to be an image, icon, or extension. This would be much more usable than --icon, --image, and --iconpath
6
7
  * Docs for installing growlnotify
data/examples/growl.rb ADDED
@@ -0,0 +1,30 @@
1
+
2
+ $:.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'growl'
4
+
5
+ puts "growlnotify version #{Growl.version} installed"
6
+
7
+ imagepath = File.dirname(__FILE__) + '/../spec/fixtures/image.png'
8
+ iconpath = File.dirname(__FILE__) + '/../spec/fixtures/icon.icns'
9
+
10
+ Growl.notify do |notification|
11
+ notification.sticky!
12
+ notification.title = 'Sticky'
13
+ notification.message = 'Im sticky'
14
+ end
15
+
16
+ Growl.notify do
17
+ sticky!
18
+ self.title = 'Image'
19
+ self.message = 'I have an image as an icon'
20
+ self.image = imagepath
21
+ end
22
+
23
+ include Growl
24
+
25
+ notify 'Whoop', :appIcon => 'Safari'
26
+ notify 'Image processing complete', :icon => :jpeg
27
+ notify 'Kicks ass!', :title => 'Growl', :iconpath => iconpath
28
+ notify_info 'New email received'
29
+ notify_ok 'Deployment complete'
30
+ notify_error 'Deployment failure'
data/lib/growl/growl.rb CHANGED
@@ -9,37 +9,69 @@ module Growl
9
9
 
10
10
  class Error < StandardError; end
11
11
 
12
+ ##
13
+ # Display a growl notification +message+, with +options+
14
+ # documented below. Alternatively a +block+ may be passed
15
+ # which is then instance evaluated or yielded to the block.
16
+ #
17
+ # This method is simply returns nil when growlnotify
18
+ # is not installed, as growl notifications should never
19
+ # be the only means of communication between your application
20
+ # and your user.
21
+ #
22
+ # === Examples
23
+ #
24
+ # Growl.notify 'Hello'
25
+ # Growl.notify 'Hello', :title => 'TJ Says:', :sticky => true
26
+ # Growl.notify { |n| n.message = 'Hello'; n.sticky! }
27
+ # Growl.notify { self.message = 'Hello'; sticky! }
28
+ #
29
+
30
+ def notify message = nil, options = {}, &block
31
+ return unless Growl.installed?
32
+ options.merge! :message => message if message
33
+ Growl.new(options, &block).run
34
+ end
35
+ module_function :notify
36
+
12
37
  #--
13
- # Singleton methods
38
+ # Generate notify_STATUS methods.
14
39
  #++
15
40
 
16
- module_function
41
+ %w( ok info warning error ).each do |type|
42
+ define_method :"notify_#{type}" do |message, *args|
43
+ options = args.first || {}
44
+ image = File.join File.expand_path(File.dirname(__FILE__)), 'images', "#{type}.png"
45
+ notify message, options.merge(:image => image)
46
+ end
47
+ module_function :"notify_#{type}"
48
+ end
17
49
 
18
50
  ##
19
51
  # Execute +args+ against the binary.
20
52
 
21
- def exec *args
53
+ def self.exec *args
22
54
  Kernel.system BIN, *args
23
55
  end
24
56
 
25
57
  ##
26
58
  # Return the version triple of the binary.
27
59
 
28
- def version
60
+ def self.version
29
61
  @version ||= `#{BIN} --version`.split[1]
30
62
  end
31
63
 
32
64
  ##
33
65
  # Check if the binary is installed and accessable.
34
66
 
35
- def installed?
36
- !! version
67
+ def self.installed?
68
+ version
37
69
  end
38
70
 
39
71
  ##
40
72
  # Return an instance of Growl::Base or nil when not installed.
41
73
 
42
- def new *args, &block
74
+ def self.new *args, &block
43
75
  return unless installed?
44
76
  Base.new *args, &block
45
77
  end
@@ -78,7 +110,7 @@ module Growl
78
110
  self.class.switches.each do |switch|
79
111
  if send(:"#{switch}?")
80
112
  args << "--#{switch}"
81
- args << send(switch) if send(switch).is_a? String
113
+ args << send(switch).to_s if send(switch) && !(TrueClass === send(switch))
82
114
  end
83
115
  end
84
116
  Growl.exec *args
@@ -100,9 +132,8 @@ module Growl
100
132
  def self.switch name
101
133
  ivar = :"@#{name}"
102
134
  (@switches ||= []) << name
103
- define_method(:"#{name}") { instance_variable_get(ivar) }
104
- define_method(:"#{name}=") { |value| instance_variable_set(ivar, value) }
105
- define_method(:"#{name}?") { !! instance_variable_get(ivar) }
135
+ attr_accessor :"#{name}"
136
+ define_method(:"#{name}?") { instance_variable_get(ivar) }
106
137
  define_method(:"#{name}!") { instance_variable_set(ivar, true) }
107
138
  end
108
139
 
@@ -136,9 +167,4 @@ module Growl
136
167
 
137
168
  end
138
169
 
139
- end
140
-
141
- def Growl options = {}, &block
142
- return unless Growl.installed?
143
- Growl.new(options, &block).run
144
170
  end
Binary file
Binary file
Binary file
Binary file
data/lib/growl/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Growl
3
- VERSION = '0.0.5'
3
+ VERSION = '0.0.6'
4
4
  end
data/spec/growl_spec.rb CHANGED
@@ -18,19 +18,27 @@ describe Growl do
18
18
  @growl.message = 'Hello World'
19
19
  end
20
20
 
21
- describe "#Growl" do
21
+ describe "#notify" do
22
22
  it "should accept a block, running immediately after" do
23
- Growl { |n| n.message = 'Invoked via Growl' }
23
+ Growl.notify { |n| n.message = 'Invoked via Growl' }.should be_true
24
24
  end
25
25
 
26
26
  it "should accept a hash" do
27
- Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl'
27
+ Growl.notify('Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl').should be_true
28
28
  end
29
29
 
30
30
  it "should return nil when not installed" do
31
31
  Growl.stub!(:installed?).and_return(false)
32
32
  Growl.new.should be_nil
33
- lambda { Growl :message => 'I should never show :)' }.should_not raise_error
33
+ lambda { Growl.notify 'I should never show :)' }.should_not raise_error
34
+ end
35
+ end
36
+
37
+ %w( ok info warning error ).each do |type|
38
+ describe "#notify_#{type}" do
39
+ it "should display #{type} notifications" do
40
+ Growl.send(:"notify_#{type}", "Hello", :title => type).should be_true
41
+ end
34
42
  end
35
43
  end
36
44
 
@@ -73,7 +81,7 @@ describe Growl do
73
81
  describe "#appIcon" do
74
82
  it "should use an application for the icon" do
75
83
  @growl.appIcon = 'Safari'
76
- @growl.message = 'Safari Icon'
84
+ @growl.message = 'Safari icon'
77
85
  @growl.run.should be_true
78
86
  end
79
87
  end
@@ -81,7 +89,7 @@ describe Growl do
81
89
  describe "#iconpath" do
82
90
  it "should use a path for the icon" do
83
91
  @growl.iconpath = fixture 'icon.icns'
84
- @growl.message = 'Custom Icon'
92
+ @growl.message = 'Custom icon'
85
93
  @growl.run.should be_true
86
94
  end
87
95
  end
@@ -92,6 +100,12 @@ describe Growl do
92
100
  @growl.message = 'Jpeg Icon'
93
101
  @growl.run.should be_true
94
102
  end
103
+
104
+ it "should allow symbols" do
105
+ @growl.icon = :jpeg
106
+ @growl.message = 'Jpeg icon with symbol'
107
+ @growl.run.should be_true
108
+ end
95
109
  end
96
110
 
97
111
  describe "#image" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-growl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-08 00:00:00 -07:00
12
+ date: 2009-04-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -21,6 +21,10 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - lib/growl/growl.rb
24
+ - lib/growl/images/error.png
25
+ - lib/growl/images/info.png
26
+ - lib/growl/images/ok.png
27
+ - lib/growl/images/warning.png
24
28
  - lib/growl/version.rb
25
29
  - lib/growl.rb
26
30
  - README.rdoc
@@ -28,9 +32,14 @@ extra_rdoc_files:
28
32
  - tasks/gemspec.rake
29
33
  - tasks/spec.rake
30
34
  files:
35
+ - examples/growl.rb
31
36
  - Growl.gemspec
32
37
  - History.rdoc
33
38
  - lib/growl/growl.rb
39
+ - lib/growl/images/error.png
40
+ - lib/growl/images/info.png
41
+ - lib/growl/images/ok.png
42
+ - lib/growl/images/warning.png
34
43
  - lib/growl/version.rb
35
44
  - lib/growl.rb
36
45
  - Manifest