ruby-net-nntp 0.2.2 → 1.0.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.
@@ -0,0 +1,48 @@
1
+ # $Id$
2
+
3
+ if HAVE_SVN
4
+
5
+ unless PROJ.svn.root
6
+ info = %x/svn info ./
7
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
8
+ PROJ.svn.root = (m.nil? ? '' : m[1])
9
+ end
10
+ PROJ.svn.root = File.join(PROJ.svn.root, PROJ.svn.path) unless PROJ.svn.path.empty?
11
+
12
+ namespace :svn do
13
+
14
+ # A prerequisites task that all other tasks depend upon
15
+ task :prereqs
16
+
17
+ desc 'Show tags from the SVN repository'
18
+ task :show_tags => 'svn:prereqs' do |t|
19
+ tags = %x/svn list #{File.join(PROJ.svn.root, PROJ.svn.tags)}/
20
+ tags.gsub!(%r/\/$/, '')
21
+ tags = tags.split("\n").sort {|a,b| b <=> a}
22
+ puts tags
23
+ end
24
+
25
+ desc 'Create a new tag in the SVN repository'
26
+ task :create_tag => 'svn:prereqs' do |t|
27
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
28
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
29
+
30
+ svn = PROJ.svn
31
+ trunk = File.join(svn.root, svn.trunk)
32
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
33
+ tag = File.join(svn.root, svn.tags, tag)
34
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
35
+
36
+ puts "Creating SVN tag '#{tag}'"
37
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
38
+ abort "Tag creation failed"
39
+ end
40
+ end
41
+
42
+ end # namespace :svn
43
+
44
+ task 'gem:release' => 'svn:create_tag'
45
+
46
+ end # if PROJ.svn.path
47
+
48
+ # EOF
@@ -0,0 +1,38 @@
1
+ # $Id$
2
+
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
10
+ else PROJ.test.files end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test.opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
19
+ opts = opts.join(' ')
20
+ files = if test(?f, PROJ.test.file) then [PROJ.test.file]
21
+ else PROJ.test.files end
22
+ files = files.join(' ')
23
+ sh "#{RCOV} #{files} #{opts}"
24
+ end
25
+
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ # EOF
metadata CHANGED
@@ -1,17 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-net-nntp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Anton Bangratz
7
+ - Anton 'tony' Bangratz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-17 00:00:00 +01:00
12
+ date: 2008-06-04 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: tmail
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
15
24
  - !ruby/object:Gem::Dependency
16
25
  name: log4r
17
26
  version_requirement:
@@ -21,41 +30,62 @@ dependencies:
21
30
  - !ruby/object:Gem::Version
22
31
  version: "0"
23
32
  version:
24
- description: ""
33
+ description: The Net::NNTP library provides a simple communication layer for the NNTP (Network News Transfer Protocol).
25
34
  email: anton.bangratz@gmail.com
26
35
  executables: []
27
36
 
28
37
  extensions: []
29
38
 
30
39
  extra_rdoc_files:
31
- - README
32
40
  - CHANGELOG
33
- - MIT-LICENSE
41
+ - README.txt
34
42
  files:
35
- - lib/net
36
- - lib/net/nntp
37
- - lib/net/nntp/article.rb
38
- - lib/net/nntp/group.rb
39
- - lib/net/nntp/version.rb
40
- - lib/net/nntp.rb
41
- - test/functional
42
- - test/functional/test_nntp.rb
43
- - test/mock
44
- - test/mock/mock_socket.rb
45
- - test/unit
46
- - test/unit/test_nntp_article.rb
47
- - test/unit/test_nntp_group.rb
48
- - README
49
43
  - CHANGELOG
44
+ - CHANGELOG.debian
50
45
  - MIT-LICENSE
46
+ - Manifest.txt
47
+ - README.txt
48
+ - Rakefile
49
+ - build-stamp
50
+ - lib/net/nntp.rb
51
+ - lib/net/nntp/request.rb
52
+ - lib/net/nntp/response.rb
53
+ - lib/net/nntp/version.rb
54
+ - script/console
55
+ - spec/net/nntp/request_spec.rb
56
+ - spec/net/nntp/response_spec.rb
57
+ - spec/net/nntp_spec.rb
58
+ - spec/spec.opts
59
+ - spec/spec_helper.rb
60
+ - spec/stories/all.rb
61
+ - spec/stories/helper.rb
62
+ - spec/stories/net/nntp.rb
63
+ - spec/stories/net/nntp.story
64
+ - spec/stories/steps/nntp.rb
65
+ - tasks/ann.rake
66
+ - tasks/bones.rake
67
+ - tasks/gem.rake
68
+ - tasks/git.rake
69
+ - tasks/manifest.rake
70
+ - tasks/mercurial.rake
71
+ - tasks/notes.rake
72
+ - tasks/pallet.rake
73
+ - tasks/post_load.rake
74
+ - tasks/rdoc.rake
75
+ - tasks/rubyforge.rake
76
+ - tasks/setup.rb
77
+ - tasks/spec.rake
78
+ - tasks/svn.rake
79
+ - tasks/test.rake
51
80
  has_rdoc: true
52
- homepage:
81
+ homepage: http://rubyforge.org/projects/ruby-net-nntp
53
82
  post_install_message:
54
83
  rdoc_options:
55
84
  - -S
85
+ - -M
56
86
  - -N
57
87
  - --main
58
- - README
88
+ - README.txt
59
89
  require_paths:
60
90
  - lib
61
91
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -72,16 +102,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
102
  version:
73
103
  requirements: []
74
104
 
75
- rubyforge_project:
76
- rubygems_version: 1.0.1
105
+ rubyforge_project: ruby-net-nntp
106
+ rubygems_version: 1.1.1
77
107
  signing_key:
78
108
  specification_version: 2
79
- summary: Net::XXX style NNTP Library for easy access.
80
- test_files:
81
- - test/functional
82
- - test/functional/test_nntp.rb
83
- - test/mock
84
- - test/mock/mock_socket.rb
85
- - test/unit
86
- - test/unit/test_nntp_article.rb
87
- - test/unit/test_nntp_group.rb
109
+ summary: The Net::NNTP library provides a simple communication layer for the NNTP (Network News Transfer Protocol)
110
+ test_files: []
111
+
data/README DELETED
@@ -1,46 +0,0 @@
1
- libruby-nntp
2
- by Anton Bangratz
3
-
4
- == DESCRIPTION
5
-
6
- The Net::NNTP library provides a simple communication layer for the NNTP (Network News Transfer Protocol).
7
-
8
- == FEATURES
9
-
10
- The Net::NNTP library provides a communication layer in Net::XXX style for NNTP.
11
-
12
-
13
-
14
- == SYNOPSIS
15
-
16
- Net::NNTP uses a simple interface to wrap commands to communicate with an NNTP server.
17
-
18
- === Example
19
-
20
- nntp = Net::NNTP.new('localhost')
21
- if nntp.authenticate('user', 'xxxx')
22
- nntp.group 'alt.test'
23
- if nntp.next
24
- article = nntp.article
25
- end
26
- end
27
-
28
- == INSTALL
29
-
30
- * sudo gem install libruby-nntp or
31
- * sudo dpkg -r libruby-0.0.1.deb
32
-
33
- = CHANGES
34
-
35
- Version 0.1.0 introduces the Net::NNTP::Article#headers and #body attributes.
36
- Due to this, the attribute Net::NNTP::Article#id has been changed to Net::NNTP::Article#number
37
- to avoid conflicts with Object#id.
38
-
39
- Additionally, on request, Net::NNTP::Article has been changed from being a mere proxy for Net::NNTP#xover
40
- result lines to being able to parse HEAD, BODY and ARTICLE results and return a corresponding instance.
41
-
42
- == Acknowledgments
43
-
44
- Thanks to Ward Bekker and Geff Hanoian for finding and fixing bugs and providing me with useful hints and enhancements.
45
- Thanks to J�rgen Strobel for providing support and hosting of the code libraries and bug tracking system. Thanks to Tom
46
- Copeland and Rich Kilmer for rubyforge, and big thanks to Matz and everyone of the core team for Ruby.
@@ -1,188 +0,0 @@
1
- require 'ostruct'
2
-
3
- # a slightly modified OpenStruct
4
- class HeaderStruct < OpenStruct
5
- # adds of modifies a new key/value pair
6
- def add_pair(key, value)
7
- @table[key.to_sym] = value
8
- new_ostruct_member(key)
9
- end
10
- end
11
-
12
- module Net
13
- class NNTP
14
- # Article parsing class
15
- class Article
16
- attr_accessor :group, :headers, :body
17
- attr_reader :overview_format
18
-
19
- def initialize
20
- @overview_format = %w{number}
21
- @headers ||= HeaderStruct.new
22
- @body = []
23
- end
24
-
25
- # Former versions attribute proxy
26
- #
27
- # Deprecated: use corresponding headers attribute instead
28
- def number
29
- @headers.number
30
- end
31
-
32
- # Former versions attribute proxy
33
- #
34
- # Deprecated: use corresponding headers attribute instead
35
- def number=(number)
36
- @headers.number = number
37
- end
38
-
39
- # Former versions attribute proxy
40
- #
41
- # Deprecated: use corresponding headers attribute instead
42
- def messageid
43
- @headers.message_id
44
- end
45
-
46
- # Former versions attribute proxy
47
- #
48
- # Deprecated: use corresponding headers attribute instead
49
- def messageid=(id)
50
- @headers.message_id = id
51
- end
52
-
53
- # Former versions attribute proxy
54
- #
55
- # Deprecated: use corresponding headers attribute instead
56
- def subject
57
- @headers.subject
58
- end
59
-
60
- # Former versions attribute proxy
61
- #
62
- # Deprecated: use corresponding headers attribute instead
63
- def subject=(subject)
64
- @headers.subject=subject
65
- end
66
-
67
- # Former versions attribute proxy
68
- #
69
- # Deprecated: use corresponding headers attribute instead
70
- def bytes
71
- @headers.bytes
72
- end
73
-
74
- # Former versions attribute proxy
75
- #
76
- # Deprecated: use corresponding headers attribute instead
77
- def lines
78
- @headers.lines
79
- end
80
-
81
- # Former versions attribute proxy
82
- #
83
- # Deprecated: use corresponding headers attribute instead
84
- def xref
85
- @headers.xref
86
- end
87
-
88
- # Former versions attribute proxy
89
- #
90
- # Deprecated: use corresponding headers attribute instead
91
- def date
92
- @headers.date
93
- end
94
-
95
- # Former versions attribute proxy
96
- #
97
- # Deprecated: use corresponding headers attribute instead
98
- def from
99
- @headers.from
100
- end
101
-
102
- # Sets the overview format to use for parsing article from XOVER command results.
103
- #
104
- #
105
- # Takes either a tab separated line as result from 'LIST OVERVIEW.FMT' and
106
- # parses it into an array (see Net::NNTP::parse_overview_format) or takes
107
- # an already parsed array to set the format directly.
108
- def overview_format=(format)
109
- if Array === format
110
- @overview_format = format
111
- else
112
- @overview_format = Net::NNTP.parse_overview_format format
113
- end
114
- end
115
-
116
- # Parses data from XOVER command
117
- #
118
- # Takes the tab separated line corresponding to an article from the XOVER command
119
- # result and sets the header fields accordingly. CAVEAT! The overview format (see
120
- # Net::NNTP::Article#overview_format= has to be set prior of attempting this, and
121
- # has to actually correspond with the fields.
122
- def overview(over)
123
- over.split(/\t/).each_with_index do |value, index|
124
- ident = @overview_format[index]
125
- @headers.add_pair(ident, value)
126
- if @headers.messageid
127
- @headers.message_id = @headers.messageid
128
- end
129
- end
130
- end
131
-
132
- # Sets a header from the result line
133
- #
134
- # Parses a line of the format "Header: Value" and sets the @headers accordingly.
135
- # (Example: "Message-ID: <abc@def.gh>" will become @headers.message_id with the
136
- # value '<abc@def.gh>'. Scans multiline headers (if header does start with a
137
- # whitespace, it is part of the last header.
138
- def set_header(line)
139
- value = nil
140
- if line =~ /^\s/ # line starts with a whitespace
141
- oldval = @headers.send(@last_header)
142
- value = []
143
- value << oldval.strip
144
- value << line.strip
145
- key = @last_header
146
- else
147
- name, value = line.scan(/^(.*?): (.*)$/).flatten
148
- key = name.strip.gsub(/[^\w]/, '_').downcase
149
- end
150
- @last_header = key
151
- @headers.add_pair(key, value)
152
- @headers
153
- end
154
-
155
- # Creates an Net::NNTP::Article from a HEAD, BODY or ARTICLE result
156
- #
157
- # Takes the full result (including response line and stop marker ".")
158
- # and creates a Net::NNTP::Article instance with the headers in @headers and
159
- # the body in @body.
160
- def self.parse(lines)
161
- responsecode = lines[0][0..2]
162
- do_header = responsecode == '221'
163
- do_body = responsecode == '222'
164
- if responsecode == '220'
165
- do_header = do_body = true
166
- end
167
- article = Net::NNTP::Article.new
168
- count = 0
169
- lines.each do |line|
170
- count += 1
171
- next if count == 1
172
- break if line =~ /^\.$/
173
- do_header = (do_header && line !~ /^$/)
174
- next if line =~ /^$/
175
- if do_header
176
- article.set_header(line)
177
- else
178
- if do_body
179
- article.body << line
180
- end
181
- end
182
- end
183
- article
184
- end
185
-
186
- end # class Net::NNTP::Article
187
- end
188
- end