superfeedr-superfeedr-ruby 0.3.0 → 0.3.1
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/VERSION.yml +1 -1
- data/lib/stanzas/notification_stanza.rb +9 -0
- data/lib/superfeedr.rb +4 -4
- data/spec/superfeedr_ruby_spec.rb +6 -6
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
# - chunks (long entries might be notified in several chunks)
|
10
10
|
# - chunk (current chunk out of chunks)
|
11
11
|
#
|
12
|
+
require "cgi"
|
12
13
|
class Item
|
13
14
|
include SAXMachine
|
14
15
|
element :item, :as => :chunk, :value => :chunk
|
@@ -19,6 +20,10 @@ class Item
|
|
19
20
|
element :id, :as => :unique_id
|
20
21
|
element :published
|
21
22
|
|
23
|
+
def link
|
24
|
+
CGI.unescape(@link).gsub("\n", "")
|
25
|
+
end
|
26
|
+
|
22
27
|
def published
|
23
28
|
Time.parse(@published)
|
24
29
|
end
|
@@ -56,6 +61,10 @@ class NotificationStanza
|
|
56
61
|
@http_status.to_i
|
57
62
|
end
|
58
63
|
|
64
|
+
def feed_url
|
65
|
+
CGI.unescape(@feed_url).gsub("\n", "")
|
66
|
+
end
|
67
|
+
|
59
68
|
element :http, :as => :message_status
|
60
69
|
element :http, :as => :http_status, :value => :code
|
61
70
|
element :status, :value => :feed, :as => :feed_url
|
data/lib/superfeedr.rb
CHANGED
@@ -82,11 +82,11 @@ module Superfeedr
|
|
82
82
|
##
|
83
83
|
# List all subscriptions, by sending them by blocks (page), starting at page specified in argument
|
84
84
|
def self.subscriptions(start_page = 1, &block)
|
85
|
-
Superfeedr.subscriptions_by_page(start_page) do |result|
|
85
|
+
Superfeedr.subscriptions_by_page(start_page) do |page, result|
|
86
86
|
if !result.empty?
|
87
87
|
subscriptions(start_page + 1, &block)
|
88
|
+
block.call(page, result)
|
88
89
|
end
|
89
|
-
block.call(result)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -139,8 +139,8 @@ module Superfeedr
|
|
139
139
|
##
|
140
140
|
# Called with a response to a subscriptions listing
|
141
141
|
def self.on_subscriptions(stanza, &block)
|
142
|
-
page = stanza.xpath('//
|
143
|
-
feeds = stanza.xpath('//
|
142
|
+
page = stanza.xpath('//subscriptions').first["page"].to_i
|
143
|
+
feeds = stanza.xpath('//subscription').map { |s| s["node"] }
|
144
144
|
block.call(page, feeds)
|
145
145
|
end
|
146
146
|
|
@@ -41,12 +41,12 @@ describe Superfeedr do
|
|
41
41
|
it "should call subscriptions_by_page for each page as long as they're not empty" do
|
42
42
|
def method_called_upon_page
|
43
43
|
end
|
44
|
-
self.should_receive(:method_called_upon_page).exactly(
|
44
|
+
self.should_receive(:method_called_upon_page).exactly(3).times
|
45
45
|
3.times do |t|
|
46
|
-
Superfeedr.should_receive(:subscriptions_by_page).with(t+1).and_yield(["a", "b", "c"])
|
46
|
+
Superfeedr.should_receive(:subscriptions_by_page).with(t+1).and_yield( t+1 , ["a", "b", "c"])
|
47
47
|
end
|
48
|
-
Superfeedr.should_receive(:subscriptions_by_page).with(4).and_yield([])
|
49
|
-
Superfeedr.subscriptions do |result|
|
48
|
+
Superfeedr.should_receive(:subscriptions_by_page).with(4).and_yield(4, [])
|
49
|
+
Superfeedr.subscriptions do |page, result|
|
50
50
|
method_called_upon_page
|
51
51
|
end
|
52
52
|
end
|
@@ -219,8 +219,8 @@ EOXML
|
|
219
219
|
it "should call the block with the page number and the list of feeds as an array" do
|
220
220
|
xml = <<-EOXML
|
221
221
|
<iq type="result" to="you@superfeedr.com/home" id="subman1" from="firehoser.superfeedr.com">
|
222
|
-
<pubsub
|
223
|
-
<subscriptions
|
222
|
+
<pubsub>
|
223
|
+
<subscriptions page="3">
|
224
224
|
<subscription node="http://domain.tld/path/to/a/feed/atom.xml" subscription="subscribed" jid="you@superfeedr.com" />
|
225
225
|
<subscription node="http://domain2.tld/path/to/feed.rss" subscription="subscribed" jid="you@superfeedr.com" />
|
226
226
|
</subscriptions>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superfeedr-superfeedr-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- julien Genestoux
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-09 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|