visionmedia-growl 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Growl.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{growl}
5
+ s.version = "0.0.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["TJ Holowaychuk"]
9
+ s.date = %q{2009-04-08}
10
+ s.description = %q{growlnotify bindings}
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"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://github.com/visionmedia/growl}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Growl", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{growl}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{growlnotify bindings}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
data/History.rdoc ADDED
@@ -0,0 +1,16 @@
1
+
2
+ === 0.0.4 / 2009-04-08
3
+
4
+ * We dont want visionmedia-Growl, shesh :p, fixed to lowercase
5
+
6
+ === 0.0.3 / 2009-04-08
7
+
8
+ * Added #Growl hash support
9
+
10
+ === 0.0.2 / 2009-04-08
11
+
12
+ * Github build me!!!
13
+
14
+ === 0.0.1 / 2009-04-08
15
+
16
+ * Initial release
data/Manifest ADDED
@@ -0,0 +1,16 @@
1
+ Growl.gemspec
2
+ History.rdoc
3
+ lib/growl/growl.rb
4
+ lib/growl/version.rb
5
+ lib/growl.rb
6
+ Manifest
7
+ Rakefile
8
+ README.rdoc
9
+ spec/fixtures/icon.icns
10
+ spec/fixtures/image.png
11
+ spec/growl_spec.rb
12
+ spec/spec_helper.rb
13
+ tasks/docs.rake
14
+ tasks/gemspec.rake
15
+ tasks/spec.rake
16
+ Todo.rdoc
data/README.rdoc ADDED
@@ -0,0 +1,66 @@
1
+
2
+ = Growl
3
+
4
+ Ruby growlnotify 'bindings'.
5
+
6
+ == Examples
7
+
8
+ notification = Growl.new
9
+ notification.message = 'Hello World'
10
+ notification.sticky!
11
+ notification.icon = :jpeg
12
+ notification.run
13
+
14
+ # OR
15
+
16
+ Growl {
17
+ self.message = 'Hello World'
18
+ self.icon = :jpeg
19
+ sticky!
20
+ }
21
+
22
+ # OR
23
+
24
+ Growl do |n|
25
+ n.message = 'Hello World'
26
+ n.icon = :jpeg
27
+ n.stick!
28
+ end
29
+
30
+ # OR
31
+
32
+ Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl
33
+
34
+ == Features
35
+
36
+ * Check availability with Growl#installed?
37
+ * Check dependencies with Growl#version
38
+ * Use images, icon paths, application icons, or file format icons
39
+ * Sticky a notification making it appear until explicitly closed
40
+ * Set notification priority
41
+ * Etc (consult growlnotify --help)
42
+
43
+ == License:
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ 'Software'), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, an d/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+
2
+ $:.unshift 'lib'
3
+ require 'growl'
4
+ require 'rubygems'
5
+ require 'rake'
6
+ require 'echoe'
7
+
8
+ Echoe.new "growl", Growl::VERSION do |p|
9
+ p.author = "TJ Holowaychuk"
10
+ p.email = "tj@vision-media.ca"
11
+ p.summary = "growlnotify bindings"
12
+ p.url = "http://github.com/visionmedia/growl"
13
+ p.runtime_dependencies = []
14
+ end
15
+
16
+ Dir['tasks/**/*.rake'].sort.each { |f| load f }
data/Todo.rdoc ADDED
@@ -0,0 +1,14 @@
1
+
2
+ == Major:
3
+
4
+ * Switch aliases since appIcon is ... lame
5
+ * Allow the icon switch to be an image, icon, or extension. This would be much more usable than --icon, --image, and --iconpath
6
+ * Docs for installing growlnotify
7
+
8
+ == Minor:
9
+
10
+ * Nothing
11
+
12
+ == Brainstorming:
13
+
14
+ * Nothing
@@ -0,0 +1,142 @@
1
+
2
+ module Growl
3
+
4
+ BIN = 'growlnotify'
5
+
6
+ #--
7
+ # Exceptions
8
+ #++
9
+
10
+ class Error < StandardError; end
11
+
12
+ #--
13
+ # Singleton methods
14
+ #++
15
+
16
+ module_function
17
+
18
+ ##
19
+ # Execute +args+ against the binary.
20
+
21
+ def exec *args
22
+ Kernel.system BIN, *args
23
+ end
24
+
25
+ ##
26
+ # Return the version triple of the binary.
27
+
28
+ def version
29
+ `#{BIN} --version`.split[1]
30
+ end
31
+
32
+ ##
33
+ # Check if the binary is installed and accessable.
34
+
35
+ def installed?
36
+ !! version
37
+ end
38
+
39
+ ##
40
+ # Return an instance of Growl::Base.
41
+
42
+ def new *args, &block
43
+ Base.new *args, &block
44
+ end
45
+
46
+ #--
47
+ # Growl base
48
+ #++
49
+
50
+ class Base
51
+ attr_reader :args
52
+
53
+ ##
54
+ # Initialize with optional +block+, which is then
55
+ # instance evaled or yielded depending on the blocks arity.
56
+
57
+ def initialize options = {}, &block
58
+ @args = []
59
+ if block_given?
60
+ if block.arity > 0
61
+ yield self
62
+ else
63
+ self.instance_eval &block
64
+ end
65
+ else
66
+ options.each do |key, value|
67
+ send :"#{key}=", value
68
+ end
69
+ end
70
+ end
71
+
72
+ ##
73
+ # Run the notification, only --message is required.
74
+
75
+ def run
76
+ raise Error, 'message required' unless message
77
+ self.class.switches.each do |switch|
78
+ if send(:"#{switch}?")
79
+ args << "--#{switch}"
80
+ args << send(switch) if send(switch).is_a? String
81
+ end
82
+ end
83
+ Growl.exec *args
84
+ end
85
+
86
+ ##
87
+ # Define a switch +name+.
88
+ #
89
+ # === examples
90
+ #
91
+ # switch :sticky
92
+ #
93
+ # @growl.sticky!
94
+ # @growl.sticky? # => true
95
+ # @growl.sticky = false
96
+ # @growl.sticky? # => false
97
+ #
98
+
99
+ def self.switch name
100
+ ivar = :"@#{name}"
101
+ (@switches ||= []) << name
102
+ define_method(:"#{name}") { instance_variable_get(ivar) }
103
+ define_method(:"#{name}=") { |value| instance_variable_set(ivar, value) }
104
+ define_method(:"#{name}?") { !! instance_variable_get(ivar) }
105
+ define_method(:"#{name}!") { instance_variable_set(ivar, true) }
106
+ end
107
+
108
+ ##
109
+ # Return array of available switch symbols.
110
+
111
+ def self.switches
112
+ @switches
113
+ end
114
+
115
+ #--
116
+ # Switches
117
+ #++
118
+
119
+ switch :title
120
+ switch :message
121
+ switch :sticky
122
+ switch :name
123
+ switch :appIcon
124
+ switch :icon
125
+ switch :iconpath
126
+ switch :image
127
+ switch :priority
128
+ switch :identifier
129
+ switch :host
130
+ switch :password
131
+ switch :udp
132
+ switch :port
133
+ switch :auth
134
+ switch :crypt
135
+
136
+ end
137
+
138
+ end
139
+
140
+ def Growl options = {}, &block
141
+ Growl.new(options, &block).run
142
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module Growl
3
+ VERSION = '0.0.4'
4
+ end
data/lib/growl.rb ADDED
@@ -0,0 +1,25 @@
1
+ #--
2
+ # Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'growl/version'
25
+ require 'growl/growl'
File without changes
Binary file
@@ -0,0 +1,99 @@
1
+
2
+ describe Growl do
3
+
4
+ describe "#installed?" do
5
+ it "should check if growlnotify is available" do
6
+ Growl.should be_installed
7
+ end
8
+ end
9
+
10
+ describe "#version" do
11
+ it "should return only the version triple" do
12
+ Growl.version.should match(/\d+\.\d+\.\d+/)
13
+ end
14
+ end
15
+
16
+ before :each do
17
+ @growl = Growl.new
18
+ @growl.message = 'Hello World'
19
+ end
20
+
21
+ describe "#Growl" do
22
+ it "should accept a block, running immediately after" do
23
+ Growl { |n| n.message = 'Invoked via Growl' }
24
+ end
25
+
26
+ it "should accept a hash" do
27
+ Growl :message => 'Invoked via Growl with hash', :icon => 'jpeg', :title => 'Growl'
28
+ end
29
+ end
30
+
31
+ describe "#run" do
32
+ it "should fail when no message is present" do
33
+ lambda { Growl.new.run }.should raise_error(Growl::Error, /message required/)
34
+ end
35
+
36
+ it "should execute a growl notification" do
37
+ @growl.run.should be_true
38
+ end
39
+ end
40
+
41
+ describe "#sticky!" do
42
+ it "should make a notification stick until explicitly closed" do
43
+ @growl.sticky = false
44
+ @growl.should_not be_sticky
45
+ @growl.sticky!
46
+ @growl.should be_sticky
47
+ @growl.message = 'Im Sticky'
48
+ @growl.run.should be_true
49
+ end
50
+ end
51
+
52
+ describe "#name" do
53
+ it "should set the application name" do
54
+ @growl.name = 'Ruby'
55
+ @growl.run.should be_true
56
+ end
57
+ end
58
+
59
+ describe "#title" do
60
+ it "should add a title" do
61
+ @growl.title = 'Im a title'
62
+ @growl.message = 'I am not a title'
63
+ @growl.run.should be_true
64
+ end
65
+ end
66
+
67
+ describe "#appIcon" do
68
+ it "should use an application for the icon" do
69
+ @growl.appIcon = 'Safari'
70
+ @growl.message = 'Safari Icon'
71
+ @growl.run.should be_true
72
+ end
73
+ end
74
+
75
+ describe "#iconpath" do
76
+ it "should use a path for the icon" do
77
+ @growl.iconpath = fixture 'icon.icns'
78
+ @growl.message = 'Custom Icon'
79
+ @growl.run.should be_true
80
+ end
81
+ end
82
+
83
+ describe "#icon" do
84
+ it "should use an icon based on a file type" do
85
+ @growl.icon = 'jpeg'
86
+ @growl.message = 'Jpeg Icon'
87
+ @growl.run.should be_true
88
+ end
89
+ end
90
+
91
+ describe "#image" do
92
+ it "should use an image path for the 'icon'" do
93
+ @growl.image = fixture 'image.png'
94
+ @growl.message = 'Image as icon'
95
+ @growl.run.should be_true
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'growl'
3
+
4
+ def fixture path
5
+ File.expand_path File.join(File.dirname(__FILE__), 'fixtures', path)
6
+ end
data/tasks/docs.rake ADDED
@@ -0,0 +1,13 @@
1
+
2
+ namespace :docs do
3
+
4
+ desc 'Remove rdoc products'
5
+ task :remove => [:clobber_docs]
6
+
7
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
8
+ task :open do
9
+ browser = ENV["BROWSER"] || "safari"
10
+ sh "open -a #{browser} doc/index.html"
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+
2
+ desc 'Build gemspec file'
3
+ task :gemspec => [:build_gemspec]
data/tasks/spec.rake ADDED
@@ -0,0 +1,25 @@
1
+
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all specifications"
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ t.libs << "lib"
7
+ t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
8
+ end
9
+
10
+ namespace :spec do
11
+
12
+ desc "Run all specifications verbosely"
13
+ Spec::Rake::SpecTask.new(:verbose) do |t|
14
+ t.libs << "lib"
15
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
16
+ end
17
+
18
+ desc "Run specific specification verbosely (specify SPEC)"
19
+ Spec::Rake::SpecTask.new(:select) do |t|
20
+ t.libs << "lib"
21
+ t.spec_files = [ENV["SPEC"]]
22
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: visionmedia-growl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - TJ Holowaychuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-04-08 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: growlnotify bindings
17
+ email: tj@vision-media.ca
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/growl/growl.rb
24
+ - lib/growl/version.rb
25
+ - lib/growl.rb
26
+ - README.rdoc
27
+ - tasks/docs.rake
28
+ - tasks/gemspec.rake
29
+ - tasks/spec.rake
30
+ files:
31
+ - Growl.gemspec
32
+ - History.rdoc
33
+ - lib/growl/growl.rb
34
+ - lib/growl/version.rb
35
+ - lib/growl.rb
36
+ - Manifest
37
+ - Rakefile
38
+ - README.rdoc
39
+ - spec/fixtures/icon.icns
40
+ - spec/fixtures/image.png
41
+ - spec/growl_spec.rb
42
+ - spec/spec_helper.rb
43
+ - tasks/docs.rake
44
+ - tasks/gemspec.rake
45
+ - tasks/spec.rake
46
+ - Todo.rdoc
47
+ - growl.gemspec
48
+ has_rdoc: true
49
+ homepage: http://github.com/visionmedia/growl
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --line-numbers
53
+ - --inline-source
54
+ - --title
55
+ - Growl
56
+ - --main
57
+ - README.rdoc
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: "1.2"
71
+ version:
72
+ requirements: []
73
+
74
+ rubyforge_project: growl
75
+ rubygems_version: 1.2.0
76
+ signing_key:
77
+ specification_version: 2
78
+ summary: growlnotify bindings
79
+ test_files: []
80
+