ruby-net-nntp 0.1.0 → 0.2.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/CHANGELOG +21 -1
- data/lib/net/nntp.rb +21 -4
- data/lib/net/nntp/article.rb +1 -1
- data/lib/net/nntp/version.rb +1 -1
- data/test/functional/test_nntp.rb +10 -0
- metadata +4 -6
data/CHANGELOG
CHANGED
@@ -1,4 +1,24 @@
|
|
1
|
-
2007-
|
1
|
+
2007-08-22 17:00 +0200 Anton 'tony' Bangratz <anton.bangratz@gmail.com> (1eb71d8b00b4 [tip])
|
2
|
+
|
3
|
+
* lib/net/nntp.rb, lib/net/nntp/version.rb,
|
4
|
+
test/functional/test_nntp.rb:
|
5
|
+
added newnews command, response_timeout (used only in xover at the
|
6
|
+
moment)
|
7
|
+
|
8
|
+
* added newnews command
|
9
|
+
* added response_timeout variable
|
10
|
+
* patched xover to use response_timeout variable instead of static
|
11
|
+
value
|
12
|
+
|
13
|
+
2007-08-03 17:56 +0200 Anton 'tony' Bangratz <anton.bangratz@gmail.com> (e54f52f53711)
|
14
|
+
|
15
|
+
* lib/net/nntp.rb, lib/net/nntp/article.rb, lib/net/nntp/version.rb:
|
16
|
+
fixed encoding and header parsing bugs
|
17
|
+
* lib/net/nntp.rb: fixed encoding ('..') of lines on
|
18
|
+
fetching
|
19
|
+
* lib/net/nntp/article.rb: fixed header parsing regexp
|
20
|
+
|
21
|
+
2007-07-14 12:22 +0200 Anton 'tony' Bangratz <anton.bangratz@gmail.com> (5de9968582e9)
|
2
22
|
|
3
23
|
* README, lib/net/nntp.rb, lib/net/nntp/article.rb,
|
4
24
|
lib/net/nntp/group.rb, lib/net/nntp/version.rb,
|
data/lib/net/nntp.rb
CHANGED
@@ -29,7 +29,8 @@ module Net
|
|
29
29
|
end
|
30
30
|
|
31
31
|
|
32
|
-
attr_reader :socket, :grouplist, :overview_format
|
32
|
+
attr_reader :socket, :grouplist, :overview_format
|
33
|
+
attr_accessor :response_timeout
|
33
34
|
|
34
35
|
def self.logger=(logger)
|
35
36
|
@@logger = logger
|
@@ -46,10 +47,11 @@ module Net
|
|
46
47
|
@@logger.debug(message)
|
47
48
|
end
|
48
49
|
|
49
|
-
# initializes NNTP class with host and
|
50
|
-
|
50
|
+
# initializes NNTP class with host, port and timeout values
|
51
|
+
def initialize(host, port = 119, response_timeout = 10)
|
51
52
|
@host = host
|
52
53
|
@port = port
|
54
|
+
@response_timeout = response_timeout
|
53
55
|
@socket_class = TCPSocket
|
54
56
|
@group = nil
|
55
57
|
@@logger ||= Log4r::Logger['net::nntp'] || Log4r::Logger.new('net::nntp')
|
@@ -169,12 +171,26 @@ module Net
|
|
169
171
|
cmd = [prefix, suffix].join ' '
|
170
172
|
send_cmd(cmd)
|
171
173
|
response = nil
|
172
|
-
timeout(
|
174
|
+
timeout(@response_timeout) do
|
173
175
|
response = read_response()
|
174
176
|
end
|
175
177
|
response
|
176
178
|
end
|
177
179
|
|
180
|
+
def newnews(groups='*', date=nil, time=nil, gmt=true)
|
181
|
+
gmt_str = gmt ? '"GMT"' : ""
|
182
|
+
debug groups
|
183
|
+
debug date
|
184
|
+
debug time
|
185
|
+
debug gmt_str
|
186
|
+
cmd = 'newnews %s %s %s %s' % [groups, date, time, gmt_str]
|
187
|
+
debug "Sending #{cmd}"
|
188
|
+
send_cmd(cmd)
|
189
|
+
response = nil
|
190
|
+
response = read_response
|
191
|
+
response
|
192
|
+
end
|
193
|
+
|
178
194
|
# Issues 'LISTGROUP' command to NNTP Server, and returns raw response. Checks if group has been selected, selects group
|
179
195
|
# otherwise.
|
180
196
|
#
|
@@ -342,6 +358,7 @@ module Net
|
|
342
358
|
loop do
|
343
359
|
str = @socket.readline
|
344
360
|
#debug " -> got line: '#{str}'"
|
361
|
+
str = str[1..-1] if str && str[0..1] == '..'
|
345
362
|
ra << str.chomp if str
|
346
363
|
break if force_oneline || (!str || str.chomp == "." || (linecnt == 0 && ONELINE_STATUSES.include?(str[0..2])) )
|
347
364
|
linecnt += 1
|
data/lib/net/nntp/article.rb
CHANGED
@@ -134,7 +134,7 @@ module Net
|
|
134
134
|
# (Example: "Message-ID: <abc@def.gh>" will become @headers.message_id with the
|
135
135
|
# value '<abc@def.gh>'.
|
136
136
|
def set_header(line)
|
137
|
-
name, value = line.scan(/^(
|
137
|
+
name, value = line.scan(/^(.*?): (.*)$/).flatten
|
138
138
|
key = name.strip.gsub(/[^\w]/, '_').downcase
|
139
139
|
@headers.add_pair(key, value)
|
140
140
|
@headers
|
data/lib/net/nntp/version.rb
CHANGED
@@ -22,12 +22,16 @@ module TestNet
|
|
22
22
|
def test_new
|
23
23
|
host = 'localhost'
|
24
24
|
port = '119'
|
25
|
+
timeout = 14
|
25
26
|
assert_nothing_raised do
|
26
27
|
@nntp = Net::NNTP.new(host)
|
27
28
|
end
|
28
29
|
assert_nothing_raised do
|
29
30
|
nntp_new(host, port)
|
30
31
|
end
|
32
|
+
assert_nothing_raised do
|
33
|
+
@nntp = Net::NNTP.new(host, port, timeout)
|
34
|
+
end
|
31
35
|
end
|
32
36
|
|
33
37
|
def test_connect
|
@@ -36,6 +40,12 @@ module TestNet
|
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
43
|
+
def test_response_timeout
|
44
|
+
assert_equal 10, @nntp.response_timeout
|
45
|
+
@nntp.response_timeout = 11
|
46
|
+
assert_equal 11, @nntp.response_timeout
|
47
|
+
end
|
48
|
+
|
39
49
|
def test_help
|
40
50
|
help = @nntp.help.join
|
41
51
|
assert_equal '100', help[0..2]
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-net-nntp
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.0
|
7
|
+
date: 2007-08-22 00:00:00 +02:00
|
8
8
|
summary: Net::XXX style NNTP Library for easy access.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -31,8 +31,8 @@ authors:
|
|
31
31
|
files:
|
32
32
|
- lib/net
|
33
33
|
- lib/net/nntp
|
34
|
-
- lib/net/nntp/article.rb
|
35
34
|
- lib/net/nntp/group.rb
|
35
|
+
- lib/net/nntp/article.rb
|
36
36
|
- lib/net/nntp/version.rb
|
37
37
|
- lib/net/nntp.rb
|
38
38
|
- test/functional
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- test/unit
|
43
43
|
- test/unit/test_nntp_article.rb
|
44
44
|
- test/unit/test_nntp_group.rb
|
45
|
-
- test/logs
|
46
45
|
- README
|
47
46
|
- CHANGELOG
|
48
47
|
- MIT-LICENSE
|
@@ -54,7 +53,6 @@ test_files:
|
|
54
53
|
- test/unit
|
55
54
|
- test/unit/test_nntp_article.rb
|
56
55
|
- test/unit/test_nntp_group.rb
|
57
|
-
- test/logs
|
58
56
|
rdoc_options:
|
59
57
|
- -S
|
60
58
|
- -N
|