carrier-pigeon 0.5.0 → 0.6.0
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/.travis.yml +3 -0
- data/README.org +35 -11
- data/Rakefile +9 -1
- data/carrier-pigeon.gemspec +3 -1
- data/lib/carrier-pigeon.rb +9 -4
- data/test/send_tests.rb +139 -0
- metadata +22 -6
data/.travis.yml
ADDED
data/README.org
CHANGED
@@ -1,40 +1,64 @@
|
|
1
|
+
[[https://secure.travis-ci.org/portertech/carrier-pigeon.png]]
|
2
|
+
|
1
3
|
* Install
|
2
4
|
|
3
5
|
: gem install carrier-pigeon
|
4
6
|
|
5
7
|
* Usage
|
6
8
|
|
7
|
-
: require
|
8
|
-
|
9
|
-
|
9
|
+
: require "carrier-pigeon"
|
10
|
+
|
11
|
+
Send a private message
|
12
|
+
|
10
13
|
: CarrierPigeon.send(
|
11
14
|
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
12
15
|
: :message => "cooooo, coo coo"
|
13
16
|
: )
|
14
|
-
|
15
|
-
|
17
|
+
|
18
|
+
Send a notice
|
19
|
+
|
20
|
+
: CarrierPigeon.send(
|
21
|
+
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
22
|
+
: :message => "cooooo, coo coo",
|
23
|
+
: :notice => true
|
24
|
+
: )
|
25
|
+
|
26
|
+
Use SSL
|
27
|
+
|
16
28
|
: CarrierPigeon.send(
|
17
29
|
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
18
30
|
: :message => "coo, secret plan",
|
19
31
|
: :ssl => true
|
20
32
|
: )
|
21
|
-
|
22
|
-
|
33
|
+
|
34
|
+
Join a channel (required for most Freenode channels)
|
35
|
+
|
23
36
|
: CarrierPigeon.send(
|
24
37
|
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
25
38
|
: :message => "cooooo, part of the flock",
|
26
39
|
: :join => true
|
27
40
|
: )
|
28
|
-
|
29
|
-
|
41
|
+
|
42
|
+
Join a channel that requires a password
|
43
|
+
|
30
44
|
: CarrierPigeon.send(
|
31
45
|
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
32
46
|
: :message => "coo, the password is ..."
|
33
47
|
: :channel_password => "secret",
|
34
48
|
: :join => true
|
35
49
|
: )
|
36
|
-
|
37
|
-
|
50
|
+
|
51
|
+
Identify with NickServ
|
52
|
+
|
53
|
+
: CarrierPigeon.send(
|
54
|
+
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
55
|
+
: :message => "nickserv, coo coo",
|
56
|
+
: :nickserv_password => "secret"
|
57
|
+
: )
|
58
|
+
|
59
|
+
Register (ping reply) prior to joining or messaging a channel
|
60
|
+
(required for some private servers)
|
61
|
+
|
38
62
|
: CarrierPigeon.send(
|
39
63
|
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
40
64
|
: :message => "cooooo, coo coo",
|
data/Rakefile
CHANGED
data/carrier-pigeon.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "carrier-pigeon"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.6.0"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.authors = ["Sean Porter"]
|
6
6
|
s.email = ["portertech@gmail.com"]
|
@@ -14,6 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_dependency("addressable")
|
16
16
|
|
17
|
+
s.add_development_dependency("rake")
|
18
|
+
|
17
19
|
s.files = `git ls-files`.split("\n")
|
18
20
|
s.require_paths = ["lib"]
|
19
21
|
end
|
data/lib/carrier-pigeon.rb
CHANGED
@@ -32,11 +32,16 @@ class CarrierPigeon
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
if options[:join]
|
36
|
+
join = "JOIN #{options[:channel]}"
|
37
|
+
join += " #{options[:channel_password]}" if options[:channel_password]
|
38
|
+
sendln join
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
|
-
def message(channel, message)
|
39
|
-
|
42
|
+
def message(channel, message, notice = false)
|
43
|
+
command = notice ? "NOTICE" : "PRIVMSG"
|
44
|
+
sendln "#{command} #{channel} :#{message}"
|
40
45
|
end
|
41
46
|
|
42
47
|
def die
|
@@ -59,7 +64,7 @@ class CarrierPigeon
|
|
59
64
|
"PRIVMSG NICKSERV :IDENTIFY #{options[:nickserv_password]}"
|
60
65
|
end
|
61
66
|
pigeon = new(options)
|
62
|
-
pigeon.message(options[:channel], options[:message])
|
67
|
+
pigeon.message(options[:channel], options[:message], options[:notice])
|
63
68
|
pigeon.die
|
64
69
|
end
|
65
70
|
|
data/test/send_tests.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
require "minitest/spec"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "socket"
|
4
|
+
|
5
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "carrier-pigeon")
|
6
|
+
|
7
|
+
PRIVATE_MESSAGE = <<"EXPECTED"
|
8
|
+
NICK foo
|
9
|
+
USER foo 0 * :foo
|
10
|
+
PRIVMSG #test :test
|
11
|
+
QUIT :quit
|
12
|
+
EXPECTED
|
13
|
+
|
14
|
+
NOTICE = <<"EXPECTED"
|
15
|
+
NICK foo
|
16
|
+
USER foo 0 * :foo
|
17
|
+
NOTICE #test :test
|
18
|
+
QUIT :quit
|
19
|
+
EXPECTED
|
20
|
+
|
21
|
+
JOIN = <<"EXPECTED"
|
22
|
+
NICK foo
|
23
|
+
USER foo 0 * :foo
|
24
|
+
JOIN #test
|
25
|
+
PRIVMSG #test :test
|
26
|
+
QUIT :quit
|
27
|
+
EXPECTED
|
28
|
+
|
29
|
+
JOIN_PASSWORD = <<"EXPECTED"
|
30
|
+
NICK foo
|
31
|
+
USER foo 0 * :foo
|
32
|
+
JOIN #test bar
|
33
|
+
PRIVMSG #test :test
|
34
|
+
QUIT :quit
|
35
|
+
EXPECTED
|
36
|
+
|
37
|
+
REGISTER = <<"EXPECTED"
|
38
|
+
NICK foo
|
39
|
+
USER foo 0 * :foo
|
40
|
+
PONG :hello
|
41
|
+
PRIVMSG #test :test
|
42
|
+
QUIT :quit
|
43
|
+
EXPECTED
|
44
|
+
|
45
|
+
NICKSERV_PASSWORD = <<"EXPECTED"
|
46
|
+
NICK foo
|
47
|
+
USER foo 0 * :foo
|
48
|
+
PRIVMSG NICKSERV :IDENTIFY bar
|
49
|
+
PRIVMSG #test :test
|
50
|
+
QUIT :quit
|
51
|
+
EXPECTED
|
52
|
+
|
53
|
+
describe CarrierPigeon do
|
54
|
+
|
55
|
+
before do
|
56
|
+
@server_received = ""
|
57
|
+
@tcp_server = TCPServer.new(16667)
|
58
|
+
Thread.new do
|
59
|
+
socket = @tcp_server.accept
|
60
|
+
socket.puts "PING :hello"
|
61
|
+
while line = socket.gets
|
62
|
+
@server_received << line
|
63
|
+
socket.close if line =~ /:quit/
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
after do
|
69
|
+
@tcp_server.close
|
70
|
+
sleep 1
|
71
|
+
end
|
72
|
+
|
73
|
+
it "can send a private message to an irc channel" do
|
74
|
+
CarrierPigeon.send(
|
75
|
+
:uri => "irc://foo@localhost:16667/#test",
|
76
|
+
:message => "test"
|
77
|
+
)
|
78
|
+
@server_received.must_equal(PRIVATE_MESSAGE)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "can send a notice to an irc channel" do
|
82
|
+
CarrierPigeon.send(
|
83
|
+
:uri => "irc://foo@localhost:16667/#test",
|
84
|
+
:message => "test",
|
85
|
+
:notice => true
|
86
|
+
)
|
87
|
+
@server_received.must_equal(NOTICE)
|
88
|
+
end
|
89
|
+
|
90
|
+
it "can join an irc channel and send a private message" do
|
91
|
+
CarrierPigeon.send(
|
92
|
+
:uri => "irc://foo@localhost:16667/#test",
|
93
|
+
:message => "test",
|
94
|
+
:join => true
|
95
|
+
)
|
96
|
+
@server_received.must_equal(JOIN)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "can join an irc channel with a password and send a private message" do
|
100
|
+
CarrierPigeon.send(
|
101
|
+
:uri => "irc://foo@localhost:16667/#test",
|
102
|
+
:message => "test",
|
103
|
+
:channel_password => "bar",
|
104
|
+
:join => true
|
105
|
+
)
|
106
|
+
@server_received.must_equal(JOIN_PASSWORD)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "can identify with nickserv and send a private message to an irc channel" do
|
110
|
+
CarrierPigeon.send(
|
111
|
+
:uri => "irc://foo@localhost:16667/#test",
|
112
|
+
:message => "test",
|
113
|
+
:nickserv_password => "bar"
|
114
|
+
)
|
115
|
+
@server_received.must_equal(NICKSERV_PASSWORD)
|
116
|
+
end
|
117
|
+
|
118
|
+
it "can require registration and send a private message to an irc channel" do
|
119
|
+
CarrierPigeon.send(
|
120
|
+
:uri => "irc://foo@localhost:16667/#test",
|
121
|
+
:message => "test",
|
122
|
+
:register_first => true
|
123
|
+
)
|
124
|
+
@server_received.must_equal(REGISTER)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "must be provided an irc uri" do
|
128
|
+
lambda {
|
129
|
+
CarrierPigeon.send(:message => "test")
|
130
|
+
}.must_raise RuntimeError
|
131
|
+
end
|
132
|
+
|
133
|
+
it "must be provided an irc message" do
|
134
|
+
lambda {
|
135
|
+
CarrierPigeon.send(:uri => "irc://foo@localhost:16667/#test")
|
136
|
+
}.must_raise RuntimeError
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrier-pigeon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 6
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.6.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Porter
|
@@ -15,12 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: addressable
|
23
|
-
prerelease: false
|
24
22
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
23
|
none: false
|
26
24
|
requirements:
|
@@ -31,7 +29,23 @@ dependencies:
|
|
31
29
|
- 0
|
32
30
|
version: "0"
|
33
31
|
type: :runtime
|
32
|
+
name: addressable
|
33
|
+
prerelease: false
|
34
34
|
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
name: rake
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
35
49
|
description: The simplest library to say something on IRC
|
36
50
|
email:
|
37
51
|
- portertech@gmail.com
|
@@ -43,12 +57,14 @@ extra_rdoc_files: []
|
|
43
57
|
|
44
58
|
files:
|
45
59
|
- .gitignore
|
60
|
+
- .travis.yml
|
46
61
|
- Gemfile
|
47
62
|
- MIT-LICENSE.txt
|
48
63
|
- README.org
|
49
64
|
- Rakefile
|
50
65
|
- carrier-pigeon.gemspec
|
51
66
|
- lib/carrier-pigeon.rb
|
67
|
+
- test/send_tests.rb
|
52
68
|
has_rdoc: true
|
53
69
|
homepage: https://github.com/portertech/carrier-pigeon
|
54
70
|
licenses:
|