carrier-pigeon 0.6.0 → 0.7.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/README.org +0 -8
- data/carrier-pigeon.gemspec +1 -1
- data/lib/carrier-pigeon.rb +7 -8
- data/test/send_tests.rb +83 -63
- metadata +4 -4
data/README.org
CHANGED
@@ -56,12 +56,4 @@ Identify with NickServ
|
|
56
56
|
: :nickserv_password => "secret"
|
57
57
|
: )
|
58
58
|
|
59
|
-
Register (ping reply) prior to joining or messaging a channel
|
60
|
-
(required for some private servers)
|
61
59
|
|
62
|
-
: CarrierPigeon.send(
|
63
|
-
: :uri => "irc://nick:password@irc.domain.com:6667/#channel",
|
64
|
-
: :message => "cooooo, coo coo",
|
65
|
-
: :register_first => true,
|
66
|
-
: :join => true
|
67
|
-
: )
|
data/carrier-pigeon.gemspec
CHANGED
data/lib/carrier-pigeon.rb
CHANGED
@@ -22,16 +22,15 @@ class CarrierPigeon
|
|
22
22
|
sendln "PASS #{options[:password]}" if options[:password]
|
23
23
|
sendln "NICK #{options[:nick]}"
|
24
24
|
sendln "USER #{options[:nick]} 0 * :#{options[:nick]}"
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
break
|
32
|
-
end
|
25
|
+
while line = @socket.gets
|
26
|
+
case line
|
27
|
+
when /00[1-4] #{Regexp.escape(options[:nick])}/
|
28
|
+
break
|
29
|
+
when /^PING :(.+)$/i
|
30
|
+
sendln "PONG :#{$1}"
|
33
31
|
end
|
34
32
|
end
|
33
|
+
sendln options[:nickserv_command] if options[:nickserv_command]
|
35
34
|
if options[:join]
|
36
35
|
join = "JOIN #{options[:channel]}"
|
37
36
|
join += " #{options[:channel_password]}" if options[:channel_password]
|
data/test/send_tests.rb
CHANGED
@@ -26,18 +26,18 @@ PRIVMSG #test :test
|
|
26
26
|
QUIT :quit
|
27
27
|
EXPECTED
|
28
28
|
|
29
|
-
|
29
|
+
PONG = <<"EXPECTED"
|
30
30
|
NICK foo
|
31
31
|
USER foo 0 * :foo
|
32
|
-
|
32
|
+
PONG :dummy
|
33
33
|
PRIVMSG #test :test
|
34
34
|
QUIT :quit
|
35
35
|
EXPECTED
|
36
36
|
|
37
|
-
|
37
|
+
JOIN_PASSWORD = <<"EXPECTED"
|
38
38
|
NICK foo
|
39
39
|
USER foo 0 * :foo
|
40
|
-
|
40
|
+
JOIN #test bar
|
41
41
|
PRIVMSG #test :test
|
42
42
|
QUIT :quit
|
43
43
|
EXPECTED
|
@@ -51,13 +51,12 @@ QUIT :quit
|
|
51
51
|
EXPECTED
|
52
52
|
|
53
53
|
describe CarrierPigeon do
|
54
|
-
|
55
54
|
before do
|
56
55
|
@server_received = ""
|
57
56
|
@tcp_server = TCPServer.new(16667)
|
58
57
|
Thread.new do
|
59
58
|
socket = @tcp_server.accept
|
60
|
-
socket.puts
|
59
|
+
server_messages.each { |msg| socket.puts msg }
|
61
60
|
while line = socket.gets
|
62
61
|
@server_received << line
|
63
62
|
socket.close if line =~ /:quit/
|
@@ -70,70 +69,91 @@ describe CarrierPigeon do
|
|
70
69
|
sleep 1
|
71
70
|
end
|
72
71
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
72
|
+
describe "with server reply" do
|
73
|
+
let :server_messages do
|
74
|
+
[
|
75
|
+
":dummy 001 foo :Welcome to the Internet Relay Network",
|
76
|
+
":dummy 002 foo :Your host is dummy",
|
77
|
+
":dummy 003 foo :This server was created now",
|
78
|
+
":dummy 004 foo dummy"
|
79
|
+
]
|
80
|
+
end
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
82
|
+
it "can send a private message to an irc channel" do
|
83
|
+
CarrierPigeon.send(
|
84
|
+
:uri => "irc://foo@localhost:16667/#test",
|
85
|
+
:message => "test"
|
86
|
+
)
|
87
|
+
@server_received.must_equal(PRIVATE_MESSAGE)
|
88
|
+
end
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
90
|
+
it "can send a notice to an irc channel" do
|
91
|
+
CarrierPigeon.send(
|
92
|
+
:uri => "irc://foo@localhost:16667/#test",
|
93
|
+
:message => "test",
|
94
|
+
:notice => true
|
95
|
+
)
|
96
|
+
@server_received.must_equal(NOTICE)
|
97
|
+
end
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
99
|
+
it "can join an irc channel and send a private message" do
|
100
|
+
CarrierPigeon.send(
|
101
|
+
:uri => "irc://foo@localhost:16667/#test",
|
102
|
+
:message => "test",
|
103
|
+
:join => true
|
104
|
+
)
|
105
|
+
@server_received.must_equal(JOIN)
|
106
|
+
end
|
108
107
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
108
|
+
it "can join an irc channel with a password and send a private message" do
|
109
|
+
CarrierPigeon.send(
|
110
|
+
:uri => "irc://foo@localhost:16667/#test",
|
111
|
+
:message => "test",
|
112
|
+
:channel_password => "bar",
|
113
|
+
:join => true
|
114
|
+
)
|
115
|
+
@server_received.must_equal(JOIN_PASSWORD)
|
116
|
+
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
118
|
+
it "can identify with nickserv and send a private message to an irc channel" do
|
119
|
+
CarrierPigeon.send(
|
120
|
+
:uri => "irc://foo@localhost:16667/#test",
|
121
|
+
:message => "test",
|
122
|
+
:nickserv_password => "bar"
|
123
|
+
)
|
124
|
+
@server_received.must_equal(NICKSERV_PASSWORD)
|
125
|
+
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
it "must be provided an irc uri" do
|
128
|
+
lambda {
|
129
|
+
CarrierPigeon.send(:message => "test")
|
130
|
+
}.must_raise RuntimeError
|
131
|
+
end
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
137
138
|
end
|
138
139
|
|
140
|
+
describe "with server PING before initial reply" do
|
141
|
+
let :server_messages do
|
142
|
+
[
|
143
|
+
"PING :dummy",
|
144
|
+
":dummy 001 foo :Welcome to the Internet Relay Network",
|
145
|
+
":dummy 002 foo :Your host is dummy",
|
146
|
+
":dummy 003 foo :This server was created now",
|
147
|
+
":dummy 004 foo dummy"
|
148
|
+
]
|
149
|
+
end
|
150
|
+
|
151
|
+
it "must reply with PONG" do
|
152
|
+
CarrierPigeon.send(
|
153
|
+
:uri => "irc://foo@localhost:16667/#test",
|
154
|
+
:message => "test"
|
155
|
+
)
|
156
|
+
@server_received.must_equal(PONG)
|
157
|
+
end
|
158
|
+
end
|
139
159
|
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: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 7
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.7.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Porter
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-04-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|