cacophony 0.0.3 → 0.0.4
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 +16 -4
- data/bin/cacophony +7 -8
- data/lib/cacophony.rb +20 -5
- data/lib/cacophony/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -4,9 +4,8 @@
|
|
4
4
|
|
5
5
|
== Caco-whatsie?
|
6
6
|
|
7
|
-
Cacophony is a small
|
8
|
-
It is great for notifiying you(or others) when a long running task is complete.
|
9
|
-
It operates as a standalone executable, and it also can read from STDIN to pipe output from your tasks to the notifiers.
|
7
|
+
Cacophony is a small library that broadcasts notifications via a variety of mechanisms, such as growl, email and twitter. All instances of cacophony can share a configuration file, which can be used to centralise notification configfuration for a variety of applications. Thus, you can manage the way notifications are sent from all applications from one config file.
|
8
|
+
It also comes with a command line executable which is great for notifiying you(or others) when a long running task is complete. It operates as a standalone executable, and it also can read from STDIN to pipe output from your tasks to the notifiers.
|
10
9
|
The various notifiers are configured in ~/.cacophony, or via a config file passed via -c option.
|
11
10
|
|
12
11
|
== Requirements
|
@@ -21,7 +20,20 @@ The various notifiers are configured in ~/.cacophony, or via a config file passe
|
|
21
20
|
|
22
21
|
Running cacophony for the first time will prompt you to create a sample configuration file, which you can edit as appropriate.
|
23
22
|
|
24
|
-
== Usage
|
23
|
+
== Usage - Ruby library
|
24
|
+
|
25
|
+
Some examples:
|
26
|
+
|
27
|
+
notifier = Cacophony::Notifier.new #defaults to reading config from ~/.cacophony
|
28
|
+
notifier.notifiy('Witty title', 'informative message')
|
29
|
+
|
30
|
+
notifier = Cacophony::Notifier.new('~/.alternative_config_file')
|
31
|
+
notifier.notifiy('Witty title', 'informative message')
|
32
|
+
|
33
|
+
notifier = Cacophony::Notifier.new({:growl_notifier => {...}}) #pass config hash directly.
|
34
|
+
notifier.notifiy('Witty title', 'informative message')
|
35
|
+
|
36
|
+
== Usage - Command line
|
25
37
|
|
26
38
|
Some examples:
|
27
39
|
|
data/bin/cacophony
CHANGED
@@ -15,7 +15,6 @@ RESULTS_SIZE = 50
|
|
15
15
|
DEFAULT_TITLE = 'Cacophony Notifier'
|
16
16
|
DEFAULT_MSG = 'Task finished!'
|
17
17
|
|
18
|
-
DEFAULT_CONF_PATH = '~/.cacophony'
|
19
18
|
|
20
19
|
opts = Trollop::options do
|
21
20
|
version "Cacophony v#{Cacophony::VERSION}(c) 2011 David Lyons"
|
@@ -23,7 +22,7 @@ opts = Trollop::options do
|
|
23
22
|
Cacophony is a small program that broadcasts notifications via a variety of mechanisms, such as growl, email and twitter.
|
24
23
|
It is great for notifiying you(or others) when a long running task is complete.
|
25
24
|
It operates as a standalone executable, and it also can read from STDIN to pipe output from your tasks to the notifiers.
|
26
|
-
The various notifiers are configured in #{DEFAULT_CONF_PATH}, or via a config file passed via -c option.
|
25
|
+
The various notifiers are configured in #{Cacophony::DEFAULT_CONF_PATH}, or via a config file passed via -c option.
|
27
26
|
|
28
27
|
Usage:
|
29
28
|
cacophony [-options] [message]
|
@@ -38,16 +37,16 @@ Options:
|
|
38
37
|
EOS
|
39
38
|
opt :message, "The message to send via the notifiers", :short => 'm', :type => String, :default => DEFAULT_MSG
|
40
39
|
opt :title, "The title/subject to attach to messages", :short => 't', :type => String, :default => DEFAULT_TITLE
|
41
|
-
opt :conf_file, "Alternate location of config file (default: #{DEFAULT_CONF_PATH})", :short => 'c', :type => String
|
40
|
+
opt :conf_file, "Alternate location of config file (default: #{Cacophony::DEFAULT_CONF_PATH})", :short => 'c', :type => String
|
42
41
|
end
|
43
42
|
Trollop::die :conf_file, "must exist" unless File.exist?(opts[:conf_file]) if opts[:conf_file]
|
44
43
|
|
45
|
-
unless opts[:conf_file] || File.exist?(File.expand_path(DEFAULT_CONF_PATH))
|
46
|
-
puts "No cacophony config file found at #{DEFAULT_CONF_PATH}."
|
47
|
-
print "Would you like me to create a sample config file at #{DEFAULT_CONF_PATH} for you? (y/n):"
|
44
|
+
unless opts[:conf_file] || File.exist?(File.expand_path(Cacophony::DEFAULT_CONF_PATH))
|
45
|
+
puts "No cacophony config file found at #{Cacophony::DEFAULT_CONF_PATH}."
|
46
|
+
print "Would you like me to create a sample config file at #{Cacophony::DEFAULT_CONF_PATH} for you? (y/n):"
|
48
47
|
if $stdin.getc == 'y'
|
49
|
-
puts "Copying sample to #{DEFAULT_CONF_PATH}."
|
50
|
-
FileUtils.cp(File.join(File.dirname(THIS_FILE), '..', 'config', 'cacophony_sample.yaml'), File.expand_path(DEFAULT_CONF_PATH))
|
48
|
+
puts "Copying sample to #{Cacophony::DEFAULT_CONF_PATH}."
|
49
|
+
FileUtils.cp(File.join(File.dirname(THIS_FILE), '..', 'config', 'cacophony_sample.yaml'), File.expand_path(Cacophony::DEFAULT_CONF_PATH))
|
51
50
|
puts "Please edit this file to configure cacophony, and run again."
|
52
51
|
exit
|
53
52
|
end
|
data/lib/cacophony.rb
CHANGED
@@ -1,17 +1,32 @@
|
|
1
|
-
|
1
|
+
require 'yaml'
|
2
2
|
require 'cacophony/version'
|
3
|
+
#require all the notifiers
|
3
4
|
Dir.glob(File.join(File.dirname(__FILE__), 'notifiers', '*.rb')) {|f| require f}
|
4
5
|
|
5
6
|
|
6
7
|
module Cacophony
|
8
|
+
DEFAULT_CONF_PATH = '~/.cacophony'
|
9
|
+
|
7
10
|
class Notifier
|
8
11
|
|
9
|
-
def initialize(
|
10
|
-
|
11
|
-
|
12
|
+
def initialize(config_hash_or_filename = nil)
|
13
|
+
if config_hash_or_filename.is_a?(Hash)
|
14
|
+
@conf = config_hash_or_filename
|
15
|
+
elsif config_hash_or_filename.nil? || config_hash_or_filename.is_a?(String)
|
16
|
+
config_hash_or_filename ||= DEFAULT_CONF_PATH
|
17
|
+
path = File.expand_path(config_hash_or_filename)
|
18
|
+
begin
|
19
|
+
@conf = YAML.load_file(path)
|
20
|
+
rescue
|
21
|
+
raise "#{$!} couldn't read Cacophony config file from #{path} "
|
22
|
+
end
|
23
|
+
|
24
|
+
else
|
25
|
+
raise 'invalid config parameter.'
|
26
|
+
end
|
12
27
|
end
|
13
28
|
|
14
|
-
def notify(title, message, data)
|
29
|
+
def notify(title, message, data = [])
|
15
30
|
|
16
31
|
threads = []
|
17
32
|
@conf.each do |notifier_type, opts|
|
data/lib/cacophony/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: cacophony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dave Lyons
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-14 00:00:00 +11:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|