irc-socket 0.9 → 0.9.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.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/irc-socket.rb +22 -22
  3. data/spec/irc-socket_spec.rb +11 -0
  4. metadata +4 -17
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require "spec/rake/spectask"
5
5
  require "rake/rdoctask"
6
6
 
7
7
  NAME = 'irc-socket'
8
- VERSION = '0.9'
8
+ VERSION = '0.9.1'
9
9
  CLEAN.include ["*.gem", "rdoc"]
10
10
 
11
11
  RDOC_OPTS = [
data/lib/irc-socket.rb CHANGED
@@ -100,7 +100,7 @@ class IRCSocket
100
100
  # the line will have the CRLF chomp'ed. Returns nil if no data could be read
101
101
  def read(chompstr="\r\n")
102
102
  if data = @socket.gets("\r\n")
103
- data.chomp(chompstr) if chompstr
103
+ data.chomp!(chompstr) if chompstr
104
104
  data
105
105
  else
106
106
  nil
@@ -139,7 +139,7 @@ class IRCSocket
139
139
  write("NICK #{nickname}")
140
140
  end
141
141
 
142
- # Send USER command -
142
+ # Send USER command
143
143
  def user(user, mode, unused, realname)
144
144
  write("USER #{user} #{mode} #{unused} :#{realname}")
145
145
  end
@@ -165,7 +165,7 @@ class IRCSocket
165
165
  write("JOIN #{channel}")
166
166
  end
167
167
 
168
- # Send PART command -
168
+ # Send PART command
169
169
  def part(channel, message=nil)
170
170
  raw("PART", channel, message)
171
171
  end
@@ -185,97 +185,97 @@ class IRCSocket
185
185
  write("LIST #{channels.join(',') unless channels.empty?}")
186
186
  end
187
187
 
188
- # Send INVITE
188
+ # Send INVITE command
189
189
  def invite(nickname, channel)
190
190
  write("INVITE #{nickname} #{channel}")
191
191
  end
192
192
 
193
- # Send KICK
193
+ # Send KICK command
194
194
  def kick(channel, user, comment=nil)
195
195
  raw("KICK", channel, user, comment)
196
196
  end
197
197
 
198
- # Send PRIVMSG
198
+ # Send PRIVMSG command
199
199
  def privmsg(target, message)
200
200
  write("PRIVMSG #{target} :#{message}")
201
201
  end
202
202
 
203
- # Send NOTICE
203
+ # Send NOTICE command
204
204
  def notice(target, message)
205
205
  write("NOTICE #{target} :#{message}")
206
206
  end
207
207
 
208
- # Send MOTD
208
+ # Send MOTD command
209
209
  def motd(target=nil)
210
210
  write_optional("MOTD", target)
211
211
  end
212
212
 
213
- # Send VERSION
213
+ # Send VERSION command
214
214
  def version(target=nil)
215
215
  write_optional("VERSION", target)
216
216
  end
217
217
 
218
- # Send STATS
218
+ # Send STATS command
219
219
  def stats(*params)
220
220
  write_optional("STATS", params)
221
221
  end
222
222
 
223
- # Send TIME
223
+ # Send TIME command
224
224
  def time(target=nil)
225
225
  write_optional("TIME", target)
226
226
  end
227
227
 
228
- # Send INFO
228
+ # Send INFO command
229
229
  def info(target=nil)
230
230
  write_optional("INFO", target)
231
231
  end
232
232
 
233
- # Send SQUERY
233
+ # Send SQUERY command
234
234
  def squery(target, message)
235
235
  write("SQUERY #{target} :#{message}")
236
236
  end
237
237
 
238
- # Send WHO
238
+ # Send WHO command
239
239
  def who(*params)
240
240
  write_optional("WHO", params)
241
241
  end
242
242
 
243
- # Send WHOIS
243
+ # Send WHOIS command
244
244
  def whois(*params)
245
245
  write_optional("WHOIS", params)
246
246
  end
247
247
 
248
- # Send WHOWAS
248
+ # Send WHOWAS command
249
249
  def whowas(*params)
250
250
  write_optional("WHOWAS", params)
251
251
  end
252
252
 
253
- # Send KILL
253
+ # Send KILL command
254
254
  def kill(user, message)
255
255
  write("KILL #{user} :#{message}")
256
256
  end
257
257
 
258
- # Send PING
258
+ # Send PING command
259
259
  def ping(server)
260
260
  write("PING #{server}")
261
261
  end
262
262
 
263
- # Send PONG
263
+ # Send PONG command
264
264
  def pong(server)
265
265
  write("PONG #{server}")
266
266
  end
267
267
 
268
- # Send AWAY
268
+ # Send AWAY command
269
269
  def away(message=nil)
270
270
  raw("AWAY", message)
271
271
  end
272
272
 
273
- # Send USERS
273
+ # Send USERS command
274
274
  def users(target=nil)
275
275
  write_optional("USERS", target)
276
276
  end
277
277
 
278
- # Send USERHOST
278
+ # Send USERHOST command
279
279
  def userhost(*users)
280
280
  write("USERHOST #{users.join(' ')}")
281
281
  end
@@ -4,6 +4,11 @@ class IRCSocket
4
4
  def write(data)
5
5
  return data
6
6
  end
7
+
8
+ def read(chompstr="\r\n")
9
+ str = "foo bar baz\r\n"
10
+ str.chomp!(chompstr) if chompstr
11
+ end
7
12
  end
8
13
 
9
14
  commands = [
@@ -63,7 +68,13 @@ describe "IRCSocket" do
63
68
  it "should set socket instance as nil" do
64
69
  @irc.socket.should == nil
65
70
  end
71
+ end
66
72
 
73
+ describe "#read" do
74
+ it "should chomp CRLF by default" do
75
+ @irc.read.should == "foo bar baz"
76
+ @irc.read.should_not == "foo bar baz\r\n"
77
+ end
67
78
  end
68
79
 
69
80
  describe "IRC commands as per rfc2812" do
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- version: "0.9"
8
+ - 1
9
+ version: 0.9.1
9
10
  platform: ruby
10
11
  authors:
11
12
  - Lee 'injekt' Jarvis
@@ -16,24 +17,10 @@ cert_chain: []
16
17
  date: 2010-04-22 00:00:00 +01:00
17
18
  default_executable:
18
19
  dependencies:
19
- - !ruby/object:Gem::Dependency
20
- name: bacon
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "="
25
- - !ruby/object:Gem::Version
26
- segments:
27
- - 1
28
- - 1
29
- - 0
30
- version: 1.1.0
31
- type: :development
32
- version_requirements: *id001
33
20
  - !ruby/object:Gem::Dependency
34
21
  name: rspec
35
22
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
37
24
  requirements:
38
25
  - - "="
39
26
  - !ruby/object:Gem::Version
@@ -43,7 +30,7 @@ dependencies:
43
30
  - 0
44
31
  version: 1.3.0
45
32
  type: :development
46
- version_requirements: *id002
33
+ version_requirements: *id001
47
34
  description: An IRC wrapper around TCPSocket
48
35
  email: ljjarvis@gmail.com
49
36
  executables: []