prowlnotify 0.2.1
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/Rakefile +20 -0
- data/Readme.md +30 -0
- data/bin/prowlnotify +119 -0
- metadata +84 -0
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "rake/gempackagetask"
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = "prowlnotify"
|
5
|
+
s.version = "0.2.1"
|
6
|
+
s.author = "Caius Durling"
|
7
|
+
s.email = "dev@caius.name"
|
8
|
+
s.homepage = "http://github.com/caius/prowlnotify"
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = "Easily send prowl notifications from the command line"
|
11
|
+
s.bindir = "bin"
|
12
|
+
s.files = FileList["lib/**/*.rb", "bin/*", "[A-Z]*", "spec/**/*"].to_a
|
13
|
+
s.executables << "prowlnotify"
|
14
|
+
s.has_rdoc = false
|
15
|
+
s.add_dependency("prowl", "~> 0.1.3")
|
16
|
+
end
|
17
|
+
|
18
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
19
|
+
pkg.need_tar = true
|
20
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Prowlnotify
|
2
|
+
|
3
|
+
Little cli tool to let you push notifications to your phone. Modelled after `growlnotify` for growl.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
[sudo] gem install prowlnotify
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
Usage: prowlnotify [options] MESSAGE
|
12
|
+
|
13
|
+
Message can be either a string or "-" to read from stdin
|
14
|
+
|
15
|
+
-k, --api-key [KEY] Prowl API Key [optional]
|
16
|
+
If this isn't specified then -f arg or ~/.prowl is read
|
17
|
+
-p, --priority [VALUE] Priority of notification. [optional]
|
18
|
+
Defaults to "Normal"
|
19
|
+
Value between -2 and 2, or a string:
|
20
|
+
-2. Very Low
|
21
|
+
-1. Moderate
|
22
|
+
0. Normal
|
23
|
+
1. High
|
24
|
+
2. Emergency
|
25
|
+
|
26
|
+
-a, --application [NAME] Name of application sending notification. [optional]
|
27
|
+
Defaults to "prowlnotify"
|
28
|
+
-s, --subject [STRING] Subject line. [optional]
|
29
|
+
-r, --provider-key [KEY] Provider API key. [optional]
|
30
|
+
-f, --file [FILE] File to read API key from. Defaults to ~/.prowl. Ignored if -a is passed.
|
data/bin/prowlnotify
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# CHANGELOG
|
5
|
+
# * 0.2.1 More gemification
|
6
|
+
# * 0.2 Gemified
|
7
|
+
# * 0.1.5 Bugfixes, -f
|
8
|
+
# * 0.1.0 Initial Release
|
9
|
+
#
|
10
|
+
|
11
|
+
require "optparse"
|
12
|
+
# Play nicely with non-rubygemists
|
13
|
+
begin
|
14
|
+
require "prowl"
|
15
|
+
rescue LoadError
|
16
|
+
require "rubygems"
|
17
|
+
require "prowl"
|
18
|
+
end
|
19
|
+
|
20
|
+
config = {}
|
21
|
+
|
22
|
+
OptionParser.new do |opts|
|
23
|
+
opts.banner = "Usage: prowlnotify [options] MESSAGE"
|
24
|
+
opts.separator ""
|
25
|
+
opts.separator %Q{Message can be either a string or "-" to read from stdin}
|
26
|
+
opts.separator ""
|
27
|
+
|
28
|
+
opts.on("-k", "--api-key [KEY]", "Prowl API Key [optional]", "If this isn't specified then -f arg or ~/.prowl is read") do |key|
|
29
|
+
config[:api_key] = key
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on("-p", "--priority [VALUE]",
|
33
|
+
"Priority of notification. [optional]",
|
34
|
+
%Q{Defaults to "Normal"},
|
35
|
+
"Value between -2 and 2, or a string:",
|
36
|
+
"\t -2. Very Low",
|
37
|
+
"\t -1. Moderate",
|
38
|
+
"\t 0. Normal",
|
39
|
+
"\t 1. High",
|
40
|
+
"\t 2. Emergency"
|
41
|
+
) do |priority|
|
42
|
+
strings = {"very low" => -2, "moderate" => -1, "normal" => 0, "high" => 1, "emergency" => 2}
|
43
|
+
if priority.to_i.to_s == priority.to_s
|
44
|
+
# It's an integer
|
45
|
+
config[:priority] = priority.to_i
|
46
|
+
else
|
47
|
+
# It's a string
|
48
|
+
config[:priority] = strings[priority.downcase]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.separator ""
|
53
|
+
|
54
|
+
opts.on("-a", "--application [NAME]", "Name of application sending notification. [optional]",
|
55
|
+
%Q{Defaults to "prowlnotify"}) do |name|
|
56
|
+
config[:application] = name
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("-s", "--subject [STRING]", "Subject line. [optional]") do |subject|
|
60
|
+
config[:event] = subject
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("-r", "--provider-key [KEY]", "Provider API key. [optional]") do |key|
|
64
|
+
config[:provider_key] = key
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("-f", "--file [FILE]", "File to read API key from. Defaults to ~/.prowl. Ignored if -a is passed.") do |path|
|
68
|
+
config[:api_file] = File.expand_path(path)
|
69
|
+
end
|
70
|
+
end.parse!
|
71
|
+
|
72
|
+
# Setup some defaults for optional args
|
73
|
+
config[:priority] ||= 0
|
74
|
+
config[:application] ||= "prowlnotify"
|
75
|
+
config[:event] ||= ""
|
76
|
+
|
77
|
+
# Unless key is specified, read it from ~/.prowl if it exists
|
78
|
+
# If the key isn't set and file doesn't exist we error later
|
79
|
+
unless config[:api_key]
|
80
|
+
api_file = config[:api_file] || File.expand_path("~/.prowl")
|
81
|
+
config[:api_key] = File.open(api_file, "r").read.chomp if File.exists?(api_file)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Grab the message
|
85
|
+
config[:description] = ARGV.join(" ")
|
86
|
+
|
87
|
+
# Check if we're reading stdin
|
88
|
+
if config[:description] == "-"
|
89
|
+
config[:description] = $stdin.read.chomp
|
90
|
+
end
|
91
|
+
|
92
|
+
# Check we've got what we need to send a notification
|
93
|
+
unless config.has_key?(:api_key) && !config[:api_key].empty?
|
94
|
+
puts "ERROR: Missing API key."
|
95
|
+
puts "Either pass it as an argument or put it in ~/.prowl"
|
96
|
+
exit(1)
|
97
|
+
end
|
98
|
+
|
99
|
+
unless config.has_key?(:description) && !config[:description].empty?
|
100
|
+
puts "ERROR: Missing message text."
|
101
|
+
puts %Q{Either pass it as a string, or pass "-" to read from stdin.}
|
102
|
+
exit(1)
|
103
|
+
end
|
104
|
+
|
105
|
+
puts "Sending #{config[:description].inspect}"
|
106
|
+
|
107
|
+
prowl_hash = {
|
108
|
+
:apikey => config[:api_key],
|
109
|
+
:application => config[:application],
|
110
|
+
:event => config[:event],
|
111
|
+
:description => config[:description],
|
112
|
+
:priority => config[:priority]
|
113
|
+
}
|
114
|
+
|
115
|
+
if config[:provider_key]
|
116
|
+
prowl_hash.merge!(:providerkey => config[:providerkey])
|
117
|
+
end
|
118
|
+
|
119
|
+
Prowl.add(prowl_hash)
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prowlnotify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Caius Durling
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-07-20 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: prowl
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 29
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 1
|
33
|
+
- 3
|
34
|
+
version: 0.1.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description:
|
38
|
+
email: dev@caius.name
|
39
|
+
executables:
|
40
|
+
- prowlnotify
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- bin/prowlnotify
|
47
|
+
- Rakefile
|
48
|
+
- Readme.md
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/caius/prowlnotify
|
51
|
+
licenses: []
|
52
|
+
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
hash: 3
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirements: []
|
77
|
+
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.3.7
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Easily send prowl notifications from the command line
|
83
|
+
test_files: []
|
84
|
+
|