ostatus 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ostatus.rb +5 -2
- data/lib/ostatus/feed.rb +15 -5
- data/lib/ostatus/version.rb +1 -1
- data/spec/entry_spec.rb +2 -3
- metadata +2 -2
data/lib/ostatus.rb
CHANGED
data/lib/ostatus/feed.rb
CHANGED
@@ -3,12 +3,14 @@ require 'open-uri'
|
|
3
3
|
require 'tinyatom'
|
4
4
|
|
5
5
|
require_relative 'entry'
|
6
|
+
require_relative 'author'
|
6
7
|
|
7
8
|
module OStatus
|
8
9
|
|
9
10
|
# This class represents an OStatus Feed object.
|
10
11
|
class Feed
|
11
|
-
def initialize(url, access_token, author, entries, id, title, links)
|
12
|
+
def initialize(str, url, access_token, author, entries, id, title, links)
|
13
|
+
@str = str
|
12
14
|
@url = url
|
13
15
|
@access_token = access_token
|
14
16
|
@author = author
|
@@ -25,13 +27,17 @@ module OStatus
|
|
25
27
|
# Creates a new Feed instance given by the atom feed located at 'url'
|
26
28
|
# and optionally using the OAuth::AccessToken given.
|
27
29
|
def Feed.from_url(url, access_token = nil)
|
28
|
-
Feed.new(url, access_token, nil, nil, nil, nil, nil)
|
30
|
+
Feed.new(nil, url, access_token, nil, nil, nil, nil, nil)
|
29
31
|
end
|
30
32
|
|
31
33
|
# Creates a new Feed instance that contains the information given by
|
32
34
|
# the various instances of author and entries.
|
33
35
|
def Feed.from_data(id, title, url, author, entries, links)
|
34
|
-
Feed.new(url, nil, author, entries, id, title, links)
|
36
|
+
Feed.new(nil, url, nil, author, entries, id, title, links)
|
37
|
+
end
|
38
|
+
|
39
|
+
def Feed.from_string(str)
|
40
|
+
Feed.new(str, nil, nil, nil, nil, nil, nil, nil)
|
35
41
|
end
|
36
42
|
|
37
43
|
# Returns an array of Nokogiri::XML::Element instances for all link tags
|
@@ -67,7 +73,9 @@ module OStatus
|
|
67
73
|
# the atom feed. It will make a network request (through OAuth if
|
68
74
|
# an access token was given) to retrieve the document if necessary.
|
69
75
|
def atom
|
70
|
-
if @
|
76
|
+
if @str != nil
|
77
|
+
@str
|
78
|
+
elsif @id == nil and @access_token == nil
|
71
79
|
# simply open the url
|
72
80
|
open(@url).read
|
73
81
|
elsif @id == nil and @url != nil
|
@@ -93,7 +101,9 @@ module OStatus
|
|
93
101
|
entry.title,
|
94
102
|
entry.updated,
|
95
103
|
|
96
|
-
|
104
|
+
@url,
|
105
|
+
|
106
|
+
:published => entry.published,
|
97
107
|
|
98
108
|
:content => entry.content,
|
99
109
|
|
data/lib/ostatus/version.rb
CHANGED
data/spec/entry_spec.rb
CHANGED
@@ -79,9 +79,8 @@ describe OStatus::Entry do
|
|
79
79
|
@entry.info[:content_type].should eql("html")
|
80
80
|
end
|
81
81
|
|
82
|
-
it "should contain a
|
83
|
-
@entry.info[:link].class.should eql(
|
84
|
-
@entry.info[:link][0].class.should eql(Nokogiri::XML::Element)
|
82
|
+
it "should contain a Hash for the link" do
|
83
|
+
@entry.info[:link].class.should eql(Hash)
|
85
84
|
end
|
86
85
|
|
87
86
|
it "should contain the published DateTime" do
|