messenger 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +49 -0
- data/VERSION.yml +4 -3
- data/bin/messenger +4 -4
- data/lib/messenger/campfire.rb +2 -0
- data/lib/messenger/email.rb +8 -2
- data/lib/messenger/jabber.rb +8 -0
- data/lib/messenger/web.rb +4 -0
- metadata +1 -1
data/README.markdown
CHANGED
@@ -1,2 +1,51 @@
|
|
1
1
|
Messenger
|
2
|
+
=========
|
3
|
+
|
4
|
+
Messenger makes it easy to send messages using a variety of services (e.g. email, web, campfire, jabber). It is designed to be used via the command-line or invoked directly with in a Ruby application. One of the guiding principles behind the library is to specify as much as possible through a single URL.
|
5
|
+
|
6
|
+
|
7
|
+
Services
|
2
8
|
========
|
9
|
+
|
10
|
+
Email
|
11
|
+
-----
|
12
|
+
|
13
|
+
Email messages are sent using the Pony gem.
|
14
|
+
|
15
|
+
messenger mailto:email@example.com "Message" --email-from your.email@example.com --email-subject "Hi"
|
16
|
+
|
17
|
+
|
18
|
+
Web
|
19
|
+
---
|
20
|
+
|
21
|
+
Web posts are send using the HTTParty gem. The message is sent as the request body, not the query.
|
22
|
+
|
23
|
+
messenger http://example.com "Message"
|
24
|
+
|
25
|
+
|
26
|
+
Campfire
|
27
|
+
--------
|
28
|
+
|
29
|
+
Campfire messages are sent using the HTTParty gem against the Campfire API.
|
30
|
+
|
31
|
+
messenger campfire://api-key:room-id@subdomain.campfirenow.com "Message"
|
32
|
+
|
33
|
+
|
34
|
+
Jabber
|
35
|
+
------
|
36
|
+
|
37
|
+
Jabber messages are sent using the xmppr4-simple gem. It's important to note that the jabber server can be sent in the URL if it can't be inferred from the jabber ID (as is the case for Google Apps ids).
|
38
|
+
|
39
|
+
messenger jabber://email@example.com/jabber_server "Message" --jabber-id your.email@example.com --jabber-password #######
|
40
|
+
|
41
|
+
|
42
|
+
Config
|
43
|
+
======
|
44
|
+
|
45
|
+
Messenger will also read in ~/.messenger (a YAML file) for default config information, such as:
|
46
|
+
|
47
|
+
jabber_id: email@example.com
|
48
|
+
jabber_password: ########
|
49
|
+
|
50
|
+
|
51
|
+
(c) 2010 Brandon Arbini / Zencoder, Inc.
|
data/VERSION.yml
CHANGED
data/bin/messenger
CHANGED
@@ -44,7 +44,7 @@ trollop_options = Trollop::options do
|
|
44
44
|
Messenger makes sending messages easy.
|
45
45
|
|
46
46
|
Usage:
|
47
|
-
|
47
|
+
messenger [options] <service> <message>
|
48
48
|
|
49
49
|
Where [options] are:
|
50
50
|
EOS
|
@@ -53,8 +53,8 @@ EOS
|
|
53
53
|
opt :timeout, "The number of seconds to allow for the call", :type => Integer
|
54
54
|
|
55
55
|
# Email options
|
56
|
-
opt :
|
57
|
-
opt :
|
56
|
+
opt :email_from, "Who the message is from (email).", :type => String
|
57
|
+
opt :email_subject, "The message subject (email).", :type => String
|
58
58
|
|
59
59
|
# Jabber options
|
60
60
|
opt :jabber_id, "The jabber ID to connect as (user@example.com)", :type => String
|
@@ -77,7 +77,7 @@ Error: no service or message specified.
|
|
77
77
|
|
78
78
|
Usage (--help for more):
|
79
79
|
|
80
|
-
|
80
|
+
messenger [options] <service> <message>
|
81
81
|
|
82
82
|
EOS
|
83
83
|
exit -1
|
data/lib/messenger/campfire.rb
CHANGED
data/lib/messenger/email.rb
CHANGED
@@ -4,11 +4,17 @@ module Messenger
|
|
4
4
|
|
5
5
|
class Email
|
6
6
|
|
7
|
+
# URL format:
|
8
|
+
# mailto:email@example.com
|
9
|
+
#
|
10
|
+
# Options:
|
11
|
+
# :email_from => Who the email is from
|
12
|
+
# :email_subject => The subject of the email
|
7
13
|
def self.send(url, message, options={})
|
8
14
|
Pony.mail(
|
9
15
|
:to => url.sub(/mailto:/, ''),
|
10
|
-
:from => options[:
|
11
|
-
:subject => options[:
|
16
|
+
:from => options[:email_from],
|
17
|
+
:subject => options[:email_subject],
|
12
18
|
:body => message
|
13
19
|
)
|
14
20
|
[true, nil]
|
data/lib/messenger/jabber.rb
CHANGED
@@ -4,6 +4,14 @@ module Messenger
|
|
4
4
|
|
5
5
|
class Jabber
|
6
6
|
|
7
|
+
# URL format:
|
8
|
+
# jabber://email@example.com/server_hostname
|
9
|
+
#
|
10
|
+
# The server's hostname is optional, but needed for Google Apps jabber accounts.
|
11
|
+
#
|
12
|
+
# Options:
|
13
|
+
# :jabber_id => The jabber id of the sender
|
14
|
+
# :jabber_password => The password of the sender
|
7
15
|
def self.send(url, body, options={})
|
8
16
|
recipient, host = url.sub("jabber://", "").split("/")[0,2]
|
9
17
|
jabber = ::Jabber::Simple.new(options[:jabber_id], options[:jabber_password], host)
|
data/lib/messenger/web.rb
CHANGED
@@ -4,6 +4,10 @@ module Messenger
|
|
4
4
|
|
5
5
|
class Web
|
6
6
|
|
7
|
+
# URL format:
|
8
|
+
# http://example.com
|
9
|
+
#
|
10
|
+
# The body of the message is posted as the body of the request, not the query.
|
7
11
|
def self.send(url, body, options={})
|
8
12
|
response = HTTParty.post(url, options.merge(:body => body))
|
9
13
|
[success?(response), response]
|