minter-raccdoc 0.0.3 → 0.0.4
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 +2 -0
- data/README +2 -0
- data/lib/raccdoc.rb +33 -5
- data/raccdoc.gemspec +2 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -10,6 +10,8 @@ Raccdoc is an API into the data of several classic telnet-based BBS systems, inc
|
|
10
10
|
|
11
11
|
This is a Ruby version of that API.
|
12
12
|
|
13
|
+
The Raccdoc API document can be found at http://dev.iscabbs.com/doku.php?id=raccdoc_protocol_documentation
|
14
|
+
|
13
15
|
== EXAMPLE
|
14
16
|
|
15
17
|
require 'raccdoc'
|
data/lib/raccdoc.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Raccdoc
|
2
2
|
|
3
|
-
VERSION = '0.0.
|
3
|
+
VERSION = '0.0.4'
|
4
4
|
require 'socket'
|
5
5
|
require 'time'
|
6
6
|
|
@@ -71,6 +71,9 @@ module Raccdoc
|
|
71
71
|
# * lastnote - The earliest post ID number in the forum
|
72
72
|
# * admin - The handle of the forum admin
|
73
73
|
#
|
74
|
+
# The argument can be one of: ALL (default), PUBLIC, PRIVATE, TODO, JOINED, NAMED, THREADS
|
75
|
+
# depending on server support
|
76
|
+
#
|
74
77
|
# Note that this does not return actual Raccdoc::Forum objects in the interest of saving resources, so you'll need to jump to the forum that you want.
|
75
78
|
def forums(type="all")
|
76
79
|
@socket.puts "LIST #{type}"
|
@@ -105,14 +108,18 @@ module Raccdoc
|
|
105
108
|
attr_reader :id
|
106
109
|
attr_reader :name
|
107
110
|
attr_reader :admin
|
111
|
+
attr_reader :anonymous
|
112
|
+
attr_reader :private
|
108
113
|
|
109
114
|
# Sets the active forum on the server to the specified forum number (0) or name (Lobby, Program), then returns a new Raccdoc::Forum object.
|
110
115
|
#
|
111
|
-
# There are
|
116
|
+
# There are five instance variables exposed through attr_reader:
|
112
117
|
#
|
113
118
|
# * id - The forum ID number
|
114
119
|
# * name - The forum name
|
115
120
|
# * admin - The name of the forum administrator
|
121
|
+
# * anonymous - either true, false, or force, depending on whether the anonymous posting option is on, off, or required
|
122
|
+
# * private - True if the forum is private (invite-only), false otherwise
|
116
123
|
def initialize(socket, forum = 0)
|
117
124
|
@socket = socket
|
118
125
|
@socket.puts "TOPIC #{forum.to_s}"
|
@@ -129,6 +136,18 @@ module Raccdoc
|
|
129
136
|
@headers[key.downcase.to_sym] = value
|
130
137
|
end
|
131
138
|
|
139
|
+
flags = @headers[:flags].split('/')
|
140
|
+
|
141
|
+
if flags.include?("forceanonymous")
|
142
|
+
@anonymous = "force"
|
143
|
+
elsif flags.include?("cananonymous")
|
144
|
+
@anonymous = true
|
145
|
+
else
|
146
|
+
@anonymous = false
|
147
|
+
end
|
148
|
+
|
149
|
+
@private = flags.include?("private") ? true : false
|
150
|
+
|
132
151
|
@id = @headers[:topic]
|
133
152
|
@name = @headers[:name]
|
134
153
|
@admin = @headers[:admin]
|
@@ -242,6 +261,11 @@ module Raccdoc
|
|
242
261
|
Post.new(@socket,postid)
|
243
262
|
end
|
244
263
|
|
264
|
+
# Attempts to do a "DAMMIT" read, overriding anonymous and deleted flags. If you do not have permission to bypass those flags, this is equivalent to a plain read.
|
265
|
+
def read!(postid)
|
266
|
+
Post.new(@socket,postid,:dammit => true)
|
267
|
+
end
|
268
|
+
|
245
269
|
# Creates a new post in the current forum using the text provided in the argument.
|
246
270
|
#
|
247
271
|
# Returns a new Raccdoc::Post object that results from reading the newly created post.
|
@@ -286,8 +310,9 @@ module Raccdoc
|
|
286
310
|
attr_reader :date
|
287
311
|
attr_reader :author
|
288
312
|
attr_reader :body
|
313
|
+
attr_reader :authority
|
289
314
|
|
290
|
-
# Creates a new Raccdoc::Post object by reading the specified post.
|
315
|
+
# Creates a new Raccdoc::Post object by reading the specified post. If no post is given, it returns the first unread post, if any.
|
291
316
|
#
|
292
317
|
# Useful information returned:
|
293
318
|
#
|
@@ -295,9 +320,11 @@ module Raccdoc
|
|
295
320
|
# * date - The date the post was made (or the current date in UTC if the post is anonymous)
|
296
321
|
# * author - The username of the user that created the post
|
297
322
|
# * body - The textual body of the post.
|
298
|
-
|
323
|
+
# * authority - either "Sysop" or "Forum Moderator" if the post was made with that header.
|
324
|
+
def initialize(socket,postid,args={})
|
299
325
|
@socket = socket
|
300
|
-
|
326
|
+
dammit = args[:dammit] ? '' : 'DAMMIT'
|
327
|
+
@socket.puts "READ #{postid.to_s} #{dammit}"
|
301
328
|
response = @socket.readline.chomp
|
302
329
|
unless response.match(/^3/)
|
303
330
|
raise RuntimeError, response
|
@@ -325,6 +352,7 @@ module Raccdoc
|
|
325
352
|
@date = post[:date]
|
326
353
|
@author = post[:author]
|
327
354
|
@body = post[:body]
|
355
|
+
@authority = post[:authority]
|
328
356
|
return post
|
329
357
|
end
|
330
358
|
|
data/raccdoc.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{raccdoc}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["H. Wade Minter"]
|
9
|
-
s.date = %q{2009-01-
|
9
|
+
s.date = %q{2009-01-13}
|
10
10
|
s.description = %q{A Ruby interface into the Raccdoc protocol}
|
11
11
|
s.email = %q{minter@lunenburg.org}
|
12
12
|
s.extra_rdoc_files = ["CHANGELOG", "lib/raccdoc.rb", "LICENSE", "README"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minter-raccdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- H. Wade Minter
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01-
|
12
|
+
date: 2009-01-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|