livejournal 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +4 -0
- data/Rakefile +2 -2
- data/lib/livejournal/entry.rb +47 -13
- data/sample/progressbar.rb +5 -1
- data/test/database.rb +1 -1
- data/test/roundtrip.rb +2 -2
- metadata +17 -15
data/Changes
ADDED
data/Rakefile
CHANGED
@@ -5,10 +5,10 @@ require 'rake/rdoctask'
|
|
5
5
|
require 'rake/testtask'
|
6
6
|
|
7
7
|
PKG_NAME = 'livejournal'
|
8
|
-
PKG_VERSION = '0.3.
|
8
|
+
PKG_VERSION = '0.3.1'
|
9
9
|
|
10
10
|
FILES = FileList[
|
11
|
-
'Rakefile', 'README', 'LICENSE', 'setup.rb',
|
11
|
+
'Rakefile', 'README', 'Changes', 'LICENSE', 'setup.rb',
|
12
12
|
'lib/**/*', 'sample/*', 'test/*'
|
13
13
|
]
|
14
14
|
|
data/lib/livejournal/entry.rb
CHANGED
@@ -53,7 +53,14 @@ module LiveJournal
|
|
53
53
|
attr_accessor :security # values: {:public, :private, :friends, :custom}
|
54
54
|
attr_accessor :allowmask
|
55
55
|
attr_accessor :screening # values {:default, :all, :anonymous, :nonfriends, :none}
|
56
|
+
|
57
|
+
# A hash of any leftover properties (including those in KNOWN_EXTRA_PROPS)
|
58
|
+
# that aren't explicitly supported by ljrb. (See the
|
59
|
+
# Request::GetEvents#new for details.)
|
56
60
|
attr_accessor :props
|
61
|
+
# A list of extra properties we're aware of but don't wrap explicitly.
|
62
|
+
# Upon retrieval stored in the props hash.
|
63
|
+
KNOWN_EXTRA_PROPS = %w{revnum revtime commentalter unknown8bit useragent}
|
57
64
|
|
58
65
|
def initialize
|
59
66
|
@subject = nil
|
@@ -74,21 +81,24 @@ module LiveJournal
|
|
74
81
|
@props = {}
|
75
82
|
end
|
76
83
|
|
77
|
-
def
|
84
|
+
def ==(other)
|
78
85
|
[:subject, :event, :moodid,
|
79
86
|
:mood, :music, :location, :taglist, :pickeyword,
|
80
|
-
:preformatted, :backdated, :comments, :
|
87
|
+
:preformatted, :backdated, :comments, :security, :allowmask,
|
81
88
|
:screening, :props].each do |attr|
|
82
89
|
return false if send(attr) != other.send(attr)
|
83
90
|
end
|
91
|
+
# compare time fields one-by-one because livejournal ignores the
|
92
|
+
# "seconds" field.
|
93
|
+
[:year, :mon, :day, :hour, :min, :zone].each do |attr|
|
94
|
+
return false if @time.send(attr) != other.time.send(attr)
|
95
|
+
end
|
84
96
|
return true
|
85
97
|
end
|
86
98
|
|
87
99
|
def time=(time)
|
88
100
|
raise RuntimeError, "Must use GMT times everywhere to reduce confusion. See LiveJournal::coerce_gmt for details." unless time.gmt?
|
89
|
-
|
90
|
-
components[0] = 0 # set seconds to zero
|
91
|
-
@time = Time.gm *components
|
101
|
+
@time = time
|
92
102
|
end
|
93
103
|
|
94
104
|
def from_request(req)
|
@@ -115,7 +125,8 @@ module LiveJournal
|
|
115
125
|
|
116
126
|
self
|
117
127
|
end
|
118
|
-
|
128
|
+
|
129
|
+
def load_prop(name, value, strict=false) #:nodoc:#
|
119
130
|
case name
|
120
131
|
when 'current_mood'
|
121
132
|
@mood = value.to_i
|
@@ -149,14 +160,19 @@ module LiveJournal
|
|
149
160
|
end
|
150
161
|
when 'hasscreened'
|
151
162
|
@screened = value == '1'
|
152
|
-
# and then some props we just store by name
|
153
|
-
when 'revnum'; @props[name] = value
|
154
|
-
when 'revtime'; @props[name] = value
|
155
|
-
when 'commentalter'; @props[name] = value
|
156
|
-
when 'unknown8bit'; @props[name] = value
|
157
163
|
else
|
164
|
+
# LJ keeps adding props, so we store all leftovers in a hash.
|
165
|
+
# Unfortunately, we don't know which of these need to be passed
|
166
|
+
# on to new entries. This may mean we drop some data when we
|
167
|
+
# round-trip.
|
168
|
+
#
|
169
|
+
# Some we've seen so far:
|
170
|
+
# revnum, revtime, commentalter, unknown8bit, useragent
|
158
171
|
@props[name] = value
|
159
|
-
|
172
|
+
|
173
|
+
unless KNOWN_EXTRA_PROPS.include? name or not strict
|
174
|
+
raise Request::ProtocolException, "unknown prop (#{name}, #{value})"
|
175
|
+
end
|
160
176
|
end
|
161
177
|
end
|
162
178
|
|
@@ -259,10 +275,28 @@ module LiveJournal
|
|
259
275
|
# * <tt>GetEvents.new(user, :itemid => itemid)</tt> (fetch a single item)
|
260
276
|
# * <tt>GetEvents.new(user, :recent => n)</tt> (fetch most recent n itemds)
|
261
277
|
# * <tt>GetEvents.new(user, :lastsync => lastsync)</tt> (for syncing)
|
278
|
+
#
|
279
|
+
# We support one final option called <tt>:strict</tt>, which requires
|
280
|
+
# a bit of explanation.
|
281
|
+
#
|
282
|
+
# Whenever LiveJournal adds new metadata to entries (such as the
|
283
|
+
# location field, which was introduced in 2006) it also exposes this
|
284
|
+
# metadata via the LJ protocol. However, ljrb can't know about future
|
285
|
+
# metadata and doesn't know how to handle it properly. Some metadata
|
286
|
+
# (like the current location) must be sent to the server to
|
287
|
+
# publish an entry correctly; others, like the last revision time,
|
288
|
+
# must not be.
|
289
|
+
#
|
290
|
+
# Normally, when we see a new property we abort with a ProtocolException.
|
291
|
+
# If the object is constructed with <tt>:strict => false</tt>, we'll
|
292
|
+
# skip over any new properties.
|
262
293
|
def initialize(user, opts)
|
263
294
|
super(user, 'getevents')
|
264
295
|
@request['lineendings'] = 'unix'
|
265
296
|
|
297
|
+
@strict = true
|
298
|
+
@strict = opts[:strict] if opts.has_key? :strict
|
299
|
+
|
266
300
|
if opts.has_key? :itemid
|
267
301
|
@request['selecttype'] = 'one'
|
268
302
|
@request['itemid'] = opts[:itemid]
|
@@ -290,7 +324,7 @@ module LiveJournal
|
|
290
324
|
|
291
325
|
each_in_array('prop') do |prop|
|
292
326
|
itemid = prop['itemid'].to_i
|
293
|
-
entries[itemid].load_prop(prop['name'], prop['value'])
|
327
|
+
entries[itemid].load_prop(prop['name'], prop['value'], @strict)
|
294
328
|
end
|
295
329
|
|
296
330
|
if @request.has_key? 'itemid'
|
data/sample/progressbar.rb
CHANGED
data/test/database.rb
CHANGED
data/test/roundtrip.rb
CHANGED
@@ -18,7 +18,7 @@ class TC_RoundTrip < Test::Unit::TestCase
|
|
18
18
|
|
19
19
|
getevents = Request::GetEvents.new(@user, :itemid => entry.itemid)
|
20
20
|
new_entry = getevents.run
|
21
|
-
|
21
|
+
assert_equal(new_entry, entry)
|
22
22
|
|
23
23
|
delete = Request::EditEvent.new(@user, entry, :delete => true)
|
24
24
|
delete.run
|
@@ -27,7 +27,7 @@ class TC_RoundTrip < Test::Unit::TestCase
|
|
27
27
|
def test_roundtrip
|
28
28
|
e = Entry.new
|
29
29
|
e.subject = 'subject'
|
30
|
-
e.event = 'event here
|
30
|
+
e.event = 'event here'
|
31
31
|
e.time = LiveJournal::coerce_gmt Time.now
|
32
32
|
roundtrip e
|
33
33
|
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: livejournal
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date:
|
6
|
+
version: 0.3.1
|
7
|
+
date: 2007-01-06 00:00:00 -08:00
|
8
8
|
summary: module for interacting with livejournal
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,34 +25,36 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- Evan Martin
|
30
31
|
files:
|
31
32
|
- Rakefile
|
32
33
|
- README
|
34
|
+
- Changes
|
33
35
|
- LICENSE
|
34
36
|
- setup.rb
|
35
37
|
- lib/livejournal
|
36
38
|
- lib/livejournal/database.rb
|
37
|
-
- lib/livejournal/
|
38
|
-
- lib/livejournal/sync.rb
|
39
|
-
- lib/livejournal/request.rb
|
40
|
-
- lib/livejournal/entry.rb
|
41
|
-
- lib/livejournal/comments-xml.rb
|
42
|
-
- lib/livejournal/login.rb
|
39
|
+
- lib/livejournal/basic.rb
|
43
40
|
- lib/livejournal/comment.rb
|
41
|
+
- lib/livejournal/comments-xml.rb
|
42
|
+
- lib/livejournal/entry.rb
|
44
43
|
- lib/livejournal/friends.rb
|
45
|
-
- lib/livejournal/
|
44
|
+
- lib/livejournal/login.rb
|
45
|
+
- lib/livejournal/logjam.rb
|
46
|
+
- lib/livejournal/request.rb
|
47
|
+
- lib/livejournal/sync.rb
|
48
|
+
- sample/export
|
49
|
+
- sample/graph
|
46
50
|
- sample/fuse
|
47
51
|
- sample/progressbar.rb
|
48
|
-
-
|
49
|
-
-
|
52
|
+
- test/login.rb
|
53
|
+
- test/checkfriends.rb
|
54
|
+
- test/comments-xml.rb
|
50
55
|
- test/database.rb
|
51
56
|
- test/time.rb
|
52
|
-
- test/checkfriends.rb
|
53
57
|
- test/roundtrip.rb
|
54
|
-
- test/comments-xml.rb
|
55
|
-
- test/login.rb
|
56
58
|
test_files: []
|
57
59
|
|
58
60
|
rdoc_options: []
|